babylon.d.txt 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */ private _willBeUnregistered: boolean;
  110. /**
  111. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  112. */
  113. unregisterOnNextCall: boolean;
  114. /**
  115. * Creates a new observer
  116. * @param callback defines the callback to call when the observer is notified
  117. * @param mask defines the mask of the observer (used to filter notifications)
  118. * @param scope defines the current scope used to restore the JS context
  119. */
  120. constructor(
  121. /**
  122. * Defines the callback to call when the observer is notified
  123. */
  124. callback: (eventData: T, eventState: EventState) => void,
  125. /**
  126. * Defines the mask of the observer (used to filter notifications)
  127. */
  128. mask: number,
  129. /**
  130. * Defines the current scope used to restore the JS context
  131. */
  132. scope?: any);
  133. }
  134. /**
  135. * Represent a list of observers registered to multiple Observables object.
  136. */
  137. export class MultiObserver<T> {
  138. private _observers;
  139. private _observables;
  140. /**
  141. * Release associated resources
  142. */
  143. dispose(): void;
  144. /**
  145. * Raise a callback when one of the observable will notify
  146. * @param observables defines a list of observables to watch
  147. * @param callback defines the callback to call on notification
  148. * @param mask defines the mask used to filter notifications
  149. * @param scope defines the current scope used to restore the JS context
  150. * @returns the new MultiObserver
  151. */
  152. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  153. }
  154. /**
  155. * The Observable class is a simple implementation of the Observable pattern.
  156. *
  157. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  158. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  159. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  160. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  161. */
  162. export class Observable<T> {
  163. private _observers;
  164. private _eventState;
  165. private _onObserverAdded;
  166. /**
  167. * Gets the list of observers
  168. */
  169. readonly observers: Array<Observer<T>>;
  170. /**
  171. * Creates a new observable
  172. * @param onObserverAdded defines a callback to call when a new observer is added
  173. */
  174. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  175. /**
  176. * Create a new Observer with the specified callback
  177. * @param callback the callback that will be executed for that Observer
  178. * @param mask the mask used to filter observers
  179. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  180. * @param scope optional scope for the callback to be called from
  181. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  182. * @returns the new observer created for the callback
  183. */
  184. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  185. /**
  186. * Create a new Observer with the specified callback and unregisters after the next notification
  187. * @param callback the callback that will be executed for that Observer
  188. * @returns the new observer created for the callback
  189. */
  190. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  191. /**
  192. * Remove an Observer from the Observable object
  193. * @param observer the instance of the Observer to remove
  194. * @returns false if it doesn't belong to this Observable
  195. */
  196. remove(observer: Nullable<Observer<T>>): boolean;
  197. /**
  198. * Remove a callback from the Observable object
  199. * @param callback the callback to remove
  200. * @param scope optional scope. If used only the callbacks with this scope will be removed
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  204. private _deferUnregister;
  205. private _remove;
  206. /**
  207. * Moves the observable to the top of the observer list making it get called first when notified
  208. * @param observer the observer to move
  209. */
  210. makeObserverTopPriority(observer: Observer<T>): void;
  211. /**
  212. * Moves the observable to the bottom of the observer list making it get called last when notified
  213. * @param observer the observer to move
  214. */
  215. makeObserverBottomPriority(observer: Observer<T>): void;
  216. /**
  217. * Notify all Observers by calling their respective callback with the given data
  218. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  219. * @param eventData defines the data to send to all observers
  220. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  221. * @param target defines the original target of the state
  222. * @param currentTarget defines the current target of the state
  223. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  224. */
  225. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  226. /**
  227. * Calling this will execute each callback, expecting it to be a promise or return a value.
  228. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  229. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  230. * and it is crucial that all callbacks will be executed.
  231. * The order of the callbacks is kept, callbacks are not executed parallel.
  232. *
  233. * @param eventData The data to be sent to each callback
  234. * @param mask is used to filter observers defaults to -1
  235. * @param target defines the callback target (see EventState)
  236. * @param currentTarget defines he current object in the bubbling phase
  237. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  238. */
  239. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  240. /**
  241. * Notify a specific observer
  242. * @param observer defines the observer to notify
  243. * @param eventData defines the data to be sent to each callback
  244. * @param mask is used to filter observers defaults to -1
  245. */
  246. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  247. /**
  248. * Gets a boolean indicating if the observable has at least one observer
  249. * @returns true is the Observable has at least one Observer registered
  250. */
  251. hasObservers(): boolean;
  252. /**
  253. * Clear the list of observers
  254. */
  255. clear(): void;
  256. /**
  257. * Clone the current observable
  258. * @returns a new observable
  259. */
  260. clone(): Observable<T>;
  261. /**
  262. * Does this observable handles observer registered with a given mask
  263. * @param mask defines the mask to be tested
  264. * @return whether or not one observer registered with the given mask is handeled
  265. **/
  266. hasSpecificMask(mask?: number): boolean;
  267. }
  268. }
  269. declare module BABYLON {
  270. /**
  271. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  272. * Babylon.js
  273. */
  274. export class DomManagement {
  275. /**
  276. * Checks if the window object exists
  277. * @returns true if the window object exists
  278. */
  279. static IsWindowObjectExist(): boolean;
  280. /**
  281. * Checks if the navigator object exists
  282. * @returns true if the navigator object exists
  283. */
  284. static IsNavigatorAvailable(): boolean;
  285. /**
  286. * Extracts text content from a DOM element hierarchy
  287. * @param element defines the root element
  288. * @returns a string
  289. */
  290. static GetDOMTextContent(element: HTMLElement): string;
  291. }
  292. }
  293. declare module BABYLON {
  294. /**
  295. * Logger used througouht the application to allow configuration of
  296. * the log level required for the messages.
  297. */
  298. export class Logger {
  299. /**
  300. * No log
  301. */
  302. static readonly NoneLogLevel: number;
  303. /**
  304. * Only message logs
  305. */
  306. static readonly MessageLogLevel: number;
  307. /**
  308. * Only warning logs
  309. */
  310. static readonly WarningLogLevel: number;
  311. /**
  312. * Only error logs
  313. */
  314. static readonly ErrorLogLevel: number;
  315. /**
  316. * All logs
  317. */
  318. static readonly AllLogLevel: number;
  319. private static _LogCache;
  320. /**
  321. * Gets a value indicating the number of loading errors
  322. * @ignorenaming
  323. */
  324. static errorsCount: number;
  325. /**
  326. * Callback called when a new log is added
  327. */
  328. static OnNewCacheEntry: (entry: string) => void;
  329. private static _AddLogEntry;
  330. private static _FormatMessage;
  331. private static _LogDisabled;
  332. private static _LogEnabled;
  333. private static _WarnDisabled;
  334. private static _WarnEnabled;
  335. private static _ErrorDisabled;
  336. private static _ErrorEnabled;
  337. /**
  338. * Log a message to the console
  339. */
  340. static Log: (message: string) => void;
  341. /**
  342. * Write a warning message to the console
  343. */
  344. static Warn: (message: string) => void;
  345. /**
  346. * Write an error message to the console
  347. */
  348. static Error: (message: string) => void;
  349. /**
  350. * Gets current log cache (list of logs)
  351. */
  352. static readonly LogCache: string;
  353. /**
  354. * Clears the log cache
  355. */
  356. static ClearLogCache(): void;
  357. /**
  358. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  359. */
  360. static LogLevels: number;
  361. }
  362. }
  363. declare module BABYLON {
  364. /** @hidden */
  365. export class _TypeStore {
  366. /** @hidden */
  367. static RegisteredTypes: {
  368. [key: string]: Object;
  369. };
  370. /** @hidden */
  371. static GetClass(fqdn: string): any;
  372. }
  373. }
  374. declare module BABYLON {
  375. /**
  376. * Class containing a set of static utilities functions for deep copy.
  377. */
  378. export class DeepCopier {
  379. /**
  380. * Tries to copy an object by duplicating every property
  381. * @param source defines the source object
  382. * @param destination defines the target object
  383. * @param doNotCopyList defines a list of properties to avoid
  384. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  385. */
  386. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  387. }
  388. }
  389. declare module BABYLON {
  390. /**
  391. * Class containing a set of static utilities functions for precision date
  392. */
  393. export class PrecisionDate {
  394. /**
  395. * Gets either window.performance.now() if supported or Date.now() else
  396. */
  397. static readonly Now: number;
  398. }
  399. }
  400. declare module BABYLON {
  401. /** @hidden */
  402. export class _DevTools {
  403. static WarnImport(name: string): string;
  404. }
  405. }
  406. declare module BABYLON {
  407. /**
  408. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  409. */
  410. export class WebRequest {
  411. private _xhr;
  412. /**
  413. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  414. * i.e. when loading files, where the server/service expects an Authorization header
  415. */
  416. static CustomRequestHeaders: {
  417. [key: string]: string;
  418. };
  419. /**
  420. * Add callback functions in this array to update all the requests before they get sent to the network
  421. */
  422. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  423. private _injectCustomRequestHeaders;
  424. /**
  425. * Gets or sets a function to be called when loading progress changes
  426. */
  427. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  428. /**
  429. * Returns client's state
  430. */
  431. readonly readyState: number;
  432. /**
  433. * Returns client's status
  434. */
  435. readonly status: number;
  436. /**
  437. * Returns client's status as a text
  438. */
  439. readonly statusText: string;
  440. /**
  441. * Returns client's response
  442. */
  443. readonly response: any;
  444. /**
  445. * Returns client's response url
  446. */
  447. readonly responseURL: string;
  448. /**
  449. * Returns client's response as text
  450. */
  451. readonly responseText: string;
  452. /**
  453. * Gets or sets the expected response type
  454. */
  455. responseType: XMLHttpRequestResponseType;
  456. /** @hidden */
  457. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  458. /** @hidden */
  459. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  460. /**
  461. * Cancels any network activity
  462. */
  463. abort(): void;
  464. /**
  465. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  466. * @param body defines an optional request body
  467. */
  468. send(body?: Document | BodyInit | null): void;
  469. /**
  470. * Sets the request method, request URL
  471. * @param method defines the method to use (GET, POST, etc..)
  472. * @param url defines the url to connect with
  473. */
  474. open(method: string, url: string): void;
  475. }
  476. }
  477. declare module BABYLON {
  478. /**
  479. * File request interface
  480. */
  481. export interface IFileRequest {
  482. /**
  483. * Raised when the request is complete (success or error).
  484. */
  485. onCompleteObservable: Observable<IFileRequest>;
  486. /**
  487. * Aborts the request for a file.
  488. */
  489. abort: () => void;
  490. }
  491. }
  492. declare module BABYLON {
  493. /**
  494. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  495. */
  496. export class PerformanceMonitor {
  497. private _enabled;
  498. private _rollingFrameTime;
  499. private _lastFrameTimeMs;
  500. /**
  501. * constructor
  502. * @param frameSampleSize The number of samples required to saturate the sliding window
  503. */
  504. constructor(frameSampleSize?: number);
  505. /**
  506. * Samples current frame
  507. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  508. */
  509. sampleFrame(timeMs?: number): void;
  510. /**
  511. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  512. */
  513. readonly averageFrameTime: number;
  514. /**
  515. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  516. */
  517. readonly averageFrameTimeVariance: number;
  518. /**
  519. * Returns the frame time of the most recent frame
  520. */
  521. readonly instantaneousFrameTime: number;
  522. /**
  523. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  524. */
  525. readonly averageFPS: number;
  526. /**
  527. * Returns the average framerate in frames per second using the most recent frame time
  528. */
  529. readonly instantaneousFPS: number;
  530. /**
  531. * Returns true if enough samples have been taken to completely fill the sliding window
  532. */
  533. readonly isSaturated: boolean;
  534. /**
  535. * Enables contributions to the sliding window sample set
  536. */
  537. enable(): void;
  538. /**
  539. * Disables contributions to the sliding window sample set
  540. * Samples will not be interpolated over the disabled period
  541. */
  542. disable(): void;
  543. /**
  544. * Returns true if sampling is enabled
  545. */
  546. readonly isEnabled: boolean;
  547. /**
  548. * Resets performance monitor
  549. */
  550. reset(): void;
  551. }
  552. /**
  553. * RollingAverage
  554. *
  555. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  556. */
  557. export class RollingAverage {
  558. /**
  559. * Current average
  560. */
  561. average: number;
  562. /**
  563. * Current variance
  564. */
  565. variance: number;
  566. protected _samples: Array<number>;
  567. protected _sampleCount: number;
  568. protected _pos: number;
  569. protected _m2: number;
  570. /**
  571. * constructor
  572. * @param length The number of samples required to saturate the sliding window
  573. */
  574. constructor(length: number);
  575. /**
  576. * Adds a sample to the sample set
  577. * @param v The sample value
  578. */
  579. add(v: number): void;
  580. /**
  581. * Returns previously added values or null if outside of history or outside the sliding window domain
  582. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  583. * @return Value previously recorded with add() or null if outside of range
  584. */
  585. history(i: number): number;
  586. /**
  587. * Returns true if enough samples have been taken to completely fill the sliding window
  588. * @return true if sample-set saturated
  589. */
  590. isSaturated(): boolean;
  591. /**
  592. * Resets the rolling average (equivalent to 0 samples taken so far)
  593. */
  594. reset(): void;
  595. /**
  596. * Wraps a value around the sample range boundaries
  597. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  598. * @return Wrapped position in sample range
  599. */
  600. protected _wrapPosition(i: number): number;
  601. }
  602. }
  603. declare module BABYLON {
  604. /**
  605. * This class implement a typical dictionary using a string as key and the generic type T as value.
  606. * The underlying implementation relies on an associative array to ensure the best performances.
  607. * The value can be anything including 'null' but except 'undefined'
  608. */
  609. export class StringDictionary<T> {
  610. /**
  611. * This will clear this dictionary and copy the content from the 'source' one.
  612. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  613. * @param source the dictionary to take the content from and copy to this dictionary
  614. */
  615. copyFrom(source: StringDictionary<T>): void;
  616. /**
  617. * Get a value based from its key
  618. * @param key the given key to get the matching value from
  619. * @return the value if found, otherwise undefined is returned
  620. */
  621. get(key: string): T | undefined;
  622. /**
  623. * Get a value from its key or add it if it doesn't exist.
  624. * This method will ensure you that a given key/data will be present in the dictionary.
  625. * @param key the given key to get the matching value from
  626. * @param factory the factory that will create the value if the key is not present in the dictionary.
  627. * The factory will only be invoked if there's no data for the given key.
  628. * @return the value corresponding to the key.
  629. */
  630. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  631. /**
  632. * Get a value from its key if present in the dictionary otherwise add it
  633. * @param key the key to get the value from
  634. * @param val if there's no such key/value pair in the dictionary add it with this value
  635. * @return the value corresponding to the key
  636. */
  637. getOrAdd(key: string, val: T): T;
  638. /**
  639. * Check if there's a given key in the dictionary
  640. * @param key the key to check for
  641. * @return true if the key is present, false otherwise
  642. */
  643. contains(key: string): boolean;
  644. /**
  645. * Add a new key and its corresponding value
  646. * @param key the key to add
  647. * @param value the value corresponding to the key
  648. * @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
  649. */
  650. add(key: string, value: T): boolean;
  651. /**
  652. * Update a specific value associated to a key
  653. * @param key defines the key to use
  654. * @param value defines the value to store
  655. * @returns true if the value was updated (or false if the key was not found)
  656. */
  657. set(key: string, value: T): boolean;
  658. /**
  659. * Get the element of the given key and remove it from the dictionary
  660. * @param key defines the key to search
  661. * @returns the value associated with the key or null if not found
  662. */
  663. getAndRemove(key: string): Nullable<T>;
  664. /**
  665. * Remove a key/value from the dictionary.
  666. * @param key the key to remove
  667. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  668. */
  669. remove(key: string): boolean;
  670. /**
  671. * Clear the whole content of the dictionary
  672. */
  673. clear(): void;
  674. /**
  675. * Gets the current count
  676. */
  677. readonly count: number;
  678. /**
  679. * Execute a callback on each key/val of the dictionary.
  680. * Note that you can remove any element in this dictionary in the callback implementation
  681. * @param callback the callback to execute on a given key/value pair
  682. */
  683. forEach(callback: (key: string, val: T) => void): void;
  684. /**
  685. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  686. * If the callback returns null or undefined the method will iterate to the next key/value pair
  687. * Note that you can remove any element in this dictionary in the callback implementation
  688. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  689. * @returns the first item
  690. */
  691. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  692. private _count;
  693. private _data;
  694. }
  695. }
  696. declare module BABYLON {
  697. /**
  698. * Class used to store gfx data (like WebGLBuffer)
  699. */
  700. export class DataBuffer {
  701. /**
  702. * Gets or sets the number of objects referencing this buffer
  703. */
  704. references: number;
  705. /** Gets or sets the size of the underlying buffer */
  706. capacity: number;
  707. /**
  708. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  709. */
  710. is32Bits: boolean;
  711. /**
  712. * Gets the underlying buffer
  713. */
  714. readonly underlyingResource: any;
  715. }
  716. }
  717. declare module BABYLON {
  718. /**
  719. * Class used to store data that will be store in GPU memory
  720. */
  721. export class Buffer {
  722. private _engine;
  723. private _buffer;
  724. /** @hidden */ private _data: Nullable<DataArray>;
  725. private _updatable;
  726. private _instanced;
  727. /**
  728. * Gets the byte stride.
  729. */
  730. readonly byteStride: number;
  731. /**
  732. * Constructor
  733. * @param engine the engine
  734. * @param data the data to use for this buffer
  735. * @param updatable whether the data is updatable
  736. * @param stride the stride (optional)
  737. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  738. * @param instanced whether the buffer is instanced (optional)
  739. * @param useBytes set to true if the stride in in bytes (optional)
  740. */
  741. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  742. /**
  743. * Create a new VertexBuffer based on the current buffer
  744. * @param kind defines the vertex buffer kind (position, normal, etc.)
  745. * @param offset defines offset in the buffer (0 by default)
  746. * @param size defines the size in floats of attributes (position is 3 for instance)
  747. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  748. * @param instanced defines if the vertex buffer contains indexed data
  749. * @param useBytes defines if the offset and stride are in bytes
  750. * @returns the new vertex buffer
  751. */
  752. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  753. /**
  754. * Gets a boolean indicating if the Buffer is updatable?
  755. * @returns true if the buffer is updatable
  756. */
  757. isUpdatable(): boolean;
  758. /**
  759. * Gets current buffer's data
  760. * @returns a DataArray or null
  761. */
  762. getData(): Nullable<DataArray>;
  763. /**
  764. * Gets underlying native buffer
  765. * @returns underlying native buffer
  766. */
  767. getBuffer(): Nullable<DataBuffer>;
  768. /**
  769. * Gets the stride in float32 units (i.e. byte stride / 4).
  770. * May not be an integer if the byte stride is not divisible by 4.
  771. * DEPRECATED. Use byteStride instead.
  772. * @returns the stride in float32 units
  773. */
  774. getStrideSize(): number;
  775. /**
  776. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  777. * @param data defines the data to store
  778. */
  779. create(data?: Nullable<DataArray>): void;
  780. /** @hidden */ private _rebuild(): void;
  781. /**
  782. * Update current buffer data
  783. * @param data defines the data to store
  784. */
  785. update(data: DataArray): void;
  786. /**
  787. * Updates the data directly.
  788. * @param data the new data
  789. * @param offset the new offset
  790. * @param vertexCount the vertex count (optional)
  791. * @param useBytes set to true if the offset is in bytes
  792. */
  793. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  794. /**
  795. * Release all resources
  796. */
  797. dispose(): void;
  798. }
  799. /**
  800. * Specialized buffer used to store vertex data
  801. */
  802. export class VertexBuffer {
  803. /** @hidden */ private _buffer: Buffer;
  804. private _kind;
  805. private _size;
  806. private _ownsBuffer;
  807. private _instanced;
  808. private _instanceDivisor;
  809. /**
  810. * The byte type.
  811. */
  812. static readonly BYTE: number;
  813. /**
  814. * The unsigned byte type.
  815. */
  816. static readonly UNSIGNED_BYTE: number;
  817. /**
  818. * The short type.
  819. */
  820. static readonly SHORT: number;
  821. /**
  822. * The unsigned short type.
  823. */
  824. static readonly UNSIGNED_SHORT: number;
  825. /**
  826. * The integer type.
  827. */
  828. static readonly INT: number;
  829. /**
  830. * The unsigned integer type.
  831. */
  832. static readonly UNSIGNED_INT: number;
  833. /**
  834. * The float type.
  835. */
  836. static readonly FLOAT: number;
  837. /**
  838. * Gets or sets the instance divisor when in instanced mode
  839. */
  840. instanceDivisor: number;
  841. /**
  842. * Gets the byte stride.
  843. */
  844. readonly byteStride: number;
  845. /**
  846. * Gets the byte offset.
  847. */
  848. readonly byteOffset: number;
  849. /**
  850. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  851. */
  852. readonly normalized: boolean;
  853. /**
  854. * Gets the data type of each component in the array.
  855. */
  856. readonly type: number;
  857. /**
  858. * Constructor
  859. * @param engine the engine
  860. * @param data the data to use for this vertex buffer
  861. * @param kind the vertex buffer kind
  862. * @param updatable whether the data is updatable
  863. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  864. * @param stride the stride (optional)
  865. * @param instanced whether the buffer is instanced (optional)
  866. * @param offset the offset of the data (optional)
  867. * @param size the number of components (optional)
  868. * @param type the type of the component (optional)
  869. * @param normalized whether the data contains normalized data (optional)
  870. * @param useBytes set to true if stride and offset are in bytes (optional)
  871. */
  872. 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);
  873. /** @hidden */ private _rebuild(): void;
  874. /**
  875. * Returns the kind of the VertexBuffer (string)
  876. * @returns a string
  877. */
  878. getKind(): string;
  879. /**
  880. * Gets a boolean indicating if the VertexBuffer is updatable?
  881. * @returns true if the buffer is updatable
  882. */
  883. isUpdatable(): boolean;
  884. /**
  885. * Gets current buffer's data
  886. * @returns a DataArray or null
  887. */
  888. getData(): Nullable<DataArray>;
  889. /**
  890. * Gets underlying native buffer
  891. * @returns underlying native buffer
  892. */
  893. getBuffer(): Nullable<DataBuffer>;
  894. /**
  895. * Gets the stride in float32 units (i.e. byte stride / 4).
  896. * May not be an integer if the byte stride is not divisible by 4.
  897. * DEPRECATED. Use byteStride instead.
  898. * @returns the stride in float32 units
  899. */
  900. getStrideSize(): number;
  901. /**
  902. * Returns the offset as a multiple of the type byte length.
  903. * DEPRECATED. Use byteOffset instead.
  904. * @returns the offset in bytes
  905. */
  906. getOffset(): number;
  907. /**
  908. * Returns the number of components per vertex attribute (integer)
  909. * @returns the size in float
  910. */
  911. getSize(): number;
  912. /**
  913. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  914. * @returns true if this buffer is instanced
  915. */
  916. getIsInstanced(): boolean;
  917. /**
  918. * Returns the instancing divisor, zero for non-instanced (integer).
  919. * @returns a number
  920. */
  921. getInstanceDivisor(): number;
  922. /**
  923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  924. * @param data defines the data to store
  925. */
  926. create(data?: DataArray): void;
  927. /**
  928. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  929. * This function will create a new buffer if the current one is not updatable
  930. * @param data defines the data to store
  931. */
  932. update(data: DataArray): void;
  933. /**
  934. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  935. * Returns the directly updated WebGLBuffer.
  936. * @param data the new data
  937. * @param offset the new offset
  938. * @param useBytes set to true if the offset is in bytes
  939. */
  940. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  941. /**
  942. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  943. */
  944. dispose(): void;
  945. /**
  946. * Enumerates each value of this vertex buffer as numbers.
  947. * @param count the number of values to enumerate
  948. * @param callback the callback function called for each value
  949. */
  950. forEach(count: number, callback: (value: number, index: number) => void): void;
  951. /**
  952. * Positions
  953. */
  954. static readonly PositionKind: string;
  955. /**
  956. * Normals
  957. */
  958. static readonly NormalKind: string;
  959. /**
  960. * Tangents
  961. */
  962. static readonly TangentKind: string;
  963. /**
  964. * Texture coordinates
  965. */
  966. static readonly UVKind: string;
  967. /**
  968. * Texture coordinates 2
  969. */
  970. static readonly UV2Kind: string;
  971. /**
  972. * Texture coordinates 3
  973. */
  974. static readonly UV3Kind: string;
  975. /**
  976. * Texture coordinates 4
  977. */
  978. static readonly UV4Kind: string;
  979. /**
  980. * Texture coordinates 5
  981. */
  982. static readonly UV5Kind: string;
  983. /**
  984. * Texture coordinates 6
  985. */
  986. static readonly UV6Kind: string;
  987. /**
  988. * Colors
  989. */
  990. static readonly ColorKind: string;
  991. /**
  992. * Matrix indices (for bones)
  993. */
  994. static readonly MatricesIndicesKind: string;
  995. /**
  996. * Matrix weights (for bones)
  997. */
  998. static readonly MatricesWeightsKind: string;
  999. /**
  1000. * Additional matrix indices (for bones)
  1001. */
  1002. static readonly MatricesIndicesExtraKind: string;
  1003. /**
  1004. * Additional matrix weights (for bones)
  1005. */
  1006. static readonly MatricesWeightsExtraKind: string;
  1007. /**
  1008. * Deduces the stride given a kind.
  1009. * @param kind The kind string to deduce
  1010. * @returns The deduced stride
  1011. */
  1012. static DeduceStride(kind: string): number;
  1013. /**
  1014. * Gets the byte length of the given type.
  1015. * @param type the type
  1016. * @returns the number of bytes
  1017. */
  1018. static GetTypeByteLength(type: number): number;
  1019. /**
  1020. * Enumerates each value of the given parameters as numbers.
  1021. * @param data the data to enumerate
  1022. * @param byteOffset the byte offset of the data
  1023. * @param byteStride the byte stride of the data
  1024. * @param componentCount the number of components per element
  1025. * @param componentType the type of the component
  1026. * @param count the number of values to enumerate
  1027. * @param normalized whether the data is normalized
  1028. * @param callback the callback function called for each value
  1029. */
  1030. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1031. private static _GetFloatValue;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * Scalar computation library
  1037. */
  1038. export class Scalar {
  1039. /**
  1040. * Two pi constants convenient for computation.
  1041. */
  1042. static TwoPi: number;
  1043. /**
  1044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1045. * @param a number
  1046. * @param b number
  1047. * @param epsilon (default = 1.401298E-45)
  1048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1049. */
  1050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1051. /**
  1052. * Returns a string : the upper case translation of the number i to hexadecimal.
  1053. * @param i number
  1054. * @returns the upper case translation of the number i to hexadecimal.
  1055. */
  1056. static ToHex(i: number): string;
  1057. /**
  1058. * Returns -1 if value is negative and +1 is value is positive.
  1059. * @param value the value
  1060. * @returns the value itself if it's equal to zero.
  1061. */
  1062. static Sign(value: number): number;
  1063. /**
  1064. * Returns the value itself if it's between min and max.
  1065. * Returns min if the value is lower than min.
  1066. * Returns max if the value is greater than max.
  1067. * @param value the value to clmap
  1068. * @param min the min value to clamp to (default: 0)
  1069. * @param max the max value to clamp to (default: 1)
  1070. * @returns the clamped value
  1071. */
  1072. static Clamp(value: number, min?: number, max?: number): number;
  1073. /**
  1074. * the log2 of value.
  1075. * @param value the value to compute log2 of
  1076. * @returns the log2 of value.
  1077. */
  1078. static Log2(value: number): number;
  1079. /**
  1080. * Loops the value, so that it is never larger than length and never smaller than 0.
  1081. *
  1082. * This is similar to the modulo operator but it works with floating point numbers.
  1083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1084. * With t = 5 and length = 2.5, the result would be 0.0.
  1085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1086. * @param value the value
  1087. * @param length the length
  1088. * @returns the looped value
  1089. */
  1090. static Repeat(value: number, length: number): number;
  1091. /**
  1092. * Normalize the value between 0.0 and 1.0 using min and max values
  1093. * @param value value to normalize
  1094. * @param min max to normalize between
  1095. * @param max min to normalize between
  1096. * @returns the normalized value
  1097. */
  1098. static Normalize(value: number, min: number, max: number): number;
  1099. /**
  1100. * Denormalize the value from 0.0 and 1.0 using min and max values
  1101. * @param normalized value to denormalize
  1102. * @param min max to denormalize between
  1103. * @param max min to denormalize between
  1104. * @returns the denormalized value
  1105. */
  1106. static Denormalize(normalized: number, min: number, max: number): number;
  1107. /**
  1108. * Calculates the shortest difference between two given angles given in degrees.
  1109. * @param current current angle in degrees
  1110. * @param target target angle in degrees
  1111. * @returns the delta
  1112. */
  1113. static DeltaAngle(current: number, target: number): number;
  1114. /**
  1115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1116. * @param tx value
  1117. * @param length length
  1118. * @returns The returned value will move back and forth between 0 and length
  1119. */
  1120. static PingPong(tx: number, length: number): number;
  1121. /**
  1122. * Interpolates between min and max with smoothing at the limits.
  1123. *
  1124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1126. * @param from from
  1127. * @param to to
  1128. * @param tx value
  1129. * @returns the smooth stepped value
  1130. */
  1131. static SmoothStep(from: number, to: number, tx: number): number;
  1132. /**
  1133. * Moves a value current towards target.
  1134. *
  1135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1136. * Negative values of maxDelta pushes the value away from target.
  1137. * @param current current value
  1138. * @param target target value
  1139. * @param maxDelta max distance to move
  1140. * @returns resulting value
  1141. */
  1142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1143. /**
  1144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1145. *
  1146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1148. * @param current current value
  1149. * @param target target value
  1150. * @param maxDelta max distance to move
  1151. * @returns resulting angle
  1152. */
  1153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1154. /**
  1155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1156. * @param start start value
  1157. * @param end target value
  1158. * @param amount amount to lerp between
  1159. * @returns the lerped value
  1160. */
  1161. static Lerp(start: number, end: number, amount: number): number;
  1162. /**
  1163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1165. * @param start start value
  1166. * @param end target value
  1167. * @param amount amount to lerp between
  1168. * @returns the lerped value
  1169. */
  1170. static LerpAngle(start: number, end: number, amount: number): number;
  1171. /**
  1172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1173. * @param a start value
  1174. * @param b target value
  1175. * @param value value between a and b
  1176. * @returns the inverseLerp value
  1177. */
  1178. static InverseLerp(a: number, b: number, value: number): number;
  1179. /**
  1180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1182. * @param value1 spline value
  1183. * @param tangent1 spline value
  1184. * @param value2 spline value
  1185. * @param tangent2 spline value
  1186. * @param amount input value
  1187. * @returns hermite result
  1188. */
  1189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1190. /**
  1191. * Returns a random float number between and min and max values
  1192. * @param min min value of random
  1193. * @param max max value of random
  1194. * @returns random value
  1195. */
  1196. static RandomRange(min: number, max: number): number;
  1197. /**
  1198. * This function returns percentage of a number in a given range.
  1199. *
  1200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1202. * @param number to convert to percentage
  1203. * @param min min range
  1204. * @param max max range
  1205. * @returns the percentage
  1206. */
  1207. static RangeToPercent(number: number, min: number, max: number): number;
  1208. /**
  1209. * This function returns number that corresponds to the percentage in a given range.
  1210. *
  1211. * PercentToRange(0.34,0,100) will return 34.
  1212. * @param percent to convert to number
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the number
  1216. */
  1217. static PercentToRange(percent: number, min: number, max: number): number;
  1218. /**
  1219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1220. * @param angle The angle to normalize in radian.
  1221. * @return The converted angle.
  1222. */
  1223. static NormalizeRadians(angle: number): number;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /**
  1228. * Constant used to convert a value to gamma space
  1229. * @ignorenaming
  1230. */
  1231. export const ToGammaSpace: number;
  1232. /**
  1233. * Constant used to convert a value to linear space
  1234. * @ignorenaming
  1235. */
  1236. export const ToLinearSpace = 2.2;
  1237. /**
  1238. * Constant used to define the minimal number value in Babylon.js
  1239. * @ignorenaming
  1240. */
  1241. let Epsilon: number;
  1242. }
  1243. declare module BABYLON {
  1244. /**
  1245. * Class used to represent a viewport on screen
  1246. */
  1247. export class Viewport {
  1248. /** viewport left coordinate */
  1249. x: number;
  1250. /** viewport top coordinate */
  1251. y: number;
  1252. /**viewport width */
  1253. width: number;
  1254. /** viewport height */
  1255. height: number;
  1256. /**
  1257. * Creates a Viewport object located at (x, y) and sized (width, height)
  1258. * @param x defines viewport left coordinate
  1259. * @param y defines viewport top coordinate
  1260. * @param width defines the viewport width
  1261. * @param height defines the viewport height
  1262. */
  1263. constructor(
  1264. /** viewport left coordinate */
  1265. x: number,
  1266. /** viewport top coordinate */
  1267. y: number,
  1268. /**viewport width */
  1269. width: number,
  1270. /** viewport height */
  1271. height: number);
  1272. /**
  1273. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1274. * @param renderWidth defines the rendering width
  1275. * @param renderHeight defines the rendering height
  1276. * @returns a new Viewport
  1277. */
  1278. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1279. /**
  1280. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1281. * @param renderWidth defines the rendering width
  1282. * @param renderHeight defines the rendering height
  1283. * @param ref defines the target viewport
  1284. * @returns the current viewport
  1285. */
  1286. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1287. /**
  1288. * Returns a new Viewport copied from the current one
  1289. * @returns a new Viewport
  1290. */
  1291. clone(): Viewport;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class containing a set of static utilities functions for arrays.
  1297. */
  1298. export class ArrayTools {
  1299. /**
  1300. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1301. * @param size the number of element to construct and put in the array
  1302. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1303. * @returns a new array filled with new objects
  1304. */
  1305. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * @hidden
  1311. */
  1312. export interface IColor4Like {
  1313. r: float;
  1314. g: float;
  1315. b: float;
  1316. a: float;
  1317. }
  1318. /**
  1319. * @hidden
  1320. */
  1321. export interface IColor3Like {
  1322. r: float;
  1323. g: float;
  1324. b: float;
  1325. }
  1326. /**
  1327. * @hidden
  1328. */
  1329. export interface IVector4Like {
  1330. x: float;
  1331. y: float;
  1332. z: float;
  1333. w: float;
  1334. }
  1335. /**
  1336. * @hidden
  1337. */
  1338. export interface IVector3Like {
  1339. x: float;
  1340. y: float;
  1341. z: float;
  1342. }
  1343. /**
  1344. * @hidden
  1345. */
  1346. export interface IVector2Like {
  1347. x: float;
  1348. y: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IMatrixLike {
  1354. toArray(): DeepImmutable<Float32Array>;
  1355. updateFlag: int;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IViewportLike {
  1361. x: float;
  1362. y: float;
  1363. width: float;
  1364. height: float;
  1365. }
  1366. /**
  1367. * @hidden
  1368. */
  1369. export interface IPlaneLike {
  1370. normal: IVector3Like;
  1371. d: float;
  1372. normalize(): void;
  1373. }
  1374. }
  1375. declare module BABYLON {
  1376. /**
  1377. * Class representing a vector containing 2 coordinates
  1378. */
  1379. export class Vector2 {
  1380. /** defines the first coordinate */
  1381. x: number;
  1382. /** defines the second coordinate */
  1383. y: number;
  1384. /**
  1385. * Creates a new Vector2 from the given x and y coordinates
  1386. * @param x defines the first coordinate
  1387. * @param y defines the second coordinate
  1388. */
  1389. constructor(
  1390. /** defines the first coordinate */
  1391. x?: number,
  1392. /** defines the second coordinate */
  1393. y?: number);
  1394. /**
  1395. * Gets a string with the Vector2 coordinates
  1396. * @returns a string with the Vector2 coordinates
  1397. */
  1398. toString(): string;
  1399. /**
  1400. * Gets class name
  1401. * @returns the string "Vector2"
  1402. */
  1403. getClassName(): string;
  1404. /**
  1405. * Gets current vector hash code
  1406. * @returns the Vector2 hash code as a number
  1407. */
  1408. getHashCode(): number;
  1409. /**
  1410. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1411. * @param array defines the source array
  1412. * @param index defines the offset in source array
  1413. * @returns the current Vector2
  1414. */
  1415. toArray(array: FloatArray, index?: number): Vector2;
  1416. /**
  1417. * Copy the current vector to an array
  1418. * @returns a new array with 2 elements: the Vector2 coordinates.
  1419. */
  1420. asArray(): number[];
  1421. /**
  1422. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1423. * @param source defines the source Vector2
  1424. * @returns the current updated Vector2
  1425. */
  1426. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1427. /**
  1428. * Sets the Vector2 coordinates with the given floats
  1429. * @param x defines the first coordinate
  1430. * @param y defines the second coordinate
  1431. * @returns the current updated Vector2
  1432. */
  1433. copyFromFloats(x: number, y: number): Vector2;
  1434. /**
  1435. * Sets the Vector2 coordinates with the given floats
  1436. * @param x defines the first coordinate
  1437. * @param y defines the second coordinate
  1438. * @returns the current updated Vector2
  1439. */
  1440. set(x: number, y: number): Vector2;
  1441. /**
  1442. * Add another vector with the current one
  1443. * @param otherVector defines the other vector
  1444. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1445. */
  1446. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1447. /**
  1448. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1449. * @param otherVector defines the other vector
  1450. * @param result defines the target vector
  1451. * @returns the unmodified current Vector2
  1452. */
  1453. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1454. /**
  1455. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1456. * @param otherVector defines the other vector
  1457. * @returns the current updated Vector2
  1458. */
  1459. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1460. /**
  1461. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1462. * @param otherVector defines the other vector
  1463. * @returns a new Vector2
  1464. */
  1465. addVector3(otherVector: Vector3): Vector2;
  1466. /**
  1467. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1468. * @param otherVector defines the other vector
  1469. * @returns a new Vector2
  1470. */
  1471. subtract(otherVector: Vector2): Vector2;
  1472. /**
  1473. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1474. * @param otherVector defines the other vector
  1475. * @param result defines the target vector
  1476. * @returns the unmodified current Vector2
  1477. */
  1478. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1479. /**
  1480. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1481. * @param otherVector defines the other vector
  1482. * @returns the current updated Vector2
  1483. */
  1484. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1485. /**
  1486. * Multiplies in place the current Vector2 coordinates by the given ones
  1487. * @param otherVector defines the other vector
  1488. * @returns the current updated Vector2
  1489. */
  1490. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1491. /**
  1492. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1493. * @param otherVector defines the other vector
  1494. * @returns a new Vector2
  1495. */
  1496. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1497. /**
  1498. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1499. * @param otherVector defines the other vector
  1500. * @param result defines the target vector
  1501. * @returns the unmodified current Vector2
  1502. */
  1503. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1504. /**
  1505. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1506. * @param x defines the first coordinate
  1507. * @param y defines the second coordinate
  1508. * @returns a new Vector2
  1509. */
  1510. multiplyByFloats(x: number, y: number): Vector2;
  1511. /**
  1512. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1513. * @param otherVector defines the other vector
  1514. * @returns a new Vector2
  1515. */
  1516. divide(otherVector: Vector2): Vector2;
  1517. /**
  1518. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1519. * @param otherVector defines the other vector
  1520. * @param result defines the target vector
  1521. * @returns the unmodified current Vector2
  1522. */
  1523. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1524. /**
  1525. * Divides the current Vector2 coordinates by the given ones
  1526. * @param otherVector defines the other vector
  1527. * @returns the current updated Vector2
  1528. */
  1529. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1530. /**
  1531. * Gets a new Vector2 with current Vector2 negated coordinates
  1532. * @returns a new Vector2
  1533. */
  1534. negate(): Vector2;
  1535. /**
  1536. * Multiply the Vector2 coordinates by scale
  1537. * @param scale defines the scaling factor
  1538. * @returns the current updated Vector2
  1539. */
  1540. scaleInPlace(scale: number): Vector2;
  1541. /**
  1542. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1543. * @param scale defines the scaling factor
  1544. * @returns a new Vector2
  1545. */
  1546. scale(scale: number): Vector2;
  1547. /**
  1548. * Scale the current Vector2 values by a factor to a given Vector2
  1549. * @param scale defines the scale factor
  1550. * @param result defines the Vector2 object where to store the result
  1551. * @returns the unmodified current Vector2
  1552. */
  1553. scaleToRef(scale: number, result: Vector2): Vector2;
  1554. /**
  1555. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1556. * @param scale defines the scale factor
  1557. * @param result defines the Vector2 object where to store the result
  1558. * @returns the unmodified current Vector2
  1559. */
  1560. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1561. /**
  1562. * Gets a boolean if two vectors are equals
  1563. * @param otherVector defines the other vector
  1564. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1565. */
  1566. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1567. /**
  1568. * Gets a boolean if two vectors are equals (using an epsilon value)
  1569. * @param otherVector defines the other vector
  1570. * @param epsilon defines the minimal distance to consider equality
  1571. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1572. */
  1573. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. floor(): Vector2;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. fract(): Vector2;
  1584. /**
  1585. * Gets the length of the vector
  1586. * @returns the vector length (float)
  1587. */
  1588. length(): number;
  1589. /**
  1590. * Gets the vector squared length
  1591. * @returns the vector squared length (float)
  1592. */
  1593. lengthSquared(): number;
  1594. /**
  1595. * Normalize the vector
  1596. * @returns the current updated Vector2
  1597. */
  1598. normalize(): Vector2;
  1599. /**
  1600. * Gets a new Vector2 copied from the Vector2
  1601. * @returns a new Vector2
  1602. */
  1603. clone(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(0, 0)
  1606. * @returns a new Vector2
  1607. */
  1608. static Zero(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(1, 1)
  1611. * @returns a new Vector2
  1612. */
  1613. static One(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 set from the given index element of the given array
  1616. * @param array defines the data source
  1617. * @param offset defines the offset in the data source
  1618. * @returns a new Vector2
  1619. */
  1620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1621. /**
  1622. * Sets "result" from the given index element of the given array
  1623. * @param array defines the data source
  1624. * @param offset defines the offset in the data source
  1625. * @param result defines the target vector
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1628. /**
  1629. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1630. * @param value1 defines 1st point of control
  1631. * @param value2 defines 2nd point of control
  1632. * @param value3 defines 3rd point of control
  1633. * @param value4 defines 4th point of control
  1634. * @param amount defines the interpolation factor
  1635. * @returns a new Vector2
  1636. */
  1637. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1638. /**
  1639. * 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".
  1640. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1641. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1642. * @param value defines the value to clamp
  1643. * @param min defines the lower limit
  1644. * @param max defines the upper limit
  1645. * @returns a new Vector2
  1646. */
  1647. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1648. /**
  1649. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1650. * @param value1 defines the 1st control point
  1651. * @param tangent1 defines the outgoing tangent
  1652. * @param value2 defines the 2nd control point
  1653. * @param tangent2 defines the incoming tangent
  1654. * @param amount defines the interpolation factor
  1655. * @returns a new Vector2
  1656. */
  1657. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1660. * @param start defines the start vector
  1661. * @param end defines the end vector
  1662. * @param amount defines the interpolation factor
  1663. * @returns a new Vector2
  1664. */
  1665. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1666. /**
  1667. * Gets the dot product of the vector "left" and the vector "right"
  1668. * @param left defines first vector
  1669. * @param right defines second vector
  1670. * @returns the dot product (float)
  1671. */
  1672. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1673. /**
  1674. * Returns a new Vector2 equal to the normalized given vector
  1675. * @param vector defines the vector to normalize
  1676. * @returns a new Vector2
  1677. */
  1678. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1679. /**
  1680. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1681. * @param left defines 1st vector
  1682. * @param right defines 2nd vector
  1683. * @returns a new Vector2
  1684. */
  1685. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1686. /**
  1687. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1688. * @param left defines 1st vector
  1689. * @param right defines 2nd vector
  1690. * @returns a new Vector2
  1691. */
  1692. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1693. /**
  1694. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1695. * @param vector defines the vector to transform
  1696. * @param transformation defines the matrix to apply
  1697. * @returns a new Vector2
  1698. */
  1699. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1700. /**
  1701. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1702. * @param vector defines the vector to transform
  1703. * @param transformation defines the matrix to apply
  1704. * @param result defines the target vector
  1705. */
  1706. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1707. /**
  1708. * Determines if a given vector is included in a triangle
  1709. * @param p defines the vector to test
  1710. * @param p0 defines 1st triangle point
  1711. * @param p1 defines 2nd triangle point
  1712. * @param p2 defines 3rd triangle point
  1713. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1714. */
  1715. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1716. /**
  1717. * Gets the distance between the vectors "value1" and "value2"
  1718. * @param value1 defines first vector
  1719. * @param value2 defines second vector
  1720. * @returns the distance between vectors
  1721. */
  1722. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1723. /**
  1724. * Returns the squared distance between the vectors "value1" and "value2"
  1725. * @param value1 defines first vector
  1726. * @param value2 defines second vector
  1727. * @returns the squared distance between vectors
  1728. */
  1729. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1730. /**
  1731. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1732. * @param value1 defines first vector
  1733. * @param value2 defines second vector
  1734. * @returns a new Vector2
  1735. */
  1736. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1737. /**
  1738. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1739. * @param p defines the middle point
  1740. * @param segA defines one point of the segment
  1741. * @param segB defines the other point of the segment
  1742. * @returns the shortest distance
  1743. */
  1744. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1745. }
  1746. /**
  1747. * Classed used to store (x,y,z) vector representation
  1748. * A Vector3 is the main object used in 3D geometry
  1749. * It can represent etiher the coordinates of a point the space, either a direction
  1750. * Reminder: js uses a left handed forward facing system
  1751. */
  1752. export class Vector3 {
  1753. /**
  1754. * Defines the first coordinates (on X axis)
  1755. */
  1756. x: number;
  1757. /**
  1758. * Defines the second coordinates (on Y axis)
  1759. */
  1760. y: number;
  1761. /**
  1762. * Defines the third coordinates (on Z axis)
  1763. */
  1764. z: number;
  1765. private static _UpReadOnly;
  1766. private static _ZeroReadOnly;
  1767. /**
  1768. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1769. * @param x defines the first coordinates (on X axis)
  1770. * @param y defines the second coordinates (on Y axis)
  1771. * @param z defines the third coordinates (on Z axis)
  1772. */
  1773. constructor(
  1774. /**
  1775. * Defines the first coordinates (on X axis)
  1776. */
  1777. x?: number,
  1778. /**
  1779. * Defines the second coordinates (on Y axis)
  1780. */
  1781. y?: number,
  1782. /**
  1783. * Defines the third coordinates (on Z axis)
  1784. */
  1785. z?: number);
  1786. /**
  1787. * Creates a string representation of the Vector3
  1788. * @returns a string with the Vector3 coordinates.
  1789. */
  1790. toString(): string;
  1791. /**
  1792. * Gets the class name
  1793. * @returns the string "Vector3"
  1794. */
  1795. getClassName(): string;
  1796. /**
  1797. * Creates the Vector3 hash code
  1798. * @returns a number which tends to be unique between Vector3 instances
  1799. */
  1800. getHashCode(): number;
  1801. /**
  1802. * Creates an array containing three elements : the coordinates of the Vector3
  1803. * @returns a new array of numbers
  1804. */
  1805. asArray(): number[];
  1806. /**
  1807. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1808. * @param array defines the destination array
  1809. * @param index defines the offset in the destination array
  1810. * @returns the current Vector3
  1811. */
  1812. toArray(array: FloatArray, index?: number): Vector3;
  1813. /**
  1814. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1815. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1816. */
  1817. toQuaternion(): Quaternion;
  1818. /**
  1819. * Adds the given vector to the current Vector3
  1820. * @param otherVector defines the second operand
  1821. * @returns the current updated Vector3
  1822. */
  1823. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1824. /**
  1825. * Adds the given coordinates to the current Vector3
  1826. * @param x defines the x coordinate of the operand
  1827. * @param y defines the y coordinate of the operand
  1828. * @param z defines the z coordinate of the operand
  1829. * @returns the current updated Vector3
  1830. */
  1831. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1832. /**
  1833. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1834. * @param otherVector defines the second operand
  1835. * @returns the resulting Vector3
  1836. */
  1837. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1838. /**
  1839. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1840. * @param otherVector defines the second operand
  1841. * @param result defines the Vector3 object where to store the result
  1842. * @returns the current Vector3
  1843. */
  1844. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1845. /**
  1846. * Subtract the given vector from the current Vector3
  1847. * @param otherVector defines the second operand
  1848. * @returns the current updated Vector3
  1849. */
  1850. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1851. /**
  1852. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1853. * @param otherVector defines the second operand
  1854. * @returns the resulting Vector3
  1855. */
  1856. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1859. * @param otherVector defines the second operand
  1860. * @param result defines the Vector3 object where to store the result
  1861. * @returns the current Vector3
  1862. */
  1863. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1864. /**
  1865. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1866. * @param x defines the x coordinate of the operand
  1867. * @param y defines the y coordinate of the operand
  1868. * @param z defines the z coordinate of the operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1872. /**
  1873. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1874. * @param x defines the x coordinate of the operand
  1875. * @param y defines the y coordinate of the operand
  1876. * @param z defines the z coordinate of the operand
  1877. * @param result defines the Vector3 object where to store the result
  1878. * @returns the current Vector3
  1879. */
  1880. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1881. /**
  1882. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1883. * @returns a new Vector3
  1884. */
  1885. negate(): Vector3;
  1886. /**
  1887. * Multiplies the Vector3 coordinates by the float "scale"
  1888. * @param scale defines the multiplier factor
  1889. * @returns the current updated Vector3
  1890. */
  1891. scaleInPlace(scale: number): Vector3;
  1892. /**
  1893. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1894. * @param scale defines the multiplier factor
  1895. * @returns a new Vector3
  1896. */
  1897. scale(scale: number): Vector3;
  1898. /**
  1899. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1900. * @param scale defines the multiplier factor
  1901. * @param result defines the Vector3 object where to store the result
  1902. * @returns the current Vector3
  1903. */
  1904. scaleToRef(scale: number, result: Vector3): Vector3;
  1905. /**
  1906. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1907. * @param scale defines the scale factor
  1908. * @param result defines the Vector3 object where to store the result
  1909. * @returns the unmodified current Vector3
  1910. */
  1911. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1912. /**
  1913. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1914. * @param otherVector defines the second operand
  1915. * @returns true if both vectors are equals
  1916. */
  1917. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1918. /**
  1919. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1920. * @param otherVector defines the second operand
  1921. * @param epsilon defines the minimal distance to define values as equals
  1922. * @returns true if both vectors are distant less than epsilon
  1923. */
  1924. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1925. /**
  1926. * Returns true if the current Vector3 coordinates equals the given floats
  1927. * @param x defines the x coordinate of the operand
  1928. * @param y defines the y coordinate of the operand
  1929. * @param z defines the z coordinate of the operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equalsToFloats(x: number, y: number, z: number): boolean;
  1933. /**
  1934. * Multiplies the current Vector3 coordinates by the given ones
  1935. * @param otherVector defines the second operand
  1936. * @returns the current updated Vector3
  1937. */
  1938. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1939. /**
  1940. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1941. * @param otherVector defines the second operand
  1942. * @returns the new Vector3
  1943. */
  1944. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1947. * @param otherVector defines the second operand
  1948. * @param result defines the Vector3 object where to store the result
  1949. * @returns the current Vector3
  1950. */
  1951. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1952. /**
  1953. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1954. * @param x defines the x coordinate of the operand
  1955. * @param y defines the y coordinate of the operand
  1956. * @param z defines the z coordinate of the operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1960. /**
  1961. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1962. * @param otherVector defines the second operand
  1963. * @returns the new Vector3
  1964. */
  1965. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1966. /**
  1967. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1968. * @param otherVector defines the second operand
  1969. * @param result defines the Vector3 object where to store the result
  1970. * @returns the current Vector3
  1971. */
  1972. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1973. /**
  1974. * Divides the current Vector3 coordinates by the given ones.
  1975. * @param otherVector defines the second operand
  1976. * @returns the current updated Vector3
  1977. */
  1978. divideInPlace(otherVector: Vector3): Vector3;
  1979. /**
  1980. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1981. * @param other defines the second operand
  1982. * @returns the current updated Vector3
  1983. */
  1984. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1985. /**
  1986. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1987. * @param other defines the second operand
  1988. * @returns the current updated Vector3
  1989. */
  1990. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1991. /**
  1992. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1993. * @param x defines the x coordinate of the operand
  1994. * @param y defines the y coordinate of the operand
  1995. * @param z defines the z coordinate of the operand
  1996. * @returns the current updated Vector3
  1997. */
  1998. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1999. /**
  2000. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2001. * @param x defines the x coordinate of the operand
  2002. * @param y defines the y coordinate of the operand
  2003. * @param z defines the z coordinate of the operand
  2004. * @returns the current updated Vector3
  2005. */
  2006. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2007. /**
  2008. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2009. * Check if is non uniform within a certain amount of decimal places to account for this
  2010. * @param epsilon the amount the values can differ
  2011. * @returns if the the vector is non uniform to a certain number of decimal places
  2012. */
  2013. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2014. /**
  2015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2016. */
  2017. readonly isNonUniform: boolean;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. floor(): Vector3;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. fract(): Vector3;
  2028. /**
  2029. * Gets the length of the Vector3
  2030. * @returns the length of the Vector3
  2031. */
  2032. length(): number;
  2033. /**
  2034. * Gets the squared length of the Vector3
  2035. * @returns squared length of the Vector3
  2036. */
  2037. lengthSquared(): number;
  2038. /**
  2039. * Normalize the current Vector3.
  2040. * Please note that this is an in place operation.
  2041. * @returns the current updated Vector3
  2042. */
  2043. normalize(): Vector3;
  2044. /**
  2045. * Reorders the x y z properties of the vector in place
  2046. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2047. * @returns the current updated vector
  2048. */
  2049. reorderInPlace(order: string): this;
  2050. /**
  2051. * Rotates the vector around 0,0,0 by a quaternion
  2052. * @param quaternion the rotation quaternion
  2053. * @param result vector to store the result
  2054. * @returns the resulting vector
  2055. */
  2056. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2057. /**
  2058. * Rotates a vector around a given point
  2059. * @param quaternion the rotation quaternion
  2060. * @param point the point to rotate around
  2061. * @param result vector to store the result
  2062. * @returns the resulting vector
  2063. */
  2064. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2065. /**
  2066. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2067. * The cross product is then orthogonal to both current and "other"
  2068. * @param other defines the right operand
  2069. * @returns the cross product
  2070. */
  2071. cross(other: Vector3): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 with the given input length.
  2074. * Please note that this is an in place operation.
  2075. * @param len the length of the vector
  2076. * @returns the current updated Vector3
  2077. */
  2078. normalizeFromLength(len: number): Vector3;
  2079. /**
  2080. * Normalize the current Vector3 to a new vector
  2081. * @returns the new Vector3
  2082. */
  2083. normalizeToNew(): Vector3;
  2084. /**
  2085. * Normalize the current Vector3 to the reference
  2086. * @param reference define the Vector3 to update
  2087. * @returns the updated Vector3
  2088. */
  2089. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2090. /**
  2091. * Creates a new Vector3 copied from the current Vector3
  2092. * @returns the new Vector3
  2093. */
  2094. clone(): Vector3;
  2095. /**
  2096. * Copies the given vector coordinates to the current Vector3 ones
  2097. * @param source defines the source Vector3
  2098. * @returns the current updated Vector3
  2099. */
  2100. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2101. /**
  2102. * Copies the given floats to the current Vector3 coordinates
  2103. * @param x defines the x coordinate of the operand
  2104. * @param y defines the y coordinate of the operand
  2105. * @param z defines the z coordinate of the operand
  2106. * @returns the current updated Vector3
  2107. */
  2108. copyFromFloats(x: number, y: number, z: number): Vector3;
  2109. /**
  2110. * Copies the given floats to the current Vector3 coordinates
  2111. * @param x defines the x coordinate of the operand
  2112. * @param y defines the y coordinate of the operand
  2113. * @param z defines the z coordinate of the operand
  2114. * @returns the current updated Vector3
  2115. */
  2116. set(x: number, y: number, z: number): Vector3;
  2117. /**
  2118. * Copies the given float to the current Vector3 coordinates
  2119. * @param v defines the x, y and z coordinates of the operand
  2120. * @returns the current updated Vector3
  2121. */
  2122. setAll(v: number): Vector3;
  2123. /**
  2124. * Get the clip factor between two vectors
  2125. * @param vector0 defines the first operand
  2126. * @param vector1 defines the second operand
  2127. * @param axis defines the axis to use
  2128. * @param size defines the size along the axis
  2129. * @returns the clip factor
  2130. */
  2131. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2132. /**
  2133. * Get angle between two vectors
  2134. * @param vector0 angle between vector0 and vector1
  2135. * @param vector1 angle between vector0 and vector1
  2136. * @param normal direction of the normal
  2137. * @return the angle between vector0 and vector1
  2138. */
  2139. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2140. /**
  2141. * Returns a new Vector3 set from the index "offset" of the given array
  2142. * @param array defines the source array
  2143. * @param offset defines the offset in the source array
  2144. * @returns the new Vector3
  2145. */
  2146. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2147. /**
  2148. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2149. * This function is deprecated. Use FromArray instead
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @returns the new Vector3
  2153. */
  2154. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2155. /**
  2156. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2157. * @param array defines the source array
  2158. * @param offset defines the offset in the source array
  2159. * @param result defines the Vector3 where to store the result
  2160. */
  2161. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2162. /**
  2163. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2164. * This function is deprecated. Use FromArrayToRef instead.
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @param result defines the Vector3 where to store the result
  2168. */
  2169. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2170. /**
  2171. * Sets the given vector "result" with the given floats.
  2172. * @param x defines the x coordinate of the source
  2173. * @param y defines the y coordinate of the source
  2174. * @param z defines the z coordinate of the source
  2175. * @param result defines the Vector3 where to store the result
  2176. */
  2177. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2178. /**
  2179. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2180. * @returns a new empty Vector3
  2181. */
  2182. static Zero(): Vector3;
  2183. /**
  2184. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2185. * @returns a new unit Vector3
  2186. */
  2187. static One(): Vector3;
  2188. /**
  2189. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2190. * @returns a new up Vector3
  2191. */
  2192. static Up(): Vector3;
  2193. /**
  2194. * Gets a up Vector3 that must not be updated
  2195. */
  2196. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2197. /**
  2198. * Gets a zero Vector3 that must not be updated
  2199. */
  2200. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2201. /**
  2202. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2203. * @returns a new down Vector3
  2204. */
  2205. static Down(): Vector3;
  2206. /**
  2207. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2208. * @returns a new forward Vector3
  2209. */
  2210. static Forward(): Vector3;
  2211. /**
  2212. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2213. * @returns a new forward Vector3
  2214. */
  2215. static Backward(): Vector3;
  2216. /**
  2217. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2218. * @returns a new right Vector3
  2219. */
  2220. static Right(): Vector3;
  2221. /**
  2222. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2223. * @returns a new left Vector3
  2224. */
  2225. static Left(): Vector3;
  2226. /**
  2227. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2228. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2229. * @param vector defines the Vector3 to transform
  2230. * @param transformation defines the transformation matrix
  2231. * @returns the transformed Vector3
  2232. */
  2233. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2234. /**
  2235. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2236. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2237. * @param vector defines the Vector3 to transform
  2238. * @param transformation defines the transformation matrix
  2239. * @param result defines the Vector3 where to store the result
  2240. */
  2241. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2242. /**
  2243. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2244. * This method computes tranformed coordinates only, not transformed direction vectors
  2245. * @param x define the x coordinate of the source vector
  2246. * @param y define the y coordinate of the source vector
  2247. * @param z define the z coordinate of the source vector
  2248. * @param transformation defines the transformation matrix
  2249. * @param result defines the Vector3 where to store the result
  2250. */
  2251. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2252. /**
  2253. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2254. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2255. * @param vector defines the Vector3 to transform
  2256. * @param transformation defines the transformation matrix
  2257. * @returns the new Vector3
  2258. */
  2259. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2260. /**
  2261. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2262. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2263. * @param vector defines the Vector3 to transform
  2264. * @param transformation defines the transformation matrix
  2265. * @param result defines the Vector3 where to store the result
  2266. */
  2267. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2268. /**
  2269. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2270. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2271. * @param x define the x coordinate of the source vector
  2272. * @param y define the y coordinate of the source vector
  2273. * @param z define the z coordinate of the source vector
  2274. * @param transformation defines the transformation matrix
  2275. * @param result defines the Vector3 where to store the result
  2276. */
  2277. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2278. /**
  2279. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2280. * @param value1 defines the first control point
  2281. * @param value2 defines the second control point
  2282. * @param value3 defines the third control point
  2283. * @param value4 defines the fourth control point
  2284. * @param amount defines the amount on the spline to use
  2285. * @returns the new Vector3
  2286. */
  2287. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2288. /**
  2289. * 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"
  2290. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2291. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2292. * @param value defines the current value
  2293. * @param min defines the lower range value
  2294. * @param max defines the upper range value
  2295. * @returns the new Vector3
  2296. */
  2297. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2298. /**
  2299. * 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"
  2300. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2301. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2302. * @param value defines the current value
  2303. * @param min defines the lower range value
  2304. * @param max defines the upper range value
  2305. * @param result defines the Vector3 where to store the result
  2306. */
  2307. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2308. /**
  2309. * Checks if a given vector is inside a specific range
  2310. * @param v defines the vector to test
  2311. * @param min defines the minimum range
  2312. * @param max defines the maximum range
  2313. */
  2314. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2315. /**
  2316. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2317. * @param value1 defines the first control point
  2318. * @param tangent1 defines the first tangent vector
  2319. * @param value2 defines the second control point
  2320. * @param tangent2 defines the second tangent vector
  2321. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2322. * @returns the new Vector3
  2323. */
  2324. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2325. /**
  2326. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2327. * @param start defines the start value
  2328. * @param end defines the end value
  2329. * @param amount max defines amount between both (between 0 and 1)
  2330. * @returns the new Vector3
  2331. */
  2332. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2333. /**
  2334. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2335. * @param start defines the start value
  2336. * @param end defines the end value
  2337. * @param amount max defines amount between both (between 0 and 1)
  2338. * @param result defines the Vector3 where to store the result
  2339. */
  2340. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2341. /**
  2342. * Returns the dot product (float) between the vectors "left" and "right"
  2343. * @param left defines the left operand
  2344. * @param right defines the right operand
  2345. * @returns the dot product
  2346. */
  2347. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2348. /**
  2349. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2350. * The cross product is then orthogonal to both "left" and "right"
  2351. * @param left defines the left operand
  2352. * @param right defines the right operand
  2353. * @returns the cross product
  2354. */
  2355. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2356. /**
  2357. * Sets the given vector "result" with the cross product of "left" and "right"
  2358. * The cross product is then orthogonal to both "left" and "right"
  2359. * @param left defines the left operand
  2360. * @param right defines the right operand
  2361. * @param result defines the Vector3 where to store the result
  2362. */
  2363. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2364. /**
  2365. * Returns a new Vector3 as the normalization of the given vector
  2366. * @param vector defines the Vector3 to normalize
  2367. * @returns the new Vector3
  2368. */
  2369. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2370. /**
  2371. * Sets the given vector "result" with the normalization of the given first vector
  2372. * @param vector defines the Vector3 to normalize
  2373. * @param result defines the Vector3 where to store the result
  2374. */
  2375. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2376. /**
  2377. * Project a Vector3 onto screen space
  2378. * @param vector defines the Vector3 to project
  2379. * @param world defines the world matrix to use
  2380. * @param transform defines the transform (view x projection) matrix to use
  2381. * @param viewport defines the screen viewport to use
  2382. * @returns the new Vector3
  2383. */
  2384. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2385. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2386. /**
  2387. * Unproject from screen space to object space
  2388. * @param source defines the screen space Vector3 to use
  2389. * @param viewportWidth defines the current width of the viewport
  2390. * @param viewportHeight defines the current height of the viewport
  2391. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2392. * @param transform defines the transform (view x projection) matrix to use
  2393. * @returns the new Vector3
  2394. */
  2395. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2396. /**
  2397. * Unproject from screen space to object space
  2398. * @param source defines the screen space Vector3 to use
  2399. * @param viewportWidth defines the current width of the viewport
  2400. * @param viewportHeight defines the current height of the viewport
  2401. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2402. * @param view defines the view matrix to use
  2403. * @param projection defines the projection matrix to use
  2404. * @returns the new Vector3
  2405. */
  2406. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2407. /**
  2408. * Unproject from screen space to object space
  2409. * @param source defines the screen space Vector3 to use
  2410. * @param viewportWidth defines the current width of the viewport
  2411. * @param viewportHeight defines the current height of the viewport
  2412. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2413. * @param view defines the view matrix to use
  2414. * @param projection defines the projection matrix to use
  2415. * @param result defines the Vector3 where to store the result
  2416. */
  2417. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2418. /**
  2419. * Unproject from screen space to object space
  2420. * @param sourceX defines the screen space x coordinate to use
  2421. * @param sourceY defines the screen space y coordinate to use
  2422. * @param sourceZ defines the screen space z coordinate to use
  2423. * @param viewportWidth defines the current width of the viewport
  2424. * @param viewportHeight defines the current height of the viewport
  2425. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2426. * @param view defines the view matrix to use
  2427. * @param projection defines the projection matrix to use
  2428. * @param result defines the Vector3 where to store the result
  2429. */
  2430. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2431. /**
  2432. * Gets the minimal coordinate values between two Vector3
  2433. * @param left defines the first operand
  2434. * @param right defines the second operand
  2435. * @returns the new Vector3
  2436. */
  2437. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2438. /**
  2439. * Gets the maximal coordinate values between two Vector3
  2440. * @param left defines the first operand
  2441. * @param right defines the second operand
  2442. * @returns the new Vector3
  2443. */
  2444. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2445. /**
  2446. * Returns the distance between the vectors "value1" and "value2"
  2447. * @param value1 defines the first operand
  2448. * @param value2 defines the second operand
  2449. * @returns the distance
  2450. */
  2451. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2452. /**
  2453. * Returns the squared distance between the vectors "value1" and "value2"
  2454. * @param value1 defines the first operand
  2455. * @param value2 defines the second operand
  2456. * @returns the squared distance
  2457. */
  2458. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2459. /**
  2460. * Returns a new Vector3 located at the center between "value1" and "value2"
  2461. * @param value1 defines the first operand
  2462. * @param value2 defines the second operand
  2463. * @returns the new Vector3
  2464. */
  2465. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2466. /**
  2467. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2468. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2469. * to something in order to rotate it from its local system to the given target system
  2470. * Note: axis1, axis2 and axis3 are normalized during this operation
  2471. * @param axis1 defines the first axis
  2472. * @param axis2 defines the second axis
  2473. * @param axis3 defines the third axis
  2474. * @returns a new Vector3
  2475. */
  2476. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2477. /**
  2478. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2479. * @param axis1 defines the first axis
  2480. * @param axis2 defines the second axis
  2481. * @param axis3 defines the third axis
  2482. * @param ref defines the Vector3 where to store the result
  2483. */
  2484. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2485. }
  2486. /**
  2487. * Vector4 class created for EulerAngle class conversion to Quaternion
  2488. */
  2489. export class Vector4 {
  2490. /** x value of the vector */
  2491. x: number;
  2492. /** y value of the vector */
  2493. y: number;
  2494. /** z value of the vector */
  2495. z: number;
  2496. /** w value of the vector */
  2497. w: number;
  2498. /**
  2499. * Creates a Vector4 object from the given floats.
  2500. * @param x x value of the vector
  2501. * @param y y value of the vector
  2502. * @param z z value of the vector
  2503. * @param w w value of the vector
  2504. */
  2505. constructor(
  2506. /** x value of the vector */
  2507. x: number,
  2508. /** y value of the vector */
  2509. y: number,
  2510. /** z value of the vector */
  2511. z: number,
  2512. /** w value of the vector */
  2513. w: number);
  2514. /**
  2515. * Returns the string with the Vector4 coordinates.
  2516. * @returns a string containing all the vector values
  2517. */
  2518. toString(): string;
  2519. /**
  2520. * Returns the string "Vector4".
  2521. * @returns "Vector4"
  2522. */
  2523. getClassName(): string;
  2524. /**
  2525. * Returns the Vector4 hash code.
  2526. * @returns a unique hash code
  2527. */
  2528. getHashCode(): number;
  2529. /**
  2530. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2531. * @returns the resulting array
  2532. */
  2533. asArray(): number[];
  2534. /**
  2535. * Populates the given array from the given index with the Vector4 coordinates.
  2536. * @param array array to populate
  2537. * @param index index of the array to start at (default: 0)
  2538. * @returns the Vector4.
  2539. */
  2540. toArray(array: FloatArray, index?: number): Vector4;
  2541. /**
  2542. * Adds the given vector to the current Vector4.
  2543. * @param otherVector the vector to add
  2544. * @returns the updated Vector4.
  2545. */
  2546. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2547. /**
  2548. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2549. * @param otherVector the vector to add
  2550. * @returns the resulting vector
  2551. */
  2552. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2553. /**
  2554. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2555. * @param otherVector the vector to add
  2556. * @param result the vector to store the result
  2557. * @returns the current Vector4.
  2558. */
  2559. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2560. /**
  2561. * Subtract in place the given vector from the current Vector4.
  2562. * @param otherVector the vector to subtract
  2563. * @returns the updated Vector4.
  2564. */
  2565. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2566. /**
  2567. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2568. * @param otherVector the vector to add
  2569. * @returns the new vector with the result
  2570. */
  2571. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2572. /**
  2573. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2574. * @param otherVector the vector to subtract
  2575. * @param result the vector to store the result
  2576. * @returns the current Vector4.
  2577. */
  2578. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2579. /**
  2580. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2581. */
  2582. /**
  2583. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2584. * @param x value to subtract
  2585. * @param y value to subtract
  2586. * @param z value to subtract
  2587. * @param w value to subtract
  2588. * @returns new vector containing the result
  2589. */
  2590. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2591. /**
  2592. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2593. * @param x value to subtract
  2594. * @param y value to subtract
  2595. * @param z value to subtract
  2596. * @param w value to subtract
  2597. * @param result the vector to store the result in
  2598. * @returns the current Vector4.
  2599. */
  2600. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2601. /**
  2602. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2603. * @returns a new vector with the negated values
  2604. */
  2605. negate(): Vector4;
  2606. /**
  2607. * Multiplies the current Vector4 coordinates by scale (float).
  2608. * @param scale the number to scale with
  2609. * @returns the updated Vector4.
  2610. */
  2611. scaleInPlace(scale: number): Vector4;
  2612. /**
  2613. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2614. * @param scale the number to scale with
  2615. * @returns a new vector with the result
  2616. */
  2617. scale(scale: number): Vector4;
  2618. /**
  2619. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2620. * @param scale the number to scale with
  2621. * @param result a vector to store the result in
  2622. * @returns the current Vector4.
  2623. */
  2624. scaleToRef(scale: number, result: Vector4): Vector4;
  2625. /**
  2626. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2627. * @param scale defines the scale factor
  2628. * @param result defines the Vector4 object where to store the result
  2629. * @returns the unmodified current Vector4
  2630. */
  2631. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2632. /**
  2633. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2634. * @param otherVector the vector to compare against
  2635. * @returns true if they are equal
  2636. */
  2637. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2638. /**
  2639. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2640. * @param otherVector vector to compare against
  2641. * @param epsilon (Default: very small number)
  2642. * @returns true if they are equal
  2643. */
  2644. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2645. /**
  2646. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2647. * @param x x value to compare against
  2648. * @param y y value to compare against
  2649. * @param z z value to compare against
  2650. * @param w w value to compare against
  2651. * @returns true if equal
  2652. */
  2653. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2654. /**
  2655. * Multiplies in place the current Vector4 by the given one.
  2656. * @param otherVector vector to multiple with
  2657. * @returns the updated Vector4.
  2658. */
  2659. multiplyInPlace(otherVector: Vector4): Vector4;
  2660. /**
  2661. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2662. * @param otherVector vector to multiple with
  2663. * @returns resulting new vector
  2664. */
  2665. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2666. /**
  2667. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2668. * @param otherVector vector to multiple with
  2669. * @param result vector to store the result
  2670. * @returns the current Vector4.
  2671. */
  2672. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2673. /**
  2674. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2675. * @param x x value multiply with
  2676. * @param y y value multiply with
  2677. * @param z z value multiply with
  2678. * @param w w value multiply with
  2679. * @returns resulting new vector
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2682. /**
  2683. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2684. * @param otherVector vector to devide with
  2685. * @returns resulting new vector
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2688. /**
  2689. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2690. * @param otherVector vector to devide with
  2691. * @param result vector to store the result
  2692. * @returns the current Vector4.
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector vector to devide with
  2698. * @returns the updated Vector3.
  2699. */
  2700. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2701. /**
  2702. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector4
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2707. /**
  2708. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector4
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2713. /**
  2714. * Gets a new Vector4 from current Vector4 floored values
  2715. * @returns a new Vector4
  2716. */
  2717. floor(): Vector4;
  2718. /**
  2719. * Gets a new Vector4 from current Vector3 floored values
  2720. * @returns a new Vector4
  2721. */
  2722. fract(): Vector4;
  2723. /**
  2724. * Returns the Vector4 length (float).
  2725. * @returns the length
  2726. */
  2727. length(): number;
  2728. /**
  2729. * Returns the Vector4 squared length (float).
  2730. * @returns the length squared
  2731. */
  2732. lengthSquared(): number;
  2733. /**
  2734. * Normalizes in place the Vector4.
  2735. * @returns the updated Vector4.
  2736. */
  2737. normalize(): Vector4;
  2738. /**
  2739. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2740. * @returns this converted to a new vector3
  2741. */
  2742. toVector3(): Vector3;
  2743. /**
  2744. * Returns a new Vector4 copied from the current one.
  2745. * @returns the new cloned vector
  2746. */
  2747. clone(): Vector4;
  2748. /**
  2749. * Updates the current Vector4 with the given one coordinates.
  2750. * @param source the source vector to copy from
  2751. * @returns the updated Vector4.
  2752. */
  2753. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2754. /**
  2755. * Updates the current Vector4 coordinates with the given floats.
  2756. * @param x float to copy from
  2757. * @param y float to copy from
  2758. * @param z float to copy from
  2759. * @param w float to copy from
  2760. * @returns the updated Vector4.
  2761. */
  2762. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2763. /**
  2764. * Updates the current Vector4 coordinates with the given floats.
  2765. * @param x float to set from
  2766. * @param y float to set from
  2767. * @param z float to set from
  2768. * @param w float to set from
  2769. * @returns the updated Vector4.
  2770. */
  2771. set(x: number, y: number, z: number, w: number): Vector4;
  2772. /**
  2773. * Copies the given float to the current Vector3 coordinates
  2774. * @param v defines the x, y, z and w coordinates of the operand
  2775. * @returns the current updated Vector3
  2776. */
  2777. setAll(v: number): Vector4;
  2778. /**
  2779. * Returns a new Vector4 set from the starting index of the given array.
  2780. * @param array the array to pull values from
  2781. * @param offset the offset into the array to start at
  2782. * @returns the new vector
  2783. */
  2784. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2785. /**
  2786. * Updates the given vector "result" from the starting index of the given array.
  2787. * @param array the array to pull values from
  2788. * @param offset the offset into the array to start at
  2789. * @param result the vector to store the result in
  2790. */
  2791. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2792. /**
  2793. * Updates the given vector "result" from the starting index of the given Float32Array.
  2794. * @param array the array to pull values from
  2795. * @param offset the offset into the array to start at
  2796. * @param result the vector to store the result in
  2797. */
  2798. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2799. /**
  2800. * Updates the given vector "result" coordinates from the given floats.
  2801. * @param x float to set from
  2802. * @param y float to set from
  2803. * @param z float to set from
  2804. * @param w float to set from
  2805. * @param result the vector to the floats in
  2806. */
  2807. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2808. /**
  2809. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2810. * @returns the new vector
  2811. */
  2812. static Zero(): Vector4;
  2813. /**
  2814. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2815. * @returns the new vector
  2816. */
  2817. static One(): Vector4;
  2818. /**
  2819. * Returns a new normalized Vector4 from the given one.
  2820. * @param vector the vector to normalize
  2821. * @returns the vector
  2822. */
  2823. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2824. /**
  2825. * Updates the given vector "result" from the normalization of the given one.
  2826. * @param vector the vector to normalize
  2827. * @param result the vector to store the result in
  2828. */
  2829. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2830. /**
  2831. * Returns a vector with the minimum values from the left and right vectors
  2832. * @param left left vector to minimize
  2833. * @param right right vector to minimize
  2834. * @returns a new vector with the minimum of the left and right vector values
  2835. */
  2836. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2837. /**
  2838. * Returns a vector with the maximum values from the left and right vectors
  2839. * @param left left vector to maximize
  2840. * @param right right vector to maximize
  2841. * @returns a new vector with the maximum of the left and right vector values
  2842. */
  2843. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2844. /**
  2845. * Returns the distance (float) between the vectors "value1" and "value2".
  2846. * @param value1 value to calulate the distance between
  2847. * @param value2 value to calulate the distance between
  2848. * @return the distance between the two vectors
  2849. */
  2850. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2851. /**
  2852. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2853. * @param value1 value to calulate the distance between
  2854. * @param value2 value to calulate the distance between
  2855. * @return the distance between the two vectors squared
  2856. */
  2857. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2858. /**
  2859. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2860. * @param value1 value to calulate the center between
  2861. * @param value2 value to calulate the center between
  2862. * @return the center between the two vectors
  2863. */
  2864. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2865. /**
  2866. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2867. * This methods computes transformed normalized direction vectors only.
  2868. * @param vector the vector to transform
  2869. * @param transformation the transformation matrix to apply
  2870. * @returns the new vector
  2871. */
  2872. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2873. /**
  2874. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2875. * This methods computes transformed normalized direction vectors only.
  2876. * @param vector the vector to transform
  2877. * @param transformation the transformation matrix to apply
  2878. * @param result the vector to store the result in
  2879. */
  2880. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2881. /**
  2882. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2883. * This methods computes transformed normalized direction vectors only.
  2884. * @param x value to transform
  2885. * @param y value to transform
  2886. * @param z value to transform
  2887. * @param w value to transform
  2888. * @param transformation the transformation matrix to apply
  2889. * @param result the vector to store the results in
  2890. */
  2891. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2892. /**
  2893. * Creates a new Vector4 from a Vector3
  2894. * @param source defines the source data
  2895. * @param w defines the 4th component (default is 0)
  2896. * @returns a new Vector4
  2897. */
  2898. static FromVector3(source: Vector3, w?: number): Vector4;
  2899. }
  2900. /**
  2901. * Class used to store quaternion data
  2902. * @see https://en.wikipedia.org/wiki/Quaternion
  2903. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2904. */
  2905. export class Quaternion {
  2906. /** defines the first component (0 by default) */
  2907. x: number;
  2908. /** defines the second component (0 by default) */
  2909. y: number;
  2910. /** defines the third component (0 by default) */
  2911. z: number;
  2912. /** defines the fourth component (1.0 by default) */
  2913. w: number;
  2914. /**
  2915. * Creates a new Quaternion from the given floats
  2916. * @param x defines the first component (0 by default)
  2917. * @param y defines the second component (0 by default)
  2918. * @param z defines the third component (0 by default)
  2919. * @param w defines the fourth component (1.0 by default)
  2920. */
  2921. constructor(
  2922. /** defines the first component (0 by default) */
  2923. x?: number,
  2924. /** defines the second component (0 by default) */
  2925. y?: number,
  2926. /** defines the third component (0 by default) */
  2927. z?: number,
  2928. /** defines the fourth component (1.0 by default) */
  2929. w?: number);
  2930. /**
  2931. * Gets a string representation for the current quaternion
  2932. * @returns a string with the Quaternion coordinates
  2933. */
  2934. toString(): string;
  2935. /**
  2936. * Gets the class name of the quaternion
  2937. * @returns the string "Quaternion"
  2938. */
  2939. getClassName(): string;
  2940. /**
  2941. * Gets a hash code for this quaternion
  2942. * @returns the quaternion hash code
  2943. */
  2944. getHashCode(): number;
  2945. /**
  2946. * Copy the quaternion to an array
  2947. * @returns a new array populated with 4 elements from the quaternion coordinates
  2948. */
  2949. asArray(): number[];
  2950. /**
  2951. * Check if two quaternions are equals
  2952. * @param otherQuaternion defines the second operand
  2953. * @return true if the current quaternion and the given one coordinates are strictly equals
  2954. */
  2955. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2956. /**
  2957. * Clone the current quaternion
  2958. * @returns a new quaternion copied from the current one
  2959. */
  2960. clone(): Quaternion;
  2961. /**
  2962. * Copy a quaternion to the current one
  2963. * @param other defines the other quaternion
  2964. * @returns the updated current quaternion
  2965. */
  2966. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2967. /**
  2968. * Updates the current quaternion with the given float coordinates
  2969. * @param x defines the x coordinate
  2970. * @param y defines the y coordinate
  2971. * @param z defines the z coordinate
  2972. * @param w defines the w coordinate
  2973. * @returns the updated current quaternion
  2974. */
  2975. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2976. /**
  2977. * Updates the current quaternion from the given float coordinates
  2978. * @param x defines the x coordinate
  2979. * @param y defines the y coordinate
  2980. * @param z defines the z coordinate
  2981. * @param w defines the w coordinate
  2982. * @returns the updated current quaternion
  2983. */
  2984. set(x: number, y: number, z: number, w: number): Quaternion;
  2985. /**
  2986. * Adds two quaternions
  2987. * @param other defines the second operand
  2988. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2989. */
  2990. add(other: DeepImmutable<Quaternion>): Quaternion;
  2991. /**
  2992. * Add a quaternion to the current one
  2993. * @param other defines the quaternion to add
  2994. * @returns the current quaternion
  2995. */
  2996. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2997. /**
  2998. * Subtract two quaternions
  2999. * @param other defines the second operand
  3000. * @returns a new quaternion as the subtraction result of the given one from the current one
  3001. */
  3002. subtract(other: Quaternion): Quaternion;
  3003. /**
  3004. * Multiplies the current quaternion by a scale factor
  3005. * @param value defines the scale factor
  3006. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3007. */
  3008. scale(value: number): Quaternion;
  3009. /**
  3010. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3011. * @param scale defines the scale factor
  3012. * @param result defines the Quaternion object where to store the result
  3013. * @returns the unmodified current quaternion
  3014. */
  3015. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3016. /**
  3017. * Multiplies in place the current quaternion by a scale factor
  3018. * @param value defines the scale factor
  3019. * @returns the current modified quaternion
  3020. */
  3021. scaleInPlace(value: number): Quaternion;
  3022. /**
  3023. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3024. * @param scale defines the scale factor
  3025. * @param result defines the Quaternion object where to store the result
  3026. * @returns the unmodified current quaternion
  3027. */
  3028. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3029. /**
  3030. * Multiplies two quaternions
  3031. * @param q1 defines the second operand
  3032. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3033. */
  3034. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3035. /**
  3036. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3037. * @param q1 defines the second operand
  3038. * @param result defines the target quaternion
  3039. * @returns the current quaternion
  3040. */
  3041. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3042. /**
  3043. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3044. * @param q1 defines the second operand
  3045. * @returns the currentupdated quaternion
  3046. */
  3047. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3048. /**
  3049. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3050. * @param ref defines the target quaternion
  3051. * @returns the current quaternion
  3052. */
  3053. conjugateToRef(ref: Quaternion): Quaternion;
  3054. /**
  3055. * Conjugates in place (1-q) the current quaternion
  3056. * @returns the current updated quaternion
  3057. */
  3058. conjugateInPlace(): Quaternion;
  3059. /**
  3060. * Conjugates in place (1-q) the current quaternion
  3061. * @returns a new quaternion
  3062. */
  3063. conjugate(): Quaternion;
  3064. /**
  3065. * Gets length of current quaternion
  3066. * @returns the quaternion length (float)
  3067. */
  3068. length(): number;
  3069. /**
  3070. * Normalize in place the current quaternion
  3071. * @returns the current updated quaternion
  3072. */
  3073. normalize(): Quaternion;
  3074. /**
  3075. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3076. * @param order is a reserved parameter and is ignore for now
  3077. * @returns a new Vector3 containing the Euler angles
  3078. */
  3079. toEulerAngles(order?: string): Vector3;
  3080. /**
  3081. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3082. * @param result defines the vector which will be filled with the Euler angles
  3083. * @param order is a reserved parameter and is ignore for now
  3084. * @returns the current unchanged quaternion
  3085. */
  3086. toEulerAnglesToRef(result: Vector3): Quaternion;
  3087. /**
  3088. * Updates the given rotation matrix with the current quaternion values
  3089. * @param result defines the target matrix
  3090. * @returns the current unchanged quaternion
  3091. */
  3092. toRotationMatrix(result: Matrix): Quaternion;
  3093. /**
  3094. * Updates the current quaternion from the given rotation matrix values
  3095. * @param matrix defines the source matrix
  3096. * @returns the current updated quaternion
  3097. */
  3098. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3099. /**
  3100. * Creates a new quaternion from a rotation matrix
  3101. * @param matrix defines the source matrix
  3102. * @returns a new quaternion created from the given rotation matrix values
  3103. */
  3104. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3105. /**
  3106. * Updates the given quaternion with the given rotation matrix values
  3107. * @param matrix defines the source matrix
  3108. * @param result defines the target quaternion
  3109. */
  3110. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3111. /**
  3112. * Returns the dot product (float) between the quaternions "left" and "right"
  3113. * @param left defines the left operand
  3114. * @param right defines the right operand
  3115. * @returns the dot product
  3116. */
  3117. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3118. /**
  3119. * Checks if the two quaternions are close to each other
  3120. * @param quat0 defines the first quaternion to check
  3121. * @param quat1 defines the second quaternion to check
  3122. * @returns true if the two quaternions are close to each other
  3123. */
  3124. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3125. /**
  3126. * Creates an empty quaternion
  3127. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3128. */
  3129. static Zero(): Quaternion;
  3130. /**
  3131. * Inverse a given quaternion
  3132. * @param q defines the source quaternion
  3133. * @returns a new quaternion as the inverted current quaternion
  3134. */
  3135. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3136. /**
  3137. * Inverse a given quaternion
  3138. * @param q defines the source quaternion
  3139. * @param result the quaternion the result will be stored in
  3140. * @returns the result quaternion
  3141. */
  3142. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3143. /**
  3144. * Creates an identity quaternion
  3145. * @returns the identity quaternion
  3146. */
  3147. static Identity(): Quaternion;
  3148. /**
  3149. * Gets a boolean indicating if the given quaternion is identity
  3150. * @param quaternion defines the quaternion to check
  3151. * @returns true if the quaternion is identity
  3152. */
  3153. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3154. /**
  3155. * Creates a quaternion from a rotation around an axis
  3156. * @param axis defines the axis to use
  3157. * @param angle defines the angle to use
  3158. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3159. */
  3160. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3161. /**
  3162. * Creates a rotation around an axis and stores it into the given quaternion
  3163. * @param axis defines the axis to use
  3164. * @param angle defines the angle to use
  3165. * @param result defines the target quaternion
  3166. * @returns the target quaternion
  3167. */
  3168. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3169. /**
  3170. * Creates a new quaternion from data stored into an array
  3171. * @param array defines the data source
  3172. * @param offset defines the offset in the source array where the data starts
  3173. * @returns a new quaternion
  3174. */
  3175. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3176. /**
  3177. * Create a quaternion from Euler rotation angles
  3178. * @param x Pitch
  3179. * @param y Yaw
  3180. * @param z Roll
  3181. * @returns the new Quaternion
  3182. */
  3183. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3184. /**
  3185. * Updates a quaternion from Euler rotation angles
  3186. * @param x Pitch
  3187. * @param y Yaw
  3188. * @param z Roll
  3189. * @param result the quaternion to store the result
  3190. * @returns the updated quaternion
  3191. */
  3192. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3193. /**
  3194. * Create a quaternion from Euler rotation vector
  3195. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3196. * @returns the new Quaternion
  3197. */
  3198. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3199. /**
  3200. * Updates a quaternion from Euler rotation vector
  3201. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3202. * @param result the quaternion to store the result
  3203. * @returns the updated quaternion
  3204. */
  3205. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3206. /**
  3207. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3208. * @param yaw defines the rotation around Y axis
  3209. * @param pitch defines the rotation around X axis
  3210. * @param roll defines the rotation around Z axis
  3211. * @returns the new quaternion
  3212. */
  3213. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3214. /**
  3215. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3216. * @param yaw defines the rotation around Y axis
  3217. * @param pitch defines the rotation around X axis
  3218. * @param roll defines the rotation around Z axis
  3219. * @param result defines the target quaternion
  3220. */
  3221. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3222. /**
  3223. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3224. * @param alpha defines the rotation around first axis
  3225. * @param beta defines the rotation around second axis
  3226. * @param gamma defines the rotation around third axis
  3227. * @returns the new quaternion
  3228. */
  3229. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3230. /**
  3231. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3232. * @param alpha defines the rotation around first axis
  3233. * @param beta defines the rotation around second axis
  3234. * @param gamma defines the rotation around third axis
  3235. * @param result defines the target quaternion
  3236. */
  3237. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3238. /**
  3239. * 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)
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @returns the new quaternion
  3244. */
  3245. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3246. /**
  3247. * 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
  3248. * @param axis1 defines the first axis
  3249. * @param axis2 defines the second axis
  3250. * @param axis3 defines the third axis
  3251. * @param ref defines the target quaternion
  3252. */
  3253. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3254. /**
  3255. * Interpolates between two quaternions
  3256. * @param left defines first quaternion
  3257. * @param right defines second quaternion
  3258. * @param amount defines the gradient to use
  3259. * @returns the new interpolated quaternion
  3260. */
  3261. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3262. /**
  3263. * Interpolates between two quaternions and stores it into a target quaternion
  3264. * @param left defines first quaternion
  3265. * @param right defines second quaternion
  3266. * @param amount defines the gradient to use
  3267. * @param result defines the target quaternion
  3268. */
  3269. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3270. /**
  3271. * Interpolate between two quaternions using Hermite interpolation
  3272. * @param value1 defines first quaternion
  3273. * @param tangent1 defines the incoming tangent
  3274. * @param value2 defines second quaternion
  3275. * @param tangent2 defines the outgoing tangent
  3276. * @param amount defines the target quaternion
  3277. * @returns the new interpolated quaternion
  3278. */
  3279. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3280. }
  3281. /**
  3282. * Class used to store matrix data (4x4)
  3283. */
  3284. export class Matrix {
  3285. private static _updateFlagSeed;
  3286. private static _identityReadOnly;
  3287. private _isIdentity;
  3288. private _isIdentityDirty;
  3289. private _isIdentity3x2;
  3290. private _isIdentity3x2Dirty;
  3291. /**
  3292. * Gets the update flag of the matrix which is an unique number for the matrix.
  3293. * It will be incremented every time the matrix data change.
  3294. * You can use it to speed the comparison between two versions of the same matrix.
  3295. */
  3296. updateFlag: number;
  3297. private readonly _m;
  3298. /**
  3299. * Gets the internal data of the matrix
  3300. */
  3301. readonly m: DeepImmutable<Float32Array>;
  3302. /** @hidden */ private _markAsUpdated(): void;
  3303. /** @hidden */
  3304. private _updateIdentityStatus;
  3305. /**
  3306. * Creates an empty matrix (filled with zeros)
  3307. */
  3308. constructor();
  3309. /**
  3310. * Check if the current matrix is identity
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentity(): boolean;
  3314. /**
  3315. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentityAs3x2(): boolean;
  3319. /**
  3320. * Gets the determinant of the matrix
  3321. * @returns the matrix determinant
  3322. */
  3323. determinant(): number;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array
  3327. */
  3328. toArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array.
  3332. */
  3333. asArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Inverts the current matrix in place
  3336. * @returns the current inverted matrix
  3337. */
  3338. invert(): Matrix;
  3339. /**
  3340. * Sets all the matrix elements to zero
  3341. * @returns the current matrix
  3342. */
  3343. reset(): Matrix;
  3344. /**
  3345. * Adds the current matrix with a second one
  3346. * @param other defines the matrix to add
  3347. * @returns a new matrix as the addition of the current matrix and the given one
  3348. */
  3349. add(other: DeepImmutable<Matrix>): Matrix;
  3350. /**
  3351. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3352. * @param other defines the matrix to add
  3353. * @param result defines the target matrix
  3354. * @returns the current matrix
  3355. */
  3356. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3357. /**
  3358. * Adds in place the given matrix to the current matrix
  3359. * @param other defines the second operand
  3360. * @returns the current updated matrix
  3361. */
  3362. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3363. /**
  3364. * Sets the given matrix to the current inverted Matrix
  3365. * @param other defines the target matrix
  3366. * @returns the unmodified current matrix
  3367. */
  3368. invertToRef(other: Matrix): Matrix;
  3369. /**
  3370. * add a value at the specified position in the current Matrix
  3371. * @param index the index of the value within the matrix. between 0 and 15.
  3372. * @param value the value to be added
  3373. * @returns the current updated matrix
  3374. */
  3375. addAtIndex(index: number, value: number): Matrix;
  3376. /**
  3377. * mutiply the specified position in the current Matrix by a value
  3378. * @param index the index of the value within the matrix. between 0 and 15.
  3379. * @param value the value to be added
  3380. * @returns the current updated matrix
  3381. */
  3382. multiplyAtIndex(index: number, value: number): Matrix;
  3383. /**
  3384. * Inserts the translation vector (using 3 floats) in the current matrix
  3385. * @param x defines the 1st component of the translation
  3386. * @param y defines the 2nd component of the translation
  3387. * @param z defines the 3rd component of the translation
  3388. * @returns the current updated matrix
  3389. */
  3390. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3391. /**
  3392. * Adds the translation vector (using 3 floats) in the current matrix
  3393. * @param x defines the 1st component of the translation
  3394. * @param y defines the 2nd component of the translation
  3395. * @param z defines the 3rd component of the translation
  3396. * @returns the current updated matrix
  3397. */
  3398. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3399. /**
  3400. * Inserts the translation vector in the current matrix
  3401. * @param vector3 defines the translation to insert
  3402. * @returns the current updated matrix
  3403. */
  3404. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3405. /**
  3406. * Gets the translation value of the current matrix
  3407. * @returns a new Vector3 as the extracted translation from the matrix
  3408. */
  3409. getTranslation(): Vector3;
  3410. /**
  3411. * Fill a Vector3 with the extracted translation from the matrix
  3412. * @param result defines the Vector3 where to store the translation
  3413. * @returns the current matrix
  3414. */
  3415. getTranslationToRef(result: Vector3): Matrix;
  3416. /**
  3417. * Remove rotation and scaling part from the matrix
  3418. * @returns the updated matrix
  3419. */
  3420. removeRotationAndScaling(): Matrix;
  3421. /**
  3422. * Multiply two matrices
  3423. * @param other defines the second operand
  3424. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3425. */
  3426. multiply(other: DeepImmutable<Matrix>): Matrix;
  3427. /**
  3428. * Copy the current matrix from the given one
  3429. * @param other defines the source matrix
  3430. * @returns the current updated matrix
  3431. */
  3432. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3433. /**
  3434. * Populates the given array from the starting index with the current matrix values
  3435. * @param array defines the target array
  3436. * @param offset defines the offset in the target array where to start storing values
  3437. * @returns the current matrix
  3438. */
  3439. copyToArray(array: Float32Array, offset?: number): Matrix;
  3440. /**
  3441. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3442. * @param other defines the second operand
  3443. * @param result defines the matrix where to store the multiplication
  3444. * @returns the current matrix
  3445. */
  3446. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3447. /**
  3448. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3449. * @param other defines the second operand
  3450. * @param result defines the array where to store the multiplication
  3451. * @param offset defines the offset in the target array where to start storing values
  3452. * @returns the current matrix
  3453. */
  3454. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3455. /**
  3456. * Check equality between this matrix and a second one
  3457. * @param value defines the second matrix to compare
  3458. * @returns true is the current matrix and the given one values are strictly equal
  3459. */
  3460. equals(value: DeepImmutable<Matrix>): boolean;
  3461. /**
  3462. * Clone the current matrix
  3463. * @returns a new matrix from the current matrix
  3464. */
  3465. clone(): Matrix;
  3466. /**
  3467. * Returns the name of the current matrix class
  3468. * @returns the string "Matrix"
  3469. */
  3470. getClassName(): string;
  3471. /**
  3472. * Gets the hash code of the current matrix
  3473. * @returns the hash code
  3474. */
  3475. getHashCode(): number;
  3476. /**
  3477. * Decomposes the current Matrix into a translation, rotation and scaling components
  3478. * @param scale defines the scale vector3 given as a reference to update
  3479. * @param rotation defines the rotation quaternion given as a reference to update
  3480. * @param translation defines the translation vector3 given as a reference to update
  3481. * @returns true if operation was successful
  3482. */
  3483. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3484. /**
  3485. * Gets specific row of the matrix
  3486. * @param index defines the number of the row to get
  3487. * @returns the index-th row of the current matrix as a new Vector4
  3488. */
  3489. getRow(index: number): Nullable<Vector4>;
  3490. /**
  3491. * Sets the index-th row of the current matrix to the vector4 values
  3492. * @param index defines the number of the row to set
  3493. * @param row defines the target vector4
  3494. * @returns the updated current matrix
  3495. */
  3496. setRow(index: number, row: Vector4): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix
  3499. * @returns the new transposed matrix
  3500. */
  3501. transpose(): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix and store it in a given matrix
  3504. * @param result defines the target matrix
  3505. * @returns the current matrix
  3506. */
  3507. transposeToRef(result: Matrix): Matrix;
  3508. /**
  3509. * Sets the index-th row of the current matrix with the given 4 x float values
  3510. * @param index defines the row index
  3511. * @param x defines the x component to set
  3512. * @param y defines the y component to set
  3513. * @param z defines the z component to set
  3514. * @param w defines the w component to set
  3515. * @returns the updated current matrix
  3516. */
  3517. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3518. /**
  3519. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3520. * @param scale defines the scale factor
  3521. * @returns a new matrix
  3522. */
  3523. scale(scale: number): Matrix;
  3524. /**
  3525. * Scale the current matrix values by a factor to a given result matrix
  3526. * @param scale defines the scale factor
  3527. * @param result defines the matrix to store the result
  3528. * @returns the current matrix
  3529. */
  3530. scaleToRef(scale: number, result: Matrix): Matrix;
  3531. /**
  3532. * Scale the current matrix values by a factor and add the result to a given matrix
  3533. * @param scale defines the scale factor
  3534. * @param result defines the Matrix to store the result
  3535. * @returns the current matrix
  3536. */
  3537. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3538. /**
  3539. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3540. * @param ref matrix to store the result
  3541. */
  3542. toNormalMatrix(ref: Matrix): void;
  3543. /**
  3544. * Gets only rotation part of the current matrix
  3545. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3546. */
  3547. getRotationMatrix(): Matrix;
  3548. /**
  3549. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3550. * @param result defines the target matrix to store data to
  3551. * @returns the current matrix
  3552. */
  3553. getRotationMatrixToRef(result: Matrix): Matrix;
  3554. /**
  3555. * Toggles model matrix from being right handed to left handed in place and vice versa
  3556. */
  3557. toggleModelMatrixHandInPlace(): void;
  3558. /**
  3559. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3560. */
  3561. toggleProjectionMatrixHandInPlace(): void;
  3562. /**
  3563. * Creates a matrix from an array
  3564. * @param array defines the source array
  3565. * @param offset defines an offset in the source array
  3566. * @returns a new Matrix set from the starting index of the given array
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3569. /**
  3570. * Copy the content of an array into a given matrix
  3571. * @param array defines the source array
  3572. * @param offset defines an offset in the source array
  3573. * @param result defines the target matrix
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3576. /**
  3577. * Stores an array into a matrix after having multiplied each component by a given factor
  3578. * @param array defines the source array
  3579. * @param offset defines the offset in the source array
  3580. * @param scale defines the scaling factor
  3581. * @param result defines the target matrix
  3582. */
  3583. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3584. /**
  3585. * Gets an identity matrix that must not be updated
  3586. */
  3587. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3588. /**
  3589. * Stores a list of values (16) inside a given matrix
  3590. * @param initialM11 defines 1st value of 1st row
  3591. * @param initialM12 defines 2nd value of 1st row
  3592. * @param initialM13 defines 3rd value of 1st row
  3593. * @param initialM14 defines 4th value of 1st row
  3594. * @param initialM21 defines 1st value of 2nd row
  3595. * @param initialM22 defines 2nd value of 2nd row
  3596. * @param initialM23 defines 3rd value of 2nd row
  3597. * @param initialM24 defines 4th value of 2nd row
  3598. * @param initialM31 defines 1st value of 3rd row
  3599. * @param initialM32 defines 2nd value of 3rd row
  3600. * @param initialM33 defines 3rd value of 3rd row
  3601. * @param initialM34 defines 4th value of 3rd row
  3602. * @param initialM41 defines 1st value of 4th row
  3603. * @param initialM42 defines 2nd value of 4th row
  3604. * @param initialM43 defines 3rd value of 4th row
  3605. * @param initialM44 defines 4th value of 4th row
  3606. * @param result defines the target matrix
  3607. */
  3608. 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;
  3609. /**
  3610. * Creates new matrix from a list of values (16)
  3611. * @param initialM11 defines 1st value of 1st row
  3612. * @param initialM12 defines 2nd value of 1st row
  3613. * @param initialM13 defines 3rd value of 1st row
  3614. * @param initialM14 defines 4th value of 1st row
  3615. * @param initialM21 defines 1st value of 2nd row
  3616. * @param initialM22 defines 2nd value of 2nd row
  3617. * @param initialM23 defines 3rd value of 2nd row
  3618. * @param initialM24 defines 4th value of 2nd row
  3619. * @param initialM31 defines 1st value of 3rd row
  3620. * @param initialM32 defines 2nd value of 3rd row
  3621. * @param initialM33 defines 3rd value of 3rd row
  3622. * @param initialM34 defines 4th value of 3rd row
  3623. * @param initialM41 defines 1st value of 4th row
  3624. * @param initialM42 defines 2nd value of 4th row
  3625. * @param initialM43 defines 3rd value of 4th row
  3626. * @param initialM44 defines 4th value of 4th row
  3627. * @returns the new matrix
  3628. */
  3629. 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;
  3630. /**
  3631. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3632. * @param scale defines the scale vector3
  3633. * @param rotation defines the rotation quaternion
  3634. * @param translation defines the translation vector3
  3635. * @returns a new matrix
  3636. */
  3637. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3638. /**
  3639. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3640. * @param scale defines the scale vector3
  3641. * @param rotation defines the rotation quaternion
  3642. * @param translation defines the translation vector3
  3643. * @param result defines the target matrix
  3644. */
  3645. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3646. /**
  3647. * Creates a new identity matrix
  3648. * @returns a new identity matrix
  3649. */
  3650. static Identity(): Matrix;
  3651. /**
  3652. * Creates a new identity matrix and stores the result in a given matrix
  3653. * @param result defines the target matrix
  3654. */
  3655. static IdentityToRef(result: Matrix): void;
  3656. /**
  3657. * Creates a new zero matrix
  3658. * @returns a new zero matrix
  3659. */
  3660. static Zero(): Matrix;
  3661. /**
  3662. * Creates a new rotation matrix for "angle" radians around the X axis
  3663. * @param angle defines the angle (in radians) to use
  3664. * @return the new matrix
  3665. */
  3666. static RotationX(angle: number): Matrix;
  3667. /**
  3668. * Creates a new matrix as the invert of a given matrix
  3669. * @param source defines the source matrix
  3670. * @returns the new matrix
  3671. */
  3672. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3673. /**
  3674. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3675. * @param angle defines the angle (in radians) to use
  3676. * @param result defines the target matrix
  3677. */
  3678. static RotationXToRef(angle: number, result: Matrix): void;
  3679. /**
  3680. * Creates a new rotation matrix for "angle" radians around the Y axis
  3681. * @param angle defines the angle (in radians) to use
  3682. * @return the new matrix
  3683. */
  3684. static RotationY(angle: number): Matrix;
  3685. /**
  3686. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3687. * @param angle defines the angle (in radians) to use
  3688. * @param result defines the target matrix
  3689. */
  3690. static RotationYToRef(angle: number, result: Matrix): void;
  3691. /**
  3692. * Creates a new rotation matrix for "angle" radians around the Z axis
  3693. * @param angle defines the angle (in radians) to use
  3694. * @return the new matrix
  3695. */
  3696. static RotationZ(angle: number): Matrix;
  3697. /**
  3698. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3699. * @param angle defines the angle (in radians) to use
  3700. * @param result defines the target matrix
  3701. */
  3702. static RotationZToRef(angle: number, result: Matrix): void;
  3703. /**
  3704. * Creates a new rotation matrix for "angle" radians around the given axis
  3705. * @param axis defines the axis to use
  3706. * @param angle defines the angle (in radians) to use
  3707. * @return the new matrix
  3708. */
  3709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3710. /**
  3711. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3712. * @param axis defines the axis to use
  3713. * @param angle defines the angle (in radians) to use
  3714. * @param result defines the target matrix
  3715. */
  3716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3717. /**
  3718. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3719. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3720. * @param from defines the vector to align
  3721. * @param to defines the vector to align to
  3722. * @param result defines the target matrix
  3723. */
  3724. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3725. /**
  3726. * Creates a rotation matrix
  3727. * @param yaw defines the yaw angle in radians (Y axis)
  3728. * @param pitch defines the pitch angle in radians (X axis)
  3729. * @param roll defines the roll angle in radians (X axis)
  3730. * @returns the new rotation matrix
  3731. */
  3732. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3733. /**
  3734. * Creates a rotation matrix and stores it in a given matrix
  3735. * @param yaw defines the yaw angle in radians (Y axis)
  3736. * @param pitch defines the pitch angle in radians (X axis)
  3737. * @param roll defines the roll angle in radians (X axis)
  3738. * @param result defines the target matrix
  3739. */
  3740. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3741. /**
  3742. * Creates a scaling matrix
  3743. * @param x defines the scale factor on X axis
  3744. * @param y defines the scale factor on Y axis
  3745. * @param z defines the scale factor on Z axis
  3746. * @returns the new matrix
  3747. */
  3748. static Scaling(x: number, y: number, z: number): Matrix;
  3749. /**
  3750. * Creates a scaling matrix and stores it in a given matrix
  3751. * @param x defines the scale factor on X axis
  3752. * @param y defines the scale factor on Y axis
  3753. * @param z defines the scale factor on Z axis
  3754. * @param result defines the target matrix
  3755. */
  3756. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3757. /**
  3758. * Creates a translation matrix
  3759. * @param x defines the translation on X axis
  3760. * @param y defines the translation on Y axis
  3761. * @param z defines the translationon Z axis
  3762. * @returns the new matrix
  3763. */
  3764. static Translation(x: number, y: number, z: number): Matrix;
  3765. /**
  3766. * Creates a translation matrix and stores it in a given matrix
  3767. * @param x defines the translation on X axis
  3768. * @param y defines the translation on Y axis
  3769. * @param z defines the translationon Z axis
  3770. * @param result defines the target matrix
  3771. */
  3772. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3773. /**
  3774. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3775. * @param startValue defines the start value
  3776. * @param endValue defines the end value
  3777. * @param gradient defines the gradient factor
  3778. * @returns the new matrix
  3779. */
  3780. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3781. /**
  3782. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3783. * @param startValue defines the start value
  3784. * @param endValue defines the end value
  3785. * @param gradient defines the gradient factor
  3786. * @param result defines the Matrix object where to store data
  3787. */
  3788. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3789. /**
  3790. * Builds a new matrix whose values are computed by:
  3791. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3792. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3793. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3794. * @param startValue defines the first matrix
  3795. * @param endValue defines the second matrix
  3796. * @param gradient defines the gradient between the two matrices
  3797. * @returns the new matrix
  3798. */
  3799. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3800. /**
  3801. * Update a matrix to values which are computed by:
  3802. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3803. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3804. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3805. * @param startValue defines the first matrix
  3806. * @param endValue defines the second matrix
  3807. * @param gradient defines the gradient between the two matrices
  3808. * @param result defines the target matrix
  3809. */
  3810. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3811. /**
  3812. * 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"
  3813. * This function works in left handed mode
  3814. * @param eye defines the final position of the entity
  3815. * @param target defines where the entity should look at
  3816. * @param up defines the up vector for the entity
  3817. * @returns the new matrix
  3818. */
  3819. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3820. /**
  3821. * 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".
  3822. * This function works in left handed mode
  3823. * @param eye defines the final position of the entity
  3824. * @param target defines where the entity should look at
  3825. * @param up defines the up vector for the entity
  3826. * @param result defines the target matrix
  3827. */
  3828. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3829. /**
  3830. * 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"
  3831. * This function works in right handed mode
  3832. * @param eye defines the final position of the entity
  3833. * @param target defines where the entity should look at
  3834. * @param up defines the up vector for the entity
  3835. * @returns the new matrix
  3836. */
  3837. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3838. /**
  3839. * 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".
  3840. * This function works in right handed mode
  3841. * @param eye defines the final position of the entity
  3842. * @param target defines where the entity should look at
  3843. * @param up defines the up vector for the entity
  3844. * @param result defines the target matrix
  3845. */
  3846. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3847. /**
  3848. * Create a left-handed orthographic projection matrix
  3849. * @param width defines the viewport width
  3850. * @param height defines the viewport height
  3851. * @param znear defines the near clip plane
  3852. * @param zfar defines the far clip plane
  3853. * @returns a new matrix as a left-handed orthographic projection matrix
  3854. */
  3855. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3856. /**
  3857. * Store a left-handed orthographic projection to a given matrix
  3858. * @param width defines the viewport width
  3859. * @param height defines the viewport height
  3860. * @param znear defines the near clip plane
  3861. * @param zfar defines the far clip plane
  3862. * @param result defines the target matrix
  3863. */
  3864. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3865. /**
  3866. * Create a left-handed orthographic projection matrix
  3867. * @param left defines the viewport left coordinate
  3868. * @param right defines the viewport right coordinate
  3869. * @param bottom defines the viewport bottom coordinate
  3870. * @param top defines the viewport top coordinate
  3871. * @param znear defines the near clip plane
  3872. * @param zfar defines the far clip plane
  3873. * @returns a new matrix as a left-handed orthographic projection matrix
  3874. */
  3875. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3876. /**
  3877. * Stores a left-handed orthographic projection into a given matrix
  3878. * @param left defines the viewport left coordinate
  3879. * @param right defines the viewport right coordinate
  3880. * @param bottom defines the viewport bottom coordinate
  3881. * @param top defines the viewport top coordinate
  3882. * @param znear defines the near clip plane
  3883. * @param zfar defines the far clip plane
  3884. * @param result defines the target matrix
  3885. */
  3886. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3887. /**
  3888. * Creates a right-handed orthographic projection matrix
  3889. * @param left defines the viewport left coordinate
  3890. * @param right defines the viewport right coordinate
  3891. * @param bottom defines the viewport bottom coordinate
  3892. * @param top defines the viewport top coordinate
  3893. * @param znear defines the near clip plane
  3894. * @param zfar defines the far clip plane
  3895. * @returns a new matrix as a right-handed orthographic projection matrix
  3896. */
  3897. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3898. /**
  3899. * Stores a right-handed orthographic projection into a given matrix
  3900. * @param left defines the viewport left coordinate
  3901. * @param right defines the viewport right coordinate
  3902. * @param bottom defines the viewport bottom coordinate
  3903. * @param top defines the viewport top coordinate
  3904. * @param znear defines the near clip plane
  3905. * @param zfar defines the far clip plane
  3906. * @param result defines the target matrix
  3907. */
  3908. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3909. /**
  3910. * Creates a left-handed perspective projection matrix
  3911. * @param width defines the viewport width
  3912. * @param height defines the viewport height
  3913. * @param znear defines the near clip plane
  3914. * @param zfar defines the far clip plane
  3915. * @returns a new matrix as a left-handed perspective projection matrix
  3916. */
  3917. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3918. /**
  3919. * Creates a left-handed perspective projection matrix
  3920. * @param fov defines the horizontal field of view
  3921. * @param aspect defines the aspect ratio
  3922. * @param znear defines the near clip plane
  3923. * @param zfar defines the far clip plane
  3924. * @returns a new matrix as a left-handed perspective projection matrix
  3925. */
  3926. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3927. /**
  3928. * Stores a left-handed perspective projection into a given matrix
  3929. * @param fov defines the horizontal field of view
  3930. * @param aspect defines the aspect ratio
  3931. * @param znear defines the near clip plane
  3932. * @param zfar defines the far clip plane
  3933. * @param result defines the target matrix
  3934. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3935. */
  3936. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3937. /**
  3938. * Creates a right-handed perspective projection matrix
  3939. * @param fov defines the horizontal field of view
  3940. * @param aspect defines the aspect ratio
  3941. * @param znear defines the near clip plane
  3942. * @param zfar defines the far clip plane
  3943. * @returns a new matrix as a right-handed perspective projection matrix
  3944. */
  3945. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3946. /**
  3947. * Stores a right-handed perspective projection into a given matrix
  3948. * @param fov defines the horizontal field of view
  3949. * @param aspect defines the aspect ratio
  3950. * @param znear defines the near clip plane
  3951. * @param zfar defines the far clip plane
  3952. * @param result defines the target matrix
  3953. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3954. */
  3955. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3956. /**
  3957. * Stores a perspective projection for WebVR info a given matrix
  3958. * @param fov defines the field of view
  3959. * @param znear defines the near clip plane
  3960. * @param zfar defines the far clip plane
  3961. * @param result defines the target matrix
  3962. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3963. */
  3964. static PerspectiveFovWebVRToRef(fov: {
  3965. upDegrees: number;
  3966. downDegrees: number;
  3967. leftDegrees: number;
  3968. rightDegrees: number;
  3969. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3970. /**
  3971. * Computes a complete transformation matrix
  3972. * @param viewport defines the viewport to use
  3973. * @param world defines the world matrix
  3974. * @param view defines the view matrix
  3975. * @param projection defines the projection matrix
  3976. * @param zmin defines the near clip plane
  3977. * @param zmax defines the far clip plane
  3978. * @returns the transformation matrix
  3979. */
  3980. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3981. /**
  3982. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3983. * @param matrix defines the matrix to use
  3984. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3985. */
  3986. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3987. /**
  3988. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3989. * @param matrix defines the matrix to use
  3990. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3991. */
  3992. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3993. /**
  3994. * Compute the transpose of a given matrix
  3995. * @param matrix defines the matrix to transpose
  3996. * @returns the new matrix
  3997. */
  3998. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3999. /**
  4000. * Compute the transpose of a matrix and store it in a target matrix
  4001. * @param matrix defines the matrix to transpose
  4002. * @param result defines the target matrix
  4003. */
  4004. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4005. /**
  4006. * Computes a reflection matrix from a plane
  4007. * @param plane defines the reflection plane
  4008. * @returns a new matrix
  4009. */
  4010. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4011. /**
  4012. * Computes a reflection matrix from a plane
  4013. * @param plane defines the reflection plane
  4014. * @param result defines the target matrix
  4015. */
  4016. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4017. /**
  4018. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4019. * @param xaxis defines the value of the 1st axis
  4020. * @param yaxis defines the value of the 2nd axis
  4021. * @param zaxis defines the value of the 3rd axis
  4022. * @param result defines the target matrix
  4023. */
  4024. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4025. /**
  4026. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4027. * @param quat defines the quaternion to use
  4028. * @param result defines the target matrix
  4029. */
  4030. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4031. }
  4032. /**
  4033. * @hidden
  4034. */
  4035. export class TmpVectors {
  4036. static Vector2: Vector2[];
  4037. static Vector3: Vector3[];
  4038. static Vector4: Vector4[];
  4039. static Quaternion: Quaternion[];
  4040. static Matrix: Matrix[];
  4041. }
  4042. }
  4043. declare module BABYLON {
  4044. /** Defines the cross module used constants to avoid circular dependncies */
  4045. export class Constants {
  4046. /** Defines that alpha blending is disabled */
  4047. static readonly ALPHA_DISABLE: number;
  4048. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4049. static readonly ALPHA_ADD: number;
  4050. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4051. static readonly ALPHA_COMBINE: number;
  4052. /** Defines that alpha blending to DEST - SRC * DEST */
  4053. static readonly ALPHA_SUBTRACT: number;
  4054. /** Defines that alpha blending to SRC * DEST */
  4055. static readonly ALPHA_MULTIPLY: number;
  4056. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4057. static readonly ALPHA_MAXIMIZED: number;
  4058. /** Defines that alpha blending to SRC + DEST */
  4059. static readonly ALPHA_ONEONE: number;
  4060. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4061. static readonly ALPHA_PREMULTIPLIED: number;
  4062. /**
  4063. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4064. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4065. */
  4066. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4067. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4068. static readonly ALPHA_INTERPOLATE: number;
  4069. /**
  4070. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4071. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4072. */
  4073. static readonly ALPHA_SCREENMODE: number;
  4074. /** Defines that the ressource is not delayed*/
  4075. static readonly DELAYLOADSTATE_NONE: number;
  4076. /** Defines that the ressource was successfully delay loaded */
  4077. static readonly DELAYLOADSTATE_LOADED: number;
  4078. /** Defines that the ressource is currently delay loading */
  4079. static readonly DELAYLOADSTATE_LOADING: number;
  4080. /** Defines that the ressource is delayed and has not started loading */
  4081. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4083. static readonly NEVER: number;
  4084. /** 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 */
  4085. static readonly ALWAYS: number;
  4086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4087. static readonly LESS: number;
  4088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4089. static readonly EQUAL: number;
  4090. /** 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 */
  4091. static readonly LEQUAL: number;
  4092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4093. static readonly GREATER: number;
  4094. /** 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 */
  4095. static readonly GEQUAL: number;
  4096. /** 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 */
  4097. static readonly NOTEQUAL: number;
  4098. /** Passed to stencilOperation to specify that stencil value must be kept */
  4099. static readonly KEEP: number;
  4100. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4101. static readonly REPLACE: number;
  4102. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4103. static readonly INCR: number;
  4104. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4105. static readonly DECR: number;
  4106. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4107. static readonly INVERT: number;
  4108. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4109. static readonly INCR_WRAP: number;
  4110. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4111. static readonly DECR_WRAP: number;
  4112. /** Texture is not repeating outside of 0..1 UVs */
  4113. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4114. /** Texture is repeating outside of 0..1 UVs */
  4115. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4116. /** Texture is repeating and mirrored */
  4117. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4118. /** ALPHA */
  4119. static readonly TEXTUREFORMAT_ALPHA: number;
  4120. /** LUMINANCE */
  4121. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4122. /** LUMINANCE_ALPHA */
  4123. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4124. /** RGB */
  4125. static readonly TEXTUREFORMAT_RGB: number;
  4126. /** RGBA */
  4127. static readonly TEXTUREFORMAT_RGBA: number;
  4128. /** RED */
  4129. static readonly TEXTUREFORMAT_RED: number;
  4130. /** RED (2nd reference) */
  4131. static readonly TEXTUREFORMAT_R: number;
  4132. /** RG */
  4133. static readonly TEXTUREFORMAT_RG: number;
  4134. /** RED_INTEGER */
  4135. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4136. /** RED_INTEGER (2nd reference) */
  4137. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4138. /** RG_INTEGER */
  4139. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4140. /** RGB_INTEGER */
  4141. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4142. /** RGBA_INTEGER */
  4143. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4144. /** UNSIGNED_BYTE */
  4145. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4146. /** UNSIGNED_BYTE (2nd reference) */
  4147. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4148. /** FLOAT */
  4149. static readonly TEXTURETYPE_FLOAT: number;
  4150. /** HALF_FLOAT */
  4151. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4152. /** BYTE */
  4153. static readonly TEXTURETYPE_BYTE: number;
  4154. /** SHORT */
  4155. static readonly TEXTURETYPE_SHORT: number;
  4156. /** UNSIGNED_SHORT */
  4157. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4158. /** INT */
  4159. static readonly TEXTURETYPE_INT: number;
  4160. /** UNSIGNED_INT */
  4161. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4162. /** UNSIGNED_SHORT_4_4_4_4 */
  4163. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4164. /** UNSIGNED_SHORT_5_5_5_1 */
  4165. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4166. /** UNSIGNED_SHORT_5_6_5 */
  4167. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4168. /** UNSIGNED_INT_2_10_10_10_REV */
  4169. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4170. /** UNSIGNED_INT_24_8 */
  4171. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4172. /** UNSIGNED_INT_10F_11F_11F_REV */
  4173. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4174. /** UNSIGNED_INT_5_9_9_9_REV */
  4175. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4176. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4177. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4178. /** nearest is mag = nearest and min = nearest and mip = linear */
  4179. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4180. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4181. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4182. /** Trilinear is mag = linear and min = linear and mip = linear */
  4183. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4184. /** nearest is mag = nearest and min = nearest and mip = linear */
  4185. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4186. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4187. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4188. /** Trilinear is mag = linear and min = linear and mip = linear */
  4189. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4190. /** mag = nearest and min = nearest and mip = nearest */
  4191. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4192. /** mag = nearest and min = linear and mip = nearest */
  4193. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4194. /** mag = nearest and min = linear and mip = linear */
  4195. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4196. /** mag = nearest and min = linear and mip = none */
  4197. static readonly TEXTURE_NEAREST_LINEAR: number;
  4198. /** mag = nearest and min = nearest and mip = none */
  4199. static readonly TEXTURE_NEAREST_NEAREST: number;
  4200. /** mag = linear and min = nearest and mip = nearest */
  4201. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4202. /** mag = linear and min = nearest and mip = linear */
  4203. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4204. /** mag = linear and min = linear and mip = none */
  4205. static readonly TEXTURE_LINEAR_LINEAR: number;
  4206. /** mag = linear and min = nearest and mip = none */
  4207. static readonly TEXTURE_LINEAR_NEAREST: number;
  4208. /** Explicit coordinates mode */
  4209. static readonly TEXTURE_EXPLICIT_MODE: number;
  4210. /** Spherical coordinates mode */
  4211. static readonly TEXTURE_SPHERICAL_MODE: number;
  4212. /** Planar coordinates mode */
  4213. static readonly TEXTURE_PLANAR_MODE: number;
  4214. /** Cubic coordinates mode */
  4215. static readonly TEXTURE_CUBIC_MODE: number;
  4216. /** Projection coordinates mode */
  4217. static readonly TEXTURE_PROJECTION_MODE: number;
  4218. /** Skybox coordinates mode */
  4219. static readonly TEXTURE_SKYBOX_MODE: number;
  4220. /** Inverse Cubic coordinates mode */
  4221. static readonly TEXTURE_INVCUBIC_MODE: number;
  4222. /** Equirectangular coordinates mode */
  4223. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4224. /** Equirectangular Fixed coordinates mode */
  4225. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4226. /** Equirectangular Fixed Mirrored coordinates mode */
  4227. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4228. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4229. static readonly SCALEMODE_FLOOR: number;
  4230. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4231. static readonly SCALEMODE_NEAREST: number;
  4232. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4233. static readonly SCALEMODE_CEILING: number;
  4234. /**
  4235. * The dirty texture flag value
  4236. */
  4237. static readonly MATERIAL_TextureDirtyFlag: number;
  4238. /**
  4239. * The dirty light flag value
  4240. */
  4241. static readonly MATERIAL_LightDirtyFlag: number;
  4242. /**
  4243. * The dirty fresnel flag value
  4244. */
  4245. static readonly MATERIAL_FresnelDirtyFlag: number;
  4246. /**
  4247. * The dirty attribute flag value
  4248. */
  4249. static readonly MATERIAL_AttributesDirtyFlag: number;
  4250. /**
  4251. * The dirty misc flag value
  4252. */
  4253. static readonly MATERIAL_MiscDirtyFlag: number;
  4254. /**
  4255. * The all dirty flag value
  4256. */
  4257. static readonly MATERIAL_AllDirtyFlag: number;
  4258. /**
  4259. * Returns the triangle fill mode
  4260. */
  4261. static readonly MATERIAL_TriangleFillMode: number;
  4262. /**
  4263. * Returns the wireframe mode
  4264. */
  4265. static readonly MATERIAL_WireFrameFillMode: number;
  4266. /**
  4267. * Returns the point fill mode
  4268. */
  4269. static readonly MATERIAL_PointFillMode: number;
  4270. /**
  4271. * Returns the point list draw mode
  4272. */
  4273. static readonly MATERIAL_PointListDrawMode: number;
  4274. /**
  4275. * Returns the line list draw mode
  4276. */
  4277. static readonly MATERIAL_LineListDrawMode: number;
  4278. /**
  4279. * Returns the line loop draw mode
  4280. */
  4281. static readonly MATERIAL_LineLoopDrawMode: number;
  4282. /**
  4283. * Returns the line strip draw mode
  4284. */
  4285. static readonly MATERIAL_LineStripDrawMode: number;
  4286. /**
  4287. * Returns the triangle strip draw mode
  4288. */
  4289. static readonly MATERIAL_TriangleStripDrawMode: number;
  4290. /**
  4291. * Returns the triangle fan draw mode
  4292. */
  4293. static readonly MATERIAL_TriangleFanDrawMode: number;
  4294. /**
  4295. * Stores the clock-wise side orientation
  4296. */
  4297. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4298. /**
  4299. * Stores the counter clock-wise side orientation
  4300. */
  4301. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4302. /**
  4303. * Nothing
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_NothingTrigger: number;
  4307. /**
  4308. * On pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnPickTrigger: number;
  4312. /**
  4313. * On left pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnLeftPickTrigger: number;
  4317. /**
  4318. * On right pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnRightPickTrigger: number;
  4322. /**
  4323. * On center pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnCenterPickTrigger: number;
  4327. /**
  4328. * On pick down
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnPickDownTrigger: number;
  4332. /**
  4333. * On double pick
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnDoublePickTrigger: number;
  4337. /**
  4338. * On pick up
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnPickUpTrigger: number;
  4342. /**
  4343. * On pick out.
  4344. * This trigger will only be raised if you also declared a OnPickDown
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnPickOutTrigger: number;
  4348. /**
  4349. * On long press
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnLongPressTrigger: number;
  4353. /**
  4354. * On pointer over
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOverTrigger: number;
  4358. /**
  4359. * On pointer out
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOutTrigger: number;
  4363. /**
  4364. * On every frame
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnEveryFrameTrigger: number;
  4368. /**
  4369. * On intersection enter
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4373. /**
  4374. * On intersection exit
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionExitTrigger: number;
  4378. /**
  4379. * On key down
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyDownTrigger: number;
  4383. /**
  4384. * On key up
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyUpTrigger: number;
  4388. /**
  4389. * Billboard mode will only apply to Y axis
  4390. */
  4391. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4392. /**
  4393. * Billboard mode will apply to all axes
  4394. */
  4395. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4396. /**
  4397. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4398. */
  4399. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4400. /**
  4401. * Gets or sets base Assets URL
  4402. */
  4403. static PARTICLES_BaseAssetsUrl: string;
  4404. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4405. * Test order :
  4406. * Is the bounding sphere outside the frustum ?
  4407. * If not, are the bounding box vertices outside the frustum ?
  4408. * It not, then the cullable object is in the frustum.
  4409. */
  4410. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4411. /** Culling strategy : Bounding Sphere Only.
  4412. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4413. * It's also less accurate than the standard because some not visible objects can still be selected.
  4414. * Test : is the bounding sphere outside the frustum ?
  4415. * If not, then the cullable object is in the frustum.
  4416. */
  4417. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4418. /** Culling strategy : Optimistic Inclusion.
  4419. * This in an inclusion test first, then the standard exclusion test.
  4420. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4421. * 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.
  4422. * Anyway, it's as accurate as the standard strategy.
  4423. * Test :
  4424. * Is the cullable object bounding sphere center in the frustum ?
  4425. * If not, apply the default culling strategy.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4428. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4429. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4430. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4431. * 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.
  4432. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4433. * Test :
  4434. * Is the cullable object bounding sphere center in the frustum ?
  4435. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4436. */
  4437. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4438. /**
  4439. * No logging while loading
  4440. */
  4441. static readonly SCENELOADER_NO_LOGGING: number;
  4442. /**
  4443. * Minimal logging while loading
  4444. */
  4445. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4446. /**
  4447. * Summary logging while loading
  4448. */
  4449. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4450. /**
  4451. * Detailled logging while loading
  4452. */
  4453. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4454. }
  4455. }
  4456. declare module BABYLON {
  4457. /**
  4458. * Class used to store and describe the pipeline context associated with an effect
  4459. */
  4460. export interface IPipelineContext {
  4461. /**
  4462. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4463. */
  4464. isAsync: boolean;
  4465. /**
  4466. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4467. */
  4468. isReady: boolean;
  4469. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4470. }
  4471. }
  4472. declare module BABYLON {
  4473. /** @hidden */
  4474. export interface IShaderProcessor {
  4475. attributeProcessor?: (attribute: string) => string;
  4476. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4477. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4478. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4479. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4480. lineProcessor?: (line: string, isFragment: boolean) => string;
  4481. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4482. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4483. }
  4484. }
  4485. declare module BABYLON {
  4486. /** @hidden */
  4487. export interface ProcessingOptions {
  4488. defines: string[];
  4489. indexParameters: any;
  4490. isFragment: boolean;
  4491. shouldUseHighPrecisionShader: boolean;
  4492. supportsUniformBuffers: boolean;
  4493. shadersRepository: string;
  4494. includesShadersStore: {
  4495. [key: string]: string;
  4496. };
  4497. processor?: IShaderProcessor;
  4498. version: string;
  4499. platformName: string;
  4500. lookForClosingBracketForUniformBuffer?: boolean;
  4501. }
  4502. }
  4503. declare module BABYLON {
  4504. /**
  4505. * Helper to manipulate strings
  4506. */
  4507. export class StringTools {
  4508. /**
  4509. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4510. * @param str Source string
  4511. * @param suffix Suffix to search for in the source string
  4512. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4513. */
  4514. static EndsWith(str: string, suffix: string): boolean;
  4515. /**
  4516. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static StartsWith(str: string, suffix: string): boolean;
  4522. }
  4523. }
  4524. declare module BABYLON {
  4525. /** @hidden */
  4526. export class ShaderCodeNode {
  4527. line: string;
  4528. children: ShaderCodeNode[];
  4529. additionalDefineKey?: string;
  4530. additionalDefineValue?: string;
  4531. isValid(preprocessors: {
  4532. [key: string]: string;
  4533. }): boolean;
  4534. process(preprocessors: {
  4535. [key: string]: string;
  4536. }, options: ProcessingOptions): string;
  4537. }
  4538. }
  4539. declare module BABYLON {
  4540. /** @hidden */
  4541. export class ShaderCodeCursor {
  4542. private _lines;
  4543. lineIndex: number;
  4544. readonly currentLine: string;
  4545. readonly canRead: boolean;
  4546. lines: string[];
  4547. }
  4548. }
  4549. declare module BABYLON {
  4550. /** @hidden */
  4551. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4552. process(preprocessors: {
  4553. [key: string]: string;
  4554. }, options: ProcessingOptions): string;
  4555. }
  4556. }
  4557. declare module BABYLON {
  4558. /** @hidden */
  4559. export class ShaderDefineExpression {
  4560. isTrue(preprocessors: {
  4561. [key: string]: string;
  4562. }): boolean;
  4563. }
  4564. }
  4565. declare module BABYLON {
  4566. /** @hidden */
  4567. export class ShaderCodeTestNode extends ShaderCodeNode {
  4568. testExpression: ShaderDefineExpression;
  4569. isValid(preprocessors: {
  4570. [key: string]: string;
  4571. }): boolean;
  4572. }
  4573. }
  4574. declare module BABYLON {
  4575. /** @hidden */
  4576. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4577. define: string;
  4578. not: boolean;
  4579. constructor(define: string, not?: boolean);
  4580. isTrue(preprocessors: {
  4581. [key: string]: string;
  4582. }): boolean;
  4583. }
  4584. }
  4585. declare module BABYLON {
  4586. /** @hidden */
  4587. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4588. leftOperand: ShaderDefineExpression;
  4589. rightOperand: ShaderDefineExpression;
  4590. isTrue(preprocessors: {
  4591. [key: string]: string;
  4592. }): boolean;
  4593. }
  4594. }
  4595. declare module BABYLON {
  4596. /** @hidden */
  4597. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4598. leftOperand: ShaderDefineExpression;
  4599. rightOperand: ShaderDefineExpression;
  4600. isTrue(preprocessors: {
  4601. [key: string]: string;
  4602. }): boolean;
  4603. }
  4604. }
  4605. declare module BABYLON {
  4606. /** @hidden */
  4607. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4608. define: string;
  4609. operand: string;
  4610. testValue: string;
  4611. constructor(define: string, operand: string, testValue: string);
  4612. isTrue(preprocessors: {
  4613. [key: string]: string;
  4614. }): boolean;
  4615. }
  4616. }
  4617. declare module BABYLON {
  4618. /**
  4619. * @ignore
  4620. * Application error to support additional information when loading a file
  4621. */
  4622. export class LoadFileError extends Error {
  4623. /** defines the optional web request */
  4624. request?: WebRequest | undefined;
  4625. private static _setPrototypeOf;
  4626. /**
  4627. * Creates a new LoadFileError
  4628. * @param message defines the message of the error
  4629. * @param request defines the optional web request
  4630. */
  4631. constructor(message: string,
  4632. /** defines the optional web request */
  4633. request?: WebRequest | undefined);
  4634. }
  4635. }
  4636. declare module BABYLON {
  4637. /**
  4638. * Class used to enable access to offline support
  4639. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4640. */
  4641. export interface IOfflineProvider {
  4642. /**
  4643. * Gets a boolean indicating if scene must be saved in the database
  4644. */
  4645. enableSceneOffline: boolean;
  4646. /**
  4647. * Gets a boolean indicating if textures must be saved in the database
  4648. */
  4649. enableTexturesOffline: boolean;
  4650. /**
  4651. * Open the offline support and make it available
  4652. * @param successCallback defines the callback to call on success
  4653. * @param errorCallback defines the callback to call on error
  4654. */
  4655. open(successCallback: () => void, errorCallback: () => void): void;
  4656. /**
  4657. * Loads an image from the offline support
  4658. * @param url defines the url to load from
  4659. * @param image defines the target DOM image
  4660. */
  4661. loadImage(url: string, image: HTMLImageElement): void;
  4662. /**
  4663. * Loads a file from offline support
  4664. * @param url defines the URL to load from
  4665. * @param sceneLoaded defines a callback to call on success
  4666. * @param progressCallBack defines a callback to call when progress changed
  4667. * @param errorCallback defines a callback to call on error
  4668. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4669. */
  4670. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4671. }
  4672. }
  4673. declare module BABYLON {
  4674. /**
  4675. * Class used to help managing file picking and drag'n'drop
  4676. * File Storage
  4677. */
  4678. export class FilesInputStore {
  4679. /**
  4680. * List of files ready to be loaded
  4681. */
  4682. static FilesToLoad: {
  4683. [key: string]: File;
  4684. };
  4685. }
  4686. }
  4687. declare module BABYLON {
  4688. /**
  4689. * Class used to define a retry strategy when error happens while loading assets
  4690. */
  4691. export class RetryStrategy {
  4692. /**
  4693. * Function used to defines an exponential back off strategy
  4694. * @param maxRetries defines the maximum number of retries (3 by default)
  4695. * @param baseInterval defines the interval between retries
  4696. * @returns the strategy function to use
  4697. */
  4698. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4699. }
  4700. }
  4701. declare module BABYLON {
  4702. /**
  4703. * @hidden
  4704. */
  4705. export class FileTools {
  4706. /**
  4707. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4708. */
  4709. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4710. /**
  4711. * Gets or sets the base URL to use to load assets
  4712. */
  4713. static BaseUrl: string;
  4714. /**
  4715. * Default behaviour for cors in the application.
  4716. * It can be a string if the expected behavior is identical in the entire app.
  4717. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4718. */
  4719. static CorsBehavior: string | ((url: string | string[]) => string);
  4720. /**
  4721. * Gets or sets a function used to pre-process url before using them to load assets
  4722. */
  4723. static PreprocessUrl: (url: string) => string;
  4724. /**
  4725. * Removes unwanted characters from an url
  4726. * @param url defines the url to clean
  4727. * @returns the cleaned url
  4728. */
  4729. private static _CleanUrl;
  4730. /**
  4731. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4732. * @param url define the url we are trying
  4733. * @param element define the dom element where to configure the cors policy
  4734. */
  4735. static SetCorsBehavior(url: string | string[], element: {
  4736. crossOrigin: string | null;
  4737. }): void;
  4738. /**
  4739. * Loads an image as an HTMLImageElement.
  4740. * @param input url string, ArrayBuffer, or Blob to load
  4741. * @param onLoad callback called when the image successfully loads
  4742. * @param onError callback called when the image fails to load
  4743. * @param offlineProvider offline provider for caching
  4744. * @returns the HTMLImageElement of the loaded image
  4745. */
  4746. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4747. /**
  4748. * Loads a file
  4749. * @param fileToLoad defines the file to load
  4750. * @param callback defines the callback to call when data is loaded
  4751. * @param progressCallBack defines the callback to call during loading process
  4752. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4753. * @returns a file request object
  4754. */
  4755. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4756. /**
  4757. * Loads a file
  4758. * @param url url string, ArrayBuffer, or Blob to load
  4759. * @param onSuccess callback called when the file successfully loads
  4760. * @param onProgress callback called while file is loading (if the server supports this mode)
  4761. * @param offlineProvider defines the offline provider for caching
  4762. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4763. * @param onError callback called when the file fails to load
  4764. * @returns a file request object
  4765. */
  4766. 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;
  4767. /**
  4768. * Checks if the loaded document was accessed via `file:`-Protocol.
  4769. * @returns boolean
  4770. */
  4771. static IsFileURL(): boolean;
  4772. }
  4773. }
  4774. declare module BABYLON {
  4775. /** @hidden */
  4776. export class ShaderProcessor {
  4777. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4778. private static _ProcessPrecision;
  4779. private static _ExtractOperation;
  4780. private static _BuildSubExpression;
  4781. private static _BuildExpression;
  4782. private static _MoveCursorWithinIf;
  4783. private static _MoveCursor;
  4784. private static _EvaluatePreProcessors;
  4785. private static _PreparePreProcessors;
  4786. private static _ProcessShaderConversion;
  4787. private static _ProcessIncludes;
  4788. }
  4789. }
  4790. declare module BABYLON {
  4791. /**
  4792. * Class used to hold a RBG color
  4793. */
  4794. export class Color3 {
  4795. /**
  4796. * Defines the red component (between 0 and 1, default is 0)
  4797. */
  4798. r: number;
  4799. /**
  4800. * Defines the green component (between 0 and 1, default is 0)
  4801. */
  4802. g: number;
  4803. /**
  4804. * Defines the blue component (between 0 and 1, default is 0)
  4805. */
  4806. b: number;
  4807. /**
  4808. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4809. * @param r defines the red component (between 0 and 1, default is 0)
  4810. * @param g defines the green component (between 0 and 1, default is 0)
  4811. * @param b defines the blue component (between 0 and 1, default is 0)
  4812. */
  4813. constructor(
  4814. /**
  4815. * Defines the red component (between 0 and 1, default is 0)
  4816. */
  4817. r?: number,
  4818. /**
  4819. * Defines the green component (between 0 and 1, default is 0)
  4820. */
  4821. g?: number,
  4822. /**
  4823. * Defines the blue component (between 0 and 1, default is 0)
  4824. */
  4825. b?: number);
  4826. /**
  4827. * Creates a string with the Color3 current values
  4828. * @returns the string representation of the Color3 object
  4829. */
  4830. toString(): string;
  4831. /**
  4832. * Returns the string "Color3"
  4833. * @returns "Color3"
  4834. */
  4835. getClassName(): string;
  4836. /**
  4837. * Compute the Color3 hash code
  4838. * @returns an unique number that can be used to hash Color3 objects
  4839. */
  4840. getHashCode(): number;
  4841. /**
  4842. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4843. * @param array defines the array where to store the r,g,b components
  4844. * @param index defines an optional index in the target array to define where to start storing values
  4845. * @returns the current Color3 object
  4846. */
  4847. toArray(array: FloatArray, index?: number): Color3;
  4848. /**
  4849. * Returns a new Color4 object from the current Color3 and the given alpha
  4850. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4851. * @returns a new Color4 object
  4852. */
  4853. toColor4(alpha?: number): Color4;
  4854. /**
  4855. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4856. * @returns the new array
  4857. */
  4858. asArray(): number[];
  4859. /**
  4860. * Returns the luminance value
  4861. * @returns a float value
  4862. */
  4863. toLuminance(): number;
  4864. /**
  4865. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4866. * @param otherColor defines the second operand
  4867. * @returns the new Color3 object
  4868. */
  4869. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4870. /**
  4871. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4872. * @param otherColor defines the second operand
  4873. * @param result defines the Color3 object where to store the result
  4874. * @returns the current Color3
  4875. */
  4876. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4877. /**
  4878. * Determines equality between Color3 objects
  4879. * @param otherColor defines the second operand
  4880. * @returns true if the rgb values are equal to the given ones
  4881. */
  4882. equals(otherColor: DeepImmutable<Color3>): boolean;
  4883. /**
  4884. * Determines equality between the current Color3 object and a set of r,b,g values
  4885. * @param r defines the red component to check
  4886. * @param g defines the green component to check
  4887. * @param b defines the blue component to check
  4888. * @returns true if the rgb values are equal to the given ones
  4889. */
  4890. equalsFloats(r: number, g: number, b: number): boolean;
  4891. /**
  4892. * Multiplies in place each rgb value by scale
  4893. * @param scale defines the scaling factor
  4894. * @returns the updated Color3
  4895. */
  4896. scale(scale: number): Color3;
  4897. /**
  4898. * Multiplies the rgb values by scale and stores the result into "result"
  4899. * @param scale defines the scaling factor
  4900. * @param result defines the Color3 object where to store the result
  4901. * @returns the unmodified current Color3
  4902. */
  4903. scaleToRef(scale: number, result: Color3): Color3;
  4904. /**
  4905. * Scale the current Color3 values by a factor and add the result to a given Color3
  4906. * @param scale defines the scale factor
  4907. * @param result defines color to store the result into
  4908. * @returns the unmodified current Color3
  4909. */
  4910. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4911. /**
  4912. * Clamps the rgb values by the min and max values and stores the result into "result"
  4913. * @param min defines minimum clamping value (default is 0)
  4914. * @param max defines maximum clamping value (default is 1)
  4915. * @param result defines color to store the result into
  4916. * @returns the original Color3
  4917. */
  4918. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4919. /**
  4920. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4921. * @param otherColor defines the second operand
  4922. * @returns the new Color3
  4923. */
  4924. add(otherColor: DeepImmutable<Color3>): Color3;
  4925. /**
  4926. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4927. * @param otherColor defines the second operand
  4928. * @param result defines Color3 object to store the result into
  4929. * @returns the unmodified current Color3
  4930. */
  4931. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4932. /**
  4933. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4934. * @param otherColor defines the second operand
  4935. * @returns the new Color3
  4936. */
  4937. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4938. /**
  4939. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4940. * @param otherColor defines the second operand
  4941. * @param result defines Color3 object to store the result into
  4942. * @returns the unmodified current Color3
  4943. */
  4944. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4945. /**
  4946. * Copy the current object
  4947. * @returns a new Color3 copied the current one
  4948. */
  4949. clone(): Color3;
  4950. /**
  4951. * Copies the rgb values from the source in the current Color3
  4952. * @param source defines the source Color3 object
  4953. * @returns the updated Color3 object
  4954. */
  4955. copyFrom(source: DeepImmutable<Color3>): Color3;
  4956. /**
  4957. * Updates the Color3 rgb values from the given floats
  4958. * @param r defines the red component to read from
  4959. * @param g defines the green component to read from
  4960. * @param b defines the blue component to read from
  4961. * @returns the current Color3 object
  4962. */
  4963. copyFromFloats(r: number, g: number, b: number): Color3;
  4964. /**
  4965. * Updates the Color3 rgb values from the given floats
  4966. * @param r defines the red component to read from
  4967. * @param g defines the green component to read from
  4968. * @param b defines the blue component to read from
  4969. * @returns the current Color3 object
  4970. */
  4971. set(r: number, g: number, b: number): Color3;
  4972. /**
  4973. * Compute the Color3 hexadecimal code as a string
  4974. * @returns a string containing the hexadecimal representation of the Color3 object
  4975. */
  4976. toHexString(): string;
  4977. /**
  4978. * Computes a new Color3 converted from the current one to linear space
  4979. * @returns a new Color3 object
  4980. */
  4981. toLinearSpace(): Color3;
  4982. /**
  4983. * Converts current color in rgb space to HSV values
  4984. * @returns a new color3 representing the HSV values
  4985. */
  4986. toHSV(): Color3;
  4987. /**
  4988. * Converts current color in rgb space to HSV values
  4989. * @param result defines the Color3 where to store the HSV values
  4990. */
  4991. toHSVToRef(result: Color3): void;
  4992. /**
  4993. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4994. * @param convertedColor defines the Color3 object where to store the linear space version
  4995. * @returns the unmodified Color3
  4996. */
  4997. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4998. /**
  4999. * Computes a new Color3 converted from the current one to gamma space
  5000. * @returns a new Color3 object
  5001. */
  5002. toGammaSpace(): Color3;
  5003. /**
  5004. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5005. * @param convertedColor defines the Color3 object where to store the gamma space version
  5006. * @returns the unmodified Color3
  5007. */
  5008. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5009. private static _BlackReadOnly;
  5010. /**
  5011. * Convert Hue, saturation and value to a Color3 (RGB)
  5012. * @param hue defines the hue
  5013. * @param saturation defines the saturation
  5014. * @param value defines the value
  5015. * @param result defines the Color3 where to store the RGB values
  5016. */
  5017. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5018. /**
  5019. * Creates a new Color3 from the string containing valid hexadecimal values
  5020. * @param hex defines a string containing valid hexadecimal values
  5021. * @returns a new Color3 object
  5022. */
  5023. static FromHexString(hex: string): Color3;
  5024. /**
  5025. * Creates a new Color3 from the starting index of the given array
  5026. * @param array defines the source array
  5027. * @param offset defines an offset in the source array
  5028. * @returns a new Color3 object
  5029. */
  5030. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5031. /**
  5032. * Creates a new Color3 from integer values (< 256)
  5033. * @param r defines the red component to read from (value between 0 and 255)
  5034. * @param g defines the green component to read from (value between 0 and 255)
  5035. * @param b defines the blue component to read from (value between 0 and 255)
  5036. * @returns a new Color3 object
  5037. */
  5038. static FromInts(r: number, g: number, b: number): Color3;
  5039. /**
  5040. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5041. * @param start defines the start Color3 value
  5042. * @param end defines the end Color3 value
  5043. * @param amount defines the gradient value between start and end
  5044. * @returns a new Color3 object
  5045. */
  5046. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5047. /**
  5048. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5049. * @param left defines the start value
  5050. * @param right defines the end value
  5051. * @param amount defines the gradient factor
  5052. * @param result defines the Color3 object where to store the result
  5053. */
  5054. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5055. /**
  5056. * Returns a Color3 value containing a red color
  5057. * @returns a new Color3 object
  5058. */
  5059. static Red(): Color3;
  5060. /**
  5061. * Returns a Color3 value containing a green color
  5062. * @returns a new Color3 object
  5063. */
  5064. static Green(): Color3;
  5065. /**
  5066. * Returns a Color3 value containing a blue color
  5067. * @returns a new Color3 object
  5068. */
  5069. static Blue(): Color3;
  5070. /**
  5071. * Returns a Color3 value containing a black color
  5072. * @returns a new Color3 object
  5073. */
  5074. static Black(): Color3;
  5075. /**
  5076. * Gets a Color3 value containing a black color that must not be updated
  5077. */
  5078. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5079. /**
  5080. * Returns a Color3 value containing a white color
  5081. * @returns a new Color3 object
  5082. */
  5083. static White(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a purple color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Purple(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a magenta color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Magenta(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a yellow color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Yellow(): Color3;
  5099. /**
  5100. * Returns a Color3 value containing a gray color
  5101. * @returns a new Color3 object
  5102. */
  5103. static Gray(): Color3;
  5104. /**
  5105. * Returns a Color3 value containing a teal color
  5106. * @returns a new Color3 object
  5107. */
  5108. static Teal(): Color3;
  5109. /**
  5110. * Returns a Color3 value containing a random color
  5111. * @returns a new Color3 object
  5112. */
  5113. static Random(): Color3;
  5114. }
  5115. /**
  5116. * Class used to hold a RBGA color
  5117. */
  5118. export class Color4 {
  5119. /**
  5120. * Defines the red component (between 0 and 1, default is 0)
  5121. */
  5122. r: number;
  5123. /**
  5124. * Defines the green component (between 0 and 1, default is 0)
  5125. */
  5126. g: number;
  5127. /**
  5128. * Defines the blue component (between 0 and 1, default is 0)
  5129. */
  5130. b: number;
  5131. /**
  5132. * Defines the alpha component (between 0 and 1, default is 1)
  5133. */
  5134. a: number;
  5135. /**
  5136. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5137. * @param r defines the red component (between 0 and 1, default is 0)
  5138. * @param g defines the green component (between 0 and 1, default is 0)
  5139. * @param b defines the blue component (between 0 and 1, default is 0)
  5140. * @param a defines the alpha component (between 0 and 1, default is 1)
  5141. */
  5142. constructor(
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r?: number,
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g?: number,
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b?: number,
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a?: number);
  5159. /**
  5160. * Adds in place the given Color4 values to the current Color4 object
  5161. * @param right defines the second operand
  5162. * @returns the current updated Color4 object
  5163. */
  5164. addInPlace(right: DeepImmutable<Color4>): Color4;
  5165. /**
  5166. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5167. * @returns the new array
  5168. */
  5169. asArray(): number[];
  5170. /**
  5171. * Stores from the starting index in the given array the Color4 successive values
  5172. * @param array defines the array where to store the r,g,b components
  5173. * @param index defines an optional index in the target array to define where to start storing values
  5174. * @returns the current Color4 object
  5175. */
  5176. toArray(array: number[], index?: number): Color4;
  5177. /**
  5178. * Determines equality between Color4 objects
  5179. * @param otherColor defines the second operand
  5180. * @returns true if the rgba values are equal to the given ones
  5181. */
  5182. equals(otherColor: DeepImmutable<Color4>): boolean;
  5183. /**
  5184. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5185. * @param right defines the second operand
  5186. * @returns a new Color4 object
  5187. */
  5188. add(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5191. * @param right defines the second operand
  5192. * @returns a new Color4 object
  5193. */
  5194. subtract(right: DeepImmutable<Color4>): Color4;
  5195. /**
  5196. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5197. * @param right defines the second operand
  5198. * @param result defines the Color4 object where to store the result
  5199. * @returns the current Color4 object
  5200. */
  5201. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5202. /**
  5203. * Creates a new Color4 with the current Color4 values multiplied by scale
  5204. * @param scale defines the scaling factor to apply
  5205. * @returns a new Color4 object
  5206. */
  5207. scale(scale: number): Color4;
  5208. /**
  5209. * Multiplies the current Color4 values by scale and stores the result in "result"
  5210. * @param scale defines the scaling factor to apply
  5211. * @param result defines the Color4 object where to store the result
  5212. * @returns the current unmodified Color4
  5213. */
  5214. scaleToRef(scale: number, result: Color4): Color4;
  5215. /**
  5216. * Scale the current Color4 values by a factor and add the result to a given Color4
  5217. * @param scale defines the scale factor
  5218. * @param result defines the Color4 object where to store the result
  5219. * @returns the unmodified current Color4
  5220. */
  5221. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5222. /**
  5223. * Clamps the rgb values by the min and max values and stores the result into "result"
  5224. * @param min defines minimum clamping value (default is 0)
  5225. * @param max defines maximum clamping value (default is 1)
  5226. * @param result defines color to store the result into.
  5227. * @returns the cuurent Color4
  5228. */
  5229. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5230. /**
  5231. * Multipy an Color4 value by another and return a new Color4 object
  5232. * @param color defines the Color4 value to multiply by
  5233. * @returns a new Color4 object
  5234. */
  5235. multiply(color: Color4): Color4;
  5236. /**
  5237. * Multipy a Color4 value by another and push the result in a reference value
  5238. * @param color defines the Color4 value to multiply by
  5239. * @param result defines the Color4 to fill the result in
  5240. * @returns the result Color4
  5241. */
  5242. multiplyToRef(color: Color4, result: Color4): Color4;
  5243. /**
  5244. * Creates a string with the Color4 current values
  5245. * @returns the string representation of the Color4 object
  5246. */
  5247. toString(): string;
  5248. /**
  5249. * Returns the string "Color4"
  5250. * @returns "Color4"
  5251. */
  5252. getClassName(): string;
  5253. /**
  5254. * Compute the Color4 hash code
  5255. * @returns an unique number that can be used to hash Color4 objects
  5256. */
  5257. getHashCode(): number;
  5258. /**
  5259. * Creates a new Color4 copied from the current one
  5260. * @returns a new Color4 object
  5261. */
  5262. clone(): Color4;
  5263. /**
  5264. * Copies the given Color4 values into the current one
  5265. * @param source defines the source Color4 object
  5266. * @returns the current updated Color4 object
  5267. */
  5268. copyFrom(source: Color4): Color4;
  5269. /**
  5270. * Copies the given float values into the current one
  5271. * @param r defines the red component to read from
  5272. * @param g defines the green component to read from
  5273. * @param b defines the blue component to read from
  5274. * @param a defines the alpha component to read from
  5275. * @returns the current updated Color4 object
  5276. */
  5277. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5278. /**
  5279. * Copies the given float values into the current one
  5280. * @param r defines the red component to read from
  5281. * @param g defines the green component to read from
  5282. * @param b defines the blue component to read from
  5283. * @param a defines the alpha component to read from
  5284. * @returns the current updated Color4 object
  5285. */
  5286. set(r: number, g: number, b: number, a: number): Color4;
  5287. /**
  5288. * Compute the Color4 hexadecimal code as a string
  5289. * @returns a string containing the hexadecimal representation of the Color4 object
  5290. */
  5291. toHexString(): string;
  5292. /**
  5293. * Computes a new Color4 converted from the current one to linear space
  5294. * @returns a new Color4 object
  5295. */
  5296. toLinearSpace(): Color4;
  5297. /**
  5298. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5299. * @param convertedColor defines the Color4 object where to store the linear space version
  5300. * @returns the unmodified Color4
  5301. */
  5302. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5303. /**
  5304. * Computes a new Color4 converted from the current one to gamma space
  5305. * @returns a new Color4 object
  5306. */
  5307. toGammaSpace(): Color4;
  5308. /**
  5309. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5310. * @param convertedColor defines the Color4 object where to store the gamma space version
  5311. * @returns the unmodified Color4
  5312. */
  5313. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5314. /**
  5315. * Creates a new Color4 from the string containing valid hexadecimal values
  5316. * @param hex defines a string containing valid hexadecimal values
  5317. * @returns a new Color4 object
  5318. */
  5319. static FromHexString(hex: string): Color4;
  5320. /**
  5321. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5322. * @param left defines the start value
  5323. * @param right defines the end value
  5324. * @param amount defines the gradient factor
  5325. * @returns a new Color4 object
  5326. */
  5327. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5328. /**
  5329. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5330. * @param left defines the start value
  5331. * @param right defines the end value
  5332. * @param amount defines the gradient factor
  5333. * @param result defines the Color4 object where to store data
  5334. */
  5335. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5336. /**
  5337. * Creates a new Color4 from a Color3 and an alpha value
  5338. * @param color3 defines the source Color3 to read from
  5339. * @param alpha defines the alpha component (1.0 by default)
  5340. * @returns a new Color4 object
  5341. */
  5342. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5343. /**
  5344. * Creates a new Color4 from the starting index element of the given array
  5345. * @param array defines the source array to read from
  5346. * @param offset defines the offset in the source array
  5347. * @returns a new Color4 object
  5348. */
  5349. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5350. /**
  5351. * Creates a new Color3 from integer values (< 256)
  5352. * @param r defines the red component to read from (value between 0 and 255)
  5353. * @param g defines the green component to read from (value between 0 and 255)
  5354. * @param b defines the blue component to read from (value between 0 and 255)
  5355. * @param a defines the alpha component to read from (value between 0 and 255)
  5356. * @returns a new Color3 object
  5357. */
  5358. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5359. /**
  5360. * Check the content of a given array and convert it to an array containing RGBA data
  5361. * If the original array was already containing count * 4 values then it is returned directly
  5362. * @param colors defines the array to check
  5363. * @param count defines the number of RGBA data to expect
  5364. * @returns an array containing count * 4 values (RGBA)
  5365. */
  5366. static CheckColors4(colors: number[], count: number): number[];
  5367. }
  5368. /**
  5369. * @hidden
  5370. */
  5371. export class TmpColors {
  5372. static Color3: Color3[];
  5373. static Color4: Color4[];
  5374. }
  5375. }
  5376. declare module BABYLON {
  5377. /**
  5378. * Class representing spherical harmonics coefficients to the 3rd degree
  5379. */
  5380. export class SphericalHarmonics {
  5381. /**
  5382. * Defines whether or not the harmonics have been prescaled for rendering.
  5383. */
  5384. preScaled: boolean;
  5385. /**
  5386. * The l0,0 coefficients of the spherical harmonics
  5387. */
  5388. l00: Vector3;
  5389. /**
  5390. * The l1,-1 coefficients of the spherical harmonics
  5391. */
  5392. l1_1: Vector3;
  5393. /**
  5394. * The l1,0 coefficients of the spherical harmonics
  5395. */
  5396. l10: Vector3;
  5397. /**
  5398. * The l1,1 coefficients of the spherical harmonics
  5399. */
  5400. l11: Vector3;
  5401. /**
  5402. * The l2,-2 coefficients of the spherical harmonics
  5403. */
  5404. l2_2: Vector3;
  5405. /**
  5406. * The l2,-1 coefficients of the spherical harmonics
  5407. */
  5408. l2_1: Vector3;
  5409. /**
  5410. * The l2,0 coefficients of the spherical harmonics
  5411. */
  5412. l20: Vector3;
  5413. /**
  5414. * The l2,1 coefficients of the spherical harmonics
  5415. */
  5416. l21: Vector3;
  5417. /**
  5418. * The l2,2 coefficients of the spherical harmonics
  5419. */
  5420. l22: Vector3;
  5421. /**
  5422. * Adds a light to the spherical harmonics
  5423. * @param direction the direction of the light
  5424. * @param color the color of the light
  5425. * @param deltaSolidAngle the delta solid angle of the light
  5426. */
  5427. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5428. /**
  5429. * Scales the spherical harmonics by the given amount
  5430. * @param scale the amount to scale
  5431. */
  5432. scaleInPlace(scale: number): void;
  5433. /**
  5434. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5435. *
  5436. * ```
  5437. * E_lm = A_l * L_lm
  5438. * ```
  5439. *
  5440. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5441. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5442. * the scaling factors are given in equation 9.
  5443. */
  5444. convertIncidentRadianceToIrradiance(): void;
  5445. /**
  5446. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5447. *
  5448. * ```
  5449. * L = (1/pi) * E * rho
  5450. * ```
  5451. *
  5452. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5453. */
  5454. convertIrradianceToLambertianRadiance(): void;
  5455. /**
  5456. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5457. * required operations at run time.
  5458. *
  5459. * This is simply done by scaling back the SH with Ylm constants parameter.
  5460. * The trigonometric part being applied by the shader at run time.
  5461. */
  5462. preScaleForRendering(): void;
  5463. /**
  5464. * Constructs a spherical harmonics from an array.
  5465. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5466. * @returns the spherical harmonics
  5467. */
  5468. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5469. /**
  5470. * Gets the spherical harmonics from polynomial
  5471. * @param polynomial the spherical polynomial
  5472. * @returns the spherical harmonics
  5473. */
  5474. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5475. }
  5476. /**
  5477. * Class representing spherical polynomial coefficients to the 3rd degree
  5478. */
  5479. export class SphericalPolynomial {
  5480. private _harmonics;
  5481. /**
  5482. * The spherical harmonics used to create the polynomials.
  5483. */
  5484. readonly preScaledHarmonics: SphericalHarmonics;
  5485. /**
  5486. * The x coefficients of the spherical polynomial
  5487. */
  5488. x: Vector3;
  5489. /**
  5490. * The y coefficients of the spherical polynomial
  5491. */
  5492. y: Vector3;
  5493. /**
  5494. * The z coefficients of the spherical polynomial
  5495. */
  5496. z: Vector3;
  5497. /**
  5498. * The xx coefficients of the spherical polynomial
  5499. */
  5500. xx: Vector3;
  5501. /**
  5502. * The yy coefficients of the spherical polynomial
  5503. */
  5504. yy: Vector3;
  5505. /**
  5506. * The zz coefficients of the spherical polynomial
  5507. */
  5508. zz: Vector3;
  5509. /**
  5510. * The xy coefficients of the spherical polynomial
  5511. */
  5512. xy: Vector3;
  5513. /**
  5514. * The yz coefficients of the spherical polynomial
  5515. */
  5516. yz: Vector3;
  5517. /**
  5518. * The zx coefficients of the spherical polynomial
  5519. */
  5520. zx: Vector3;
  5521. /**
  5522. * Adds an ambient color to the spherical polynomial
  5523. * @param color the color to add
  5524. */
  5525. addAmbient(color: Color3): void;
  5526. /**
  5527. * Scales the spherical polynomial by the given amount
  5528. * @param scale the amount to scale
  5529. */
  5530. scaleInPlace(scale: number): void;
  5531. /**
  5532. * Gets the spherical polynomial from harmonics
  5533. * @param harmonics the spherical harmonics
  5534. * @returns the spherical polynomial
  5535. */
  5536. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5537. /**
  5538. * Constructs a spherical polynomial from an array.
  5539. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5540. * @returns the spherical polynomial
  5541. */
  5542. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5543. }
  5544. }
  5545. declare module BABYLON {
  5546. /**
  5547. * Define options used to create a render target texture
  5548. */
  5549. export class RenderTargetCreationOptions {
  5550. /**
  5551. * Specifies is mipmaps must be generated
  5552. */
  5553. generateMipMaps?: boolean;
  5554. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5555. generateDepthBuffer?: boolean;
  5556. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5557. generateStencilBuffer?: boolean;
  5558. /** Defines texture type (int by default) */
  5559. type?: number;
  5560. /** Defines sampling mode (trilinear by default) */
  5561. samplingMode?: number;
  5562. /** Defines format (RGBA by default) */
  5563. format?: number;
  5564. }
  5565. }
  5566. declare module BABYLON {
  5567. /**
  5568. * @hidden
  5569. **/
  5570. export class _AlphaState {
  5571. private _isAlphaBlendDirty;
  5572. private _isBlendFunctionParametersDirty;
  5573. private _isBlendEquationParametersDirty;
  5574. private _isBlendConstantsDirty;
  5575. private _alphaBlend;
  5576. private _blendFunctionParameters;
  5577. private _blendEquationParameters;
  5578. private _blendConstants;
  5579. /**
  5580. * Initializes the state.
  5581. */
  5582. constructor();
  5583. readonly isDirty: boolean;
  5584. alphaBlend: boolean;
  5585. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5586. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5587. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5588. reset(): void;
  5589. apply(gl: WebGLRenderingContext): void;
  5590. }
  5591. }
  5592. declare module BABYLON {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _DepthCullingState {
  5597. private _isDepthTestDirty;
  5598. private _isDepthMaskDirty;
  5599. private _isDepthFuncDirty;
  5600. private _isCullFaceDirty;
  5601. private _isCullDirty;
  5602. private _isZOffsetDirty;
  5603. private _isFrontFaceDirty;
  5604. private _depthTest;
  5605. private _depthMask;
  5606. private _depthFunc;
  5607. private _cull;
  5608. private _cullFace;
  5609. private _zOffset;
  5610. private _frontFace;
  5611. /**
  5612. * Initializes the state.
  5613. */
  5614. constructor();
  5615. readonly isDirty: boolean;
  5616. zOffset: number;
  5617. cullFace: Nullable<number>;
  5618. cull: Nullable<boolean>;
  5619. depthFunc: Nullable<number>;
  5620. depthMask: boolean;
  5621. depthTest: boolean;
  5622. frontFace: Nullable<number>;
  5623. reset(): void;
  5624. apply(gl: WebGLRenderingContext): void;
  5625. }
  5626. }
  5627. declare module BABYLON {
  5628. /**
  5629. * @hidden
  5630. **/
  5631. export class _StencilState {
  5632. /** 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 */
  5633. static readonly ALWAYS: number;
  5634. /** Passed to stencilOperation to specify that stencil value must be kept */
  5635. static readonly KEEP: number;
  5636. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5637. static readonly REPLACE: number;
  5638. private _isStencilTestDirty;
  5639. private _isStencilMaskDirty;
  5640. private _isStencilFuncDirty;
  5641. private _isStencilOpDirty;
  5642. private _stencilTest;
  5643. private _stencilMask;
  5644. private _stencilFunc;
  5645. private _stencilFuncRef;
  5646. private _stencilFuncMask;
  5647. private _stencilOpStencilFail;
  5648. private _stencilOpDepthFail;
  5649. private _stencilOpStencilDepthPass;
  5650. readonly isDirty: boolean;
  5651. stencilFunc: number;
  5652. stencilFuncRef: number;
  5653. stencilFuncMask: number;
  5654. stencilOpStencilFail: number;
  5655. stencilOpDepthFail: number;
  5656. stencilOpStencilDepthPass: number;
  5657. stencilMask: number;
  5658. stencilTest: boolean;
  5659. constructor();
  5660. reset(): void;
  5661. apply(gl: WebGLRenderingContext): void;
  5662. }
  5663. }
  5664. declare module BABYLON {
  5665. /**
  5666. * @hidden
  5667. **/
  5668. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class used to evalaute queries containing `and` and `or` operators
  5674. */
  5675. export class AndOrNotEvaluator {
  5676. /**
  5677. * Evaluate a query
  5678. * @param query defines the query to evaluate
  5679. * @param evaluateCallback defines the callback used to filter result
  5680. * @returns true if the query matches
  5681. */
  5682. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5683. private static _HandleParenthesisContent;
  5684. private static _SimplifyNegation;
  5685. }
  5686. }
  5687. declare module BABYLON {
  5688. /**
  5689. * Class used to store custom tags
  5690. */
  5691. export class Tags {
  5692. /**
  5693. * Adds support for tags on the given object
  5694. * @param obj defines the object to use
  5695. */
  5696. static EnableFor(obj: any): void;
  5697. /**
  5698. * Removes tags support
  5699. * @param obj defines the object to use
  5700. */
  5701. static DisableFor(obj: any): void;
  5702. /**
  5703. * Gets a boolean indicating if the given object has tags
  5704. * @param obj defines the object to use
  5705. * @returns a boolean
  5706. */
  5707. static HasTags(obj: any): boolean;
  5708. /**
  5709. * Gets the tags available on a given object
  5710. * @param obj defines the object to use
  5711. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5712. * @returns the tags
  5713. */
  5714. static GetTags(obj: any, asString?: boolean): any;
  5715. /**
  5716. * Adds tags to an object
  5717. * @param obj defines the object to use
  5718. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5719. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5720. */
  5721. static AddTagsTo(obj: any, tagsString: string): void;
  5722. /**
  5723. * @hidden
  5724. */ private static _AddTagTo(obj: any, tag: string): void;
  5725. /**
  5726. * Removes specific tags from a specific object
  5727. * @param obj defines the object to use
  5728. * @param tagsString defines the tags to remove
  5729. */
  5730. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5731. /**
  5732. * @hidden
  5733. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5734. /**
  5735. * Defines if tags hosted on an object match a given query
  5736. * @param obj defines the object to use
  5737. * @param tagsQuery defines the tag query
  5738. * @returns a boolean
  5739. */
  5740. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5741. }
  5742. }
  5743. declare module BABYLON {
  5744. /**
  5745. * Defines potential orientation for back face culling
  5746. */
  5747. export enum Orientation {
  5748. /**
  5749. * Clockwise
  5750. */
  5751. CW = 0,
  5752. /** Counter clockwise */
  5753. CCW = 1
  5754. }
  5755. /** Class used to represent a Bezier curve */
  5756. export class BezierCurve {
  5757. /**
  5758. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5759. * @param t defines the time
  5760. * @param x1 defines the left coordinate on X axis
  5761. * @param y1 defines the left coordinate on Y axis
  5762. * @param x2 defines the right coordinate on X axis
  5763. * @param y2 defines the right coordinate on Y axis
  5764. * @returns the interpolated value
  5765. */
  5766. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5767. }
  5768. /**
  5769. * Defines angle representation
  5770. */
  5771. export class Angle {
  5772. private _radians;
  5773. /**
  5774. * Creates an Angle object of "radians" radians (float).
  5775. * @param radians the angle in radians
  5776. */
  5777. constructor(radians: number);
  5778. /**
  5779. * Get value in degrees
  5780. * @returns the Angle value in degrees (float)
  5781. */
  5782. degrees(): number;
  5783. /**
  5784. * Get value in radians
  5785. * @returns the Angle value in radians (float)
  5786. */
  5787. radians(): number;
  5788. /**
  5789. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5790. * @param a defines first vector
  5791. * @param b defines second vector
  5792. * @returns a new Angle
  5793. */
  5794. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5795. /**
  5796. * Gets a new Angle object from the given float in radians
  5797. * @param radians defines the angle value in radians
  5798. * @returns a new Angle
  5799. */
  5800. static FromRadians(radians: number): Angle;
  5801. /**
  5802. * Gets a new Angle object from the given float in degrees
  5803. * @param degrees defines the angle value in degrees
  5804. * @returns a new Angle
  5805. */
  5806. static FromDegrees(degrees: number): Angle;
  5807. }
  5808. /**
  5809. * This represents an arc in a 2d space.
  5810. */
  5811. export class Arc2 {
  5812. /** Defines the start point of the arc */
  5813. startPoint: Vector2;
  5814. /** Defines the mid point of the arc */
  5815. midPoint: Vector2;
  5816. /** Defines the end point of the arc */
  5817. endPoint: Vector2;
  5818. /**
  5819. * Defines the center point of the arc.
  5820. */
  5821. centerPoint: Vector2;
  5822. /**
  5823. * Defines the radius of the arc.
  5824. */
  5825. radius: number;
  5826. /**
  5827. * Defines the angle of the arc (from mid point to end point).
  5828. */
  5829. angle: Angle;
  5830. /**
  5831. * Defines the start angle of the arc (from start point to middle point).
  5832. */
  5833. startAngle: Angle;
  5834. /**
  5835. * Defines the orientation of the arc (clock wise/counter clock wise).
  5836. */
  5837. orientation: Orientation;
  5838. /**
  5839. * Creates an Arc object from the three given points : start, middle and end.
  5840. * @param startPoint Defines the start point of the arc
  5841. * @param midPoint Defines the midlle point of the arc
  5842. * @param endPoint Defines the end point of the arc
  5843. */
  5844. constructor(
  5845. /** Defines the start point of the arc */
  5846. startPoint: Vector2,
  5847. /** Defines the mid point of the arc */
  5848. midPoint: Vector2,
  5849. /** Defines the end point of the arc */
  5850. endPoint: Vector2);
  5851. }
  5852. /**
  5853. * Represents a 2D path made up of multiple 2D points
  5854. */
  5855. export class Path2 {
  5856. private _points;
  5857. private _length;
  5858. /**
  5859. * If the path start and end point are the same
  5860. */
  5861. closed: boolean;
  5862. /**
  5863. * Creates a Path2 object from the starting 2D coordinates x and y.
  5864. * @param x the starting points x value
  5865. * @param y the starting points y value
  5866. */
  5867. constructor(x: number, y: number);
  5868. /**
  5869. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5870. * @param x the added points x value
  5871. * @param y the added points y value
  5872. * @returns the updated Path2.
  5873. */
  5874. addLineTo(x: number, y: number): Path2;
  5875. /**
  5876. * 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.
  5877. * @param midX middle point x value
  5878. * @param midY middle point y value
  5879. * @param endX end point x value
  5880. * @param endY end point y value
  5881. * @param numberOfSegments (default: 36)
  5882. * @returns the updated Path2.
  5883. */
  5884. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5885. /**
  5886. * Closes the Path2.
  5887. * @returns the Path2.
  5888. */
  5889. close(): Path2;
  5890. /**
  5891. * Gets the sum of the distance between each sequential point in the path
  5892. * @returns the Path2 total length (float).
  5893. */
  5894. length(): number;
  5895. /**
  5896. * Gets the points which construct the path
  5897. * @returns the Path2 internal array of points.
  5898. */
  5899. getPoints(): Vector2[];
  5900. /**
  5901. * Retreives the point at the distance aways from the starting point
  5902. * @param normalizedLengthPosition the length along the path to retreive the point from
  5903. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5904. */
  5905. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5906. /**
  5907. * Creates a new path starting from an x and y position
  5908. * @param x starting x value
  5909. * @param y starting y value
  5910. * @returns a new Path2 starting at the coordinates (x, y).
  5911. */
  5912. static StartingAt(x: number, y: number): Path2;
  5913. }
  5914. /**
  5915. * Represents a 3D path made up of multiple 3D points
  5916. */
  5917. export class Path3D {
  5918. /**
  5919. * an array of Vector3, the curve axis of the Path3D
  5920. */
  5921. path: Vector3[];
  5922. private _curve;
  5923. private _distances;
  5924. private _tangents;
  5925. private _normals;
  5926. private _binormals;
  5927. private _raw;
  5928. /**
  5929. * new Path3D(path, normal, raw)
  5930. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5931. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5932. * @param path an array of Vector3, the curve axis of the Path3D
  5933. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5934. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5935. */
  5936. constructor(
  5937. /**
  5938. * an array of Vector3, the curve axis of the Path3D
  5939. */
  5940. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5941. /**
  5942. * Returns the Path3D array of successive Vector3 designing its curve.
  5943. * @returns the Path3D array of successive Vector3 designing its curve.
  5944. */
  5945. getCurve(): Vector3[];
  5946. /**
  5947. * Returns an array populated with tangent vectors on each Path3D curve point.
  5948. * @returns an array populated with tangent vectors on each Path3D curve point.
  5949. */
  5950. getTangents(): Vector3[];
  5951. /**
  5952. * Returns an array populated with normal vectors on each Path3D curve point.
  5953. * @returns an array populated with normal vectors on each Path3D curve point.
  5954. */
  5955. getNormals(): Vector3[];
  5956. /**
  5957. * Returns an array populated with binormal vectors on each Path3D curve point.
  5958. * @returns an array populated with binormal vectors on each Path3D curve point.
  5959. */
  5960. getBinormals(): Vector3[];
  5961. /**
  5962. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5963. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5964. */
  5965. getDistances(): number[];
  5966. /**
  5967. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5968. * @param path path which all values are copied into the curves points
  5969. * @param firstNormal which should be projected onto the curve
  5970. * @returns the same object updated.
  5971. */
  5972. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5973. private _compute;
  5974. private _getFirstNonNullVector;
  5975. private _getLastNonNullVector;
  5976. private _normalVector;
  5977. }
  5978. /**
  5979. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5980. * A Curve3 is designed from a series of successive Vector3.
  5981. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5982. */
  5983. export class Curve3 {
  5984. private _points;
  5985. private _length;
  5986. /**
  5987. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5988. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5989. * @param v1 (Vector3) the control point
  5990. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5991. * @param nbPoints (integer) the wanted number of points in the curve
  5992. * @returns the created Curve3
  5993. */
  5994. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5995. /**
  5996. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5997. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5998. * @param v1 (Vector3) the first control point
  5999. * @param v2 (Vector3) the second control point
  6000. * @param v3 (Vector3) the end point of the Cubic Bezier
  6001. * @param nbPoints (integer) the wanted number of points in the curve
  6002. * @returns the created Curve3
  6003. */
  6004. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6005. /**
  6006. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6007. * @param p1 (Vector3) the origin point of the Hermite Spline
  6008. * @param t1 (Vector3) the tangent vector at the origin point
  6009. * @param p2 (Vector3) the end point of the Hermite Spline
  6010. * @param t2 (Vector3) the tangent vector at the end point
  6011. * @param nbPoints (integer) the wanted number of points in the curve
  6012. * @returns the created Curve3
  6013. */
  6014. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6015. /**
  6016. * Returns a Curve3 object along a CatmullRom Spline curve :
  6017. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6018. * @param nbPoints (integer) the wanted number of points between each curve control points
  6019. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6020. * @returns the created Curve3
  6021. */
  6022. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6023. /**
  6024. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6025. * A Curve3 is designed from a series of successive Vector3.
  6026. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6027. * @param points points which make up the curve
  6028. */
  6029. constructor(points: Vector3[]);
  6030. /**
  6031. * @returns the Curve3 stored array of successive Vector3
  6032. */
  6033. getPoints(): Vector3[];
  6034. /**
  6035. * @returns the computed length (float) of the curve.
  6036. */
  6037. length(): number;
  6038. /**
  6039. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6040. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6041. * curveA and curveB keep unchanged.
  6042. * @param curve the curve to continue from this curve
  6043. * @returns the newly constructed curve
  6044. */
  6045. continue(curve: DeepImmutable<Curve3>): Curve3;
  6046. private _computeLength;
  6047. }
  6048. }
  6049. declare module BABYLON {
  6050. /**
  6051. * This represents the main contract an easing function should follow.
  6052. * Easing functions are used throughout the animation system.
  6053. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6054. */
  6055. export interface IEasingFunction {
  6056. /**
  6057. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6058. * of the easing function.
  6059. * The link below provides some of the most common examples of easing functions.
  6060. * @see https://easings.net/
  6061. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6062. * @returns the corresponding value on the curve defined by the easing function
  6063. */
  6064. ease(gradient: number): number;
  6065. }
  6066. /**
  6067. * Base class used for every default easing function.
  6068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6069. */
  6070. export class EasingFunction implements IEasingFunction {
  6071. /**
  6072. * Interpolation follows the mathematical formula associated with the easing function.
  6073. */
  6074. static readonly EASINGMODE_EASEIN: number;
  6075. /**
  6076. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6077. */
  6078. static readonly EASINGMODE_EASEOUT: number;
  6079. /**
  6080. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6081. */
  6082. static readonly EASINGMODE_EASEINOUT: number;
  6083. private _easingMode;
  6084. /**
  6085. * Sets the easing mode of the current function.
  6086. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6087. */
  6088. setEasingMode(easingMode: number): void;
  6089. /**
  6090. * Gets the current easing mode.
  6091. * @returns the easing mode
  6092. */
  6093. getEasingMode(): number;
  6094. /**
  6095. * @hidden
  6096. */
  6097. easeInCore(gradient: number): number;
  6098. /**
  6099. * Given an input gradient between 0 and 1, this returns the corresponding value
  6100. * of the easing function.
  6101. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6102. * @returns the corresponding value on the curve defined by the easing function
  6103. */
  6104. ease(gradient: number): number;
  6105. }
  6106. /**
  6107. * Easing function with a circle shape (see link below).
  6108. * @see https://easings.net/#easeInCirc
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class CircleEase extends EasingFunction implements IEasingFunction {
  6112. /** @hidden */
  6113. easeInCore(gradient: number): number;
  6114. }
  6115. /**
  6116. * Easing function with a ease back shape (see link below).
  6117. * @see https://easings.net/#easeInBack
  6118. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6119. */
  6120. export class BackEase extends EasingFunction implements IEasingFunction {
  6121. /** Defines the amplitude of the function */
  6122. amplitude: number;
  6123. /**
  6124. * Instantiates a back ease easing
  6125. * @see https://easings.net/#easeInBack
  6126. * @param amplitude Defines the amplitude of the function
  6127. */
  6128. constructor(
  6129. /** Defines the amplitude of the function */
  6130. amplitude?: number);
  6131. /** @hidden */
  6132. easeInCore(gradient: number): number;
  6133. }
  6134. /**
  6135. * Easing function with a bouncing shape (see link below).
  6136. * @see https://easings.net/#easeInBounce
  6137. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6138. */
  6139. export class BounceEase extends EasingFunction implements IEasingFunction {
  6140. /** Defines the number of bounces */
  6141. bounces: number;
  6142. /** Defines the amplitude of the bounce */
  6143. bounciness: number;
  6144. /**
  6145. * Instantiates a bounce easing
  6146. * @see https://easings.net/#easeInBounce
  6147. * @param bounces Defines the number of bounces
  6148. * @param bounciness Defines the amplitude of the bounce
  6149. */
  6150. constructor(
  6151. /** Defines the number of bounces */
  6152. bounces?: number,
  6153. /** Defines the amplitude of the bounce */
  6154. bounciness?: number);
  6155. /** @hidden */
  6156. easeInCore(gradient: number): number;
  6157. }
  6158. /**
  6159. * Easing function with a power of 3 shape (see link below).
  6160. * @see https://easings.net/#easeInCubic
  6161. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6162. */
  6163. export class CubicEase extends EasingFunction implements IEasingFunction {
  6164. /** @hidden */
  6165. easeInCore(gradient: number): number;
  6166. }
  6167. /**
  6168. * Easing function with an elastic shape (see link below).
  6169. * @see https://easings.net/#easeInElastic
  6170. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6171. */
  6172. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6173. /** Defines the number of oscillations*/
  6174. oscillations: number;
  6175. /** Defines the amplitude of the oscillations*/
  6176. springiness: number;
  6177. /**
  6178. * Instantiates an elastic easing function
  6179. * @see https://easings.net/#easeInElastic
  6180. * @param oscillations Defines the number of oscillations
  6181. * @param springiness Defines the amplitude of the oscillations
  6182. */
  6183. constructor(
  6184. /** Defines the number of oscillations*/
  6185. oscillations?: number,
  6186. /** Defines the amplitude of the oscillations*/
  6187. springiness?: number);
  6188. /** @hidden */
  6189. easeInCore(gradient: number): number;
  6190. }
  6191. /**
  6192. * Easing function with an exponential shape (see link below).
  6193. * @see https://easings.net/#easeInExpo
  6194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6195. */
  6196. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6197. /** Defines the exponent of the function */
  6198. exponent: number;
  6199. /**
  6200. * Instantiates an exponential easing function
  6201. * @see https://easings.net/#easeInExpo
  6202. * @param exponent Defines the exponent of the function
  6203. */
  6204. constructor(
  6205. /** Defines the exponent of the function */
  6206. exponent?: number);
  6207. /** @hidden */
  6208. easeInCore(gradient: number): number;
  6209. }
  6210. /**
  6211. * Easing function with a power shape (see link below).
  6212. * @see https://easings.net/#easeInQuad
  6213. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6214. */
  6215. export class PowerEase extends EasingFunction implements IEasingFunction {
  6216. /** Defines the power of the function */
  6217. power: number;
  6218. /**
  6219. * Instantiates an power base easing function
  6220. * @see https://easings.net/#easeInQuad
  6221. * @param power Defines the power of the function
  6222. */
  6223. constructor(
  6224. /** Defines the power of the function */
  6225. power?: number);
  6226. /** @hidden */
  6227. easeInCore(gradient: number): number;
  6228. }
  6229. /**
  6230. * Easing function with a power of 2 shape (see link below).
  6231. * @see https://easings.net/#easeInQuad
  6232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6233. */
  6234. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6235. /** @hidden */
  6236. easeInCore(gradient: number): number;
  6237. }
  6238. /**
  6239. * Easing function with a power of 4 shape (see link below).
  6240. * @see https://easings.net/#easeInQuart
  6241. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6242. */
  6243. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6244. /** @hidden */
  6245. easeInCore(gradient: number): number;
  6246. }
  6247. /**
  6248. * Easing function with a power of 5 shape (see link below).
  6249. * @see https://easings.net/#easeInQuint
  6250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6251. */
  6252. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6253. /** @hidden */
  6254. easeInCore(gradient: number): number;
  6255. }
  6256. /**
  6257. * Easing function with a sin shape (see link below).
  6258. * @see https://easings.net/#easeInSine
  6259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6260. */
  6261. export class SineEase extends EasingFunction implements IEasingFunction {
  6262. /** @hidden */
  6263. easeInCore(gradient: number): number;
  6264. }
  6265. /**
  6266. * Easing function with a bezier shape (see link below).
  6267. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6269. */
  6270. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6271. /** Defines the x component of the start tangent in the bezier curve */
  6272. x1: number;
  6273. /** Defines the y component of the start tangent in the bezier curve */
  6274. y1: number;
  6275. /** Defines the x component of the end tangent in the bezier curve */
  6276. x2: number;
  6277. /** Defines the y component of the end tangent in the bezier curve */
  6278. y2: number;
  6279. /**
  6280. * Instantiates a bezier function
  6281. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6282. * @param x1 Defines the x component of the start tangent in the bezier curve
  6283. * @param y1 Defines the y component of the start tangent in the bezier curve
  6284. * @param x2 Defines the x component of the end tangent in the bezier curve
  6285. * @param y2 Defines the y component of the end tangent in the bezier curve
  6286. */
  6287. constructor(
  6288. /** Defines the x component of the start tangent in the bezier curve */
  6289. x1?: number,
  6290. /** Defines the y component of the start tangent in the bezier curve */
  6291. y1?: number,
  6292. /** Defines the x component of the end tangent in the bezier curve */
  6293. x2?: number,
  6294. /** Defines the y component of the end tangent in the bezier curve */
  6295. y2?: number);
  6296. /** @hidden */
  6297. easeInCore(gradient: number): number;
  6298. }
  6299. }
  6300. declare module BABYLON {
  6301. /**
  6302. * Defines an interface which represents an animation key frame
  6303. */
  6304. export interface IAnimationKey {
  6305. /**
  6306. * Frame of the key frame
  6307. */
  6308. frame: number;
  6309. /**
  6310. * Value at the specifies key frame
  6311. */
  6312. value: any;
  6313. /**
  6314. * The input tangent for the cubic hermite spline
  6315. */
  6316. inTangent?: any;
  6317. /**
  6318. * The output tangent for the cubic hermite spline
  6319. */
  6320. outTangent?: any;
  6321. /**
  6322. * The animation interpolation type
  6323. */
  6324. interpolation?: AnimationKeyInterpolation;
  6325. }
  6326. /**
  6327. * Enum for the animation key frame interpolation type
  6328. */
  6329. export enum AnimationKeyInterpolation {
  6330. /**
  6331. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6332. */
  6333. STEP = 1
  6334. }
  6335. }
  6336. declare module BABYLON {
  6337. /**
  6338. * Represents the range of an animation
  6339. */
  6340. export class AnimationRange {
  6341. /**The name of the animation range**/
  6342. name: string;
  6343. /**The starting frame of the animation */
  6344. from: number;
  6345. /**The ending frame of the animation*/
  6346. to: number;
  6347. /**
  6348. * Initializes the range of an animation
  6349. * @param name The name of the animation range
  6350. * @param from The starting frame of the animation
  6351. * @param to The ending frame of the animation
  6352. */
  6353. constructor(
  6354. /**The name of the animation range**/
  6355. name: string,
  6356. /**The starting frame of the animation */
  6357. from: number,
  6358. /**The ending frame of the animation*/
  6359. to: number);
  6360. /**
  6361. * Makes a copy of the animation range
  6362. * @returns A copy of the animation range
  6363. */
  6364. clone(): AnimationRange;
  6365. }
  6366. }
  6367. declare module BABYLON {
  6368. /**
  6369. * Composed of a frame, and an action function
  6370. */
  6371. export class AnimationEvent {
  6372. /** The frame for which the event is triggered **/
  6373. frame: number;
  6374. /** The event to perform when triggered **/
  6375. action: (currentFrame: number) => void;
  6376. /** Specifies if the event should be triggered only once**/
  6377. onlyOnce?: boolean | undefined;
  6378. /**
  6379. * Specifies if the animation event is done
  6380. */
  6381. isDone: boolean;
  6382. /**
  6383. * Initializes the animation event
  6384. * @param frame The frame for which the event is triggered
  6385. * @param action The event to perform when triggered
  6386. * @param onlyOnce Specifies if the event should be triggered only once
  6387. */
  6388. constructor(
  6389. /** The frame for which the event is triggered **/
  6390. frame: number,
  6391. /** The event to perform when triggered **/
  6392. action: (currentFrame: number) => void,
  6393. /** Specifies if the event should be triggered only once**/
  6394. onlyOnce?: boolean | undefined);
  6395. /** @hidden */ private _clone(): AnimationEvent;
  6396. }
  6397. }
  6398. declare module BABYLON {
  6399. /**
  6400. * Interface used to define a behavior
  6401. */
  6402. export interface Behavior<T> {
  6403. /** gets or sets behavior's name */
  6404. name: string;
  6405. /**
  6406. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6407. */
  6408. init(): void;
  6409. /**
  6410. * Called when the behavior is attached to a target
  6411. * @param target defines the target where the behavior is attached to
  6412. */
  6413. attach(target: T): void;
  6414. /**
  6415. * Called when the behavior is detached from its target
  6416. */
  6417. detach(): void;
  6418. }
  6419. /**
  6420. * Interface implemented by classes supporting behaviors
  6421. */
  6422. export interface IBehaviorAware<T> {
  6423. /**
  6424. * Attach a behavior
  6425. * @param behavior defines the behavior to attach
  6426. * @returns the current host
  6427. */
  6428. addBehavior(behavior: Behavior<T>): T;
  6429. /**
  6430. * Remove a behavior from the current object
  6431. * @param behavior defines the behavior to detach
  6432. * @returns the current host
  6433. */
  6434. removeBehavior(behavior: Behavior<T>): T;
  6435. /**
  6436. * Gets a behavior using its name to search
  6437. * @param name defines the name to search
  6438. * @returns the behavior or null if not found
  6439. */
  6440. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6441. }
  6442. }
  6443. declare module BABYLON {
  6444. /**
  6445. * Defines an array and its length.
  6446. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6447. */
  6448. export interface ISmartArrayLike<T> {
  6449. /**
  6450. * The data of the array.
  6451. */
  6452. data: Array<T>;
  6453. /**
  6454. * The active length of the array.
  6455. */
  6456. length: number;
  6457. }
  6458. /**
  6459. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6460. */
  6461. export class SmartArray<T> implements ISmartArrayLike<T> {
  6462. /**
  6463. * The full set of data from the array.
  6464. */
  6465. data: Array<T>;
  6466. /**
  6467. * The active length of the array.
  6468. */
  6469. length: number;
  6470. protected _id: number;
  6471. /**
  6472. * Instantiates a Smart Array.
  6473. * @param capacity defines the default capacity of the array.
  6474. */
  6475. constructor(capacity: number);
  6476. /**
  6477. * Pushes a value at the end of the active data.
  6478. * @param value defines the object to push in the array.
  6479. */
  6480. push(value: T): void;
  6481. /**
  6482. * Iterates over the active data and apply the lambda to them.
  6483. * @param func defines the action to apply on each value.
  6484. */
  6485. forEach(func: (content: T) => void): void;
  6486. /**
  6487. * Sorts the full sets of data.
  6488. * @param compareFn defines the comparison function to apply.
  6489. */
  6490. sort(compareFn: (a: T, b: T) => number): void;
  6491. /**
  6492. * Resets the active data to an empty array.
  6493. */
  6494. reset(): void;
  6495. /**
  6496. * Releases all the data from the array as well as the array.
  6497. */
  6498. dispose(): void;
  6499. /**
  6500. * Concats the active data with a given array.
  6501. * @param array defines the data to concatenate with.
  6502. */
  6503. concat(array: any): void;
  6504. /**
  6505. * Returns the position of a value in the active data.
  6506. * @param value defines the value to find the index for
  6507. * @returns the index if found in the active data otherwise -1
  6508. */
  6509. indexOf(value: T): number;
  6510. /**
  6511. * Returns whether an element is part of the active data.
  6512. * @param value defines the value to look for
  6513. * @returns true if found in the active data otherwise false
  6514. */
  6515. contains(value: T): boolean;
  6516. private static _GlobalId;
  6517. }
  6518. /**
  6519. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6520. * The data in this array can only be present once
  6521. */
  6522. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6523. private _duplicateId;
  6524. /**
  6525. * Pushes a value at the end of the active data.
  6526. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6527. * @param value defines the object to push in the array.
  6528. */
  6529. push(value: T): void;
  6530. /**
  6531. * Pushes a value at the end of the active data.
  6532. * If the data is already present, it won t be added again
  6533. * @param value defines the object to push in the array.
  6534. * @returns true if added false if it was already present
  6535. */
  6536. pushNoDuplicate(value: T): boolean;
  6537. /**
  6538. * Resets the active data to an empty array.
  6539. */
  6540. reset(): void;
  6541. /**
  6542. * Concats the active data with a given array.
  6543. * This ensures no dupplicate will be present in the result.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concatWithNoDuplicate(array: any): void;
  6547. }
  6548. }
  6549. declare module BABYLON {
  6550. /**
  6551. * @ignore
  6552. * This is a list of all the different input types that are available in the application.
  6553. * Fo instance: ArcRotateCameraGamepadInput...
  6554. */
  6555. export var CameraInputTypes: {};
  6556. /**
  6557. * This is the contract to implement in order to create a new input class.
  6558. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6559. */
  6560. export interface ICameraInput<TCamera extends Camera> {
  6561. /**
  6562. * Defines the camera the input is attached to.
  6563. */
  6564. camera: Nullable<TCamera>;
  6565. /**
  6566. * Gets the class name of the current intput.
  6567. * @returns the class name
  6568. */
  6569. getClassName(): string;
  6570. /**
  6571. * Get the friendly name associated with the input class.
  6572. * @returns the input friendly name
  6573. */
  6574. getSimpleName(): string;
  6575. /**
  6576. * Attach the input controls to a specific dom element to get the input from.
  6577. * @param element Defines the element the controls should be listened from
  6578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6579. */
  6580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6581. /**
  6582. * Detach the current controls from the specified dom element.
  6583. * @param element Defines the element to stop listening the inputs from
  6584. */
  6585. detachControl(element: Nullable<HTMLElement>): void;
  6586. /**
  6587. * Update the current camera state depending on the inputs that have been used this frame.
  6588. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6589. */
  6590. checkInputs?: () => void;
  6591. }
  6592. /**
  6593. * Represents a map of input types to input instance or input index to input instance.
  6594. */
  6595. export interface CameraInputsMap<TCamera extends Camera> {
  6596. /**
  6597. * Accessor to the input by input type.
  6598. */
  6599. [name: string]: ICameraInput<TCamera>;
  6600. /**
  6601. * Accessor to the input by input index.
  6602. */
  6603. [idx: number]: ICameraInput<TCamera>;
  6604. }
  6605. /**
  6606. * This represents the input manager used within a camera.
  6607. * It helps dealing with all the different kind of input attached to a camera.
  6608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6609. */
  6610. export class CameraInputsManager<TCamera extends Camera> {
  6611. /**
  6612. * Defines the list of inputs attahed to the camera.
  6613. */
  6614. attached: CameraInputsMap<TCamera>;
  6615. /**
  6616. * Defines the dom element the camera is collecting inputs from.
  6617. * This is null if the controls have not been attached.
  6618. */
  6619. attachedElement: Nullable<HTMLElement>;
  6620. /**
  6621. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6622. */
  6623. noPreventDefault: boolean;
  6624. /**
  6625. * Defined the camera the input manager belongs to.
  6626. */
  6627. camera: TCamera;
  6628. /**
  6629. * Update the current camera state depending on the inputs that have been used this frame.
  6630. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6631. */
  6632. checkInputs: () => void;
  6633. /**
  6634. * Instantiate a new Camera Input Manager.
  6635. * @param camera Defines the camera the input manager blongs to
  6636. */
  6637. constructor(camera: TCamera);
  6638. /**
  6639. * Add an input method to a camera
  6640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6641. * @param input camera input method
  6642. */
  6643. add(input: ICameraInput<TCamera>): void;
  6644. /**
  6645. * Remove a specific input method from a camera
  6646. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6647. * @param inputToRemove camera input method
  6648. */
  6649. remove(inputToRemove: ICameraInput<TCamera>): void;
  6650. /**
  6651. * Remove a specific input type from a camera
  6652. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6653. * @param inputType the type of the input to remove
  6654. */
  6655. removeByType(inputType: string): void;
  6656. private _addCheckInputs;
  6657. /**
  6658. * Attach the input controls to the currently attached dom element to listen the events from.
  6659. * @param input Defines the input to attach
  6660. */
  6661. attachInput(input: ICameraInput<TCamera>): void;
  6662. /**
  6663. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6664. * @param element Defines the dom element to collect the events from
  6665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6666. */
  6667. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6668. /**
  6669. * Detach the current manager inputs controls from a specific dom element.
  6670. * @param element Defines the dom element to collect the events from
  6671. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6672. */
  6673. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6674. /**
  6675. * Rebuild the dynamic inputCheck function from the current list of
  6676. * defined inputs in the manager.
  6677. */
  6678. rebuildInputCheck(): void;
  6679. /**
  6680. * Remove all attached input methods from a camera
  6681. */
  6682. clear(): void;
  6683. /**
  6684. * Serialize the current input manager attached to a camera.
  6685. * This ensures than once parsed,
  6686. * the input associated to the camera will be identical to the current ones
  6687. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6688. */
  6689. serialize(serializedCamera: any): void;
  6690. /**
  6691. * Parses an input manager serialized JSON to restore the previous list of inputs
  6692. * and states associated to a camera.
  6693. * @param parsedCamera Defines the JSON to parse
  6694. */
  6695. parse(parsedCamera: any): void;
  6696. }
  6697. }
  6698. declare module BABYLON {
  6699. /**
  6700. * @hidden
  6701. */
  6702. export class IntersectionInfo {
  6703. bu: Nullable<number>;
  6704. bv: Nullable<number>;
  6705. distance: number;
  6706. faceId: number;
  6707. subMeshId: number;
  6708. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6709. }
  6710. }
  6711. declare module BABYLON {
  6712. /**
  6713. * Represens a plane by the equation ax + by + cz + d = 0
  6714. */
  6715. export class Plane {
  6716. private static _TmpMatrix;
  6717. /**
  6718. * Normal of the plane (a,b,c)
  6719. */
  6720. normal: Vector3;
  6721. /**
  6722. * d component of the plane
  6723. */
  6724. d: number;
  6725. /**
  6726. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6727. * @param a a component of the plane
  6728. * @param b b component of the plane
  6729. * @param c c component of the plane
  6730. * @param d d component of the plane
  6731. */
  6732. constructor(a: number, b: number, c: number, d: number);
  6733. /**
  6734. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6735. */
  6736. asArray(): number[];
  6737. /**
  6738. * @returns a new plane copied from the current Plane.
  6739. */
  6740. clone(): Plane;
  6741. /**
  6742. * @returns the string "Plane".
  6743. */
  6744. getClassName(): string;
  6745. /**
  6746. * @returns the Plane hash code.
  6747. */
  6748. getHashCode(): number;
  6749. /**
  6750. * Normalize the current Plane in place.
  6751. * @returns the updated Plane.
  6752. */
  6753. normalize(): Plane;
  6754. /**
  6755. * Applies a transformation the plane and returns the result
  6756. * @param transformation the transformation matrix to be applied to the plane
  6757. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6758. */
  6759. transform(transformation: DeepImmutable<Matrix>): Plane;
  6760. /**
  6761. * Calcualtte the dot product between the point and the plane normal
  6762. * @param point point to calculate the dot product with
  6763. * @returns the dot product (float) of the point coordinates and the plane normal.
  6764. */
  6765. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6766. /**
  6767. * Updates the current Plane from the plane defined by the three given points.
  6768. * @param point1 one of the points used to contruct the plane
  6769. * @param point2 one of the points used to contruct the plane
  6770. * @param point3 one of the points used to contruct the plane
  6771. * @returns the updated Plane.
  6772. */
  6773. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6774. /**
  6775. * Checks if the plane is facing a given direction
  6776. * @param direction the direction to check if the plane is facing
  6777. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6778. * @returns True is the vector "direction" is the same side than the plane normal.
  6779. */
  6780. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6781. /**
  6782. * Calculates the distance to a point
  6783. * @param point point to calculate distance to
  6784. * @returns the signed distance (float) from the given point to the Plane.
  6785. */
  6786. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6787. /**
  6788. * Creates a plane from an array
  6789. * @param array the array to create a plane from
  6790. * @returns a new Plane from the given array.
  6791. */
  6792. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6793. /**
  6794. * Creates a plane from three points
  6795. * @param point1 point used to create the plane
  6796. * @param point2 point used to create the plane
  6797. * @param point3 point used to create the plane
  6798. * @returns a new Plane defined by the three given points.
  6799. */
  6800. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6801. /**
  6802. * Creates a plane from an origin point and a normal
  6803. * @param origin origin of the plane to be constructed
  6804. * @param normal normal of the plane to be constructed
  6805. * @returns a new Plane the normal vector to this plane at the given origin point.
  6806. * Note : the vector "normal" is updated because normalized.
  6807. */
  6808. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6809. /**
  6810. * Calculates the distance from a plane and a point
  6811. * @param origin origin of the plane to be constructed
  6812. * @param normal normal of the plane to be constructed
  6813. * @param point point to calculate distance to
  6814. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6815. */
  6816. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6817. }
  6818. }
  6819. declare module BABYLON {
  6820. /**
  6821. * Class used to store bounding sphere information
  6822. */
  6823. export class BoundingSphere {
  6824. /**
  6825. * Gets the center of the bounding sphere in local space
  6826. */
  6827. readonly center: Vector3;
  6828. /**
  6829. * Radius of the bounding sphere in local space
  6830. */
  6831. radius: number;
  6832. /**
  6833. * Gets the center of the bounding sphere in world space
  6834. */
  6835. readonly centerWorld: Vector3;
  6836. /**
  6837. * Radius of the bounding sphere in world space
  6838. */
  6839. radiusWorld: number;
  6840. /**
  6841. * Gets the minimum vector in local space
  6842. */
  6843. readonly minimum: Vector3;
  6844. /**
  6845. * Gets the maximum vector in local space
  6846. */
  6847. readonly maximum: Vector3;
  6848. private _worldMatrix;
  6849. private static readonly TmpVector3;
  6850. /**
  6851. * Creates a new bounding sphere
  6852. * @param min defines the minimum vector (in local space)
  6853. * @param max defines the maximum vector (in local space)
  6854. * @param worldMatrix defines the new world matrix
  6855. */
  6856. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6857. /**
  6858. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6859. * @param min defines the new minimum vector (in local space)
  6860. * @param max defines the new maximum vector (in local space)
  6861. * @param worldMatrix defines the new world matrix
  6862. */
  6863. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6864. /**
  6865. * Scale the current bounding sphere by applying a scale factor
  6866. * @param factor defines the scale factor to apply
  6867. * @returns the current bounding box
  6868. */
  6869. scale(factor: number): BoundingSphere;
  6870. /**
  6871. * Gets the world matrix of the bounding box
  6872. * @returns a matrix
  6873. */
  6874. getWorldMatrix(): DeepImmutable<Matrix>;
  6875. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6876. /**
  6877. * Tests if the bounding sphere is intersecting the frustum planes
  6878. * @param frustumPlanes defines the frustum planes to test
  6879. * @returns true if there is an intersection
  6880. */
  6881. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6882. /**
  6883. * Tests if the bounding sphere center is in between the frustum planes.
  6884. * Used for optimistic fast inclusion.
  6885. * @param frustumPlanes defines the frustum planes to test
  6886. * @returns true if the sphere center is in between the frustum planes
  6887. */
  6888. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6889. /**
  6890. * Tests if a point is inside the bounding sphere
  6891. * @param point defines the point to test
  6892. * @returns true if the point is inside the bounding sphere
  6893. */
  6894. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6895. /**
  6896. * Checks if two sphere intersct
  6897. * @param sphere0 sphere 0
  6898. * @param sphere1 sphere 1
  6899. * @returns true if the speres intersect
  6900. */
  6901. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6902. }
  6903. }
  6904. declare module BABYLON {
  6905. /**
  6906. * Class used to store bounding box information
  6907. */
  6908. export class BoundingBox implements ICullable {
  6909. /**
  6910. * Gets the 8 vectors representing the bounding box in local space
  6911. */
  6912. readonly vectors: Vector3[];
  6913. /**
  6914. * Gets the center of the bounding box in local space
  6915. */
  6916. readonly center: Vector3;
  6917. /**
  6918. * Gets the center of the bounding box in world space
  6919. */
  6920. readonly centerWorld: Vector3;
  6921. /**
  6922. * Gets the extend size in local space
  6923. */
  6924. readonly extendSize: Vector3;
  6925. /**
  6926. * Gets the extend size in world space
  6927. */
  6928. readonly extendSizeWorld: Vector3;
  6929. /**
  6930. * Gets the OBB (object bounding box) directions
  6931. */
  6932. readonly directions: Vector3[];
  6933. /**
  6934. * Gets the 8 vectors representing the bounding box in world space
  6935. */
  6936. readonly vectorsWorld: Vector3[];
  6937. /**
  6938. * Gets the minimum vector in world space
  6939. */
  6940. readonly minimumWorld: Vector3;
  6941. /**
  6942. * Gets the maximum vector in world space
  6943. */
  6944. readonly maximumWorld: Vector3;
  6945. /**
  6946. * Gets the minimum vector in local space
  6947. */
  6948. readonly minimum: Vector3;
  6949. /**
  6950. * Gets the maximum vector in local space
  6951. */
  6952. readonly maximum: Vector3;
  6953. private _worldMatrix;
  6954. private static readonly TmpVector3;
  6955. /**
  6956. * @hidden
  6957. */ private _tag: number;
  6958. /**
  6959. * Creates a new bounding box
  6960. * @param min defines the minimum vector (in local space)
  6961. * @param max defines the maximum vector (in local space)
  6962. * @param worldMatrix defines the new world matrix
  6963. */
  6964. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6965. /**
  6966. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6967. * @param min defines the new minimum vector (in local space)
  6968. * @param max defines the new maximum vector (in local space)
  6969. * @param worldMatrix defines the new world matrix
  6970. */
  6971. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6972. /**
  6973. * Scale the current bounding box by applying a scale factor
  6974. * @param factor defines the scale factor to apply
  6975. * @returns the current bounding box
  6976. */
  6977. scale(factor: number): BoundingBox;
  6978. /**
  6979. * Gets the world matrix of the bounding box
  6980. * @returns a matrix
  6981. */
  6982. getWorldMatrix(): DeepImmutable<Matrix>;
  6983. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6984. /**
  6985. * Tests if the bounding box is intersecting the frustum planes
  6986. * @param frustumPlanes defines the frustum planes to test
  6987. * @returns true if there is an intersection
  6988. */
  6989. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6990. /**
  6991. * Tests if the bounding box is entirely inside the frustum planes
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @returns true if there is an inclusion
  6994. */
  6995. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if a point is inside the bounding box
  6998. * @param point defines the point to test
  6999. * @returns true if the point is inside the bounding box
  7000. */
  7001. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7002. /**
  7003. * Tests if the bounding box intersects with a bounding sphere
  7004. * @param sphere defines the sphere to test
  7005. * @returns true if there is an intersection
  7006. */
  7007. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7008. /**
  7009. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7010. * @param min defines the min vector to use
  7011. * @param max defines the max vector to use
  7012. * @returns true if there is an intersection
  7013. */
  7014. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7015. /**
  7016. * Tests if two bounding boxes are intersections
  7017. * @param box0 defines the first box to test
  7018. * @param box1 defines the second box to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7022. /**
  7023. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7024. * @param minPoint defines the minimum vector of the bounding box
  7025. * @param maxPoint defines the maximum vector of the bounding box
  7026. * @param sphereCenter defines the sphere center
  7027. * @param sphereRadius defines the sphere radius
  7028. * @returns true if there is an intersection
  7029. */
  7030. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7031. /**
  7032. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7033. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7034. * @param frustumPlanes defines the frustum planes to test
  7035. * @return true if there is an inclusion
  7036. */
  7037. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7038. /**
  7039. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7040. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7041. * @param frustumPlanes defines the frustum planes to test
  7042. * @return true if there is an intersection
  7043. */
  7044. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7045. }
  7046. }
  7047. declare module BABYLON {
  7048. /** @hidden */
  7049. export class Collider {
  7050. /** Define if a collision was found */
  7051. collisionFound: boolean;
  7052. /**
  7053. * Define last intersection point in local space
  7054. */
  7055. intersectionPoint: Vector3;
  7056. /**
  7057. * Define last collided mesh
  7058. */
  7059. collidedMesh: Nullable<AbstractMesh>;
  7060. private _collisionPoint;
  7061. private _planeIntersectionPoint;
  7062. private _tempVector;
  7063. private _tempVector2;
  7064. private _tempVector3;
  7065. private _tempVector4;
  7066. private _edge;
  7067. private _baseToVertex;
  7068. private _destinationPoint;
  7069. private _slidePlaneNormal;
  7070. private _displacementVector;
  7071. /** @hidden */ private _radius: Vector3;
  7072. /** @hidden */ private _retry: number;
  7073. private _velocity;
  7074. private _basePoint;
  7075. private _epsilon;
  7076. /** @hidden */ private _velocityWorldLength: number;
  7077. /** @hidden */ private _basePointWorld: Vector3;
  7078. private _velocityWorld;
  7079. private _normalizedVelocity;
  7080. /** @hidden */ private _initialVelocity: Vector3;
  7081. /** @hidden */ private _initialPosition: Vector3;
  7082. private _nearestDistance;
  7083. private _collisionMask;
  7084. collisionMask: number;
  7085. /**
  7086. * Gets the plane normal used to compute the sliding response (in local space)
  7087. */
  7088. readonly slidePlaneNormal: Vector3;
  7089. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7090. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7091. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7092. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7093. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7094. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7095. }
  7096. }
  7097. declare module BABYLON {
  7098. /**
  7099. * Interface for cullable objects
  7100. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7101. */
  7102. export interface ICullable {
  7103. /**
  7104. * Checks if the object or part of the object is in the frustum
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isInFrustum(frustumPlanes: Plane[]): boolean;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7116. }
  7117. /**
  7118. * Info for a bounding data of a mesh
  7119. */
  7120. export class BoundingInfo implements ICullable {
  7121. /**
  7122. * Bounding box for the mesh
  7123. */
  7124. readonly boundingBox: BoundingBox;
  7125. /**
  7126. * Bounding sphere for the mesh
  7127. */
  7128. readonly boundingSphere: BoundingSphere;
  7129. private _isLocked;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Constructs bounding info
  7133. * @param minimum min vector of the bounding box/sphere
  7134. * @param maximum max vector of the bounding box/sphere
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * min vector of the bounding box/sphere
  7147. */
  7148. readonly minimum: Vector3;
  7149. /**
  7150. * max vector of the bounding box/sphere
  7151. */
  7152. readonly maximum: Vector3;
  7153. /**
  7154. * If the info is locked and won't be updated to avoid perf overhead
  7155. */
  7156. isLocked: boolean;
  7157. /**
  7158. * Updates the bounding sphere and box
  7159. * @param world world matrix to be used to update
  7160. */
  7161. update(world: DeepImmutable<Matrix>): void;
  7162. /**
  7163. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7164. * @param center New center of the bounding info
  7165. * @param extend New extend of the bounding info
  7166. * @returns the current bounding info
  7167. */
  7168. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7169. /**
  7170. * Scale the current bounding info by applying a scale factor
  7171. * @param factor defines the scale factor to apply
  7172. * @returns the current bounding info
  7173. */
  7174. scale(factor: number): BoundingInfo;
  7175. /**
  7176. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7177. * @param frustumPlanes defines the frustum to test
  7178. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7179. * @returns true if the bounding info is in the frustum planes
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7182. /**
  7183. * Gets the world distance between the min and max points of the bounding box
  7184. */
  7185. readonly diagonalLength: number;
  7186. /**
  7187. * Checks if a cullable object (mesh...) is in the camera frustum
  7188. * Unlike isInFrustum this cheks the full bounding box
  7189. * @param frustumPlanes Camera near/planes
  7190. * @returns true if the object is in frustum otherwise false
  7191. */
  7192. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7193. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7194. /**
  7195. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7196. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7197. * @param point the point to check intersection with
  7198. * @returns if the point intersects
  7199. */
  7200. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7201. /**
  7202. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7203. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7204. * @param boundingInfo the bounding info to check intersection with
  7205. * @param precise if the intersection should be done using OBB
  7206. * @returns if the bounding info intersects
  7207. */
  7208. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7209. }
  7210. }
  7211. declare module BABYLON {
  7212. /**
  7213. * Extracts minimum and maximum values from a list of indexed positions
  7214. * @param positions defines the positions to use
  7215. * @param indices defines the indices to the positions
  7216. * @param indexStart defines the start index
  7217. * @param indexCount defines the end index
  7218. * @param bias defines bias value to add to the result
  7219. * @return minimum and maximum values
  7220. */
  7221. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7222. minimum: Vector3;
  7223. maximum: Vector3;
  7224. };
  7225. /**
  7226. * Extracts minimum and maximum values from a list of positions
  7227. * @param positions defines the positions to use
  7228. * @param start defines the start index in the positions array
  7229. * @param count defines the number of positions to handle
  7230. * @param bias defines bias value to add to the result
  7231. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7232. * @return minimum and maximum values
  7233. */
  7234. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7235. minimum: Vector3;
  7236. maximum: Vector3;
  7237. };
  7238. }
  7239. declare module BABYLON {
  7240. /**
  7241. * Enum that determines the text-wrapping mode to use.
  7242. */
  7243. export enum InspectableType {
  7244. /**
  7245. * Checkbox for booleans
  7246. */
  7247. Checkbox = 0,
  7248. /**
  7249. * Sliders for numbers
  7250. */
  7251. Slider = 1,
  7252. /**
  7253. * Vector3
  7254. */
  7255. Vector3 = 2,
  7256. /**
  7257. * Quaternions
  7258. */
  7259. Quaternion = 3,
  7260. /**
  7261. * Color3
  7262. */
  7263. Color3 = 4,
  7264. /**
  7265. * String
  7266. */
  7267. String = 5
  7268. }
  7269. /**
  7270. * Interface used to define custom inspectable properties.
  7271. * This interface is used by the inspector to display custom property grids
  7272. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7273. */
  7274. export interface IInspectable {
  7275. /**
  7276. * Gets the label to display
  7277. */
  7278. label: string;
  7279. /**
  7280. * Gets the name of the property to edit
  7281. */
  7282. propertyName: string;
  7283. /**
  7284. * Gets the type of the editor to use
  7285. */
  7286. type: InspectableType;
  7287. /**
  7288. * Gets the minimum value of the property when using in "slider" mode
  7289. */
  7290. min?: number;
  7291. /**
  7292. * Gets the maximum value of the property when using in "slider" mode
  7293. */
  7294. max?: number;
  7295. /**
  7296. * Gets the setp to use when using in "slider" mode
  7297. */
  7298. step?: number;
  7299. }
  7300. }
  7301. declare module BABYLON {
  7302. /**
  7303. * Class used to provide helper for timing
  7304. */
  7305. export class TimingTools {
  7306. /**
  7307. * Polyfill for setImmediate
  7308. * @param action defines the action to execute after the current execution block
  7309. */
  7310. static SetImmediate(action: () => void): void;
  7311. }
  7312. }
  7313. declare module BABYLON {
  7314. /**
  7315. * Class used to enable instatition of objects by class name
  7316. */
  7317. export class InstantiationTools {
  7318. /**
  7319. * Use this object to register external classes like custom textures or material
  7320. * to allow the laoders to instantiate them
  7321. */
  7322. static RegisteredExternalClasses: {
  7323. [key: string]: Object;
  7324. };
  7325. /**
  7326. * Tries to instantiate a new object from a given class name
  7327. * @param className defines the class name to instantiate
  7328. * @returns the new object or null if the system was not able to do the instantiation
  7329. */
  7330. static Instantiate(className: string): any;
  7331. }
  7332. }
  7333. declare module BABYLON {
  7334. /**
  7335. * This represents the required contract to create a new type of texture loader.
  7336. */
  7337. export interface IInternalTextureLoader {
  7338. /**
  7339. * Defines wether the loader supports cascade loading the different faces.
  7340. */
  7341. supportCascades: boolean;
  7342. /**
  7343. * This returns if the loader support the current file information.
  7344. * @param extension defines the file extension of the file being loaded
  7345. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7346. * @param fallback defines the fallback internal texture if any
  7347. * @param isBase64 defines whether the texture is encoded as a base64
  7348. * @param isBuffer defines whether the texture data are stored as a buffer
  7349. * @returns true if the loader can load the specified file
  7350. */
  7351. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7352. /**
  7353. * Transform the url before loading if required.
  7354. * @param rootUrl the url of the texture
  7355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7356. * @returns the transformed texture
  7357. */
  7358. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7359. /**
  7360. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7361. * @param rootUrl the url of the texture
  7362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7363. * @returns the fallback texture
  7364. */
  7365. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7366. /**
  7367. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7368. * @param data contains the texture data
  7369. * @param texture defines the BabylonJS internal texture
  7370. * @param createPolynomials will be true if polynomials have been requested
  7371. * @param onLoad defines the callback to trigger once the texture is ready
  7372. * @param onError defines the callback to trigger in case of error
  7373. */
  7374. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7375. /**
  7376. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7377. * @param data contains the texture data
  7378. * @param texture defines the BabylonJS internal texture
  7379. * @param callback defines the method to call once ready to upload
  7380. */
  7381. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7382. }
  7383. }
  7384. declare module BABYLON {
  7385. interface Engine {
  7386. /**
  7387. * Creates a depth stencil cube texture.
  7388. * This is only available in WebGL 2.
  7389. * @param size The size of face edge in the cube texture.
  7390. * @param options The options defining the cube texture.
  7391. * @returns The cube texture
  7392. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7393. /**
  7394. * Creates a cube texture
  7395. * @param rootUrl defines the url where the files to load is located
  7396. * @param scene defines the current scene
  7397. * @param files defines the list of files to load (1 per face)
  7398. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7399. * @param onLoad defines an optional callback raised when the texture is loaded
  7400. * @param onError defines an optional callback raised if there is an issue to load the texture
  7401. * @param format defines the format of the data
  7402. * @param forcedExtension defines the extension to use to pick the right loader
  7403. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7404. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7405. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7406. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7407. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7408. * @returns the cube texture as an InternalTexture
  7409. */
  7410. 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;
  7411. /**
  7412. * Creates a cube texture
  7413. * @param rootUrl defines the url where the files to load is located
  7414. * @param scene defines the current scene
  7415. * @param files defines the list of files to load (1 per face)
  7416. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7417. * @param onLoad defines an optional callback raised when the texture is loaded
  7418. * @param onError defines an optional callback raised if there is an issue to load the texture
  7419. * @param format defines the format of the data
  7420. * @param forcedExtension defines the extension to use to pick the right loader
  7421. * @returns the cube texture as an InternalTexture
  7422. */
  7423. 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;
  7424. /**
  7425. * Creates a cube texture
  7426. * @param rootUrl defines the url where the files to load is located
  7427. * @param scene defines the current scene
  7428. * @param files defines the list of files to load (1 per face)
  7429. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7430. * @param onLoad defines an optional callback raised when the texture is loaded
  7431. * @param onError defines an optional callback raised if there is an issue to load the texture
  7432. * @param format defines the format of the data
  7433. * @param forcedExtension defines the extension to use to pick the right loader
  7434. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7435. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7436. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7437. * @returns the cube texture as an InternalTexture
  7438. */
  7439. 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;
  7440. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7441. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7442. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7443. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7444. }
  7445. }
  7446. declare module BABYLON {
  7447. /**
  7448. * Class for creating a cube texture
  7449. */
  7450. export class CubeTexture extends BaseTexture {
  7451. private _delayedOnLoad;
  7452. /**
  7453. * The url of the texture
  7454. */
  7455. url: string;
  7456. /**
  7457. * Gets or sets the center of the bounding box associated with the cube texture.
  7458. * It must define where the camera used to render the texture was set
  7459. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7460. */
  7461. boundingBoxPosition: Vector3;
  7462. private _boundingBoxSize;
  7463. /**
  7464. * Gets or sets the size of the bounding box associated with the cube texture
  7465. * When defined, the cubemap will switch to local mode
  7466. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7467. * @example https://www.babylonjs-playground.com/#RNASML
  7468. */
  7469. /**
  7470. * Returns the bounding box size
  7471. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7472. */
  7473. boundingBoxSize: Vector3;
  7474. protected _rotationY: number;
  7475. /**
  7476. * Sets texture matrix rotation angle around Y axis in radians.
  7477. */
  7478. /**
  7479. * Gets texture matrix rotation angle around Y axis radians.
  7480. */
  7481. rotationY: number;
  7482. /**
  7483. * Are mip maps generated for this texture or not.
  7484. */
  7485. readonly noMipmap: boolean;
  7486. private _noMipmap;
  7487. private _files;
  7488. private _extensions;
  7489. private _textureMatrix;
  7490. private _format;
  7491. private _createPolynomials;
  7492. /** @hidden */ private _prefiltered: boolean;
  7493. /**
  7494. * Creates a cube texture from an array of image urls
  7495. * @param files defines an array of image urls
  7496. * @param scene defines the hosting scene
  7497. * @param noMipmap specifies if mip maps are not used
  7498. * @returns a cube texture
  7499. */
  7500. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7501. /**
  7502. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7503. * @param url defines the url of the prefiltered texture
  7504. * @param scene defines the scene the texture is attached to
  7505. * @param forcedExtension defines the extension of the file if different from the url
  7506. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7507. * @return the prefiltered texture
  7508. */
  7509. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7510. /**
  7511. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7512. * as prefiltered data.
  7513. * @param rootUrl defines the url of the texture or the root name of the six images
  7514. * @param scene defines the scene the texture is attached to
  7515. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7516. * @param noMipmap defines if mipmaps should be created or not
  7517. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7518. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7519. * @param onError defines a callback triggered in case of error during load
  7520. * @param format defines the internal format to use for the texture once loaded
  7521. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7522. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7523. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7524. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7525. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7526. * @return the cube texture
  7527. */
  7528. 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);
  7529. /**
  7530. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7531. */
  7532. readonly isPrefiltered: boolean;
  7533. /**
  7534. * Get the current class name of the texture useful for serialization or dynamic coding.
  7535. * @returns "CubeTexture"
  7536. */
  7537. getClassName(): string;
  7538. /**
  7539. * Update the url (and optional buffer) of this texture if url was null during construction.
  7540. * @param url the url of the texture
  7541. * @param forcedExtension defines the extension to use
  7542. * @param onLoad callback called when the texture is loaded (defaults to null)
  7543. */
  7544. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7545. /**
  7546. * Delays loading of the cube texture
  7547. * @param forcedExtension defines the extension to use
  7548. */
  7549. delayLoad(forcedExtension?: string): void;
  7550. /**
  7551. * Returns the reflection texture matrix
  7552. * @returns the reflection texture matrix
  7553. */
  7554. getReflectionTextureMatrix(): Matrix;
  7555. /**
  7556. * Sets the reflection texture matrix
  7557. * @param value Reflection texture matrix
  7558. */
  7559. setReflectionTextureMatrix(value: Matrix): void;
  7560. /**
  7561. * Parses text to create a cube texture
  7562. * @param parsedTexture define the serialized text to read from
  7563. * @param scene defines the hosting scene
  7564. * @param rootUrl defines the root url of the cube texture
  7565. * @returns a cube texture
  7566. */
  7567. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7568. /**
  7569. * Makes a clone, or deep copy, of the cube texture
  7570. * @returns a new cube texture
  7571. */
  7572. clone(): CubeTexture;
  7573. }
  7574. }
  7575. declare module BABYLON {
  7576. /**
  7577. * Manages the defines for the Material
  7578. */
  7579. export class MaterialDefines {
  7580. /** @hidden */
  7581. protected _keys: string[];
  7582. private _isDirty;
  7583. /** @hidden */ private _renderId: number;
  7584. /** @hidden */ private _areLightsDirty: boolean;
  7585. /** @hidden */ private _areLightsDisposed: boolean;
  7586. /** @hidden */ private _areAttributesDirty: boolean;
  7587. /** @hidden */ private _areTexturesDirty: boolean;
  7588. /** @hidden */ private _areFresnelDirty: boolean;
  7589. /** @hidden */ private _areMiscDirty: boolean;
  7590. /** @hidden */ private _areImageProcessingDirty: boolean;
  7591. /** @hidden */ private _normals: boolean;
  7592. /** @hidden */ private _uvs: boolean;
  7593. /** @hidden */ private _needNormals: boolean;
  7594. /** @hidden */ private _needUVs: boolean;
  7595. [id: string]: any;
  7596. /**
  7597. * Specifies if the material needs to be re-calculated
  7598. */
  7599. readonly isDirty: boolean;
  7600. /**
  7601. * Marks the material to indicate that it has been re-calculated
  7602. */
  7603. markAsProcessed(): void;
  7604. /**
  7605. * Marks the material to indicate that it needs to be re-calculated
  7606. */
  7607. markAsUnprocessed(): void;
  7608. /**
  7609. * Marks the material to indicate all of its defines need to be re-calculated
  7610. */
  7611. markAllAsDirty(): void;
  7612. /**
  7613. * Marks the material to indicate that image processing needs to be re-calculated
  7614. */
  7615. markAsImageProcessingDirty(): void;
  7616. /**
  7617. * Marks the material to indicate the lights need to be re-calculated
  7618. * @param disposed Defines whether the light is dirty due to dispose or not
  7619. */
  7620. markAsLightDirty(disposed?: boolean): void;
  7621. /**
  7622. * Marks the attribute state as changed
  7623. */
  7624. markAsAttributesDirty(): void;
  7625. /**
  7626. * Marks the texture state as changed
  7627. */
  7628. markAsTexturesDirty(): void;
  7629. /**
  7630. * Marks the fresnel state as changed
  7631. */
  7632. markAsFresnelDirty(): void;
  7633. /**
  7634. * Marks the misc state as changed
  7635. */
  7636. markAsMiscDirty(): void;
  7637. /**
  7638. * Rebuilds the material defines
  7639. */
  7640. rebuild(): void;
  7641. /**
  7642. * Specifies if two material defines are equal
  7643. * @param other - A material define instance to compare to
  7644. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7645. */
  7646. isEqual(other: MaterialDefines): boolean;
  7647. /**
  7648. * Clones this instance's defines to another instance
  7649. * @param other - material defines to clone values to
  7650. */
  7651. cloneTo(other: MaterialDefines): void;
  7652. /**
  7653. * Resets the material define values
  7654. */
  7655. reset(): void;
  7656. /**
  7657. * Converts the material define values to a string
  7658. * @returns - String of material define information
  7659. */
  7660. toString(): string;
  7661. }
  7662. }
  7663. declare module BABYLON {
  7664. /**
  7665. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7666. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7667. * 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;
  7668. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7669. */
  7670. export class ColorCurves {
  7671. private _dirty;
  7672. private _tempColor;
  7673. private _globalCurve;
  7674. private _highlightsCurve;
  7675. private _midtonesCurve;
  7676. private _shadowsCurve;
  7677. private _positiveCurve;
  7678. private _negativeCurve;
  7679. private _globalHue;
  7680. private _globalDensity;
  7681. private _globalSaturation;
  7682. private _globalExposure;
  7683. /**
  7684. * Gets the global Hue value.
  7685. * 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).
  7686. */
  7687. /**
  7688. * Sets the global Hue value.
  7689. * 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).
  7690. */
  7691. globalHue: number;
  7692. /**
  7693. * Gets the global Density value.
  7694. * 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.
  7695. * Values less than zero provide a filter of opposite hue.
  7696. */
  7697. /**
  7698. * Sets the global Density value.
  7699. * 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.
  7700. * Values less than zero provide a filter of opposite hue.
  7701. */
  7702. globalDensity: number;
  7703. /**
  7704. * Gets the global Saturation value.
  7705. * 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.
  7706. */
  7707. /**
  7708. * Sets the global Saturation value.
  7709. * 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.
  7710. */
  7711. globalSaturation: number;
  7712. /**
  7713. * Gets the global Exposure value.
  7714. * 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.
  7715. */
  7716. /**
  7717. * Sets the global Exposure value.
  7718. * 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.
  7719. */
  7720. globalExposure: number;
  7721. private _highlightsHue;
  7722. private _highlightsDensity;
  7723. private _highlightsSaturation;
  7724. private _highlightsExposure;
  7725. /**
  7726. * Gets the highlights Hue value.
  7727. * 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).
  7728. */
  7729. /**
  7730. * Sets the highlights Hue value.
  7731. * 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).
  7732. */
  7733. highlightsHue: number;
  7734. /**
  7735. * Gets the highlights Density value.
  7736. * 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.
  7737. * Values less than zero provide a filter of opposite hue.
  7738. */
  7739. /**
  7740. * Sets the highlights Density value.
  7741. * 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.
  7742. * Values less than zero provide a filter of opposite hue.
  7743. */
  7744. highlightsDensity: number;
  7745. /**
  7746. * Gets the highlights Saturation value.
  7747. * 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.
  7748. */
  7749. /**
  7750. * Sets the highlights Saturation value.
  7751. * 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.
  7752. */
  7753. highlightsSaturation: number;
  7754. /**
  7755. * Gets the highlights Exposure value.
  7756. * 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.
  7757. */
  7758. /**
  7759. * Sets the highlights Exposure value.
  7760. * 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.
  7761. */
  7762. highlightsExposure: number;
  7763. private _midtonesHue;
  7764. private _midtonesDensity;
  7765. private _midtonesSaturation;
  7766. private _midtonesExposure;
  7767. /**
  7768. * Gets the midtones Hue value.
  7769. * 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).
  7770. */
  7771. /**
  7772. * Sets the midtones Hue value.
  7773. * 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).
  7774. */
  7775. midtonesHue: number;
  7776. /**
  7777. * Gets the midtones Density value.
  7778. * 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.
  7779. * Values less than zero provide a filter of opposite hue.
  7780. */
  7781. /**
  7782. * Sets the midtones Density value.
  7783. * 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.
  7784. * Values less than zero provide a filter of opposite hue.
  7785. */
  7786. midtonesDensity: number;
  7787. /**
  7788. * Gets the midtones Saturation value.
  7789. * 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.
  7790. */
  7791. /**
  7792. * Sets the midtones Saturation value.
  7793. * 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.
  7794. */
  7795. midtonesSaturation: number;
  7796. /**
  7797. * Gets the midtones Exposure value.
  7798. * 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.
  7799. */
  7800. /**
  7801. * Sets the midtones Exposure value.
  7802. * 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.
  7803. */
  7804. midtonesExposure: number;
  7805. private _shadowsHue;
  7806. private _shadowsDensity;
  7807. private _shadowsSaturation;
  7808. private _shadowsExposure;
  7809. /**
  7810. * Gets the shadows Hue value.
  7811. * 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).
  7812. */
  7813. /**
  7814. * Sets the shadows Hue value.
  7815. * 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).
  7816. */
  7817. shadowsHue: number;
  7818. /**
  7819. * Gets the shadows Density value.
  7820. * 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.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. /**
  7824. * Sets the shadows Density value.
  7825. * 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.
  7826. * Values less than zero provide a filter of opposite hue.
  7827. */
  7828. shadowsDensity: number;
  7829. /**
  7830. * Gets the shadows Saturation value.
  7831. * 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.
  7832. */
  7833. /**
  7834. * Sets the shadows Saturation value.
  7835. * 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.
  7836. */
  7837. shadowsSaturation: number;
  7838. /**
  7839. * Gets the shadows Exposure value.
  7840. * 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.
  7841. */
  7842. /**
  7843. * Sets the shadows Exposure value.
  7844. * 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.
  7845. */
  7846. shadowsExposure: number;
  7847. /**
  7848. * Returns the class name
  7849. * @returns The class name
  7850. */
  7851. getClassName(): string;
  7852. /**
  7853. * Binds the color curves to the shader.
  7854. * @param colorCurves The color curve to bind
  7855. * @param effect The effect to bind to
  7856. * @param positiveUniform The positive uniform shader parameter
  7857. * @param neutralUniform The neutral uniform shader parameter
  7858. * @param negativeUniform The negative uniform shader parameter
  7859. */
  7860. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7861. /**
  7862. * Prepare the list of uniforms associated with the ColorCurves effects.
  7863. * @param uniformsList The list of uniforms used in the effect
  7864. */
  7865. static PrepareUniforms(uniformsList: string[]): void;
  7866. /**
  7867. * Returns color grading data based on a hue, density, saturation and exposure value.
  7868. * @param filterHue The hue of the color filter.
  7869. * @param filterDensity The density of the color filter.
  7870. * @param saturation The saturation.
  7871. * @param exposure The exposure.
  7872. * @param result The result data container.
  7873. */
  7874. private getColorGradingDataToRef;
  7875. /**
  7876. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7877. * @param value The input slider value in range [-100,100].
  7878. * @returns Adjusted value.
  7879. */
  7880. private static applyColorGradingSliderNonlinear;
  7881. /**
  7882. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7883. * @param hue The hue (H) input.
  7884. * @param saturation The saturation (S) input.
  7885. * @param brightness The brightness (B) input.
  7886. * @result An RGBA color represented as Vector4.
  7887. */
  7888. private static fromHSBToRef;
  7889. /**
  7890. * Returns a value clamped between min and max
  7891. * @param value The value to clamp
  7892. * @param min The minimum of value
  7893. * @param max The maximum of value
  7894. * @returns The clamped value.
  7895. */
  7896. private static clamp;
  7897. /**
  7898. * Clones the current color curve instance.
  7899. * @return The cloned curves
  7900. */
  7901. clone(): ColorCurves;
  7902. /**
  7903. * Serializes the current color curve instance to a json representation.
  7904. * @return a JSON representation
  7905. */
  7906. serialize(): any;
  7907. /**
  7908. * Parses the color curve from a json representation.
  7909. * @param source the JSON source to parse
  7910. * @return The parsed curves
  7911. */
  7912. static Parse(source: any): ColorCurves;
  7913. }
  7914. }
  7915. declare module BABYLON {
  7916. /**
  7917. * Interface to follow in your material defines to integrate easily the
  7918. * Image proccessing functions.
  7919. * @hidden
  7920. */
  7921. export interface IImageProcessingConfigurationDefines {
  7922. IMAGEPROCESSING: boolean;
  7923. VIGNETTE: boolean;
  7924. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7925. VIGNETTEBLENDMODEOPAQUE: boolean;
  7926. TONEMAPPING: boolean;
  7927. TONEMAPPING_ACES: boolean;
  7928. CONTRAST: boolean;
  7929. EXPOSURE: boolean;
  7930. COLORCURVES: boolean;
  7931. COLORGRADING: boolean;
  7932. COLORGRADING3D: boolean;
  7933. SAMPLER3DGREENDEPTH: boolean;
  7934. SAMPLER3DBGRMAP: boolean;
  7935. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7936. }
  7937. /**
  7938. * @hidden
  7939. */
  7940. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7941. IMAGEPROCESSING: boolean;
  7942. VIGNETTE: boolean;
  7943. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7944. VIGNETTEBLENDMODEOPAQUE: boolean;
  7945. TONEMAPPING: boolean;
  7946. TONEMAPPING_ACES: boolean;
  7947. CONTRAST: boolean;
  7948. COLORCURVES: boolean;
  7949. COLORGRADING: boolean;
  7950. COLORGRADING3D: boolean;
  7951. SAMPLER3DGREENDEPTH: boolean;
  7952. SAMPLER3DBGRMAP: boolean;
  7953. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7954. EXPOSURE: boolean;
  7955. constructor();
  7956. }
  7957. /**
  7958. * This groups together the common properties used for image processing either in direct forward pass
  7959. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7960. * or not.
  7961. */
  7962. export class ImageProcessingConfiguration {
  7963. /**
  7964. * Default tone mapping applied in BabylonJS.
  7965. */
  7966. static readonly TONEMAPPING_STANDARD: number;
  7967. /**
  7968. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7969. * to other engines rendering to increase portability.
  7970. */
  7971. static readonly TONEMAPPING_ACES: number;
  7972. /**
  7973. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7974. */
  7975. colorCurves: Nullable<ColorCurves>;
  7976. private _colorCurvesEnabled;
  7977. /**
  7978. * Gets wether the color curves effect is enabled.
  7979. */
  7980. /**
  7981. * Sets wether the color curves effect is enabled.
  7982. */
  7983. colorCurvesEnabled: boolean;
  7984. private _colorGradingTexture;
  7985. /**
  7986. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7987. */
  7988. /**
  7989. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7990. */
  7991. colorGradingTexture: Nullable<BaseTexture>;
  7992. private _colorGradingEnabled;
  7993. /**
  7994. * Gets wether the color grading effect is enabled.
  7995. */
  7996. /**
  7997. * Sets wether the color grading effect is enabled.
  7998. */
  7999. colorGradingEnabled: boolean;
  8000. private _colorGradingWithGreenDepth;
  8001. /**
  8002. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8003. */
  8004. /**
  8005. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8006. */
  8007. colorGradingWithGreenDepth: boolean;
  8008. private _colorGradingBGR;
  8009. /**
  8010. * Gets wether the color grading texture contains BGR values.
  8011. */
  8012. /**
  8013. * Sets wether the color grading texture contains BGR values.
  8014. */
  8015. colorGradingBGR: boolean;
  8016. /** @hidden */ private _exposure: number;
  8017. /**
  8018. * Gets the Exposure used in the effect.
  8019. */
  8020. /**
  8021. * Sets the Exposure used in the effect.
  8022. */
  8023. exposure: number;
  8024. private _toneMappingEnabled;
  8025. /**
  8026. * Gets wether the tone mapping effect is enabled.
  8027. */
  8028. /**
  8029. * Sets wether the tone mapping effect is enabled.
  8030. */
  8031. toneMappingEnabled: boolean;
  8032. private _toneMappingType;
  8033. /**
  8034. * Gets the type of tone mapping effect.
  8035. */
  8036. /**
  8037. * Sets the type of tone mapping effect used in BabylonJS.
  8038. */
  8039. toneMappingType: number;
  8040. protected _contrast: number;
  8041. /**
  8042. * Gets the contrast used in the effect.
  8043. */
  8044. /**
  8045. * Sets the contrast used in the effect.
  8046. */
  8047. contrast: number;
  8048. /**
  8049. * Vignette stretch size.
  8050. */
  8051. vignetteStretch: number;
  8052. /**
  8053. * Vignette centre X Offset.
  8054. */
  8055. vignetteCentreX: number;
  8056. /**
  8057. * Vignette centre Y Offset.
  8058. */
  8059. vignetteCentreY: number;
  8060. /**
  8061. * Vignette weight or intensity of the vignette effect.
  8062. */
  8063. vignetteWeight: number;
  8064. /**
  8065. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8066. * if vignetteEnabled is set to true.
  8067. */
  8068. vignetteColor: Color4;
  8069. /**
  8070. * Camera field of view used by the Vignette effect.
  8071. */
  8072. vignetteCameraFov: number;
  8073. private _vignetteBlendMode;
  8074. /**
  8075. * Gets the vignette blend mode allowing different kind of effect.
  8076. */
  8077. /**
  8078. * Sets the vignette blend mode allowing different kind of effect.
  8079. */
  8080. vignetteBlendMode: number;
  8081. private _vignetteEnabled;
  8082. /**
  8083. * Gets wether the vignette effect is enabled.
  8084. */
  8085. /**
  8086. * Sets wether the vignette effect is enabled.
  8087. */
  8088. vignetteEnabled: boolean;
  8089. private _applyByPostProcess;
  8090. /**
  8091. * Gets wether the image processing is applied through a post process or not.
  8092. */
  8093. /**
  8094. * Sets wether the image processing is applied through a post process or not.
  8095. */
  8096. applyByPostProcess: boolean;
  8097. private _isEnabled;
  8098. /**
  8099. * Gets wether the image processing is enabled or not.
  8100. */
  8101. /**
  8102. * Sets wether the image processing is enabled or not.
  8103. */
  8104. isEnabled: boolean;
  8105. /**
  8106. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8107. */
  8108. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8109. /**
  8110. * Method called each time the image processing information changes requires to recompile the effect.
  8111. */
  8112. protected _updateParameters(): void;
  8113. /**
  8114. * Gets the current class name.
  8115. * @return "ImageProcessingConfiguration"
  8116. */
  8117. getClassName(): string;
  8118. /**
  8119. * Prepare the list of uniforms associated with the Image Processing effects.
  8120. * @param uniforms The list of uniforms used in the effect
  8121. * @param defines the list of defines currently in use
  8122. */
  8123. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8124. /**
  8125. * Prepare the list of samplers associated with the Image Processing effects.
  8126. * @param samplersList The list of uniforms used in the effect
  8127. * @param defines the list of defines currently in use
  8128. */
  8129. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8130. /**
  8131. * Prepare the list of defines associated to the shader.
  8132. * @param defines the list of defines to complete
  8133. * @param forPostProcess Define if we are currently in post process mode or not
  8134. */
  8135. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8136. /**
  8137. * Returns true if all the image processing information are ready.
  8138. * @returns True if ready, otherwise, false
  8139. */
  8140. isReady(): boolean;
  8141. /**
  8142. * Binds the image processing to the shader.
  8143. * @param effect The effect to bind to
  8144. * @param aspectRatio Define the current aspect ratio of the effect
  8145. */
  8146. bind(effect: Effect, aspectRatio?: number): void;
  8147. /**
  8148. * Clones the current image processing instance.
  8149. * @return The cloned image processing
  8150. */
  8151. clone(): ImageProcessingConfiguration;
  8152. /**
  8153. * Serializes the current image processing instance to a json representation.
  8154. * @return a JSON representation
  8155. */
  8156. serialize(): any;
  8157. /**
  8158. * Parses the image processing from a json representation.
  8159. * @param source the JSON source to parse
  8160. * @return The parsed image processing
  8161. */
  8162. static Parse(source: any): ImageProcessingConfiguration;
  8163. private static _VIGNETTEMODE_MULTIPLY;
  8164. private static _VIGNETTEMODE_OPAQUE;
  8165. /**
  8166. * Used to apply the vignette as a mix with the pixel color.
  8167. */
  8168. static readonly VIGNETTEMODE_MULTIPLY: number;
  8169. /**
  8170. * Used to apply the vignette as a replacement of the pixel color.
  8171. */
  8172. static readonly VIGNETTEMODE_OPAQUE: number;
  8173. }
  8174. }
  8175. declare module BABYLON {
  8176. /** @hidden */
  8177. export var postprocessVertexShader: {
  8178. name: string;
  8179. shader: string;
  8180. };
  8181. }
  8182. declare module BABYLON {
  8183. /** Defines supported spaces */
  8184. export enum Space {
  8185. /** Local (object) space */
  8186. LOCAL = 0,
  8187. /** World space */
  8188. WORLD = 1,
  8189. /** Bone space */
  8190. BONE = 2
  8191. }
  8192. /** Defines the 3 main axes */
  8193. export class Axis {
  8194. /** X axis */
  8195. static X: Vector3;
  8196. /** Y axis */
  8197. static Y: Vector3;
  8198. /** Z axis */
  8199. static Z: Vector3;
  8200. }
  8201. }
  8202. declare module BABYLON {
  8203. /**
  8204. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8205. * This is the base of the follow, arc rotate cameras and Free camera
  8206. * @see http://doc.babylonjs.com/features/cameras
  8207. */
  8208. export class TargetCamera extends Camera {
  8209. private static _RigCamTransformMatrix;
  8210. private static _TargetTransformMatrix;
  8211. private static _TargetFocalPoint;
  8212. /**
  8213. * Define the current direction the camera is moving to
  8214. */
  8215. cameraDirection: Vector3;
  8216. /**
  8217. * Define the current rotation the camera is rotating to
  8218. */
  8219. cameraRotation: Vector2;
  8220. /**
  8221. * When set, the up vector of the camera will be updated by the rotation of the camera
  8222. */
  8223. updateUpVectorFromRotation: boolean;
  8224. private _tmpQuaternion;
  8225. /**
  8226. * Define the current rotation of the camera
  8227. */
  8228. rotation: Vector3;
  8229. /**
  8230. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8231. */
  8232. rotationQuaternion: Quaternion;
  8233. /**
  8234. * Define the current speed of the camera
  8235. */
  8236. speed: number;
  8237. /**
  8238. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8239. * around all axis.
  8240. */
  8241. noRotationConstraint: boolean;
  8242. /**
  8243. * Define the current target of the camera as an object or a position.
  8244. */
  8245. lockedTarget: any;
  8246. /** @hidden */ private _currentTarget: Vector3;
  8247. /** @hidden */ private _initialFocalDistance: number;
  8248. /** @hidden */ private _viewMatrix: Matrix;
  8249. /** @hidden */ private _camMatrix: Matrix;
  8250. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8251. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8252. /** @hidden */ private _referencePoint: Vector3;
  8253. /** @hidden */ private _transformedReferencePoint: Vector3;
  8254. protected _globalCurrentTarget: Vector3;
  8255. protected _globalCurrentUpVector: Vector3;
  8256. /** @hidden */ private _reset: () => void;
  8257. private _defaultUp;
  8258. /**
  8259. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8260. * This is the base of the follow, arc rotate cameras and Free camera
  8261. * @see http://doc.babylonjs.com/features/cameras
  8262. * @param name Defines the name of the camera in the scene
  8263. * @param position Defines the start position of the camera in the scene
  8264. * @param scene Defines the scene the camera belongs to
  8265. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8266. */
  8267. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8268. /**
  8269. * Gets the position in front of the camera at a given distance.
  8270. * @param distance The distance from the camera we want the position to be
  8271. * @returns the position
  8272. */
  8273. getFrontPosition(distance: number): Vector3;
  8274. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8275. private _storedPosition;
  8276. private _storedRotation;
  8277. private _storedRotationQuaternion;
  8278. /**
  8279. * Store current camera state of the camera (fov, position, rotation, etc..)
  8280. * @returns the camera
  8281. */
  8282. storeState(): Camera;
  8283. /**
  8284. * Restored camera state. You must call storeState() first
  8285. * @returns whether it was successful or not
  8286. * @hidden
  8287. */ private _restoreStateValues(): boolean;
  8288. /** @hidden */ private _initCache(): void;
  8289. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8290. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8291. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8292. /**
  8293. * Defines the target the camera should look at.
  8294. * @param target Defines the new target as a Vector or a mesh
  8295. */
  8296. setTarget(target: Vector3): void;
  8297. /**
  8298. * Return the current target position of the camera. This value is expressed in local space.
  8299. * @returns the target position
  8300. */
  8301. getTarget(): Vector3;
  8302. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8303. /** @hidden */ private _updatePosition(): void;
  8304. /** @hidden */ private _checkInputs(): void;
  8305. protected _updateCameraRotationMatrix(): void;
  8306. /**
  8307. * 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)
  8308. * @returns the current camera
  8309. */
  8310. private _rotateUpVectorWithCameraRotationMatrix;
  8311. private _cachedRotationZ;
  8312. private _cachedQuaternionRotationZ;
  8313. /** @hidden */ private _getViewMatrix(): Matrix;
  8314. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8315. /**
  8316. * @hidden
  8317. */
  8318. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8319. /**
  8320. * @hidden
  8321. */ private _updateRigCameras(): void;
  8322. private _getRigCamPositionAndTarget;
  8323. /**
  8324. * Gets the current object class name.
  8325. * @return the class name
  8326. */
  8327. getClassName(): string;
  8328. }
  8329. }
  8330. declare module BABYLON {
  8331. /**
  8332. * Gather the list of keyboard event types as constants.
  8333. */
  8334. export class KeyboardEventTypes {
  8335. /**
  8336. * The keydown event is fired when a key becomes active (pressed).
  8337. */
  8338. static readonly KEYDOWN: number;
  8339. /**
  8340. * The keyup event is fired when a key has been released.
  8341. */
  8342. static readonly KEYUP: number;
  8343. }
  8344. /**
  8345. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8346. */
  8347. export class KeyboardInfo {
  8348. /**
  8349. * Defines the type of event (KeyboardEventTypes)
  8350. */
  8351. type: number;
  8352. /**
  8353. * Defines the related dom event
  8354. */
  8355. event: KeyboardEvent;
  8356. /**
  8357. * Instantiates a new keyboard info.
  8358. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8359. * @param type Defines the type of event (KeyboardEventTypes)
  8360. * @param event Defines the related dom event
  8361. */
  8362. constructor(
  8363. /**
  8364. * Defines the type of event (KeyboardEventTypes)
  8365. */
  8366. type: number,
  8367. /**
  8368. * Defines the related dom event
  8369. */
  8370. event: KeyboardEvent);
  8371. }
  8372. /**
  8373. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8374. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8375. */
  8376. export class KeyboardInfoPre extends KeyboardInfo {
  8377. /**
  8378. * Defines the type of event (KeyboardEventTypes)
  8379. */
  8380. type: number;
  8381. /**
  8382. * Defines the related dom event
  8383. */
  8384. event: KeyboardEvent;
  8385. /**
  8386. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8387. */
  8388. skipOnPointerObservable: boolean;
  8389. /**
  8390. * Instantiates a new keyboard pre info.
  8391. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8392. * @param type Defines the type of event (KeyboardEventTypes)
  8393. * @param event Defines the related dom event
  8394. */
  8395. constructor(
  8396. /**
  8397. * Defines the type of event (KeyboardEventTypes)
  8398. */
  8399. type: number,
  8400. /**
  8401. * Defines the related dom event
  8402. */
  8403. event: KeyboardEvent);
  8404. }
  8405. }
  8406. declare module BABYLON {
  8407. /**
  8408. * Manage the keyboard inputs to control the movement of a free camera.
  8409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8410. */
  8411. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8412. /**
  8413. * Defines the camera the input is attached to.
  8414. */
  8415. camera: FreeCamera;
  8416. /**
  8417. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8418. */
  8419. keysUp: number[];
  8420. /**
  8421. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8422. */
  8423. keysDown: number[];
  8424. /**
  8425. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8426. */
  8427. keysLeft: number[];
  8428. /**
  8429. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8430. */
  8431. keysRight: number[];
  8432. private _keys;
  8433. private _onCanvasBlurObserver;
  8434. private _onKeyboardObserver;
  8435. private _engine;
  8436. private _scene;
  8437. /**
  8438. * Attach the input controls to a specific dom element to get the input from.
  8439. * @param element Defines the element the controls should be listened from
  8440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8441. */
  8442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8443. /**
  8444. * Detach the current controls from the specified dom element.
  8445. * @param element Defines the element to stop listening the inputs from
  8446. */
  8447. detachControl(element: Nullable<HTMLElement>): void;
  8448. /**
  8449. * Update the current camera state depending on the inputs that have been used this frame.
  8450. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8451. */
  8452. checkInputs(): void;
  8453. /**
  8454. * Gets the class name of the current intput.
  8455. * @returns the class name
  8456. */
  8457. getClassName(): string;
  8458. /** @hidden */ private _onLostFocus(): void;
  8459. /**
  8460. * Get the friendly name associated with the input class.
  8461. * @returns the input friendly name
  8462. */
  8463. getSimpleName(): string;
  8464. }
  8465. }
  8466. declare module BABYLON {
  8467. /**
  8468. * Interface describing all the common properties and methods a shadow light needs to implement.
  8469. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8470. * as well as binding the different shadow properties to the effects.
  8471. */
  8472. export interface IShadowLight extends Light {
  8473. /**
  8474. * The light id in the scene (used in scene.findLighById for instance)
  8475. */
  8476. id: string;
  8477. /**
  8478. * The position the shdow will be casted from.
  8479. */
  8480. position: Vector3;
  8481. /**
  8482. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8483. */
  8484. direction: Vector3;
  8485. /**
  8486. * The transformed position. Position of the light in world space taking parenting in account.
  8487. */
  8488. transformedPosition: Vector3;
  8489. /**
  8490. * The transformed direction. Direction of the light in world space taking parenting in account.
  8491. */
  8492. transformedDirection: Vector3;
  8493. /**
  8494. * The friendly name of the light in the scene.
  8495. */
  8496. name: string;
  8497. /**
  8498. * Defines the shadow projection clipping minimum z value.
  8499. */
  8500. shadowMinZ: number;
  8501. /**
  8502. * Defines the shadow projection clipping maximum z value.
  8503. */
  8504. shadowMaxZ: number;
  8505. /**
  8506. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8507. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8508. */
  8509. computeTransformedInformation(): boolean;
  8510. /**
  8511. * Gets the scene the light belongs to.
  8512. * @returns The scene
  8513. */
  8514. getScene(): Scene;
  8515. /**
  8516. * Callback defining a custom Projection Matrix Builder.
  8517. * This can be used to override the default projection matrix computation.
  8518. */
  8519. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8520. /**
  8521. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8522. * @param matrix The materix to updated with the projection information
  8523. * @param viewMatrix The transform matrix of the light
  8524. * @param renderList The list of mesh to render in the map
  8525. * @returns The current light
  8526. */
  8527. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8528. /**
  8529. * Gets the current depth scale used in ESM.
  8530. * @returns The scale
  8531. */
  8532. getDepthScale(): number;
  8533. /**
  8534. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8535. * @returns true if a cube texture needs to be use
  8536. */
  8537. needCube(): boolean;
  8538. /**
  8539. * Detects if the projection matrix requires to be recomputed this frame.
  8540. * @returns true if it requires to be recomputed otherwise, false.
  8541. */
  8542. needProjectionMatrixCompute(): boolean;
  8543. /**
  8544. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8545. */
  8546. forceProjectionMatrixCompute(): void;
  8547. /**
  8548. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8549. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8550. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8551. */
  8552. getShadowDirection(faceIndex?: number): Vector3;
  8553. /**
  8554. * Gets the minZ used for shadow according to both the scene and the light.
  8555. * @param activeCamera The camera we are returning the min for
  8556. * @returns the depth min z
  8557. */
  8558. getDepthMinZ(activeCamera: Camera): number;
  8559. /**
  8560. * Gets the maxZ used for shadow according to both the scene and the light.
  8561. * @param activeCamera The camera we are returning the max for
  8562. * @returns the depth max z
  8563. */
  8564. getDepthMaxZ(activeCamera: Camera): number;
  8565. }
  8566. /**
  8567. * Base implementation IShadowLight
  8568. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8569. */
  8570. export abstract class ShadowLight extends Light implements IShadowLight {
  8571. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8572. protected _position: Vector3;
  8573. protected _setPosition(value: Vector3): void;
  8574. /**
  8575. * Sets the position the shadow will be casted from. Also use as the light position for both
  8576. * point and spot lights.
  8577. */
  8578. /**
  8579. * Sets the position the shadow will be casted from. Also use as the light position for both
  8580. * point and spot lights.
  8581. */
  8582. position: Vector3;
  8583. protected _direction: Vector3;
  8584. protected _setDirection(value: Vector3): void;
  8585. /**
  8586. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8587. * Also use as the light direction on spot and directional lights.
  8588. */
  8589. /**
  8590. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8591. * Also use as the light direction on spot and directional lights.
  8592. */
  8593. direction: Vector3;
  8594. private _shadowMinZ;
  8595. /**
  8596. * Gets the shadow projection clipping minimum z value.
  8597. */
  8598. /**
  8599. * Sets the shadow projection clipping minimum z value.
  8600. */
  8601. shadowMinZ: number;
  8602. private _shadowMaxZ;
  8603. /**
  8604. * Sets the shadow projection clipping maximum z value.
  8605. */
  8606. /**
  8607. * Gets the shadow projection clipping maximum z value.
  8608. */
  8609. shadowMaxZ: number;
  8610. /**
  8611. * Callback defining a custom Projection Matrix Builder.
  8612. * This can be used to override the default projection matrix computation.
  8613. */
  8614. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8615. /**
  8616. * The transformed position. Position of the light in world space taking parenting in account.
  8617. */
  8618. transformedPosition: Vector3;
  8619. /**
  8620. * The transformed direction. Direction of the light in world space taking parenting in account.
  8621. */
  8622. transformedDirection: Vector3;
  8623. private _needProjectionMatrixCompute;
  8624. /**
  8625. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8626. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8627. */
  8628. computeTransformedInformation(): boolean;
  8629. /**
  8630. * Return the depth scale used for the shadow map.
  8631. * @returns the depth scale.
  8632. */
  8633. getDepthScale(): number;
  8634. /**
  8635. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8636. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8637. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8638. */
  8639. getShadowDirection(faceIndex?: number): Vector3;
  8640. /**
  8641. * Returns the ShadowLight absolute position in the World.
  8642. * @returns the position vector in world space
  8643. */
  8644. getAbsolutePosition(): Vector3;
  8645. /**
  8646. * Sets the ShadowLight direction toward the passed target.
  8647. * @param target The point to target in local space
  8648. * @returns the updated ShadowLight direction
  8649. */
  8650. setDirectionToTarget(target: Vector3): Vector3;
  8651. /**
  8652. * Returns the light rotation in euler definition.
  8653. * @returns the x y z rotation in local space.
  8654. */
  8655. getRotation(): Vector3;
  8656. /**
  8657. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8658. * @returns true if a cube texture needs to be use
  8659. */
  8660. needCube(): boolean;
  8661. /**
  8662. * Detects if the projection matrix requires to be recomputed this frame.
  8663. * @returns true if it requires to be recomputed otherwise, false.
  8664. */
  8665. needProjectionMatrixCompute(): boolean;
  8666. /**
  8667. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8668. */
  8669. forceProjectionMatrixCompute(): void;
  8670. /** @hidden */ private _initCache(): void;
  8671. /** @hidden */ private _isSynchronized(): boolean;
  8672. /**
  8673. * Computes the world matrix of the node
  8674. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8675. * @returns the world matrix
  8676. */
  8677. computeWorldMatrix(force?: boolean): Matrix;
  8678. /**
  8679. * Gets the minZ used for shadow according to both the scene and the light.
  8680. * @param activeCamera The camera we are returning the min for
  8681. * @returns the depth min z
  8682. */
  8683. getDepthMinZ(activeCamera: Camera): number;
  8684. /**
  8685. * Gets the maxZ used for shadow according to both the scene and the light.
  8686. * @param activeCamera The camera we are returning the max for
  8687. * @returns the depth max z
  8688. */
  8689. getDepthMaxZ(activeCamera: Camera): number;
  8690. /**
  8691. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8692. * @param matrix The materix to updated with the projection information
  8693. * @param viewMatrix The transform matrix of the light
  8694. * @param renderList The list of mesh to render in the map
  8695. * @returns The current light
  8696. */
  8697. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8698. }
  8699. }
  8700. declare module BABYLON {
  8701. /**
  8702. * "Static Class" containing the most commonly used helper while dealing with material for
  8703. * rendering purpose.
  8704. *
  8705. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8706. *
  8707. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8708. */
  8709. export class MaterialHelper {
  8710. /**
  8711. * Bind the current view position to an effect.
  8712. * @param effect The effect to be bound
  8713. * @param scene The scene the eyes position is used from
  8714. */
  8715. static BindEyePosition(effect: Effect, scene: Scene): void;
  8716. /**
  8717. * Helps preparing the defines values about the UVs in used in the effect.
  8718. * UVs are shared as much as we can accross channels in the shaders.
  8719. * @param texture The texture we are preparing the UVs for
  8720. * @param defines The defines to update
  8721. * @param key The channel key "diffuse", "specular"... used in the shader
  8722. */
  8723. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8724. /**
  8725. * Binds a texture matrix value to its corrsponding uniform
  8726. * @param texture The texture to bind the matrix for
  8727. * @param uniformBuffer The uniform buffer receivin the data
  8728. * @param key The channel key "diffuse", "specular"... used in the shader
  8729. */
  8730. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8731. /**
  8732. * Gets the current status of the fog (should it be enabled?)
  8733. * @param mesh defines the mesh to evaluate for fog support
  8734. * @param scene defines the hosting scene
  8735. * @returns true if fog must be enabled
  8736. */
  8737. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8738. /**
  8739. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8740. * @param mesh defines the current mesh
  8741. * @param scene defines the current scene
  8742. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8743. * @param pointsCloud defines if point cloud rendering has to be turned on
  8744. * @param fogEnabled defines if fog has to be turned on
  8745. * @param alphaTest defines if alpha testing has to be turned on
  8746. * @param defines defines the current list of defines
  8747. */
  8748. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8749. /**
  8750. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8751. * @param scene defines the current scene
  8752. * @param engine defines the current engine
  8753. * @param defines specifies the list of active defines
  8754. * @param useInstances defines if instances have to be turned on
  8755. * @param useClipPlane defines if clip plane have to be turned on
  8756. */
  8757. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8758. /**
  8759. * Prepares the defines for bones
  8760. * @param mesh The mesh containing the geometry data we will draw
  8761. * @param defines The defines to update
  8762. */
  8763. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8764. /**
  8765. * Prepares the defines for morph targets
  8766. * @param mesh The mesh containing the geometry data we will draw
  8767. * @param defines The defines to update
  8768. */
  8769. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8770. /**
  8771. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8772. * @param mesh The mesh containing the geometry data we will draw
  8773. * @param defines The defines to update
  8774. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8775. * @param useBones Precise whether bones should be used or not (override mesh info)
  8776. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8777. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8778. * @returns false if defines are considered not dirty and have not been checked
  8779. */
  8780. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8781. /**
  8782. * Prepares the defines related to multiview
  8783. * @param scene The scene we are intending to draw
  8784. * @param defines The defines to update
  8785. */
  8786. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8787. /**
  8788. * Prepares the defines related to the light information passed in parameter
  8789. * @param scene The scene we are intending to draw
  8790. * @param mesh The mesh the effect is compiling for
  8791. * @param light The light the effect is compiling for
  8792. * @param lightIndex The index of the light
  8793. * @param defines The defines to update
  8794. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8795. * @param state Defines the current state regarding what is needed (normals, etc...)
  8796. */
  8797. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8798. needNormals: boolean;
  8799. needRebuild: boolean;
  8800. shadowEnabled: boolean;
  8801. specularEnabled: boolean;
  8802. lightmapMode: boolean;
  8803. }): void;
  8804. /**
  8805. * Prepares the defines related to the light information passed in parameter
  8806. * @param scene The scene we are intending to draw
  8807. * @param mesh The mesh the effect is compiling for
  8808. * @param defines The defines to update
  8809. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8810. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8811. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8812. * @returns true if normals will be required for the rest of the effect
  8813. */
  8814. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8815. /**
  8816. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8817. * @param lightIndex defines the light index
  8818. * @param uniformsList The uniform list
  8819. * @param samplersList The sampler list
  8820. * @param projectedLightTexture defines if projected texture must be used
  8821. * @param uniformBuffersList defines an optional list of uniform buffers
  8822. */
  8823. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8824. /**
  8825. * Prepares the uniforms and samplers list to be used in the effect
  8826. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8827. * @param samplersList The sampler list
  8828. * @param defines The defines helping in the list generation
  8829. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8830. */
  8831. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8832. /**
  8833. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8834. * @param defines The defines to update while falling back
  8835. * @param fallbacks The authorized effect fallbacks
  8836. * @param maxSimultaneousLights The maximum number of lights allowed
  8837. * @param rank the current rank of the Effect
  8838. * @returns The newly affected rank
  8839. */
  8840. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8841. private static _TmpMorphInfluencers;
  8842. /**
  8843. * Prepares the list of attributes required for morph targets according to the effect defines.
  8844. * @param attribs The current list of supported attribs
  8845. * @param mesh The mesh to prepare the morph targets attributes for
  8846. * @param influencers The number of influencers
  8847. */
  8848. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8849. /**
  8850. * Prepares the list of attributes required for morph targets according to the effect defines.
  8851. * @param attribs The current list of supported attribs
  8852. * @param mesh The mesh to prepare the morph targets attributes for
  8853. * @param defines The current Defines of the effect
  8854. */
  8855. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8856. /**
  8857. * Prepares the list of attributes required for bones according to the effect defines.
  8858. * @param attribs The current list of supported attribs
  8859. * @param mesh The mesh to prepare the bones attributes for
  8860. * @param defines The current Defines of the effect
  8861. * @param fallbacks The current efffect fallback strategy
  8862. */
  8863. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8864. /**
  8865. * Check and prepare the list of attributes required for instances according to the effect defines.
  8866. * @param attribs The current list of supported attribs
  8867. * @param defines The current MaterialDefines of the effect
  8868. */
  8869. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8870. /**
  8871. * Add the list of attributes required for instances to the attribs array.
  8872. * @param attribs The current list of supported attribs
  8873. */
  8874. static PushAttributesForInstances(attribs: string[]): void;
  8875. /**
  8876. * Binds the light shadow information to the effect for the given mesh.
  8877. * @param light The light containing the generator
  8878. * @param scene The scene the lights belongs to
  8879. * @param mesh The mesh we are binding the information to render
  8880. * @param lightIndex The light index in the effect used to render the mesh
  8881. * @param effect The effect we are binding the data to
  8882. */
  8883. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8884. /**
  8885. * Binds the light information to the effect.
  8886. * @param light The light containing the generator
  8887. * @param effect The effect we are binding the data to
  8888. * @param lightIndex The light index in the effect used to render
  8889. */
  8890. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8891. /**
  8892. * Binds the lights information from the scene to the effect for the given mesh.
  8893. * @param light Light to bind
  8894. * @param lightIndex Light index
  8895. * @param scene The scene where the light belongs to
  8896. * @param mesh The mesh we are binding the information to render
  8897. * @param effect The effect we are binding the data to
  8898. * @param useSpecular Defines if specular is supported
  8899. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8900. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8901. */
  8902. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8903. /**
  8904. * Binds the lights information from the scene to the effect for the given mesh.
  8905. * @param scene The scene the lights belongs to
  8906. * @param mesh The mesh we are binding the information to render
  8907. * @param effect The effect we are binding the data to
  8908. * @param defines The generated defines for the effect
  8909. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8910. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8911. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8912. */
  8913. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8914. private static _tempFogColor;
  8915. /**
  8916. * Binds the fog information from the scene to the effect for the given mesh.
  8917. * @param scene The scene the lights belongs to
  8918. * @param mesh The mesh we are binding the information to render
  8919. * @param effect The effect we are binding the data to
  8920. * @param linearSpace Defines if the fog effect is applied in linear space
  8921. */
  8922. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8923. /**
  8924. * Binds the bones information from the mesh to the effect.
  8925. * @param mesh The mesh we are binding the information to render
  8926. * @param effect The effect we are binding the data to
  8927. */
  8928. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8929. /**
  8930. * Binds the morph targets information from the mesh to the effect.
  8931. * @param abstractMesh The mesh we are binding the information to render
  8932. * @param effect The effect we are binding the data to
  8933. */
  8934. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8935. /**
  8936. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8937. * @param defines The generated defines used in the effect
  8938. * @param effect The effect we are binding the data to
  8939. * @param scene The scene we are willing to render with logarithmic scale for
  8940. */
  8941. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8942. /**
  8943. * Binds the clip plane information from the scene to the effect.
  8944. * @param scene The scene the clip plane information are extracted from
  8945. * @param effect The effect we are binding the data to
  8946. */
  8947. static BindClipPlane(effect: Effect, scene: Scene): void;
  8948. }
  8949. }
  8950. declare module BABYLON {
  8951. /** @hidden */
  8952. export var packingFunctions: {
  8953. name: string;
  8954. shader: string;
  8955. };
  8956. }
  8957. declare module BABYLON {
  8958. /** @hidden */
  8959. export var shadowMapPixelShader: {
  8960. name: string;
  8961. shader: string;
  8962. };
  8963. }
  8964. declare module BABYLON {
  8965. /** @hidden */
  8966. export var bonesDeclaration: {
  8967. name: string;
  8968. shader: string;
  8969. };
  8970. }
  8971. declare module BABYLON {
  8972. /** @hidden */
  8973. export var morphTargetsVertexGlobalDeclaration: {
  8974. name: string;
  8975. shader: string;
  8976. };
  8977. }
  8978. declare module BABYLON {
  8979. /** @hidden */
  8980. export var morphTargetsVertexDeclaration: {
  8981. name: string;
  8982. shader: string;
  8983. };
  8984. }
  8985. declare module BABYLON {
  8986. /** @hidden */
  8987. export var instancesDeclaration: {
  8988. name: string;
  8989. shader: string;
  8990. };
  8991. }
  8992. declare module BABYLON {
  8993. /** @hidden */
  8994. export var helperFunctions: {
  8995. name: string;
  8996. shader: string;
  8997. };
  8998. }
  8999. declare module BABYLON {
  9000. /** @hidden */
  9001. export var morphTargetsVertex: {
  9002. name: string;
  9003. shader: string;
  9004. };
  9005. }
  9006. declare module BABYLON {
  9007. /** @hidden */
  9008. export var instancesVertex: {
  9009. name: string;
  9010. shader: string;
  9011. };
  9012. }
  9013. declare module BABYLON {
  9014. /** @hidden */
  9015. export var bonesVertex: {
  9016. name: string;
  9017. shader: string;
  9018. };
  9019. }
  9020. declare module BABYLON {
  9021. /** @hidden */
  9022. export var shadowMapVertexShader: {
  9023. name: string;
  9024. shader: string;
  9025. };
  9026. }
  9027. declare module BABYLON {
  9028. /** @hidden */
  9029. export var depthBoxBlurPixelShader: {
  9030. name: string;
  9031. shader: string;
  9032. };
  9033. }
  9034. declare module BABYLON {
  9035. /**
  9036. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9037. */
  9038. export interface ICustomShaderOptions {
  9039. /**
  9040. * Gets or sets the custom shader name to use
  9041. */
  9042. shaderName: string;
  9043. /**
  9044. * The list of attribute names used in the shader
  9045. */
  9046. attributes?: string[];
  9047. /**
  9048. * The list of unifrom names used in the shader
  9049. */
  9050. uniforms?: string[];
  9051. /**
  9052. * The list of sampler names used in the shader
  9053. */
  9054. samplers?: string[];
  9055. /**
  9056. * The list of defines used in the shader
  9057. */
  9058. defines?: string[];
  9059. }
  9060. /**
  9061. * Interface to implement to create a shadow generator compatible with BJS.
  9062. */
  9063. export interface IShadowGenerator {
  9064. /**
  9065. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9066. * @returns The render target texture if present otherwise, null
  9067. */
  9068. getShadowMap(): Nullable<RenderTargetTexture>;
  9069. /**
  9070. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9071. * @returns The render target texture if the shadow map is present otherwise, null
  9072. */
  9073. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9074. /**
  9075. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9076. * @param subMesh The submesh we want to render in the shadow map
  9077. * @param useInstances Defines wether will draw in the map using instances
  9078. * @returns true if ready otherwise, false
  9079. */
  9080. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9081. /**
  9082. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9083. * @param defines Defines of the material we want to update
  9084. * @param lightIndex Index of the light in the enabled light list of the material
  9085. */
  9086. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9087. /**
  9088. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9089. * defined in the generator but impacting the effect).
  9090. * It implies the unifroms available on the materials are the standard BJS ones.
  9091. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9092. * @param effect The effect we are binfing the information for
  9093. */
  9094. bindShadowLight(lightIndex: string, effect: Effect): void;
  9095. /**
  9096. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9097. * (eq to shadow prjection matrix * light transform matrix)
  9098. * @returns The transform matrix used to create the shadow map
  9099. */
  9100. getTransformMatrix(): Matrix;
  9101. /**
  9102. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9103. * Cube and 2D textures for instance.
  9104. */
  9105. recreateShadowMap(): void;
  9106. /**
  9107. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9108. * @param onCompiled Callback triggered at the and of the effects compilation
  9109. * @param options Sets of optional options forcing the compilation with different modes
  9110. */
  9111. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9112. useInstances: boolean;
  9113. }>): void;
  9114. /**
  9115. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9116. * @param options Sets of optional options forcing the compilation with different modes
  9117. * @returns A promise that resolves when the compilation completes
  9118. */
  9119. forceCompilationAsync(options?: Partial<{
  9120. useInstances: boolean;
  9121. }>): Promise<void>;
  9122. /**
  9123. * Serializes the shadow generator setup to a json object.
  9124. * @returns The serialized JSON object
  9125. */
  9126. serialize(): any;
  9127. /**
  9128. * Disposes the Shadow map and related Textures and effects.
  9129. */
  9130. dispose(): void;
  9131. }
  9132. /**
  9133. * Default implementation IShadowGenerator.
  9134. * This is the main object responsible of generating shadows in the framework.
  9135. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9136. */
  9137. export class ShadowGenerator implements IShadowGenerator {
  9138. /**
  9139. * Shadow generator mode None: no filtering applied.
  9140. */
  9141. static readonly FILTER_NONE: number;
  9142. /**
  9143. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9144. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9145. */
  9146. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9147. /**
  9148. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9149. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9150. */
  9151. static readonly FILTER_POISSONSAMPLING: number;
  9152. /**
  9153. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9154. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9155. */
  9156. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9157. /**
  9158. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9159. * edge artifacts on steep falloff.
  9160. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9161. */
  9162. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9163. /**
  9164. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9165. * edge artifacts on steep falloff.
  9166. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9167. */
  9168. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9169. /**
  9170. * Shadow generator mode PCF: Percentage Closer Filtering
  9171. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9172. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9173. */
  9174. static readonly FILTER_PCF: number;
  9175. /**
  9176. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9177. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9178. * Contact Hardening
  9179. */
  9180. static readonly FILTER_PCSS: number;
  9181. /**
  9182. * Reserved for PCF and PCSS
  9183. * Highest Quality.
  9184. *
  9185. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9186. *
  9187. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9188. */
  9189. static readonly QUALITY_HIGH: number;
  9190. /**
  9191. * Reserved for PCF and PCSS
  9192. * Good tradeoff for quality/perf cross devices
  9193. *
  9194. * Execute PCF on a 3*3 kernel.
  9195. *
  9196. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9197. */
  9198. static readonly QUALITY_MEDIUM: number;
  9199. /**
  9200. * Reserved for PCF and PCSS
  9201. * The lowest quality but the fastest.
  9202. *
  9203. * Execute PCF on a 1*1 kernel.
  9204. *
  9205. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9206. */
  9207. static readonly QUALITY_LOW: number;
  9208. /** Gets or sets the custom shader name to use */
  9209. customShaderOptions: ICustomShaderOptions;
  9210. /**
  9211. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9212. */
  9213. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9214. /**
  9215. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9216. */
  9217. onAfterShadowMapRenderObservable: Observable<Effect>;
  9218. /**
  9219. * Observable triggered before a mesh is rendered in the shadow map.
  9220. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9221. */
  9222. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9223. /**
  9224. * Observable triggered after a mesh is rendered in the shadow map.
  9225. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9226. */
  9227. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9228. private _bias;
  9229. /**
  9230. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9231. */
  9232. /**
  9233. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9234. */
  9235. bias: number;
  9236. private _normalBias;
  9237. /**
  9238. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9239. */
  9240. /**
  9241. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9242. */
  9243. normalBias: number;
  9244. private _blurBoxOffset;
  9245. /**
  9246. * Gets the blur box offset: offset applied during the blur pass.
  9247. * Only useful if useKernelBlur = false
  9248. */
  9249. /**
  9250. * Sets the blur box offset: offset applied during the blur pass.
  9251. * Only useful if useKernelBlur = false
  9252. */
  9253. blurBoxOffset: number;
  9254. private _blurScale;
  9255. /**
  9256. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9257. * 2 means half of the size.
  9258. */
  9259. /**
  9260. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9261. * 2 means half of the size.
  9262. */
  9263. blurScale: number;
  9264. private _blurKernel;
  9265. /**
  9266. * Gets the blur kernel: kernel size of the blur pass.
  9267. * Only useful if useKernelBlur = true
  9268. */
  9269. /**
  9270. * Sets the blur kernel: kernel size of the blur pass.
  9271. * Only useful if useKernelBlur = true
  9272. */
  9273. blurKernel: number;
  9274. private _useKernelBlur;
  9275. /**
  9276. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9277. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9278. */
  9279. /**
  9280. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9281. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9282. */
  9283. useKernelBlur: boolean;
  9284. private _depthScale;
  9285. /**
  9286. * Gets the depth scale used in ESM mode.
  9287. */
  9288. /**
  9289. * Sets the depth scale used in ESM mode.
  9290. * This can override the scale stored on the light.
  9291. */
  9292. depthScale: number;
  9293. private _filter;
  9294. /**
  9295. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9296. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9297. */
  9298. /**
  9299. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9300. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9301. */
  9302. filter: number;
  9303. /**
  9304. * Gets if the current filter is set to Poisson Sampling.
  9305. */
  9306. /**
  9307. * Sets the current filter to Poisson Sampling.
  9308. */
  9309. usePoissonSampling: boolean;
  9310. /**
  9311. * Gets if the current filter is set to ESM.
  9312. */
  9313. /**
  9314. * Sets the current filter is to ESM.
  9315. */
  9316. useExponentialShadowMap: boolean;
  9317. /**
  9318. * Gets if the current filter is set to filtered ESM.
  9319. */
  9320. /**
  9321. * Gets if the current filter is set to filtered ESM.
  9322. */
  9323. useBlurExponentialShadowMap: boolean;
  9324. /**
  9325. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9326. * exponential to prevent steep falloff artifacts).
  9327. */
  9328. /**
  9329. * Sets the current filter to "close ESM" (using the inverse of the
  9330. * exponential to prevent steep falloff artifacts).
  9331. */
  9332. useCloseExponentialShadowMap: boolean;
  9333. /**
  9334. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9335. * exponential to prevent steep falloff artifacts).
  9336. */
  9337. /**
  9338. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9339. * exponential to prevent steep falloff artifacts).
  9340. */
  9341. useBlurCloseExponentialShadowMap: boolean;
  9342. /**
  9343. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9344. */
  9345. /**
  9346. * Sets the current filter to "PCF" (percentage closer filtering).
  9347. */
  9348. usePercentageCloserFiltering: boolean;
  9349. private _filteringQuality;
  9350. /**
  9351. * Gets the PCF or PCSS Quality.
  9352. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9353. */
  9354. /**
  9355. * Sets the PCF or PCSS Quality.
  9356. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9357. */
  9358. filteringQuality: number;
  9359. /**
  9360. * Gets if the current filter is set to "PCSS" (contact hardening).
  9361. */
  9362. /**
  9363. * Sets the current filter to "PCSS" (contact hardening).
  9364. */
  9365. useContactHardeningShadow: boolean;
  9366. private _contactHardeningLightSizeUVRatio;
  9367. /**
  9368. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9369. * Using a ratio helps keeping shape stability independently of the map size.
  9370. *
  9371. * It does not account for the light projection as it was having too much
  9372. * instability during the light setup or during light position changes.
  9373. *
  9374. * Only valid if useContactHardeningShadow is true.
  9375. */
  9376. /**
  9377. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9378. * Using a ratio helps keeping shape stability independently of the map size.
  9379. *
  9380. * It does not account for the light projection as it was having too much
  9381. * instability during the light setup or during light position changes.
  9382. *
  9383. * Only valid if useContactHardeningShadow is true.
  9384. */
  9385. contactHardeningLightSizeUVRatio: number;
  9386. private _darkness;
  9387. /** Gets or sets the actual darkness of a shadow */
  9388. darkness: number;
  9389. /**
  9390. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9391. * 0 means strongest and 1 would means no shadow.
  9392. * @returns the darkness.
  9393. */
  9394. getDarkness(): number;
  9395. /**
  9396. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9397. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9398. * @returns the shadow generator allowing fluent coding.
  9399. */
  9400. setDarkness(darkness: number): ShadowGenerator;
  9401. private _transparencyShadow;
  9402. /** Gets or sets the ability to have transparent shadow */
  9403. transparencyShadow: boolean;
  9404. /**
  9405. * Sets the ability to have transparent shadow (boolean).
  9406. * @param transparent True if transparent else False
  9407. * @returns the shadow generator allowing fluent coding
  9408. */
  9409. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9410. private _shadowMap;
  9411. private _shadowMap2;
  9412. /**
  9413. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9414. * @returns The render target texture if present otherwise, null
  9415. */
  9416. getShadowMap(): Nullable<RenderTargetTexture>;
  9417. /**
  9418. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9419. * @returns The render target texture if the shadow map is present otherwise, null
  9420. */
  9421. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9422. /**
  9423. * Gets the class name of that object
  9424. * @returns "ShadowGenerator"
  9425. */
  9426. getClassName(): string;
  9427. /**
  9428. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9429. * @param mesh Mesh to add
  9430. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9431. * @returns the Shadow Generator itself
  9432. */
  9433. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9434. /**
  9435. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9436. * @param mesh Mesh to remove
  9437. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9438. * @returns the Shadow Generator itself
  9439. */
  9440. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9441. /**
  9442. * Controls the extent to which the shadows fade out at the edge of the frustum
  9443. * Used only by directionals and spots
  9444. */
  9445. frustumEdgeFalloff: number;
  9446. private _light;
  9447. /**
  9448. * Returns the associated light object.
  9449. * @returns the light generating the shadow
  9450. */
  9451. getLight(): IShadowLight;
  9452. /**
  9453. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9454. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9455. * It might on the other hand introduce peter panning.
  9456. */
  9457. forceBackFacesOnly: boolean;
  9458. private _scene;
  9459. private _lightDirection;
  9460. private _effect;
  9461. private _viewMatrix;
  9462. private _projectionMatrix;
  9463. private _transformMatrix;
  9464. private _cachedPosition;
  9465. private _cachedDirection;
  9466. private _cachedDefines;
  9467. private _currentRenderID;
  9468. private _boxBlurPostprocess;
  9469. private _kernelBlurXPostprocess;
  9470. private _kernelBlurYPostprocess;
  9471. private _blurPostProcesses;
  9472. private _mapSize;
  9473. private _currentFaceIndex;
  9474. private _currentFaceIndexCache;
  9475. private _textureType;
  9476. private _defaultTextureMatrix;
  9477. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9478. /**
  9479. * Creates a ShadowGenerator object.
  9480. * A ShadowGenerator is the required tool to use the shadows.
  9481. * Each light casting shadows needs to use its own ShadowGenerator.
  9482. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9483. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9484. * @param light The light object generating the shadows.
  9485. * @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.
  9486. */
  9487. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9488. private _initializeGenerator;
  9489. private _initializeShadowMap;
  9490. private _initializeBlurRTTAndPostProcesses;
  9491. private _renderForShadowMap;
  9492. private _renderSubMeshForShadowMap;
  9493. private _applyFilterValues;
  9494. /**
  9495. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9496. * @param onCompiled Callback triggered at the and of the effects compilation
  9497. * @param options Sets of optional options forcing the compilation with different modes
  9498. */
  9499. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9500. useInstances: boolean;
  9501. }>): void;
  9502. /**
  9503. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9504. * @param options Sets of optional options forcing the compilation with different modes
  9505. * @returns A promise that resolves when the compilation completes
  9506. */
  9507. forceCompilationAsync(options?: Partial<{
  9508. useInstances: boolean;
  9509. }>): Promise<void>;
  9510. /**
  9511. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9512. * @param subMesh The submesh we want to render in the shadow map
  9513. * @param useInstances Defines wether will draw in the map using instances
  9514. * @returns true if ready otherwise, false
  9515. */
  9516. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9517. /**
  9518. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9519. * @param defines Defines of the material we want to update
  9520. * @param lightIndex Index of the light in the enabled light list of the material
  9521. */
  9522. prepareDefines(defines: any, lightIndex: number): void;
  9523. /**
  9524. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9525. * defined in the generator but impacting the effect).
  9526. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9527. * @param effect The effect we are binfing the information for
  9528. */
  9529. bindShadowLight(lightIndex: string, effect: Effect): void;
  9530. /**
  9531. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9532. * (eq to shadow prjection matrix * light transform matrix)
  9533. * @returns The transform matrix used to create the shadow map
  9534. */
  9535. getTransformMatrix(): Matrix;
  9536. /**
  9537. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9538. * Cube and 2D textures for instance.
  9539. */
  9540. recreateShadowMap(): void;
  9541. private _disposeBlurPostProcesses;
  9542. private _disposeRTTandPostProcesses;
  9543. /**
  9544. * Disposes the ShadowGenerator.
  9545. * Returns nothing.
  9546. */
  9547. dispose(): void;
  9548. /**
  9549. * Serializes the shadow generator setup to a json object.
  9550. * @returns The serialized JSON object
  9551. */
  9552. serialize(): any;
  9553. /**
  9554. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9555. * @param parsedShadowGenerator The JSON object to parse
  9556. * @param scene The scene to create the shadow map for
  9557. * @returns The parsed shadow generator
  9558. */
  9559. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9560. }
  9561. }
  9562. declare module BABYLON {
  9563. /**
  9564. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9565. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9566. * 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.
  9567. */
  9568. export abstract class Light extends Node {
  9569. /**
  9570. * Falloff Default: light is falling off following the material specification:
  9571. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9572. */
  9573. static readonly FALLOFF_DEFAULT: number;
  9574. /**
  9575. * Falloff Physical: light is falling off following the inverse squared distance law.
  9576. */
  9577. static readonly FALLOFF_PHYSICAL: number;
  9578. /**
  9579. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9580. * to enhance interoperability with other engines.
  9581. */
  9582. static readonly FALLOFF_GLTF: number;
  9583. /**
  9584. * Falloff Standard: light is falling off like in the standard material
  9585. * to enhance interoperability with other materials.
  9586. */
  9587. static readonly FALLOFF_STANDARD: number;
  9588. /**
  9589. * If every light affecting the material is in this lightmapMode,
  9590. * material.lightmapTexture adds or multiplies
  9591. * (depends on material.useLightmapAsShadowmap)
  9592. * after every other light calculations.
  9593. */
  9594. static readonly LIGHTMAP_DEFAULT: number;
  9595. /**
  9596. * material.lightmapTexture as only diffuse lighting from this light
  9597. * adds only specular lighting from this light
  9598. * adds dynamic shadows
  9599. */
  9600. static readonly LIGHTMAP_SPECULAR: number;
  9601. /**
  9602. * material.lightmapTexture as only lighting
  9603. * no light calculation from this light
  9604. * only adds dynamic shadows from this light
  9605. */
  9606. static readonly LIGHTMAP_SHADOWSONLY: number;
  9607. /**
  9608. * Each light type uses the default quantity according to its type:
  9609. * point/spot lights use luminous intensity
  9610. * directional lights use illuminance
  9611. */
  9612. static readonly INTENSITYMODE_AUTOMATIC: number;
  9613. /**
  9614. * lumen (lm)
  9615. */
  9616. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9617. /**
  9618. * candela (lm/sr)
  9619. */
  9620. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9621. /**
  9622. * lux (lm/m^2)
  9623. */
  9624. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9625. /**
  9626. * nit (cd/m^2)
  9627. */
  9628. static readonly INTENSITYMODE_LUMINANCE: number;
  9629. /**
  9630. * Light type const id of the point light.
  9631. */
  9632. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9633. /**
  9634. * Light type const id of the directional light.
  9635. */
  9636. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9637. /**
  9638. * Light type const id of the spot light.
  9639. */
  9640. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9641. /**
  9642. * Light type const id of the hemispheric light.
  9643. */
  9644. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9645. /**
  9646. * Diffuse gives the basic color to an object.
  9647. */
  9648. diffuse: Color3;
  9649. /**
  9650. * Specular produces a highlight color on an object.
  9651. * Note: This is note affecting PBR materials.
  9652. */
  9653. specular: Color3;
  9654. /**
  9655. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9656. * falling off base on range or angle.
  9657. * This can be set to any values in Light.FALLOFF_x.
  9658. *
  9659. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9660. * other types of materials.
  9661. */
  9662. falloffType: number;
  9663. /**
  9664. * Strength of the light.
  9665. * Note: By default it is define in the framework own unit.
  9666. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9667. */
  9668. intensity: number;
  9669. private _range;
  9670. protected _inverseSquaredRange: number;
  9671. /**
  9672. * Defines how far from the source the light is impacting in scene units.
  9673. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9674. */
  9675. /**
  9676. * Defines how far from the source the light is impacting in scene units.
  9677. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9678. */
  9679. range: number;
  9680. /**
  9681. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9682. * of light.
  9683. */
  9684. private _photometricScale;
  9685. private _intensityMode;
  9686. /**
  9687. * Gets the photometric scale used to interpret the intensity.
  9688. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9689. */
  9690. /**
  9691. * Sets the photometric scale used to interpret the intensity.
  9692. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9693. */
  9694. intensityMode: number;
  9695. private _radius;
  9696. /**
  9697. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9698. */
  9699. /**
  9700. * sets the light radius used by PBR Materials to simulate soft area lights.
  9701. */
  9702. radius: number;
  9703. private _renderPriority;
  9704. /**
  9705. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9706. * exceeding the number allowed of the materials.
  9707. */
  9708. renderPriority: number;
  9709. private _shadowEnabled;
  9710. /**
  9711. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9712. * the current shadow generator.
  9713. */
  9714. /**
  9715. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9716. * the current shadow generator.
  9717. */
  9718. shadowEnabled: boolean;
  9719. private _includedOnlyMeshes;
  9720. /**
  9721. * Gets the only meshes impacted by this light.
  9722. */
  9723. /**
  9724. * Sets the only meshes impacted by this light.
  9725. */
  9726. includedOnlyMeshes: AbstractMesh[];
  9727. private _excludedMeshes;
  9728. /**
  9729. * Gets the meshes not impacted by this light.
  9730. */
  9731. /**
  9732. * Sets the meshes not impacted by this light.
  9733. */
  9734. excludedMeshes: AbstractMesh[];
  9735. private _excludeWithLayerMask;
  9736. /**
  9737. * Gets the layer id use to find what meshes are not impacted by the light.
  9738. * Inactive if 0
  9739. */
  9740. /**
  9741. * Sets the layer id use to find what meshes are not impacted by the light.
  9742. * Inactive if 0
  9743. */
  9744. excludeWithLayerMask: number;
  9745. private _includeOnlyWithLayerMask;
  9746. /**
  9747. * Gets the layer id use to find what meshes are impacted by the light.
  9748. * Inactive if 0
  9749. */
  9750. /**
  9751. * Sets the layer id use to find what meshes are impacted by the light.
  9752. * Inactive if 0
  9753. */
  9754. includeOnlyWithLayerMask: number;
  9755. private _lightmapMode;
  9756. /**
  9757. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9758. */
  9759. /**
  9760. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9761. */
  9762. lightmapMode: number;
  9763. /**
  9764. * Shadow generator associted to the light.
  9765. * @hidden Internal use only.
  9766. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9767. /**
  9768. * @hidden Internal use only.
  9769. */ private _excludedMeshesIds: string[];
  9770. /**
  9771. * @hidden Internal use only.
  9772. */ private _includedOnlyMeshesIds: string[];
  9773. /**
  9774. * The current light unifom buffer.
  9775. * @hidden Internal use only.
  9776. */ private _uniformBuffer: UniformBuffer;
  9777. /**
  9778. * Creates a Light object in the scene.
  9779. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9780. * @param name The firendly name of the light
  9781. * @param scene The scene the light belongs too
  9782. */
  9783. constructor(name: string, scene: Scene);
  9784. protected abstract _buildUniformLayout(): void;
  9785. /**
  9786. * Sets the passed Effect "effect" with the Light information.
  9787. * @param effect The effect to update
  9788. * @param lightIndex The index of the light in the effect to update
  9789. * @returns The light
  9790. */
  9791. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9792. /**
  9793. * Sets the passed Effect "effect" with the Light information.
  9794. * @param effect The effect to update
  9795. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9796. * @returns The light
  9797. */
  9798. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9799. /**
  9800. * Returns the string "Light".
  9801. * @returns the class name
  9802. */
  9803. getClassName(): string;
  9804. /** @hidden */ protected readonly _isLight: boolean;
  9805. /**
  9806. * Converts the light information to a readable string for debug purpose.
  9807. * @param fullDetails Supports for multiple levels of logging within scene loading
  9808. * @returns the human readable light info
  9809. */
  9810. toString(fullDetails?: boolean): string;
  9811. /** @hidden */
  9812. protected _syncParentEnabledState(): void;
  9813. /**
  9814. * Set the enabled state of this node.
  9815. * @param value - the new enabled state
  9816. */
  9817. setEnabled(value: boolean): void;
  9818. /**
  9819. * Returns the Light associated shadow generator if any.
  9820. * @return the associated shadow generator.
  9821. */
  9822. getShadowGenerator(): Nullable<IShadowGenerator>;
  9823. /**
  9824. * Returns a Vector3, the absolute light position in the World.
  9825. * @returns the world space position of the light
  9826. */
  9827. getAbsolutePosition(): Vector3;
  9828. /**
  9829. * Specifies if the light will affect the passed mesh.
  9830. * @param mesh The mesh to test against the light
  9831. * @return true the mesh is affected otherwise, false.
  9832. */
  9833. canAffectMesh(mesh: AbstractMesh): boolean;
  9834. /**
  9835. * Sort function to order lights for rendering.
  9836. * @param a First Light object to compare to second.
  9837. * @param b Second Light object to compare first.
  9838. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9839. */
  9840. static CompareLightsPriority(a: Light, b: Light): number;
  9841. /**
  9842. * Releases resources associated with this node.
  9843. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9844. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9845. */
  9846. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9847. /**
  9848. * Returns the light type ID (integer).
  9849. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9850. */
  9851. getTypeID(): number;
  9852. /**
  9853. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9854. * @returns the scaled intensity in intensity mode unit
  9855. */
  9856. getScaledIntensity(): number;
  9857. /**
  9858. * Returns a new Light object, named "name", from the current one.
  9859. * @param name The name of the cloned light
  9860. * @returns the new created light
  9861. */
  9862. clone(name: string): Nullable<Light>;
  9863. /**
  9864. * Serializes the current light into a Serialization object.
  9865. * @returns the serialized object.
  9866. */
  9867. serialize(): any;
  9868. /**
  9869. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9870. * This new light is named "name" and added to the passed scene.
  9871. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9872. * @param name The friendly name of the light
  9873. * @param scene The scene the new light will belong to
  9874. * @returns the constructor function
  9875. */
  9876. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9877. /**
  9878. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9879. * @param parsedLight The JSON representation of the light
  9880. * @param scene The scene to create the parsed light in
  9881. * @returns the created light after parsing
  9882. */
  9883. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9884. private _hookArrayForExcluded;
  9885. private _hookArrayForIncludedOnly;
  9886. private _resyncMeshes;
  9887. /**
  9888. * Forces the meshes to update their light related information in their rendering used effects
  9889. * @hidden Internal Use Only
  9890. */ private _markMeshesAsLightDirty(): void;
  9891. /**
  9892. * Recomputes the cached photometric scale if needed.
  9893. */
  9894. private _computePhotometricScale;
  9895. /**
  9896. * Returns the Photometric Scale according to the light type and intensity mode.
  9897. */
  9898. private _getPhotometricScale;
  9899. /**
  9900. * Reorder the light in the scene according to their defined priority.
  9901. * @hidden Internal Use Only
  9902. */ private _reorderLightsInScene(): void;
  9903. /**
  9904. * Prepares the list of defines specific to the light type.
  9905. * @param defines the list of defines
  9906. * @param lightIndex defines the index of the light for the effect
  9907. */
  9908. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9909. }
  9910. }
  9911. declare module BABYLON {
  9912. /**
  9913. * Interface used to define Action
  9914. */
  9915. export interface IAction {
  9916. /**
  9917. * Trigger for the action
  9918. */
  9919. trigger: number;
  9920. /** Options of the trigger */
  9921. triggerOptions: any;
  9922. /**
  9923. * Gets the trigger parameters
  9924. * @returns the trigger parameters
  9925. */
  9926. getTriggerParameter(): any;
  9927. /**
  9928. * Internal only - executes current action event
  9929. * @hidden
  9930. */ private _executeCurrent(evt?: ActionEvent): void;
  9931. /**
  9932. * Serialize placeholder for child classes
  9933. * @param parent of child
  9934. * @returns the serialized object
  9935. */
  9936. serialize(parent: any): any;
  9937. /**
  9938. * Internal only
  9939. * @hidden
  9940. */ private _prepare(): void;
  9941. /**
  9942. * Internal only - manager for action
  9943. * @hidden
  9944. */ private _actionManager: AbstractActionManager;
  9945. /**
  9946. * Adds action to chain of actions, may be a DoNothingAction
  9947. * @param action defines the next action to execute
  9948. * @returns The action passed in
  9949. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9950. */
  9951. then(action: IAction): IAction;
  9952. }
  9953. /**
  9954. * The action to be carried out following a trigger
  9955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9956. */
  9957. export class Action implements IAction {
  9958. /** the trigger, with or without parameters, for the action */
  9959. triggerOptions: any;
  9960. /**
  9961. * Trigger for the action
  9962. */
  9963. trigger: number;
  9964. /**
  9965. * Internal only - manager for action
  9966. * @hidden
  9967. */ private _actionManager: ActionManager;
  9968. private _nextActiveAction;
  9969. private _child;
  9970. private _condition?;
  9971. private _triggerParameter;
  9972. /**
  9973. * An event triggered prior to action being executed.
  9974. */
  9975. onBeforeExecuteObservable: Observable<Action>;
  9976. /**
  9977. * Creates a new Action
  9978. * @param triggerOptions the trigger, with or without parameters, for the action
  9979. * @param condition an optional determinant of action
  9980. */
  9981. constructor(
  9982. /** the trigger, with or without parameters, for the action */
  9983. triggerOptions: any, condition?: Condition);
  9984. /**
  9985. * Internal only
  9986. * @hidden
  9987. */ private _prepare(): void;
  9988. /**
  9989. * Gets the trigger parameters
  9990. * @returns the trigger parameters
  9991. */
  9992. getTriggerParameter(): any;
  9993. /**
  9994. * Internal only - executes current action event
  9995. * @hidden
  9996. */ private _executeCurrent(evt?: ActionEvent): void;
  9997. /**
  9998. * Execute placeholder for child classes
  9999. * @param evt optional action event
  10000. */
  10001. execute(evt?: ActionEvent): void;
  10002. /**
  10003. * Skips to next active action
  10004. */
  10005. skipToNextActiveAction(): void;
  10006. /**
  10007. * Adds action to chain of actions, may be a DoNothingAction
  10008. * @param action defines the next action to execute
  10009. * @returns The action passed in
  10010. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10011. */
  10012. then(action: Action): Action;
  10013. /**
  10014. * Internal only
  10015. * @hidden
  10016. */ private _getProperty(propertyPath: string): string;
  10017. /**
  10018. * Internal only
  10019. * @hidden
  10020. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10021. /**
  10022. * Serialize placeholder for child classes
  10023. * @param parent of child
  10024. * @returns the serialized object
  10025. */
  10026. serialize(parent: any): any;
  10027. /**
  10028. * Internal only called by serialize
  10029. * @hidden
  10030. */
  10031. protected _serialize(serializedAction: any, parent?: any): any;
  10032. /**
  10033. * Internal only
  10034. * @hidden
  10035. */ private static _SerializeValueAsString: (value: any) => string;
  10036. /**
  10037. * Internal only
  10038. * @hidden
  10039. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10040. name: string;
  10041. targetType: string;
  10042. value: string;
  10043. };
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * A Condition applied to an Action
  10049. */
  10050. export class Condition {
  10051. /**
  10052. * Internal only - manager for action
  10053. * @hidden
  10054. */ private _actionManager: ActionManager;
  10055. /**
  10056. * Internal only
  10057. * @hidden
  10058. */ private _evaluationId: number;
  10059. /**
  10060. * Internal only
  10061. * @hidden
  10062. */ private _currentResult: boolean;
  10063. /**
  10064. * Creates a new Condition
  10065. * @param actionManager the manager of the action the condition is applied to
  10066. */
  10067. constructor(actionManager: ActionManager);
  10068. /**
  10069. * Check if the current condition is valid
  10070. * @returns a boolean
  10071. */
  10072. isValid(): boolean;
  10073. /**
  10074. * Internal only
  10075. * @hidden
  10076. */ private _getProperty(propertyPath: string): string;
  10077. /**
  10078. * Internal only
  10079. * @hidden
  10080. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10081. /**
  10082. * Serialize placeholder for child classes
  10083. * @returns the serialized object
  10084. */
  10085. serialize(): any;
  10086. /**
  10087. * Internal only
  10088. * @hidden
  10089. */
  10090. protected _serialize(serializedCondition: any): any;
  10091. }
  10092. /**
  10093. * Defines specific conditional operators as extensions of Condition
  10094. */
  10095. export class ValueCondition extends Condition {
  10096. /** path to specify the property of the target the conditional operator uses */
  10097. propertyPath: string;
  10098. /** the value compared by the conditional operator against the current value of the property */
  10099. value: any;
  10100. /** the conditional operator, default ValueCondition.IsEqual */
  10101. operator: number;
  10102. /**
  10103. * Internal only
  10104. * @hidden
  10105. */
  10106. private static _IsEqual;
  10107. /**
  10108. * Internal only
  10109. * @hidden
  10110. */
  10111. private static _IsDifferent;
  10112. /**
  10113. * Internal only
  10114. * @hidden
  10115. */
  10116. private static _IsGreater;
  10117. /**
  10118. * Internal only
  10119. * @hidden
  10120. */
  10121. private static _IsLesser;
  10122. /**
  10123. * returns the number for IsEqual
  10124. */
  10125. static readonly IsEqual: number;
  10126. /**
  10127. * Returns the number for IsDifferent
  10128. */
  10129. static readonly IsDifferent: number;
  10130. /**
  10131. * Returns the number for IsGreater
  10132. */
  10133. static readonly IsGreater: number;
  10134. /**
  10135. * Returns the number for IsLesser
  10136. */
  10137. static readonly IsLesser: number;
  10138. /**
  10139. * Internal only The action manager for the condition
  10140. * @hidden
  10141. */ private _actionManager: ActionManager;
  10142. /**
  10143. * Internal only
  10144. * @hidden
  10145. */
  10146. private _target;
  10147. /**
  10148. * Internal only
  10149. * @hidden
  10150. */
  10151. private _effectiveTarget;
  10152. /**
  10153. * Internal only
  10154. * @hidden
  10155. */
  10156. private _property;
  10157. /**
  10158. * Creates a new ValueCondition
  10159. * @param actionManager manager for the action the condition applies to
  10160. * @param target for the action
  10161. * @param propertyPath path to specify the property of the target the conditional operator uses
  10162. * @param value the value compared by the conditional operator against the current value of the property
  10163. * @param operator the conditional operator, default ValueCondition.IsEqual
  10164. */
  10165. constructor(actionManager: ActionManager, target: any,
  10166. /** path to specify the property of the target the conditional operator uses */
  10167. propertyPath: string,
  10168. /** the value compared by the conditional operator against the current value of the property */
  10169. value: any,
  10170. /** the conditional operator, default ValueCondition.IsEqual */
  10171. operator?: number);
  10172. /**
  10173. * Compares the given value with the property value for the specified conditional operator
  10174. * @returns the result of the comparison
  10175. */
  10176. isValid(): boolean;
  10177. /**
  10178. * Serialize the ValueCondition into a JSON compatible object
  10179. * @returns serialization object
  10180. */
  10181. serialize(): any;
  10182. /**
  10183. * Gets the name of the conditional operator for the ValueCondition
  10184. * @param operator the conditional operator
  10185. * @returns the name
  10186. */
  10187. static GetOperatorName(operator: number): string;
  10188. }
  10189. /**
  10190. * Defines a predicate condition as an extension of Condition
  10191. */
  10192. export class PredicateCondition extends Condition {
  10193. /** defines the predicate function used to validate the condition */
  10194. predicate: () => boolean;
  10195. /**
  10196. * Internal only - manager for action
  10197. * @hidden
  10198. */ private _actionManager: ActionManager;
  10199. /**
  10200. * Creates a new PredicateCondition
  10201. * @param actionManager manager for the action the condition applies to
  10202. * @param predicate defines the predicate function used to validate the condition
  10203. */
  10204. constructor(actionManager: ActionManager,
  10205. /** defines the predicate function used to validate the condition */
  10206. predicate: () => boolean);
  10207. /**
  10208. * @returns the validity of the predicate condition
  10209. */
  10210. isValid(): boolean;
  10211. }
  10212. /**
  10213. * Defines a state condition as an extension of Condition
  10214. */
  10215. export class StateCondition extends Condition {
  10216. /** Value to compare with target state */
  10217. value: string;
  10218. /**
  10219. * Internal only - manager for action
  10220. * @hidden
  10221. */ private _actionManager: ActionManager;
  10222. /**
  10223. * Internal only
  10224. * @hidden
  10225. */
  10226. private _target;
  10227. /**
  10228. * Creates a new StateCondition
  10229. * @param actionManager manager for the action the condition applies to
  10230. * @param target of the condition
  10231. * @param value to compare with target state
  10232. */
  10233. constructor(actionManager: ActionManager, target: any,
  10234. /** Value to compare with target state */
  10235. value: string);
  10236. /**
  10237. * Gets a boolean indicating if the current condition is met
  10238. * @returns the validity of the state
  10239. */
  10240. isValid(): boolean;
  10241. /**
  10242. * Serialize the StateCondition into a JSON compatible object
  10243. * @returns serialization object
  10244. */
  10245. serialize(): any;
  10246. }
  10247. }
  10248. declare module BABYLON {
  10249. /**
  10250. * This defines an action responsible to toggle a boolean once triggered.
  10251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10252. */
  10253. export class SwitchBooleanAction extends Action {
  10254. /**
  10255. * The path to the boolean property in the target object
  10256. */
  10257. propertyPath: string;
  10258. private _target;
  10259. private _effectiveTarget;
  10260. private _property;
  10261. /**
  10262. * Instantiate the action
  10263. * @param triggerOptions defines the trigger options
  10264. * @param target defines the object containing the boolean
  10265. * @param propertyPath defines the path to the boolean property in the target object
  10266. * @param condition defines the trigger related conditions
  10267. */
  10268. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10269. /** @hidden */ private _prepare(): void;
  10270. /**
  10271. * Execute the action toggle the boolean value.
  10272. */
  10273. execute(): void;
  10274. /**
  10275. * Serializes the actions and its related information.
  10276. * @param parent defines the object to serialize in
  10277. * @returns the serialized object
  10278. */
  10279. serialize(parent: any): any;
  10280. }
  10281. /**
  10282. * This defines an action responsible to set a the state field of the target
  10283. * to a desired value once triggered.
  10284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10285. */
  10286. export class SetStateAction extends Action {
  10287. /**
  10288. * The value to store in the state field.
  10289. */
  10290. value: string;
  10291. private _target;
  10292. /**
  10293. * Instantiate the action
  10294. * @param triggerOptions defines the trigger options
  10295. * @param target defines the object containing the state property
  10296. * @param value defines the value to store in the state field
  10297. * @param condition defines the trigger related conditions
  10298. */
  10299. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10300. /**
  10301. * Execute the action and store the value on the target state property.
  10302. */
  10303. execute(): void;
  10304. /**
  10305. * Serializes the actions and its related information.
  10306. * @param parent defines the object to serialize in
  10307. * @returns the serialized object
  10308. */
  10309. serialize(parent: any): any;
  10310. }
  10311. /**
  10312. * This defines an action responsible to set a property of the target
  10313. * to a desired value once triggered.
  10314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10315. */
  10316. export class SetValueAction extends Action {
  10317. /**
  10318. * The path of the property to set in the target.
  10319. */
  10320. propertyPath: string;
  10321. /**
  10322. * The value to set in the property
  10323. */
  10324. value: any;
  10325. private _target;
  10326. private _effectiveTarget;
  10327. private _property;
  10328. /**
  10329. * Instantiate the action
  10330. * @param triggerOptions defines the trigger options
  10331. * @param target defines the object containing the property
  10332. * @param propertyPath defines the path of the property to set in the target
  10333. * @param value defines the value to set in the property
  10334. * @param condition defines the trigger related conditions
  10335. */
  10336. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10337. /** @hidden */ private _prepare(): void;
  10338. /**
  10339. * Execute the action and set the targetted property to the desired value.
  10340. */
  10341. execute(): void;
  10342. /**
  10343. * Serializes the actions and its related information.
  10344. * @param parent defines the object to serialize in
  10345. * @returns the serialized object
  10346. */
  10347. serialize(parent: any): any;
  10348. }
  10349. /**
  10350. * This defines an action responsible to increment the target value
  10351. * to a desired value once triggered.
  10352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10353. */
  10354. export class IncrementValueAction extends Action {
  10355. /**
  10356. * The path of the property to increment in the target.
  10357. */
  10358. propertyPath: string;
  10359. /**
  10360. * The value we should increment the property by.
  10361. */
  10362. value: any;
  10363. private _target;
  10364. private _effectiveTarget;
  10365. private _property;
  10366. /**
  10367. * Instantiate the action
  10368. * @param triggerOptions defines the trigger options
  10369. * @param target defines the object containing the property
  10370. * @param propertyPath defines the path of the property to increment in the target
  10371. * @param value defines the value value we should increment the property by
  10372. * @param condition defines the trigger related conditions
  10373. */
  10374. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10375. /** @hidden */ private _prepare(): void;
  10376. /**
  10377. * Execute the action and increment the target of the value amount.
  10378. */
  10379. execute(): void;
  10380. /**
  10381. * Serializes the actions and its related information.
  10382. * @param parent defines the object to serialize in
  10383. * @returns the serialized object
  10384. */
  10385. serialize(parent: any): any;
  10386. }
  10387. /**
  10388. * This defines an action responsible to start an animation once triggered.
  10389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10390. */
  10391. export class PlayAnimationAction extends Action {
  10392. /**
  10393. * Where the animation should start (animation frame)
  10394. */
  10395. from: number;
  10396. /**
  10397. * Where the animation should stop (animation frame)
  10398. */
  10399. to: number;
  10400. /**
  10401. * Define if the animation should loop or stop after the first play.
  10402. */
  10403. loop?: boolean;
  10404. private _target;
  10405. /**
  10406. * Instantiate the action
  10407. * @param triggerOptions defines the trigger options
  10408. * @param target defines the target animation or animation name
  10409. * @param from defines from where the animation should start (animation frame)
  10410. * @param end defines where the animation should stop (animation frame)
  10411. * @param loop defines if the animation should loop or stop after the first play
  10412. * @param condition defines the trigger related conditions
  10413. */
  10414. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10415. /** @hidden */ private _prepare(): void;
  10416. /**
  10417. * Execute the action and play the animation.
  10418. */
  10419. execute(): void;
  10420. /**
  10421. * Serializes the actions and its related information.
  10422. * @param parent defines the object to serialize in
  10423. * @returns the serialized object
  10424. */
  10425. serialize(parent: any): any;
  10426. }
  10427. /**
  10428. * This defines an action responsible to stop an animation once triggered.
  10429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10430. */
  10431. export class StopAnimationAction extends Action {
  10432. private _target;
  10433. /**
  10434. * Instantiate the action
  10435. * @param triggerOptions defines the trigger options
  10436. * @param target defines the target animation or animation name
  10437. * @param condition defines the trigger related conditions
  10438. */
  10439. constructor(triggerOptions: any, target: any, condition?: Condition);
  10440. /** @hidden */ private _prepare(): void;
  10441. /**
  10442. * Execute the action and stop the animation.
  10443. */
  10444. execute(): void;
  10445. /**
  10446. * Serializes the actions and its related information.
  10447. * @param parent defines the object to serialize in
  10448. * @returns the serialized object
  10449. */
  10450. serialize(parent: any): any;
  10451. }
  10452. /**
  10453. * This defines an action responsible that does nothing once triggered.
  10454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10455. */
  10456. export class DoNothingAction extends Action {
  10457. /**
  10458. * Instantiate the action
  10459. * @param triggerOptions defines the trigger options
  10460. * @param condition defines the trigger related conditions
  10461. */
  10462. constructor(triggerOptions?: any, condition?: Condition);
  10463. /**
  10464. * Execute the action and do nothing.
  10465. */
  10466. execute(): void;
  10467. /**
  10468. * Serializes the actions and its related information.
  10469. * @param parent defines the object to serialize in
  10470. * @returns the serialized object
  10471. */
  10472. serialize(parent: any): any;
  10473. }
  10474. /**
  10475. * This defines an action responsible to trigger several actions once triggered.
  10476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10477. */
  10478. export class CombineAction extends Action {
  10479. /**
  10480. * The list of aggregated animations to run.
  10481. */
  10482. children: Action[];
  10483. /**
  10484. * Instantiate the action
  10485. * @param triggerOptions defines the trigger options
  10486. * @param children defines the list of aggregated animations to run
  10487. * @param condition defines the trigger related conditions
  10488. */
  10489. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10490. /** @hidden */ private _prepare(): void;
  10491. /**
  10492. * Execute the action and executes all the aggregated actions.
  10493. */
  10494. execute(evt: ActionEvent): void;
  10495. /**
  10496. * Serializes the actions and its related information.
  10497. * @param parent defines the object to serialize in
  10498. * @returns the serialized object
  10499. */
  10500. serialize(parent: any): any;
  10501. }
  10502. /**
  10503. * This defines an action responsible to run code (external event) once triggered.
  10504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10505. */
  10506. export class ExecuteCodeAction extends Action {
  10507. /**
  10508. * The callback function to run.
  10509. */
  10510. func: (evt: ActionEvent) => void;
  10511. /**
  10512. * Instantiate the action
  10513. * @param triggerOptions defines the trigger options
  10514. * @param func defines the callback function to run
  10515. * @param condition defines the trigger related conditions
  10516. */
  10517. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10518. /**
  10519. * Execute the action and run the attached code.
  10520. */
  10521. execute(evt: ActionEvent): void;
  10522. }
  10523. /**
  10524. * This defines an action responsible to set the parent property of the target once triggered.
  10525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10526. */
  10527. export class SetParentAction extends Action {
  10528. private _parent;
  10529. private _target;
  10530. /**
  10531. * Instantiate the action
  10532. * @param triggerOptions defines the trigger options
  10533. * @param target defines the target containing the parent property
  10534. * @param parent defines from where the animation should start (animation frame)
  10535. * @param condition defines the trigger related conditions
  10536. */
  10537. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10538. /** @hidden */ private _prepare(): void;
  10539. /**
  10540. * Execute the action and set the parent property.
  10541. */
  10542. execute(): void;
  10543. /**
  10544. * Serializes the actions and its related information.
  10545. * @param parent defines the object to serialize in
  10546. * @returns the serialized object
  10547. */
  10548. serialize(parent: any): any;
  10549. }
  10550. }
  10551. declare module BABYLON {
  10552. /**
  10553. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10554. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10556. */
  10557. export class ActionManager extends AbstractActionManager {
  10558. /**
  10559. * Nothing
  10560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10561. */
  10562. static readonly NothingTrigger: number;
  10563. /**
  10564. * On pick
  10565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10566. */
  10567. static readonly OnPickTrigger: number;
  10568. /**
  10569. * On left pick
  10570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10571. */
  10572. static readonly OnLeftPickTrigger: number;
  10573. /**
  10574. * On right pick
  10575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10576. */
  10577. static readonly OnRightPickTrigger: number;
  10578. /**
  10579. * On center pick
  10580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10581. */
  10582. static readonly OnCenterPickTrigger: number;
  10583. /**
  10584. * On pick down
  10585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10586. */
  10587. static readonly OnPickDownTrigger: number;
  10588. /**
  10589. * On double pick
  10590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10591. */
  10592. static readonly OnDoublePickTrigger: number;
  10593. /**
  10594. * On pick up
  10595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10596. */
  10597. static readonly OnPickUpTrigger: number;
  10598. /**
  10599. * On pick out.
  10600. * This trigger will only be raised if you also declared a OnPickDown
  10601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10602. */
  10603. static readonly OnPickOutTrigger: number;
  10604. /**
  10605. * On long press
  10606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10607. */
  10608. static readonly OnLongPressTrigger: number;
  10609. /**
  10610. * On pointer over
  10611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10612. */
  10613. static readonly OnPointerOverTrigger: number;
  10614. /**
  10615. * On pointer out
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10617. */
  10618. static readonly OnPointerOutTrigger: number;
  10619. /**
  10620. * On every frame
  10621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10622. */
  10623. static readonly OnEveryFrameTrigger: number;
  10624. /**
  10625. * On intersection enter
  10626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10627. */
  10628. static readonly OnIntersectionEnterTrigger: number;
  10629. /**
  10630. * On intersection exit
  10631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10632. */
  10633. static readonly OnIntersectionExitTrigger: number;
  10634. /**
  10635. * On key down
  10636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10637. */
  10638. static readonly OnKeyDownTrigger: number;
  10639. /**
  10640. * On key up
  10641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10642. */
  10643. static readonly OnKeyUpTrigger: number;
  10644. private _scene;
  10645. /**
  10646. * Creates a new action manager
  10647. * @param scene defines the hosting scene
  10648. */
  10649. constructor(scene: Scene);
  10650. /**
  10651. * Releases all associated resources
  10652. */
  10653. dispose(): void;
  10654. /**
  10655. * Gets hosting scene
  10656. * @returns the hosting scene
  10657. */
  10658. getScene(): Scene;
  10659. /**
  10660. * Does this action manager handles actions of any of the given triggers
  10661. * @param triggers defines the triggers to be tested
  10662. * @return a boolean indicating whether one (or more) of the triggers is handled
  10663. */
  10664. hasSpecificTriggers(triggers: number[]): boolean;
  10665. /**
  10666. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10667. * speed.
  10668. * @param triggerA defines the trigger to be tested
  10669. * @param triggerB defines the trigger to be tested
  10670. * @return a boolean indicating whether one (or more) of the triggers is handled
  10671. */
  10672. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10673. /**
  10674. * Does this action manager handles actions of a given trigger
  10675. * @param trigger defines the trigger to be tested
  10676. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10677. * @return whether the trigger is handled
  10678. */
  10679. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10680. /**
  10681. * Does this action manager has pointer triggers
  10682. */
  10683. readonly hasPointerTriggers: boolean;
  10684. /**
  10685. * Does this action manager has pick triggers
  10686. */
  10687. readonly hasPickTriggers: boolean;
  10688. /**
  10689. * Registers an action to this action manager
  10690. * @param action defines the action to be registered
  10691. * @return the action amended (prepared) after registration
  10692. */
  10693. registerAction(action: IAction): Nullable<IAction>;
  10694. /**
  10695. * Unregisters an action to this action manager
  10696. * @param action defines the action to be unregistered
  10697. * @return a boolean indicating whether the action has been unregistered
  10698. */
  10699. unregisterAction(action: IAction): Boolean;
  10700. /**
  10701. * Process a specific trigger
  10702. * @param trigger defines the trigger to process
  10703. * @param evt defines the event details to be processed
  10704. */
  10705. processTrigger(trigger: number, evt?: IActionEvent): void;
  10706. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10707. /** @hidden */ private _getProperty(propertyPath: string): string;
  10708. /**
  10709. * Serialize this manager to a JSON object
  10710. * @param name defines the property name to store this manager
  10711. * @returns a JSON representation of this manager
  10712. */
  10713. serialize(name: string): any;
  10714. /**
  10715. * Creates a new ActionManager from a JSON data
  10716. * @param parsedActions defines the JSON data to read from
  10717. * @param object defines the hosting mesh
  10718. * @param scene defines the hosting scene
  10719. */
  10720. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10721. /**
  10722. * Get a trigger name by index
  10723. * @param trigger defines the trigger index
  10724. * @returns a trigger name
  10725. */
  10726. static GetTriggerName(trigger: number): string;
  10727. }
  10728. }
  10729. declare module BABYLON {
  10730. /**
  10731. * Class representing a ray with position and direction
  10732. */
  10733. export class Ray {
  10734. /** origin point */
  10735. origin: Vector3;
  10736. /** direction */
  10737. direction: Vector3;
  10738. /** length of the ray */
  10739. length: number;
  10740. private static readonly TmpVector3;
  10741. private _tmpRay;
  10742. /**
  10743. * Creates a new ray
  10744. * @param origin origin point
  10745. * @param direction direction
  10746. * @param length length of the ray
  10747. */
  10748. constructor(
  10749. /** origin point */
  10750. origin: Vector3,
  10751. /** direction */
  10752. direction: Vector3,
  10753. /** length of the ray */
  10754. length?: number);
  10755. /**
  10756. * Checks if the ray intersects a box
  10757. * @param minimum bound of the box
  10758. * @param maximum bound of the box
  10759. * @param intersectionTreshold extra extend to be added to the box in all direction
  10760. * @returns if the box was hit
  10761. */
  10762. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10763. /**
  10764. * Checks if the ray intersects a box
  10765. * @param box the bounding box to check
  10766. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10767. * @returns if the box was hit
  10768. */
  10769. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10770. /**
  10771. * If the ray hits a sphere
  10772. * @param sphere the bounding sphere to check
  10773. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10774. * @returns true if it hits the sphere
  10775. */
  10776. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10777. /**
  10778. * If the ray hits a triange
  10779. * @param vertex0 triangle vertex
  10780. * @param vertex1 triangle vertex
  10781. * @param vertex2 triangle vertex
  10782. * @returns intersection information if hit
  10783. */
  10784. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10785. /**
  10786. * Checks if ray intersects a plane
  10787. * @param plane the plane to check
  10788. * @returns the distance away it was hit
  10789. */
  10790. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10791. /**
  10792. * Calculate the intercept of a ray on a given axis
  10793. * @param axis to check 'x' | 'y' | 'z'
  10794. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10795. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10796. */
  10797. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10798. /**
  10799. * Checks if ray intersects a mesh
  10800. * @param mesh the mesh to check
  10801. * @param fastCheck if only the bounding box should checked
  10802. * @returns picking info of the intersecton
  10803. */
  10804. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10805. /**
  10806. * Checks if ray intersects a mesh
  10807. * @param meshes the meshes to check
  10808. * @param fastCheck if only the bounding box should checked
  10809. * @param results array to store result in
  10810. * @returns Array of picking infos
  10811. */
  10812. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10813. private _comparePickingInfo;
  10814. private static smallnum;
  10815. private static rayl;
  10816. /**
  10817. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10818. * @param sega the first point of the segment to test the intersection against
  10819. * @param segb the second point of the segment to test the intersection against
  10820. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10821. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10822. */
  10823. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10824. /**
  10825. * Update the ray from viewport position
  10826. * @param x position
  10827. * @param y y position
  10828. * @param viewportWidth viewport width
  10829. * @param viewportHeight viewport height
  10830. * @param world world matrix
  10831. * @param view view matrix
  10832. * @param projection projection matrix
  10833. * @returns this ray updated
  10834. */
  10835. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10836. /**
  10837. * Creates a ray with origin and direction of 0,0,0
  10838. * @returns the new ray
  10839. */
  10840. static Zero(): Ray;
  10841. /**
  10842. * Creates a new ray from screen space and viewport
  10843. * @param x position
  10844. * @param y y position
  10845. * @param viewportWidth viewport width
  10846. * @param viewportHeight viewport height
  10847. * @param world world matrix
  10848. * @param view view matrix
  10849. * @param projection projection matrix
  10850. * @returns new ray
  10851. */
  10852. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10853. /**
  10854. * 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
  10855. * transformed to the given world matrix.
  10856. * @param origin The origin point
  10857. * @param end The end point
  10858. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10859. * @returns the new ray
  10860. */
  10861. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10862. /**
  10863. * Transforms a ray by a matrix
  10864. * @param ray ray to transform
  10865. * @param matrix matrix to apply
  10866. * @returns the resulting new ray
  10867. */
  10868. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10869. /**
  10870. * Transforms a ray by a matrix
  10871. * @param ray ray to transform
  10872. * @param matrix matrix to apply
  10873. * @param result ray to store result in
  10874. */
  10875. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10876. /**
  10877. * Unproject a ray from screen space to object space
  10878. * @param sourceX defines the screen space x coordinate to use
  10879. * @param sourceY defines the screen space y coordinate to use
  10880. * @param viewportWidth defines the current width of the viewport
  10881. * @param viewportHeight defines the current height of the viewport
  10882. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10883. * @param view defines the view matrix to use
  10884. * @param projection defines the projection matrix to use
  10885. */
  10886. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10887. }
  10888. /**
  10889. * Type used to define predicate used to select faces when a mesh intersection is detected
  10890. */
  10891. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10892. interface Scene {
  10893. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  10894. /** @hidden */ private _cachedRayForTransform: Ray;
  10895. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  10896. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10897. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10898. }
  10899. }
  10900. declare module BABYLON {
  10901. /**
  10902. * Groups all the scene component constants in one place to ease maintenance.
  10903. * @hidden
  10904. */
  10905. export class SceneComponentConstants {
  10906. static readonly NAME_EFFECTLAYER: string;
  10907. static readonly NAME_LAYER: string;
  10908. static readonly NAME_LENSFLARESYSTEM: string;
  10909. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10910. static readonly NAME_PARTICLESYSTEM: string;
  10911. static readonly NAME_GAMEPAD: string;
  10912. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10913. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10914. static readonly NAME_DEPTHRENDERER: string;
  10915. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10916. static readonly NAME_SPRITE: string;
  10917. static readonly NAME_OUTLINERENDERER: string;
  10918. static readonly NAME_PROCEDURALTEXTURE: string;
  10919. static readonly NAME_SHADOWGENERATOR: string;
  10920. static readonly NAME_OCTREE: string;
  10921. static readonly NAME_PHYSICSENGINE: string;
  10922. static readonly NAME_AUDIO: string;
  10923. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10924. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10925. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10926. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10927. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10928. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10929. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10930. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10931. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10932. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10933. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10934. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10935. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10936. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10937. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10938. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10939. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10940. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10941. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10942. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10943. static readonly STEP_AFTERRENDER_AUDIO: number;
  10944. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10945. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10946. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10947. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10948. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10949. static readonly STEP_POINTERMOVE_SPRITE: number;
  10950. static readonly STEP_POINTERDOWN_SPRITE: number;
  10951. static readonly STEP_POINTERUP_SPRITE: number;
  10952. }
  10953. /**
  10954. * This represents a scene component.
  10955. *
  10956. * This is used to decouple the dependency the scene is having on the different workloads like
  10957. * layers, post processes...
  10958. */
  10959. export interface ISceneComponent {
  10960. /**
  10961. * The name of the component. Each component must have a unique name.
  10962. */
  10963. name: string;
  10964. /**
  10965. * The scene the component belongs to.
  10966. */
  10967. scene: Scene;
  10968. /**
  10969. * Register the component to one instance of a scene.
  10970. */
  10971. register(): void;
  10972. /**
  10973. * Rebuilds the elements related to this component in case of
  10974. * context lost for instance.
  10975. */
  10976. rebuild(): void;
  10977. /**
  10978. * Disposes the component and the associated ressources.
  10979. */
  10980. dispose(): void;
  10981. }
  10982. /**
  10983. * This represents a SERIALIZABLE scene component.
  10984. *
  10985. * This extends Scene Component to add Serialization methods on top.
  10986. */
  10987. export interface ISceneSerializableComponent extends ISceneComponent {
  10988. /**
  10989. * Adds all the elements from the container to the scene
  10990. * @param container the container holding the elements
  10991. */
  10992. addFromContainer(container: AbstractScene): void;
  10993. /**
  10994. * Removes all the elements in the container from the scene
  10995. * @param container contains the elements to remove
  10996. * @param dispose if the removed element should be disposed (default: false)
  10997. */
  10998. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10999. /**
  11000. * Serializes the component data to the specified json object
  11001. * @param serializationObject The object to serialize to
  11002. */
  11003. serialize(serializationObject: any): void;
  11004. }
  11005. /**
  11006. * Strong typing of a Mesh related stage step action
  11007. */
  11008. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11009. /**
  11010. * Strong typing of a Evaluate Sub Mesh related stage step action
  11011. */
  11012. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11013. /**
  11014. * Strong typing of a Active Mesh related stage step action
  11015. */
  11016. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11017. /**
  11018. * Strong typing of a Camera related stage step action
  11019. */
  11020. export type CameraStageAction = (camera: Camera) => void;
  11021. /**
  11022. * Strong typing of a Camera Frame buffer related stage step action
  11023. */
  11024. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11025. /**
  11026. * Strong typing of a Render Target related stage step action
  11027. */
  11028. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11029. /**
  11030. * Strong typing of a RenderingGroup related stage step action
  11031. */
  11032. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11033. /**
  11034. * Strong typing of a Mesh Render related stage step action
  11035. */
  11036. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11037. /**
  11038. * Strong typing of a simple stage step action
  11039. */
  11040. export type SimpleStageAction = () => void;
  11041. /**
  11042. * Strong typing of a render target action.
  11043. */
  11044. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11045. /**
  11046. * Strong typing of a pointer move action.
  11047. */
  11048. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11049. /**
  11050. * Strong typing of a pointer up/down action.
  11051. */
  11052. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11053. /**
  11054. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11055. * @hidden
  11056. */
  11057. export class Stage<T extends Function> extends Array<{
  11058. index: number;
  11059. component: ISceneComponent;
  11060. action: T;
  11061. }> {
  11062. /**
  11063. * Hide ctor from the rest of the world.
  11064. * @param items The items to add.
  11065. */
  11066. private constructor();
  11067. /**
  11068. * Creates a new Stage.
  11069. * @returns A new instance of a Stage
  11070. */
  11071. static Create<T extends Function>(): Stage<T>;
  11072. /**
  11073. * Registers a step in an ordered way in the targeted stage.
  11074. * @param index Defines the position to register the step in
  11075. * @param component Defines the component attached to the step
  11076. * @param action Defines the action to launch during the step
  11077. */
  11078. registerStep(index: number, component: ISceneComponent, action: T): void;
  11079. /**
  11080. * Clears all the steps from the stage.
  11081. */
  11082. clear(): void;
  11083. }
  11084. }
  11085. declare module BABYLON {
  11086. interface Scene {
  11087. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11088. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11089. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11090. /**
  11091. * All of the sprite managers added to this scene
  11092. * @see http://doc.babylonjs.com/babylon101/sprites
  11093. */
  11094. spriteManagers: Array<ISpriteManager>;
  11095. /**
  11096. * An event triggered when sprites rendering is about to start
  11097. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11098. */
  11099. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11100. /**
  11101. * An event triggered when sprites rendering is done
  11102. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11103. */
  11104. onAfterSpritesRenderingObservable: Observable<Scene>;
  11105. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11106. /** Launch a ray to try to pick a sprite in the scene
  11107. * @param x position on screen
  11108. * @param y position on screen
  11109. * @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
  11110. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11111. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11112. * @returns a PickingInfo
  11113. */
  11114. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11115. /** Use the given ray to pick a sprite in the scene
  11116. * @param ray The ray (in world space) to use to pick meshes
  11117. * @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
  11118. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11119. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11120. * @returns a PickingInfo
  11121. */
  11122. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11123. /** @hidden */ private _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11124. /** Launch a ray to try to pick sprites in the scene
  11125. * @param x position on screen
  11126. * @param y position on screen
  11127. * @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
  11128. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11129. * @returns a PickingInfo array
  11130. */
  11131. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11132. /** Use the given ray to pick sprites in the scene
  11133. * @param ray The ray (in world space) to use to pick meshes
  11134. * @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
  11135. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11136. * @returns a PickingInfo array
  11137. */
  11138. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11139. /**
  11140. * Force the sprite under the pointer
  11141. * @param sprite defines the sprite to use
  11142. */
  11143. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11144. /**
  11145. * Gets the sprite under the pointer
  11146. * @returns a Sprite or null if no sprite is under the pointer
  11147. */
  11148. getPointerOverSprite(): Nullable<Sprite>;
  11149. }
  11150. /**
  11151. * Defines the sprite scene component responsible to manage sprites
  11152. * in a given scene.
  11153. */
  11154. export class SpriteSceneComponent implements ISceneComponent {
  11155. /**
  11156. * The component name helpfull to identify the component in the list of scene components.
  11157. */
  11158. readonly name: string;
  11159. /**
  11160. * The scene the component belongs to.
  11161. */
  11162. scene: Scene;
  11163. /** @hidden */
  11164. private _spritePredicate;
  11165. /**
  11166. * Creates a new instance of the component for the given scene
  11167. * @param scene Defines the scene to register the component in
  11168. */
  11169. constructor(scene: Scene);
  11170. /**
  11171. * Registers the component in a given scene
  11172. */
  11173. register(): void;
  11174. /**
  11175. * Rebuilds the elements related to this component in case of
  11176. * context lost for instance.
  11177. */
  11178. rebuild(): void;
  11179. /**
  11180. * Disposes the component and the associated ressources.
  11181. */
  11182. dispose(): void;
  11183. private _pickSpriteButKeepRay;
  11184. private _pointerMove;
  11185. private _pointerDown;
  11186. private _pointerUp;
  11187. }
  11188. }
  11189. declare module BABYLON {
  11190. /** @hidden */
  11191. export var fogFragmentDeclaration: {
  11192. name: string;
  11193. shader: string;
  11194. };
  11195. }
  11196. declare module BABYLON {
  11197. /** @hidden */
  11198. export var fogFragment: {
  11199. name: string;
  11200. shader: string;
  11201. };
  11202. }
  11203. declare module BABYLON {
  11204. /** @hidden */
  11205. export var spritesPixelShader: {
  11206. name: string;
  11207. shader: string;
  11208. };
  11209. }
  11210. declare module BABYLON {
  11211. /** @hidden */
  11212. export var fogVertexDeclaration: {
  11213. name: string;
  11214. shader: string;
  11215. };
  11216. }
  11217. declare module BABYLON {
  11218. /** @hidden */
  11219. export var spritesVertexShader: {
  11220. name: string;
  11221. shader: string;
  11222. };
  11223. }
  11224. declare module BABYLON {
  11225. /**
  11226. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11227. */
  11228. export interface ISpriteManager extends IDisposable {
  11229. /**
  11230. * Restricts the camera to viewing objects with the same layerMask.
  11231. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11232. */
  11233. layerMask: number;
  11234. /**
  11235. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11236. */
  11237. isPickable: boolean;
  11238. /**
  11239. * Specifies the rendering group id for this mesh (0 by default)
  11240. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11241. */
  11242. renderingGroupId: number;
  11243. /**
  11244. * Defines the list of sprites managed by the manager.
  11245. */
  11246. sprites: Array<Sprite>;
  11247. /**
  11248. * Tests the intersection of a sprite with a specific ray.
  11249. * @param ray The ray we are sending to test the collision
  11250. * @param camera The camera space we are sending rays in
  11251. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11252. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11253. * @returns picking info or null.
  11254. */
  11255. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11256. /**
  11257. * Intersects the sprites with a ray
  11258. * @param ray defines the ray to intersect with
  11259. * @param camera defines the current active camera
  11260. * @param predicate defines a predicate used to select candidate sprites
  11261. * @returns null if no hit or a PickingInfo array
  11262. */
  11263. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11264. /**
  11265. * Renders the list of sprites on screen.
  11266. */
  11267. render(): void;
  11268. }
  11269. /**
  11270. * Class used to manage multiple sprites on the same spritesheet
  11271. * @see http://doc.babylonjs.com/babylon101/sprites
  11272. */
  11273. export class SpriteManager implements ISpriteManager {
  11274. /** defines the manager's name */
  11275. name: string;
  11276. /** Gets the list of sprites */
  11277. sprites: Sprite[];
  11278. /** Gets or sets the rendering group id (0 by default) */
  11279. renderingGroupId: number;
  11280. /** Gets or sets camera layer mask */
  11281. layerMask: number;
  11282. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11283. fogEnabled: boolean;
  11284. /** Gets or sets a boolean indicating if the sprites are pickable */
  11285. isPickable: boolean;
  11286. /** Defines the default width of a cell in the spritesheet */
  11287. cellWidth: number;
  11288. /** Defines the default height of a cell in the spritesheet */
  11289. cellHeight: number;
  11290. /** Associative array from JSON sprite data file */
  11291. private _cellData;
  11292. /** Array of sprite names from JSON sprite data file */
  11293. private _spriteMap;
  11294. /** True when packed cell data from JSON file is ready*/
  11295. private _packedAndReady;
  11296. /**
  11297. * An event triggered when the manager is disposed.
  11298. */
  11299. onDisposeObservable: Observable<SpriteManager>;
  11300. private _onDisposeObserver;
  11301. /**
  11302. * Callback called when the manager is disposed
  11303. */
  11304. onDispose: () => void;
  11305. private _capacity;
  11306. private _fromPacked;
  11307. private _spriteTexture;
  11308. private _epsilon;
  11309. private _scene;
  11310. private _vertexData;
  11311. private _buffer;
  11312. private _vertexBuffers;
  11313. private _indexBuffer;
  11314. private _effectBase;
  11315. private _effectFog;
  11316. /**
  11317. * Gets or sets the spritesheet texture
  11318. */
  11319. texture: Texture;
  11320. /**
  11321. * Creates a new sprite manager
  11322. * @param name defines the manager's name
  11323. * @param imgUrl defines the sprite sheet url
  11324. * @param capacity defines the maximum allowed number of sprites
  11325. * @param cellSize defines the size of a sprite cell
  11326. * @param scene defines the hosting scene
  11327. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11328. * @param samplingMode defines the smapling mode to use with spritesheet
  11329. * @param fromPacked set to false; do not alter
  11330. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11331. */
  11332. constructor(
  11333. /** defines the manager's name */
  11334. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11335. private _makePacked;
  11336. private _appendSpriteVertex;
  11337. /**
  11338. * Intersects the sprites with a ray
  11339. * @param ray defines the ray to intersect with
  11340. * @param camera defines the current active camera
  11341. * @param predicate defines a predicate used to select candidate sprites
  11342. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11343. * @returns null if no hit or a PickingInfo
  11344. */
  11345. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11346. /**
  11347. * Intersects the sprites with a ray
  11348. * @param ray defines the ray to intersect with
  11349. * @param camera defines the current active camera
  11350. * @param predicate defines a predicate used to select candidate sprites
  11351. * @returns null if no hit or a PickingInfo array
  11352. */
  11353. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11354. /**
  11355. * Render all child sprites
  11356. */
  11357. render(): void;
  11358. /**
  11359. * Release associated resources
  11360. */
  11361. dispose(): void;
  11362. }
  11363. }
  11364. declare module BABYLON {
  11365. /**
  11366. * Class used to represent a sprite
  11367. * @see http://doc.babylonjs.com/babylon101/sprites
  11368. */
  11369. export class Sprite {
  11370. /** defines the name */
  11371. name: string;
  11372. /** Gets or sets the current world position */
  11373. position: Vector3;
  11374. /** Gets or sets the main color */
  11375. color: Color4;
  11376. /** Gets or sets the width */
  11377. width: number;
  11378. /** Gets or sets the height */
  11379. height: number;
  11380. /** Gets or sets rotation angle */
  11381. angle: number;
  11382. /** Gets or sets the cell index in the sprite sheet */
  11383. cellIndex: number;
  11384. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11385. cellRef: string;
  11386. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11387. invertU: number;
  11388. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11389. invertV: number;
  11390. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11391. disposeWhenFinishedAnimating: boolean;
  11392. /** Gets the list of attached animations */
  11393. animations: Animation[];
  11394. /** Gets or sets a boolean indicating if the sprite can be picked */
  11395. isPickable: boolean;
  11396. /**
  11397. * Gets or sets the associated action manager
  11398. */
  11399. actionManager: Nullable<ActionManager>;
  11400. private _animationStarted;
  11401. private _loopAnimation;
  11402. private _fromIndex;
  11403. private _toIndex;
  11404. private _delay;
  11405. private _direction;
  11406. private _manager;
  11407. private _time;
  11408. private _onAnimationEnd;
  11409. /**
  11410. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11411. */
  11412. isVisible: boolean;
  11413. /**
  11414. * Gets or sets the sprite size
  11415. */
  11416. size: number;
  11417. /**
  11418. * Creates a new Sprite
  11419. * @param name defines the name
  11420. * @param manager defines the manager
  11421. */
  11422. constructor(
  11423. /** defines the name */
  11424. name: string, manager: ISpriteManager);
  11425. /**
  11426. * Starts an animation
  11427. * @param from defines the initial key
  11428. * @param to defines the end key
  11429. * @param loop defines if the animation must loop
  11430. * @param delay defines the start delay (in ms)
  11431. * @param onAnimationEnd defines a callback to call when animation ends
  11432. */
  11433. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11434. /** Stops current animation (if any) */
  11435. stopAnimation(): void;
  11436. /** @hidden */ private _animate(deltaTime: number): void;
  11437. /** Release associated resources */
  11438. dispose(): void;
  11439. }
  11440. }
  11441. declare module BABYLON {
  11442. /**
  11443. * Information about the result of picking within a scene
  11444. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11445. */
  11446. export class PickingInfo {
  11447. /** @hidden */ private _pickingUnavailable: boolean;
  11448. /**
  11449. * If the pick collided with an object
  11450. */
  11451. hit: boolean;
  11452. /**
  11453. * Distance away where the pick collided
  11454. */
  11455. distance: number;
  11456. /**
  11457. * The location of pick collision
  11458. */
  11459. pickedPoint: Nullable<Vector3>;
  11460. /**
  11461. * The mesh corresponding the the pick collision
  11462. */
  11463. pickedMesh: Nullable<AbstractMesh>;
  11464. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11465. bu: number;
  11466. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11467. bv: number;
  11468. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11469. faceId: number;
  11470. /** Id of the the submesh that was picked */
  11471. subMeshId: number;
  11472. /** If a sprite was picked, this will be the sprite the pick collided with */
  11473. pickedSprite: Nullable<Sprite>;
  11474. /**
  11475. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11476. */
  11477. originMesh: Nullable<AbstractMesh>;
  11478. /**
  11479. * The ray that was used to perform the picking.
  11480. */
  11481. ray: Nullable<Ray>;
  11482. /**
  11483. * Gets the normal correspodning to the face the pick collided with
  11484. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11485. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11486. * @returns The normal correspodning to the face the pick collided with
  11487. */
  11488. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11489. /**
  11490. * Gets the texture coordinates of where the pick occured
  11491. * @returns the vector containing the coordnates of the texture
  11492. */
  11493. getTextureCoordinates(): Nullable<Vector2>;
  11494. }
  11495. }
  11496. declare module BABYLON {
  11497. /**
  11498. * Gather the list of pointer event types as constants.
  11499. */
  11500. export class PointerEventTypes {
  11501. /**
  11502. * 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.
  11503. */
  11504. static readonly POINTERDOWN: number;
  11505. /**
  11506. * The pointerup event is fired when a pointer is no longer active.
  11507. */
  11508. static readonly POINTERUP: number;
  11509. /**
  11510. * The pointermove event is fired when a pointer changes coordinates.
  11511. */
  11512. static readonly POINTERMOVE: number;
  11513. /**
  11514. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11515. */
  11516. static readonly POINTERWHEEL: number;
  11517. /**
  11518. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11519. */
  11520. static readonly POINTERPICK: number;
  11521. /**
  11522. * The pointertap event is fired when a the object has been touched and released without drag.
  11523. */
  11524. static readonly POINTERTAP: number;
  11525. /**
  11526. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11527. */
  11528. static readonly POINTERDOUBLETAP: number;
  11529. }
  11530. /**
  11531. * Base class of pointer info types.
  11532. */
  11533. export class PointerInfoBase {
  11534. /**
  11535. * Defines the type of event (PointerEventTypes)
  11536. */
  11537. type: number;
  11538. /**
  11539. * Defines the related dom event
  11540. */
  11541. event: PointerEvent | MouseWheelEvent;
  11542. /**
  11543. * Instantiates the base class of pointers info.
  11544. * @param type Defines the type of event (PointerEventTypes)
  11545. * @param event Defines the related dom event
  11546. */
  11547. constructor(
  11548. /**
  11549. * Defines the type of event (PointerEventTypes)
  11550. */
  11551. type: number,
  11552. /**
  11553. * Defines the related dom event
  11554. */
  11555. event: PointerEvent | MouseWheelEvent);
  11556. }
  11557. /**
  11558. * This class is used to store pointer related info for the onPrePointerObservable event.
  11559. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11560. */
  11561. export class PointerInfoPre extends PointerInfoBase {
  11562. /**
  11563. * Ray from a pointer if availible (eg. 6dof controller)
  11564. */
  11565. ray: Nullable<Ray>;
  11566. /**
  11567. * Defines the local position of the pointer on the canvas.
  11568. */
  11569. localPosition: Vector2;
  11570. /**
  11571. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11572. */
  11573. skipOnPointerObservable: boolean;
  11574. /**
  11575. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11576. * @param type Defines the type of event (PointerEventTypes)
  11577. * @param event Defines the related dom event
  11578. * @param localX Defines the local x coordinates of the pointer when the event occured
  11579. * @param localY Defines the local y coordinates of the pointer when the event occured
  11580. */
  11581. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11582. }
  11583. /**
  11584. * This type contains all the data related to a pointer event in Babylon.js.
  11585. * 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.
  11586. */
  11587. export class PointerInfo extends PointerInfoBase {
  11588. /**
  11589. * Defines the picking info associated to the info (if any)\
  11590. */
  11591. pickInfo: Nullable<PickingInfo>;
  11592. /**
  11593. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11594. * @param type Defines the type of event (PointerEventTypes)
  11595. * @param event Defines the related dom event
  11596. * @param pickInfo Defines the picking info associated to the info (if any)\
  11597. */
  11598. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11599. /**
  11600. * Defines the picking info associated to the info (if any)\
  11601. */
  11602. pickInfo: Nullable<PickingInfo>);
  11603. }
  11604. /**
  11605. * Data relating to a touch event on the screen.
  11606. */
  11607. export interface PointerTouch {
  11608. /**
  11609. * X coordinate of touch.
  11610. */
  11611. x: number;
  11612. /**
  11613. * Y coordinate of touch.
  11614. */
  11615. y: number;
  11616. /**
  11617. * Id of touch. Unique for each finger.
  11618. */
  11619. pointerId: number;
  11620. /**
  11621. * Event type passed from DOM.
  11622. */
  11623. type: any;
  11624. }
  11625. }
  11626. declare module BABYLON {
  11627. /**
  11628. * Manage the mouse inputs to control the movement of a free camera.
  11629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11630. */
  11631. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11632. /**
  11633. * Define if touch is enabled in the mouse input
  11634. */
  11635. touchEnabled: boolean;
  11636. /**
  11637. * Defines the camera the input is attached to.
  11638. */
  11639. camera: FreeCamera;
  11640. /**
  11641. * Defines the buttons associated with the input to handle camera move.
  11642. */
  11643. buttons: number[];
  11644. /**
  11645. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11646. */
  11647. angularSensibility: number;
  11648. private _pointerInput;
  11649. private _onMouseMove;
  11650. private _observer;
  11651. private previousPosition;
  11652. /**
  11653. * Observable for when a pointer move event occurs containing the move offset
  11654. */
  11655. onPointerMovedObservable: Observable<{
  11656. offsetX: number;
  11657. offsetY: number;
  11658. }>;
  11659. /**
  11660. * @hidden
  11661. * If the camera should be rotated automatically based on pointer movement
  11662. */ private _allowCameraRotation: boolean;
  11663. /**
  11664. * Manage the mouse inputs to control the movement of a free camera.
  11665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11666. * @param touchEnabled Defines if touch is enabled or not
  11667. */
  11668. constructor(
  11669. /**
  11670. * Define if touch is enabled in the mouse input
  11671. */
  11672. touchEnabled?: boolean);
  11673. /**
  11674. * Attach the input controls to a specific dom element to get the input from.
  11675. * @param element Defines the element the controls should be listened from
  11676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11677. */
  11678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11679. /**
  11680. * Called on JS contextmenu event.
  11681. * Override this method to provide functionality.
  11682. */
  11683. protected onContextMenu(evt: PointerEvent): void;
  11684. /**
  11685. * Detach the current controls from the specified dom element.
  11686. * @param element Defines the element to stop listening the inputs from
  11687. */
  11688. detachControl(element: Nullable<HTMLElement>): void;
  11689. /**
  11690. * Gets the class name of the current intput.
  11691. * @returns the class name
  11692. */
  11693. getClassName(): string;
  11694. /**
  11695. * Get the friendly name associated with the input class.
  11696. * @returns the input friendly name
  11697. */
  11698. getSimpleName(): string;
  11699. }
  11700. }
  11701. declare module BABYLON {
  11702. /**
  11703. * Manage the touch inputs to control the movement of a free camera.
  11704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11705. */
  11706. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11707. /**
  11708. * Defines the camera the input is attached to.
  11709. */
  11710. camera: FreeCamera;
  11711. /**
  11712. * Defines the touch sensibility for rotation.
  11713. * The higher the faster.
  11714. */
  11715. touchAngularSensibility: number;
  11716. /**
  11717. * Defines the touch sensibility for move.
  11718. * The higher the faster.
  11719. */
  11720. touchMoveSensibility: number;
  11721. private _offsetX;
  11722. private _offsetY;
  11723. private _pointerPressed;
  11724. private _pointerInput;
  11725. private _observer;
  11726. private _onLostFocus;
  11727. /**
  11728. * Attach the input controls to a specific dom element to get the input from.
  11729. * @param element Defines the element the controls should be listened from
  11730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11731. */
  11732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11733. /**
  11734. * Detach the current controls from the specified dom element.
  11735. * @param element Defines the element to stop listening the inputs from
  11736. */
  11737. detachControl(element: Nullable<HTMLElement>): void;
  11738. /**
  11739. * Update the current camera state depending on the inputs that have been used this frame.
  11740. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11741. */
  11742. checkInputs(): void;
  11743. /**
  11744. * Gets the class name of the current intput.
  11745. * @returns the class name
  11746. */
  11747. getClassName(): string;
  11748. /**
  11749. * Get the friendly name associated with the input class.
  11750. * @returns the input friendly name
  11751. */
  11752. getSimpleName(): string;
  11753. }
  11754. }
  11755. declare module BABYLON {
  11756. /**
  11757. * Default Inputs manager for the FreeCamera.
  11758. * It groups all the default supported inputs for ease of use.
  11759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11760. */
  11761. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11762. /**
  11763. * @hidden
  11764. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11765. /**
  11766. * Instantiates a new FreeCameraInputsManager.
  11767. * @param camera Defines the camera the inputs belong to
  11768. */
  11769. constructor(camera: FreeCamera);
  11770. /**
  11771. * Add keyboard input support to the input manager.
  11772. * @returns the current input manager
  11773. */
  11774. addKeyboard(): FreeCameraInputsManager;
  11775. /**
  11776. * Add mouse input support to the input manager.
  11777. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11778. * @returns the current input manager
  11779. */
  11780. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11781. /**
  11782. * Removes the mouse input support from the manager
  11783. * @returns the current input manager
  11784. */
  11785. removeMouse(): FreeCameraInputsManager;
  11786. /**
  11787. * Add touch input support to the input manager.
  11788. * @returns the current input manager
  11789. */
  11790. addTouch(): FreeCameraInputsManager;
  11791. /**
  11792. * Remove all attached input methods from a camera
  11793. */
  11794. clear(): void;
  11795. }
  11796. }
  11797. declare module BABYLON {
  11798. /**
  11799. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11800. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11801. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11802. */
  11803. export class FreeCamera extends TargetCamera {
  11804. /**
  11805. * Define the collision ellipsoid of the camera.
  11806. * This is helpful to simulate a camera body like the player body around the camera
  11807. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11808. */
  11809. ellipsoid: Vector3;
  11810. /**
  11811. * Define an offset for the position of the ellipsoid around the camera.
  11812. * This can be helpful to determine the center of the body near the gravity center of the body
  11813. * instead of its head.
  11814. */
  11815. ellipsoidOffset: Vector3;
  11816. /**
  11817. * Enable or disable collisions of the camera with the rest of the scene objects.
  11818. */
  11819. checkCollisions: boolean;
  11820. /**
  11821. * Enable or disable gravity on the camera.
  11822. */
  11823. applyGravity: boolean;
  11824. /**
  11825. * Define the input manager associated to the camera.
  11826. */
  11827. inputs: FreeCameraInputsManager;
  11828. /**
  11829. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11830. * Higher values reduce sensitivity.
  11831. */
  11832. /**
  11833. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11834. * Higher values reduce sensitivity.
  11835. */
  11836. angularSensibility: number;
  11837. /**
  11838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11839. */
  11840. keysUp: number[];
  11841. /**
  11842. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11843. */
  11844. keysDown: number[];
  11845. /**
  11846. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11847. */
  11848. keysLeft: number[];
  11849. /**
  11850. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11851. */
  11852. keysRight: number[];
  11853. /**
  11854. * Event raised when the camera collide with a mesh in the scene.
  11855. */
  11856. onCollide: (collidedMesh: AbstractMesh) => void;
  11857. private _collider;
  11858. private _needMoveForGravity;
  11859. private _oldPosition;
  11860. private _diffPosition;
  11861. private _newPosition;
  11862. /** @hidden */ private _localDirection: Vector3;
  11863. /** @hidden */ private _transformedDirection: Vector3;
  11864. /**
  11865. * Instantiates a Free Camera.
  11866. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11867. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11868. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11869. * @param name Define the name of the camera in the scene
  11870. * @param position Define the start position of the camera in the scene
  11871. * @param scene Define the scene the camera belongs to
  11872. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11873. */
  11874. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11875. /**
  11876. * Attached controls to the current camera.
  11877. * @param element Defines the element the controls should be listened from
  11878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11879. */
  11880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11881. /**
  11882. * Detach the current controls from the camera.
  11883. * The camera will stop reacting to inputs.
  11884. * @param element Defines the element to stop listening the inputs from
  11885. */
  11886. detachControl(element: HTMLElement): void;
  11887. private _collisionMask;
  11888. /**
  11889. * Define a collision mask to limit the list of object the camera can collide with
  11890. */
  11891. collisionMask: number;
  11892. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  11893. private _onCollisionPositionChange;
  11894. /** @hidden */ private _checkInputs(): void;
  11895. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  11896. /** @hidden */ private _updatePosition(): void;
  11897. /**
  11898. * Destroy the camera and release the current resources hold by it.
  11899. */
  11900. dispose(): void;
  11901. /**
  11902. * Gets the current object class name.
  11903. * @return the class name
  11904. */
  11905. getClassName(): string;
  11906. }
  11907. }
  11908. declare module BABYLON {
  11909. /**
  11910. * Represents a gamepad control stick position
  11911. */
  11912. export class StickValues {
  11913. /**
  11914. * The x component of the control stick
  11915. */
  11916. x: number;
  11917. /**
  11918. * The y component of the control stick
  11919. */
  11920. y: number;
  11921. /**
  11922. * Initializes the gamepad x and y control stick values
  11923. * @param x The x component of the gamepad control stick value
  11924. * @param y The y component of the gamepad control stick value
  11925. */
  11926. constructor(
  11927. /**
  11928. * The x component of the control stick
  11929. */
  11930. x: number,
  11931. /**
  11932. * The y component of the control stick
  11933. */
  11934. y: number);
  11935. }
  11936. /**
  11937. * An interface which manages callbacks for gamepad button changes
  11938. */
  11939. export interface GamepadButtonChanges {
  11940. /**
  11941. * Called when a gamepad has been changed
  11942. */
  11943. changed: boolean;
  11944. /**
  11945. * Called when a gamepad press event has been triggered
  11946. */
  11947. pressChanged: boolean;
  11948. /**
  11949. * Called when a touch event has been triggered
  11950. */
  11951. touchChanged: boolean;
  11952. /**
  11953. * Called when a value has changed
  11954. */
  11955. valueChanged: boolean;
  11956. }
  11957. /**
  11958. * Represents a gamepad
  11959. */
  11960. export class Gamepad {
  11961. /**
  11962. * The id of the gamepad
  11963. */
  11964. id: string;
  11965. /**
  11966. * The index of the gamepad
  11967. */
  11968. index: number;
  11969. /**
  11970. * The browser gamepad
  11971. */
  11972. browserGamepad: any;
  11973. /**
  11974. * Specifies what type of gamepad this represents
  11975. */
  11976. type: number;
  11977. private _leftStick;
  11978. private _rightStick;
  11979. /** @hidden */ private _isConnected: boolean;
  11980. private _leftStickAxisX;
  11981. private _leftStickAxisY;
  11982. private _rightStickAxisX;
  11983. private _rightStickAxisY;
  11984. /**
  11985. * Triggered when the left control stick has been changed
  11986. */
  11987. private _onleftstickchanged;
  11988. /**
  11989. * Triggered when the right control stick has been changed
  11990. */
  11991. private _onrightstickchanged;
  11992. /**
  11993. * Represents a gamepad controller
  11994. */
  11995. static GAMEPAD: number;
  11996. /**
  11997. * Represents a generic controller
  11998. */
  11999. static GENERIC: number;
  12000. /**
  12001. * Represents an XBox controller
  12002. */
  12003. static XBOX: number;
  12004. /**
  12005. * Represents a pose-enabled controller
  12006. */
  12007. static POSE_ENABLED: number;
  12008. /**
  12009. * Represents an Dual Shock controller
  12010. */
  12011. static DUALSHOCK: number;
  12012. /**
  12013. * Specifies whether the left control stick should be Y-inverted
  12014. */
  12015. protected _invertLeftStickY: boolean;
  12016. /**
  12017. * Specifies if the gamepad has been connected
  12018. */
  12019. readonly isConnected: boolean;
  12020. /**
  12021. * Initializes the gamepad
  12022. * @param id The id of the gamepad
  12023. * @param index The index of the gamepad
  12024. * @param browserGamepad The browser gamepad
  12025. * @param leftStickX The x component of the left joystick
  12026. * @param leftStickY The y component of the left joystick
  12027. * @param rightStickX The x component of the right joystick
  12028. * @param rightStickY The y component of the right joystick
  12029. */
  12030. constructor(
  12031. /**
  12032. * The id of the gamepad
  12033. */
  12034. id: string,
  12035. /**
  12036. * The index of the gamepad
  12037. */
  12038. index: number,
  12039. /**
  12040. * The browser gamepad
  12041. */
  12042. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12043. /**
  12044. * Callback triggered when the left joystick has changed
  12045. * @param callback
  12046. */
  12047. onleftstickchanged(callback: (values: StickValues) => void): void;
  12048. /**
  12049. * Callback triggered when the right joystick has changed
  12050. * @param callback
  12051. */
  12052. onrightstickchanged(callback: (values: StickValues) => void): void;
  12053. /**
  12054. * Gets the left joystick
  12055. */
  12056. /**
  12057. * Sets the left joystick values
  12058. */
  12059. leftStick: StickValues;
  12060. /**
  12061. * Gets the right joystick
  12062. */
  12063. /**
  12064. * Sets the right joystick value
  12065. */
  12066. rightStick: StickValues;
  12067. /**
  12068. * Updates the gamepad joystick positions
  12069. */
  12070. update(): void;
  12071. /**
  12072. * Disposes the gamepad
  12073. */
  12074. dispose(): void;
  12075. }
  12076. /**
  12077. * Represents a generic gamepad
  12078. */
  12079. export class GenericPad extends Gamepad {
  12080. private _buttons;
  12081. private _onbuttondown;
  12082. private _onbuttonup;
  12083. /**
  12084. * Observable triggered when a button has been pressed
  12085. */
  12086. onButtonDownObservable: Observable<number>;
  12087. /**
  12088. * Observable triggered when a button has been released
  12089. */
  12090. onButtonUpObservable: Observable<number>;
  12091. /**
  12092. * Callback triggered when a button has been pressed
  12093. * @param callback Called when a button has been pressed
  12094. */
  12095. onbuttondown(callback: (buttonPressed: number) => void): void;
  12096. /**
  12097. * Callback triggered when a button has been released
  12098. * @param callback Called when a button has been released
  12099. */
  12100. onbuttonup(callback: (buttonReleased: number) => void): void;
  12101. /**
  12102. * Initializes the generic gamepad
  12103. * @param id The id of the generic gamepad
  12104. * @param index The index of the generic gamepad
  12105. * @param browserGamepad The browser gamepad
  12106. */
  12107. constructor(id: string, index: number, browserGamepad: any);
  12108. private _setButtonValue;
  12109. /**
  12110. * Updates the generic gamepad
  12111. */
  12112. update(): void;
  12113. /**
  12114. * Disposes the generic gamepad
  12115. */
  12116. dispose(): void;
  12117. }
  12118. }
  12119. declare module BABYLON {
  12120. interface Engine {
  12121. /**
  12122. * Creates a raw texture
  12123. * @param data defines the data to store in the texture
  12124. * @param width defines the width of the texture
  12125. * @param height defines the height of the texture
  12126. * @param format defines the format of the data
  12127. * @param generateMipMaps defines if the engine should generate the mip levels
  12128. * @param invertY defines if data must be stored with Y axis inverted
  12129. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12130. * @param compression defines the compression used (null by default)
  12131. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12132. * @returns the raw texture inside an InternalTexture
  12133. */
  12134. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12135. /**
  12136. * Update a raw texture
  12137. * @param texture defines the texture to update
  12138. * @param data defines the data to store in the texture
  12139. * @param format defines the format of the data
  12140. * @param invertY defines if data must be stored with Y axis inverted
  12141. */
  12142. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12143. /**
  12144. * Update a raw texture
  12145. * @param texture defines the texture to update
  12146. * @param data defines the data to store in the texture
  12147. * @param format defines the format of the data
  12148. * @param invertY defines if data must be stored with Y axis inverted
  12149. * @param compression defines the compression used (null by default)
  12150. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12151. */
  12152. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12153. /**
  12154. * Creates a new raw cube texture
  12155. * @param data defines the array of data to use to create each face
  12156. * @param size defines the size of the textures
  12157. * @param format defines the format of the data
  12158. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12159. * @param generateMipMaps defines if the engine should generate the mip levels
  12160. * @param invertY defines if data must be stored with Y axis inverted
  12161. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12162. * @param compression defines the compression used (null by default)
  12163. * @returns the cube texture as an InternalTexture
  12164. */
  12165. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12166. /**
  12167. * Update a raw cube texture
  12168. * @param texture defines the texture to udpdate
  12169. * @param data defines the data to store
  12170. * @param format defines the data format
  12171. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12172. * @param invertY defines if data must be stored with Y axis inverted
  12173. */
  12174. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12175. /**
  12176. * Update a raw cube texture
  12177. * @param texture defines the texture to udpdate
  12178. * @param data defines the data to store
  12179. * @param format defines the data format
  12180. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12181. * @param invertY defines if data must be stored with Y axis inverted
  12182. * @param compression defines the compression used (null by default)
  12183. */
  12184. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12185. /**
  12186. * Update a raw cube texture
  12187. * @param texture defines the texture to udpdate
  12188. * @param data defines the data to store
  12189. * @param format defines the data format
  12190. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12191. * @param invertY defines if data must be stored with Y axis inverted
  12192. * @param compression defines the compression used (null by default)
  12193. * @param level defines which level of the texture to update
  12194. */
  12195. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12196. /**
  12197. * Creates a new raw cube texture from a specified url
  12198. * @param url defines the url where the data is located
  12199. * @param scene defines the current scene
  12200. * @param size defines the size of the textures
  12201. * @param format defines the format of the data
  12202. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12203. * @param noMipmap defines if the engine should avoid generating the mip levels
  12204. * @param callback defines a callback used to extract texture data from loaded data
  12205. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12206. * @param onLoad defines a callback called when texture is loaded
  12207. * @param onError defines a callback called if there is an error
  12208. * @returns the cube texture as an InternalTexture
  12209. */
  12210. 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;
  12211. /**
  12212. * Creates a new raw cube texture from a specified url
  12213. * @param url defines the url where the data is located
  12214. * @param scene defines the current scene
  12215. * @param size defines the size of the textures
  12216. * @param format defines the format of the data
  12217. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12218. * @param noMipmap defines if the engine should avoid generating the mip levels
  12219. * @param callback defines a callback used to extract texture data from loaded data
  12220. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12221. * @param onLoad defines a callback called when texture is loaded
  12222. * @param onError defines a callback called if there is an error
  12223. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12224. * @param invertY defines if data must be stored with Y axis inverted
  12225. * @returns the cube texture as an InternalTexture
  12226. */
  12227. 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;
  12228. /**
  12229. * Creates a new raw 3D texture
  12230. * @param data defines the data used to create the texture
  12231. * @param width defines the width of the texture
  12232. * @param height defines the height of the texture
  12233. * @param depth defines the depth of the texture
  12234. * @param format defines the format of the texture
  12235. * @param generateMipMaps defines if the engine must generate mip levels
  12236. * @param invertY defines if data must be stored with Y axis inverted
  12237. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12238. * @param compression defines the compressed used (can be null)
  12239. * @param textureType defines the compressed used (can be null)
  12240. * @returns a new raw 3D texture (stored in an InternalTexture)
  12241. */
  12242. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12243. /**
  12244. * Update a raw 3D texture
  12245. * @param texture defines the texture to update
  12246. * @param data defines the data to store
  12247. * @param format defines the data format
  12248. * @param invertY defines if data must be stored with Y axis inverted
  12249. */
  12250. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12251. /**
  12252. * Update a raw 3D texture
  12253. * @param texture defines the texture to update
  12254. * @param data defines the data to store
  12255. * @param format defines the data format
  12256. * @param invertY defines if data must be stored with Y axis inverted
  12257. * @param compression defines the used compression (can be null)
  12258. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12259. */
  12260. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12261. }
  12262. }
  12263. declare module BABYLON {
  12264. /**
  12265. * Raw texture can help creating a texture directly from an array of data.
  12266. * This can be super useful if you either get the data from an uncompressed source or
  12267. * if you wish to create your texture pixel by pixel.
  12268. */
  12269. export class RawTexture extends Texture {
  12270. /**
  12271. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12272. */
  12273. format: number;
  12274. private _engine;
  12275. /**
  12276. * Instantiates a new RawTexture.
  12277. * Raw texture can help creating a texture directly from an array of data.
  12278. * This can be super useful if you either get the data from an uncompressed source or
  12279. * if you wish to create your texture pixel by pixel.
  12280. * @param data define the array of data to use to create the texture
  12281. * @param width define the width of the texture
  12282. * @param height define the height of the texture
  12283. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12284. * @param scene define the scene the texture belongs to
  12285. * @param generateMipMaps define whether mip maps should be generated or not
  12286. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12287. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12288. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12289. */
  12290. constructor(data: ArrayBufferView, width: number, height: number,
  12291. /**
  12292. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12293. */
  12294. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12295. /**
  12296. * Updates the texture underlying data.
  12297. * @param data Define the new data of the texture
  12298. */
  12299. update(data: ArrayBufferView): void;
  12300. /**
  12301. * Creates a luminance texture from some data.
  12302. * @param data Define the texture data
  12303. * @param width Define the width of the texture
  12304. * @param height Define the height of the texture
  12305. * @param scene Define the scene the texture belongs to
  12306. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12307. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12308. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12309. * @returns the luminance texture
  12310. */
  12311. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12312. /**
  12313. * Creates a luminance alpha texture from some data.
  12314. * @param data Define the texture data
  12315. * @param width Define the width of the texture
  12316. * @param height Define the height of the texture
  12317. * @param scene Define the scene the texture belongs to
  12318. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12319. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12320. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12321. * @returns the luminance alpha texture
  12322. */
  12323. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12324. /**
  12325. * Creates an alpha texture from some data.
  12326. * @param data Define the texture data
  12327. * @param width Define the width of the texture
  12328. * @param height Define the height of the texture
  12329. * @param scene Define the scene the texture belongs to
  12330. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12331. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12332. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12333. * @returns the alpha texture
  12334. */
  12335. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12336. /**
  12337. * Creates a RGB texture from some data.
  12338. * @param data Define the texture data
  12339. * @param width Define the width of the texture
  12340. * @param height Define the height of the texture
  12341. * @param scene Define the scene the texture belongs to
  12342. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12343. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12344. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12345. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12346. * @returns the RGB alpha texture
  12347. */
  12348. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12349. /**
  12350. * Creates a RGBA texture from some data.
  12351. * @param data Define the texture data
  12352. * @param width Define the width of the texture
  12353. * @param height Define the height of the texture
  12354. * @param scene Define the scene the texture belongs to
  12355. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12356. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12357. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12358. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12359. * @returns the RGBA texture
  12360. */
  12361. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12362. /**
  12363. * Creates a R texture from some data.
  12364. * @param data Define the texture data
  12365. * @param width Define the width of the texture
  12366. * @param height Define the height of the texture
  12367. * @param scene Define the scene the texture belongs to
  12368. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12369. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12370. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12371. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12372. * @returns the R texture
  12373. */
  12374. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12375. }
  12376. }
  12377. declare module BABYLON {
  12378. /**
  12379. * Interface for the size containing width and height
  12380. */
  12381. export interface ISize {
  12382. /**
  12383. * Width
  12384. */
  12385. width: number;
  12386. /**
  12387. * Heighht
  12388. */
  12389. height: number;
  12390. }
  12391. /**
  12392. * Size containing widht and height
  12393. */
  12394. export class Size implements ISize {
  12395. /**
  12396. * Width
  12397. */
  12398. width: number;
  12399. /**
  12400. * Height
  12401. */
  12402. height: number;
  12403. /**
  12404. * Creates a Size object from the given width and height (floats).
  12405. * @param width width of the new size
  12406. * @param height height of the new size
  12407. */
  12408. constructor(width: number, height: number);
  12409. /**
  12410. * Returns a string with the Size width and height
  12411. * @returns a string with the Size width and height
  12412. */
  12413. toString(): string;
  12414. /**
  12415. * "Size"
  12416. * @returns the string "Size"
  12417. */
  12418. getClassName(): string;
  12419. /**
  12420. * Returns the Size hash code.
  12421. * @returns a hash code for a unique width and height
  12422. */
  12423. getHashCode(): number;
  12424. /**
  12425. * Updates the current size from the given one.
  12426. * @param src the given size
  12427. */
  12428. copyFrom(src: Size): void;
  12429. /**
  12430. * Updates in place the current Size from the given floats.
  12431. * @param width width of the new size
  12432. * @param height height of the new size
  12433. * @returns the updated Size.
  12434. */
  12435. copyFromFloats(width: number, height: number): Size;
  12436. /**
  12437. * Updates in place the current Size from the given floats.
  12438. * @param width width to set
  12439. * @param height height to set
  12440. * @returns the updated Size.
  12441. */
  12442. set(width: number, height: number): Size;
  12443. /**
  12444. * Multiplies the width and height by numbers
  12445. * @param w factor to multiple the width by
  12446. * @param h factor to multiple the height by
  12447. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12448. */
  12449. multiplyByFloats(w: number, h: number): Size;
  12450. /**
  12451. * Clones the size
  12452. * @returns a new Size copied from the given one.
  12453. */
  12454. clone(): Size;
  12455. /**
  12456. * True if the current Size and the given one width and height are strictly equal.
  12457. * @param other the other size to compare against
  12458. * @returns True if the current Size and the given one width and height are strictly equal.
  12459. */
  12460. equals(other: Size): boolean;
  12461. /**
  12462. * The surface of the Size : width * height (float).
  12463. */
  12464. readonly surface: number;
  12465. /**
  12466. * Create a new size of zero
  12467. * @returns a new Size set to (0.0, 0.0)
  12468. */
  12469. static Zero(): Size;
  12470. /**
  12471. * Sums the width and height of two sizes
  12472. * @param otherSize size to add to this size
  12473. * @returns a new Size set as the addition result of the current Size and the given one.
  12474. */
  12475. add(otherSize: Size): Size;
  12476. /**
  12477. * Subtracts the width and height of two
  12478. * @param otherSize size to subtract to this size
  12479. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12480. */
  12481. subtract(otherSize: Size): Size;
  12482. /**
  12483. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12484. * @param start starting size to lerp between
  12485. * @param end end size to lerp between
  12486. * @param amount amount to lerp between the start and end values
  12487. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12488. */
  12489. static Lerp(start: Size, end: Size, amount: number): Size;
  12490. }
  12491. }
  12492. declare module BABYLON {
  12493. /**
  12494. * Defines a runtime animation
  12495. */
  12496. export class RuntimeAnimation {
  12497. private _events;
  12498. /**
  12499. * The current frame of the runtime animation
  12500. */
  12501. private _currentFrame;
  12502. /**
  12503. * The animation used by the runtime animation
  12504. */
  12505. private _animation;
  12506. /**
  12507. * The target of the runtime animation
  12508. */
  12509. private _target;
  12510. /**
  12511. * The initiating animatable
  12512. */
  12513. private _host;
  12514. /**
  12515. * The original value of the runtime animation
  12516. */
  12517. private _originalValue;
  12518. /**
  12519. * The original blend value of the runtime animation
  12520. */
  12521. private _originalBlendValue;
  12522. /**
  12523. * The offsets cache of the runtime animation
  12524. */
  12525. private _offsetsCache;
  12526. /**
  12527. * The high limits cache of the runtime animation
  12528. */
  12529. private _highLimitsCache;
  12530. /**
  12531. * Specifies if the runtime animation has been stopped
  12532. */
  12533. private _stopped;
  12534. /**
  12535. * The blending factor of the runtime animation
  12536. */
  12537. private _blendingFactor;
  12538. /**
  12539. * The BabylonJS scene
  12540. */
  12541. private _scene;
  12542. /**
  12543. * The current value of the runtime animation
  12544. */
  12545. private _currentValue;
  12546. /** @hidden */ private _animationState: _IAnimationState;
  12547. /**
  12548. * The active target of the runtime animation
  12549. */
  12550. private _activeTargets;
  12551. private _currentActiveTarget;
  12552. private _directTarget;
  12553. /**
  12554. * The target path of the runtime animation
  12555. */
  12556. private _targetPath;
  12557. /**
  12558. * The weight of the runtime animation
  12559. */
  12560. private _weight;
  12561. /**
  12562. * The ratio offset of the runtime animation
  12563. */
  12564. private _ratioOffset;
  12565. /**
  12566. * The previous delay of the runtime animation
  12567. */
  12568. private _previousDelay;
  12569. /**
  12570. * The previous ratio of the runtime animation
  12571. */
  12572. private _previousRatio;
  12573. private _enableBlending;
  12574. private _keys;
  12575. private _minFrame;
  12576. private _maxFrame;
  12577. private _minValue;
  12578. private _maxValue;
  12579. private _targetIsArray;
  12580. /**
  12581. * Gets the current frame of the runtime animation
  12582. */
  12583. readonly currentFrame: number;
  12584. /**
  12585. * Gets the weight of the runtime animation
  12586. */
  12587. readonly weight: number;
  12588. /**
  12589. * Gets the current value of the runtime animation
  12590. */
  12591. readonly currentValue: any;
  12592. /**
  12593. * Gets the target path of the runtime animation
  12594. */
  12595. readonly targetPath: string;
  12596. /**
  12597. * Gets the actual target of the runtime animation
  12598. */
  12599. readonly target: any;
  12600. /** @hidden */ private _onLoop: () => void;
  12601. /**
  12602. * Create a new RuntimeAnimation object
  12603. * @param target defines the target of the animation
  12604. * @param animation defines the source animation object
  12605. * @param scene defines the hosting scene
  12606. * @param host defines the initiating Animatable
  12607. */
  12608. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12609. private _preparePath;
  12610. /**
  12611. * Gets the animation from the runtime animation
  12612. */
  12613. readonly animation: Animation;
  12614. /**
  12615. * Resets the runtime animation to the beginning
  12616. * @param restoreOriginal defines whether to restore the target property to the original value
  12617. */
  12618. reset(restoreOriginal?: boolean): void;
  12619. /**
  12620. * Specifies if the runtime animation is stopped
  12621. * @returns Boolean specifying if the runtime animation is stopped
  12622. */
  12623. isStopped(): boolean;
  12624. /**
  12625. * Disposes of the runtime animation
  12626. */
  12627. dispose(): void;
  12628. /**
  12629. * Apply the interpolated value to the target
  12630. * @param currentValue defines the value computed by the animation
  12631. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12632. */
  12633. setValue(currentValue: any, weight: number): void;
  12634. private _getOriginalValues;
  12635. private _setValue;
  12636. /**
  12637. * Gets the loop pmode of the runtime animation
  12638. * @returns Loop Mode
  12639. */
  12640. private _getCorrectLoopMode;
  12641. /**
  12642. * Move the current animation to a given frame
  12643. * @param frame defines the frame to move to
  12644. */
  12645. goToFrame(frame: number): void;
  12646. /**
  12647. * @hidden Internal use only
  12648. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12649. /**
  12650. * Execute the current animation
  12651. * @param delay defines the delay to add to the current frame
  12652. * @param from defines the lower bound of the animation range
  12653. * @param to defines the upper bound of the animation range
  12654. * @param loop defines if the current animation must loop
  12655. * @param speedRatio defines the current speed ratio
  12656. * @param weight defines the weight of the animation (default is -1 so no weight)
  12657. * @param onLoop optional callback called when animation loops
  12658. * @returns a boolean indicating if the animation is running
  12659. */
  12660. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12661. }
  12662. }
  12663. declare module BABYLON {
  12664. /**
  12665. * Class used to store an actual running animation
  12666. */
  12667. export class Animatable {
  12668. /** defines the target object */
  12669. target: any;
  12670. /** defines the starting frame number (default is 0) */
  12671. fromFrame: number;
  12672. /** defines the ending frame number (default is 100) */
  12673. toFrame: number;
  12674. /** defines if the animation must loop (default is false) */
  12675. loopAnimation: boolean;
  12676. /** defines a callback to call when animation ends if it is not looping */
  12677. onAnimationEnd?: (() => void) | null | undefined;
  12678. /** defines a callback to call when animation loops */
  12679. onAnimationLoop?: (() => void) | null | undefined;
  12680. private _localDelayOffset;
  12681. private _pausedDelay;
  12682. private _runtimeAnimations;
  12683. private _paused;
  12684. private _scene;
  12685. private _speedRatio;
  12686. private _weight;
  12687. private _syncRoot;
  12688. /**
  12689. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12690. * This will only apply for non looping animation (default is true)
  12691. */
  12692. disposeOnEnd: boolean;
  12693. /**
  12694. * Gets a boolean indicating if the animation has started
  12695. */
  12696. animationStarted: boolean;
  12697. /**
  12698. * Observer raised when the animation ends
  12699. */
  12700. onAnimationEndObservable: Observable<Animatable>;
  12701. /**
  12702. * Observer raised when the animation loops
  12703. */
  12704. onAnimationLoopObservable: Observable<Animatable>;
  12705. /**
  12706. * Gets the root Animatable used to synchronize and normalize animations
  12707. */
  12708. readonly syncRoot: Nullable<Animatable>;
  12709. /**
  12710. * Gets the current frame of the first RuntimeAnimation
  12711. * Used to synchronize Animatables
  12712. */
  12713. readonly masterFrame: number;
  12714. /**
  12715. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12716. */
  12717. weight: number;
  12718. /**
  12719. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12720. */
  12721. speedRatio: number;
  12722. /**
  12723. * Creates a new Animatable
  12724. * @param scene defines the hosting scene
  12725. * @param target defines the target object
  12726. * @param fromFrame defines the starting frame number (default is 0)
  12727. * @param toFrame defines the ending frame number (default is 100)
  12728. * @param loopAnimation defines if the animation must loop (default is false)
  12729. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12730. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12731. * @param animations defines a group of animation to add to the new Animatable
  12732. * @param onAnimationLoop defines a callback to call when animation loops
  12733. */
  12734. constructor(scene: Scene,
  12735. /** defines the target object */
  12736. target: any,
  12737. /** defines the starting frame number (default is 0) */
  12738. fromFrame?: number,
  12739. /** defines the ending frame number (default is 100) */
  12740. toFrame?: number,
  12741. /** defines if the animation must loop (default is false) */
  12742. loopAnimation?: boolean, speedRatio?: number,
  12743. /** defines a callback to call when animation ends if it is not looping */
  12744. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12745. /** defines a callback to call when animation loops */
  12746. onAnimationLoop?: (() => void) | null | undefined);
  12747. /**
  12748. * Synchronize and normalize current Animatable with a source Animatable
  12749. * This is useful when using animation weights and when animations are not of the same length
  12750. * @param root defines the root Animatable to synchronize with
  12751. * @returns the current Animatable
  12752. */
  12753. syncWith(root: Animatable): Animatable;
  12754. /**
  12755. * Gets the list of runtime animations
  12756. * @returns an array of RuntimeAnimation
  12757. */
  12758. getAnimations(): RuntimeAnimation[];
  12759. /**
  12760. * Adds more animations to the current animatable
  12761. * @param target defines the target of the animations
  12762. * @param animations defines the new animations to add
  12763. */
  12764. appendAnimations(target: any, animations: Animation[]): void;
  12765. /**
  12766. * Gets the source animation for a specific property
  12767. * @param property defines the propertyu to look for
  12768. * @returns null or the source animation for the given property
  12769. */
  12770. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12771. /**
  12772. * Gets the runtime animation for a specific property
  12773. * @param property defines the propertyu to look for
  12774. * @returns null or the runtime animation for the given property
  12775. */
  12776. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12777. /**
  12778. * Resets the animatable to its original state
  12779. */
  12780. reset(): void;
  12781. /**
  12782. * Allows the animatable to blend with current running animations
  12783. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12784. * @param blendingSpeed defines the blending speed to use
  12785. */
  12786. enableBlending(blendingSpeed: number): void;
  12787. /**
  12788. * Disable animation blending
  12789. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12790. */
  12791. disableBlending(): void;
  12792. /**
  12793. * Jump directly to a given frame
  12794. * @param frame defines the frame to jump to
  12795. */
  12796. goToFrame(frame: number): void;
  12797. /**
  12798. * Pause the animation
  12799. */
  12800. pause(): void;
  12801. /**
  12802. * Restart the animation
  12803. */
  12804. restart(): void;
  12805. private _raiseOnAnimationEnd;
  12806. /**
  12807. * Stop and delete the current animation
  12808. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12809. * @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)
  12810. */
  12811. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12812. /**
  12813. * Wait asynchronously for the animation to end
  12814. * @returns a promise which will be fullfilled when the animation ends
  12815. */
  12816. waitAsync(): Promise<Animatable>;
  12817. /** @hidden */ private _animate(delay: number): boolean;
  12818. }
  12819. interface Scene {
  12820. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12821. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  12822. totalWeight: number;
  12823. animations: RuntimeAnimation[];
  12824. originalValue: Matrix;
  12825. }): any;
  12826. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  12827. totalWeight: number;
  12828. animations: RuntimeAnimation[];
  12829. originalValue: Quaternion;
  12830. }, refQuaternion: Quaternion): Quaternion;
  12831. /** @hidden */ private _processLateAnimationBindings(): void;
  12832. /**
  12833. * Will start the animation sequence of a given target
  12834. * @param target defines the target
  12835. * @param from defines from which frame should animation start
  12836. * @param to defines until which frame should animation run.
  12837. * @param weight defines the weight to apply to the animation (1.0 by default)
  12838. * @param loop defines if the animation loops
  12839. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12840. * @param onAnimationEnd defines the function to be executed when the animation ends
  12841. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12842. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12843. * @param onAnimationLoop defines the callback to call when an animation loops
  12844. * @returns the animatable object created for this animation
  12845. */
  12846. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12847. /**
  12848. * Will start the animation sequence of a given target
  12849. * @param target defines the target
  12850. * @param from defines from which frame should animation start
  12851. * @param to defines until which frame should animation run.
  12852. * @param loop defines if the animation loops
  12853. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12854. * @param onAnimationEnd defines the function to be executed when the animation ends
  12855. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12856. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12857. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12858. * @param onAnimationLoop defines the callback to call when an animation loops
  12859. * @returns the animatable object created for this animation
  12860. */
  12861. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12862. /**
  12863. * Will start the animation sequence of a given target and its hierarchy
  12864. * @param target defines the target
  12865. * @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.
  12866. * @param from defines from which frame should animation start
  12867. * @param to defines until which frame should animation run.
  12868. * @param loop defines if the animation loops
  12869. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12870. * @param onAnimationEnd defines the function to be executed when the animation ends
  12871. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12872. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12873. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12874. * @param onAnimationLoop defines the callback to call when an animation loops
  12875. * @returns the list of created animatables
  12876. */
  12877. 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[];
  12878. /**
  12879. * Begin a new animation on a given node
  12880. * @param target defines the target where the animation will take place
  12881. * @param animations defines the list of animations to start
  12882. * @param from defines the initial value
  12883. * @param to defines the final value
  12884. * @param loop defines if you want animation to loop (off by default)
  12885. * @param speedRatio defines the speed ratio to apply to all animations
  12886. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12887. * @param onAnimationLoop defines the callback to call when an animation loops
  12888. * @returns the list of created animatables
  12889. */
  12890. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12891. /**
  12892. * Begin a new animation on a given node and its hierarchy
  12893. * @param target defines the root node where the animation will take place
  12894. * @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.
  12895. * @param animations defines the list of animations to start
  12896. * @param from defines the initial value
  12897. * @param to defines the final value
  12898. * @param loop defines if you want animation to loop (off by default)
  12899. * @param speedRatio defines the speed ratio to apply to all animations
  12900. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12901. * @param onAnimationLoop defines the callback to call when an animation loops
  12902. * @returns the list of animatables created for all nodes
  12903. */
  12904. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12905. /**
  12906. * Gets the animatable associated with a specific target
  12907. * @param target defines the target of the animatable
  12908. * @returns the required animatable if found
  12909. */
  12910. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12911. /**
  12912. * Gets all animatables associated with a given target
  12913. * @param target defines the target to look animatables for
  12914. * @returns an array of Animatables
  12915. */
  12916. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12917. /**
  12918. * Stops and removes all animations that have been applied to the scene
  12919. */
  12920. stopAllAnimations(): void;
  12921. }
  12922. interface Bone {
  12923. /**
  12924. * Copy an animation range from another bone
  12925. * @param source defines the source bone
  12926. * @param rangeName defines the range name to copy
  12927. * @param frameOffset defines the frame offset
  12928. * @param rescaleAsRequired defines if rescaling must be applied if required
  12929. * @param skelDimensionsRatio defines the scaling ratio
  12930. * @returns true if operation was successful
  12931. */
  12932. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12933. }
  12934. }
  12935. declare module BABYLON {
  12936. /**
  12937. * Class used to override all child animations of a given target
  12938. */
  12939. export class AnimationPropertiesOverride {
  12940. /**
  12941. * Gets or sets a value indicating if animation blending must be used
  12942. */
  12943. enableBlending: boolean;
  12944. /**
  12945. * Gets or sets the blending speed to use when enableBlending is true
  12946. */
  12947. blendingSpeed: number;
  12948. /**
  12949. * Gets or sets the default loop mode to use
  12950. */
  12951. loopMode: number;
  12952. }
  12953. }
  12954. declare module BABYLON {
  12955. /**
  12956. * Class used to handle skinning animations
  12957. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  12958. */
  12959. export class Skeleton implements IAnimatable {
  12960. /** defines the skeleton name */
  12961. name: string;
  12962. /** defines the skeleton Id */
  12963. id: string;
  12964. /**
  12965. * Defines the list of child bones
  12966. */
  12967. bones: Bone[];
  12968. /**
  12969. * Defines an estimate of the dimension of the skeleton at rest
  12970. */
  12971. dimensionsAtRest: Vector3;
  12972. /**
  12973. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  12974. */
  12975. needInitialSkinMatrix: boolean;
  12976. /**
  12977. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  12978. */
  12979. overrideMesh: Nullable<AbstractMesh>;
  12980. /**
  12981. * Gets the list of animations attached to this skeleton
  12982. */
  12983. animations: Array<Animation>;
  12984. private _scene;
  12985. private _isDirty;
  12986. private _transformMatrices;
  12987. private _transformMatrixTexture;
  12988. private _meshesWithPoseMatrix;
  12989. private _animatables;
  12990. private _identity;
  12991. private _synchronizedWithMesh;
  12992. private _ranges;
  12993. private _lastAbsoluteTransformsUpdateId;
  12994. private _canUseTextureForBones;
  12995. private _uniqueId;
  12996. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  12997. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  12998. /**
  12999. * Specifies if the skeleton should be serialized
  13000. */
  13001. doNotSerialize: boolean;
  13002. private _useTextureToStoreBoneMatrices;
  13003. /**
  13004. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13005. * Please note that this option is not available if the hardware does not support it
  13006. */
  13007. useTextureToStoreBoneMatrices: boolean;
  13008. private _animationPropertiesOverride;
  13009. /**
  13010. * Gets or sets the animation properties override
  13011. */
  13012. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13013. /**
  13014. * List of inspectable custom properties (used by the Inspector)
  13015. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13016. */
  13017. inspectableCustomProperties: IInspectable[];
  13018. /**
  13019. * An observable triggered before computing the skeleton's matrices
  13020. */
  13021. onBeforeComputeObservable: Observable<Skeleton>;
  13022. /**
  13023. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13024. */
  13025. readonly isUsingTextureForMatrices: boolean;
  13026. /**
  13027. * Gets the unique ID of this skeleton
  13028. */
  13029. readonly uniqueId: number;
  13030. /**
  13031. * Creates a new skeleton
  13032. * @param name defines the skeleton name
  13033. * @param id defines the skeleton Id
  13034. * @param scene defines the hosting scene
  13035. */
  13036. constructor(
  13037. /** defines the skeleton name */
  13038. name: string,
  13039. /** defines the skeleton Id */
  13040. id: string, scene: Scene);
  13041. /**
  13042. * Gets the current object class name.
  13043. * @return the class name
  13044. */
  13045. getClassName(): string;
  13046. /**
  13047. * Returns an array containing the root bones
  13048. * @returns an array containing the root bones
  13049. */
  13050. getChildren(): Array<Bone>;
  13051. /**
  13052. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13053. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13054. * @returns a Float32Array containing matrices data
  13055. */
  13056. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13057. /**
  13058. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13059. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13060. * @returns a raw texture containing the data
  13061. */
  13062. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13063. /**
  13064. * Gets the current hosting scene
  13065. * @returns a scene object
  13066. */
  13067. getScene(): Scene;
  13068. /**
  13069. * Gets a string representing the current skeleton data
  13070. * @param fullDetails defines a boolean indicating if we want a verbose version
  13071. * @returns a string representing the current skeleton data
  13072. */
  13073. toString(fullDetails?: boolean): string;
  13074. /**
  13075. * Get bone's index searching by name
  13076. * @param name defines bone's name to search for
  13077. * @return the indice of the bone. Returns -1 if not found
  13078. */
  13079. getBoneIndexByName(name: string): number;
  13080. /**
  13081. * Creater a new animation range
  13082. * @param name defines the name of the range
  13083. * @param from defines the start key
  13084. * @param to defines the end key
  13085. */
  13086. createAnimationRange(name: string, from: number, to: number): void;
  13087. /**
  13088. * Delete a specific animation range
  13089. * @param name defines the name of the range
  13090. * @param deleteFrames defines if frames must be removed as well
  13091. */
  13092. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13093. /**
  13094. * Gets a specific animation range
  13095. * @param name defines the name of the range to look for
  13096. * @returns the requested animation range or null if not found
  13097. */
  13098. getAnimationRange(name: string): Nullable<AnimationRange>;
  13099. /**
  13100. * Gets the list of all animation ranges defined on this skeleton
  13101. * @returns an array
  13102. */
  13103. getAnimationRanges(): Nullable<AnimationRange>[];
  13104. /**
  13105. * Copy animation range from a source skeleton.
  13106. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13107. * @param source defines the source skeleton
  13108. * @param name defines the name of the range to copy
  13109. * @param rescaleAsRequired defines if rescaling must be applied if required
  13110. * @returns true if operation was successful
  13111. */
  13112. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13113. /**
  13114. * Forces the skeleton to go to rest pose
  13115. */
  13116. returnToRest(): void;
  13117. private _getHighestAnimationFrame;
  13118. /**
  13119. * Begin a specific animation range
  13120. * @param name defines the name of the range to start
  13121. * @param loop defines if looping must be turned on (false by default)
  13122. * @param speedRatio defines the speed ratio to apply (1 by default)
  13123. * @param onAnimationEnd defines a callback which will be called when animation will end
  13124. * @returns a new animatable
  13125. */
  13126. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13127. /** @hidden */ private _markAsDirty(): void;
  13128. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13129. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13130. private _computeTransformMatrices;
  13131. /**
  13132. * Build all resources required to render a skeleton
  13133. */
  13134. prepare(): void;
  13135. /**
  13136. * Gets the list of animatables currently running for this skeleton
  13137. * @returns an array of animatables
  13138. */
  13139. getAnimatables(): IAnimatable[];
  13140. /**
  13141. * Clone the current skeleton
  13142. * @param name defines the name of the new skeleton
  13143. * @param id defines the id of the new skeleton
  13144. * @returns the new skeleton
  13145. */
  13146. clone(name: string, id: string): Skeleton;
  13147. /**
  13148. * Enable animation blending for this skeleton
  13149. * @param blendingSpeed defines the blending speed to apply
  13150. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13151. */
  13152. enableBlending(blendingSpeed?: number): void;
  13153. /**
  13154. * Releases all resources associated with the current skeleton
  13155. */
  13156. dispose(): void;
  13157. /**
  13158. * Serialize the skeleton in a JSON object
  13159. * @returns a JSON object
  13160. */
  13161. serialize(): any;
  13162. /**
  13163. * Creates a new skeleton from serialized data
  13164. * @param parsedSkeleton defines the serialized data
  13165. * @param scene defines the hosting scene
  13166. * @returns a new skeleton
  13167. */
  13168. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13169. /**
  13170. * Compute all node absolute transforms
  13171. * @param forceUpdate defines if computation must be done even if cache is up to date
  13172. */
  13173. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13174. /**
  13175. * Gets the root pose matrix
  13176. * @returns a matrix
  13177. */
  13178. getPoseMatrix(): Nullable<Matrix>;
  13179. /**
  13180. * Sorts bones per internal index
  13181. */
  13182. sortBones(): void;
  13183. private _sortBones;
  13184. }
  13185. }
  13186. declare module BABYLON {
  13187. /**
  13188. * Class used to store bone information
  13189. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13190. */
  13191. export class Bone extends Node {
  13192. /**
  13193. * defines the bone name
  13194. */
  13195. name: string;
  13196. private static _tmpVecs;
  13197. private static _tmpQuat;
  13198. private static _tmpMats;
  13199. /**
  13200. * Gets the list of child bones
  13201. */
  13202. children: Bone[];
  13203. /** Gets the animations associated with this bone */
  13204. animations: Animation[];
  13205. /**
  13206. * Gets or sets bone length
  13207. */
  13208. length: number;
  13209. /**
  13210. * @hidden Internal only
  13211. * Set this value to map this bone to a different index in the transform matrices
  13212. * Set this value to -1 to exclude the bone from the transform matrices
  13213. */ private _index: Nullable<number>;
  13214. private _skeleton;
  13215. private _localMatrix;
  13216. private _restPose;
  13217. private _baseMatrix;
  13218. private _absoluteTransform;
  13219. private _invertedAbsoluteTransform;
  13220. private _parent;
  13221. private _scalingDeterminant;
  13222. private _worldTransform;
  13223. private _localScaling;
  13224. private _localRotation;
  13225. private _localPosition;
  13226. private _needToDecompose;
  13227. private _needToCompose;
  13228. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13229. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13230. /** @hidden */
  13231. /** @hidden */ private _matrix: Matrix;
  13232. /**
  13233. * Create a new bone
  13234. * @param name defines the bone name
  13235. * @param skeleton defines the parent skeleton
  13236. * @param parentBone defines the parent (can be null if the bone is the root)
  13237. * @param localMatrix defines the local matrix
  13238. * @param restPose defines the rest pose matrix
  13239. * @param baseMatrix defines the base matrix
  13240. * @param index defines index of the bone in the hiearchy
  13241. */
  13242. constructor(
  13243. /**
  13244. * defines the bone name
  13245. */
  13246. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13247. /**
  13248. * Gets the current object class name.
  13249. * @return the class name
  13250. */
  13251. getClassName(): string;
  13252. /**
  13253. * Gets the parent skeleton
  13254. * @returns a skeleton
  13255. */
  13256. getSkeleton(): Skeleton;
  13257. /**
  13258. * Gets parent bone
  13259. * @returns a bone or null if the bone is the root of the bone hierarchy
  13260. */
  13261. getParent(): Nullable<Bone>;
  13262. /**
  13263. * Returns an array containing the root bones
  13264. * @returns an array containing the root bones
  13265. */
  13266. getChildren(): Array<Bone>;
  13267. /**
  13268. * Sets the parent bone
  13269. * @param parent defines the parent (can be null if the bone is the root)
  13270. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13271. */
  13272. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13273. /**
  13274. * Gets the local matrix
  13275. * @returns a matrix
  13276. */
  13277. getLocalMatrix(): Matrix;
  13278. /**
  13279. * Gets the base matrix (initial matrix which remains unchanged)
  13280. * @returns a matrix
  13281. */
  13282. getBaseMatrix(): Matrix;
  13283. /**
  13284. * Gets the rest pose matrix
  13285. * @returns a matrix
  13286. */
  13287. getRestPose(): Matrix;
  13288. /**
  13289. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13290. */
  13291. getWorldMatrix(): Matrix;
  13292. /**
  13293. * Sets the local matrix to rest pose matrix
  13294. */
  13295. returnToRest(): void;
  13296. /**
  13297. * Gets the inverse of the absolute transform matrix.
  13298. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13299. * @returns a matrix
  13300. */
  13301. getInvertedAbsoluteTransform(): Matrix;
  13302. /**
  13303. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13304. * @returns a matrix
  13305. */
  13306. getAbsoluteTransform(): Matrix;
  13307. /**
  13308. * Links with the given transform node.
  13309. * The local matrix of this bone is copied from the transform node every frame.
  13310. * @param transformNode defines the transform node to link to
  13311. */
  13312. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13313. /**
  13314. * Gets the node used to drive the bone's transformation
  13315. * @returns a transform node or null
  13316. */
  13317. getTransformNode(): Nullable<TransformNode>;
  13318. /** Gets or sets current position (in local space) */
  13319. position: Vector3;
  13320. /** Gets or sets current rotation (in local space) */
  13321. rotation: Vector3;
  13322. /** Gets or sets current rotation quaternion (in local space) */
  13323. rotationQuaternion: Quaternion;
  13324. /** Gets or sets current scaling (in local space) */
  13325. scaling: Vector3;
  13326. /**
  13327. * Gets the animation properties override
  13328. */
  13329. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13330. private _decompose;
  13331. private _compose;
  13332. /**
  13333. * Update the base and local matrices
  13334. * @param matrix defines the new base or local matrix
  13335. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13336. * @param updateLocalMatrix defines if the local matrix should be updated
  13337. */
  13338. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13339. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13340. /**
  13341. * Flag the bone as dirty (Forcing it to update everything)
  13342. */
  13343. markAsDirty(): void;
  13344. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13345. private _markAsDirtyAndDecompose;
  13346. /**
  13347. * Translate the bone in local or world space
  13348. * @param vec The amount to translate the bone
  13349. * @param space The space that the translation is in
  13350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13351. */
  13352. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13353. /**
  13354. * Set the postion of the bone in local or world space
  13355. * @param position The position to set the bone
  13356. * @param space The space that the position is in
  13357. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13358. */
  13359. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13360. /**
  13361. * Set the absolute position of the bone (world space)
  13362. * @param position The position to set the bone
  13363. * @param mesh The mesh that this bone is attached to
  13364. */
  13365. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13366. /**
  13367. * Scale the bone on the x, y and z axes (in local space)
  13368. * @param x The amount to scale the bone on the x axis
  13369. * @param y The amount to scale the bone on the y axis
  13370. * @param z The amount to scale the bone on the z axis
  13371. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13372. */
  13373. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13374. /**
  13375. * Set the bone scaling in local space
  13376. * @param scale defines the scaling vector
  13377. */
  13378. setScale(scale: Vector3): void;
  13379. /**
  13380. * Gets the current scaling in local space
  13381. * @returns the current scaling vector
  13382. */
  13383. getScale(): Vector3;
  13384. /**
  13385. * Gets the current scaling in local space and stores it in a target vector
  13386. * @param result defines the target vector
  13387. */
  13388. getScaleToRef(result: Vector3): void;
  13389. /**
  13390. * Set the yaw, pitch, and roll of the bone in local or world space
  13391. * @param yaw The rotation of the bone on the y axis
  13392. * @param pitch The rotation of the bone on the x axis
  13393. * @param roll The rotation of the bone on the z axis
  13394. * @param space The space that the axes of rotation are in
  13395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13396. */
  13397. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13398. /**
  13399. * Add a rotation to the bone on an axis in local or world space
  13400. * @param axis The axis to rotate the bone on
  13401. * @param amount The amount to rotate the bone
  13402. * @param space The space that the axis is in
  13403. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13404. */
  13405. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13406. /**
  13407. * Set the rotation of the bone to a particular axis angle in local or world space
  13408. * @param axis The axis to rotate the bone on
  13409. * @param angle The angle that the bone should be rotated to
  13410. * @param space The space that the axis is in
  13411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13412. */
  13413. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13414. /**
  13415. * Set the euler rotation of the bone in local of world space
  13416. * @param rotation The euler rotation that the bone should be set to
  13417. * @param space The space that the rotation is in
  13418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13419. */
  13420. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13421. /**
  13422. * Set the quaternion rotation of the bone in local of world space
  13423. * @param quat The quaternion rotation that the bone should be set to
  13424. * @param space The space that the rotation is in
  13425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13426. */
  13427. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13428. /**
  13429. * Set the rotation matrix of the bone in local of world space
  13430. * @param rotMat The rotation matrix that the bone should be set to
  13431. * @param space The space that the rotation is in
  13432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13433. */
  13434. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13435. private _rotateWithMatrix;
  13436. private _getNegativeRotationToRef;
  13437. /**
  13438. * Get the position of the bone in local or world space
  13439. * @param space The space that the returned position is in
  13440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13441. * @returns The position of the bone
  13442. */
  13443. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13444. /**
  13445. * Copy the position of the bone to a vector3 in local or world space
  13446. * @param space The space that the returned position is in
  13447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13448. * @param result The vector3 to copy the position to
  13449. */
  13450. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13451. /**
  13452. * Get the absolute position of the bone (world space)
  13453. * @param mesh The mesh that this bone is attached to
  13454. * @returns The absolute position of the bone
  13455. */
  13456. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13457. /**
  13458. * Copy the absolute position of the bone (world space) to the result param
  13459. * @param mesh The mesh that this bone is attached to
  13460. * @param result The vector3 to copy the absolute position to
  13461. */
  13462. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13463. /**
  13464. * Compute the absolute transforms of this bone and its children
  13465. */
  13466. computeAbsoluteTransforms(): void;
  13467. /**
  13468. * Get the world direction from an axis that is in the local space of the bone
  13469. * @param localAxis The local direction that is used to compute the world direction
  13470. * @param mesh The mesh that this bone is attached to
  13471. * @returns The world direction
  13472. */
  13473. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13474. /**
  13475. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13476. * @param localAxis The local direction that is used to compute the world direction
  13477. * @param mesh The mesh that this bone is attached to
  13478. * @param result The vector3 that the world direction will be copied to
  13479. */
  13480. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13481. /**
  13482. * Get the euler rotation of the bone in local or world space
  13483. * @param space The space that the rotation should be in
  13484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13485. * @returns The euler rotation
  13486. */
  13487. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13488. /**
  13489. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13490. * @param space The space that the rotation should be in
  13491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13492. * @param result The vector3 that the rotation should be copied to
  13493. */
  13494. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13495. /**
  13496. * Get the quaternion rotation of the bone in either local or world space
  13497. * @param space The space that the rotation should be in
  13498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13499. * @returns The quaternion rotation
  13500. */
  13501. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13502. /**
  13503. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13504. * @param space The space that the rotation should be in
  13505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13506. * @param result The quaternion that the rotation should be copied to
  13507. */
  13508. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13509. /**
  13510. * Get the rotation matrix of the bone in local or world space
  13511. * @param space The space that the rotation should be in
  13512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13513. * @returns The rotation matrix
  13514. */
  13515. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13516. /**
  13517. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13518. * @param space The space that the rotation should be in
  13519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13520. * @param result The quaternion that the rotation should be copied to
  13521. */
  13522. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13523. /**
  13524. * Get the world position of a point that is in the local space of the bone
  13525. * @param position The local position
  13526. * @param mesh The mesh that this bone is attached to
  13527. * @returns The world position
  13528. */
  13529. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13530. /**
  13531. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13532. * @param position The local position
  13533. * @param mesh The mesh that this bone is attached to
  13534. * @param result The vector3 that the world position should be copied to
  13535. */
  13536. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13537. /**
  13538. * Get the local position of a point that is in world space
  13539. * @param position The world position
  13540. * @param mesh The mesh that this bone is attached to
  13541. * @returns The local position
  13542. */
  13543. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13544. /**
  13545. * Get the local position of a point that is in world space and copy it to the result param
  13546. * @param position The world position
  13547. * @param mesh The mesh that this bone is attached to
  13548. * @param result The vector3 that the local position should be copied to
  13549. */
  13550. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13551. }
  13552. }
  13553. declare module BABYLON {
  13554. /**
  13555. * 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.
  13556. * @see https://doc.babylonjs.com/how_to/transformnode
  13557. */
  13558. export class TransformNode extends Node {
  13559. /**
  13560. * Object will not rotate to face the camera
  13561. */
  13562. static BILLBOARDMODE_NONE: number;
  13563. /**
  13564. * Object will rotate to face the camera but only on the x axis
  13565. */
  13566. static BILLBOARDMODE_X: number;
  13567. /**
  13568. * Object will rotate to face the camera but only on the y axis
  13569. */
  13570. static BILLBOARDMODE_Y: number;
  13571. /**
  13572. * Object will rotate to face the camera but only on the z axis
  13573. */
  13574. static BILLBOARDMODE_Z: number;
  13575. /**
  13576. * Object will rotate to face the camera
  13577. */
  13578. static BILLBOARDMODE_ALL: number;
  13579. /**
  13580. * Object will rotate to face the camera's position instead of orientation
  13581. */
  13582. static BILLBOARDMODE_USE_POSITION: number;
  13583. private _forward;
  13584. private _forwardInverted;
  13585. private _up;
  13586. private _right;
  13587. private _rightInverted;
  13588. private _position;
  13589. private _rotation;
  13590. private _rotationQuaternion;
  13591. protected _scaling: Vector3;
  13592. protected _isDirty: boolean;
  13593. private _transformToBoneReferal;
  13594. private _isAbsoluteSynced;
  13595. private _billboardMode;
  13596. /**
  13597. * Gets or sets the billboard mode. Default is 0.
  13598. *
  13599. * | Value | Type | Description |
  13600. * | --- | --- | --- |
  13601. * | 0 | BILLBOARDMODE_NONE | |
  13602. * | 1 | BILLBOARDMODE_X | |
  13603. * | 2 | BILLBOARDMODE_Y | |
  13604. * | 4 | BILLBOARDMODE_Z | |
  13605. * | 7 | BILLBOARDMODE_ALL | |
  13606. *
  13607. */
  13608. billboardMode: number;
  13609. private _preserveParentRotationForBillboard;
  13610. /**
  13611. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13612. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13613. */
  13614. preserveParentRotationForBillboard: boolean;
  13615. /**
  13616. * 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
  13617. */
  13618. scalingDeterminant: number;
  13619. private _infiniteDistance;
  13620. /**
  13621. * Gets or sets the distance of the object to max, often used by skybox
  13622. */
  13623. infiniteDistance: boolean;
  13624. /**
  13625. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13626. * By default the system will update normals to compensate
  13627. */
  13628. ignoreNonUniformScaling: boolean;
  13629. /**
  13630. * 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
  13631. */
  13632. reIntegrateRotationIntoRotationQuaternion: boolean;
  13633. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13634. /** @hidden */ private _localMatrix: Matrix;
  13635. private _usePivotMatrix;
  13636. private _absolutePosition;
  13637. private _absoluteScaling;
  13638. private _absoluteRotationQuaternion;
  13639. private _pivotMatrix;
  13640. private _pivotMatrixInverse;
  13641. protected _postMultiplyPivotMatrix: boolean;
  13642. protected _isWorldMatrixFrozen: boolean;
  13643. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13644. /**
  13645. * An event triggered after the world matrix is updated
  13646. */
  13647. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13648. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13649. /**
  13650. * Gets a string identifying the name of the class
  13651. * @returns "TransformNode" string
  13652. */
  13653. getClassName(): string;
  13654. /**
  13655. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13656. */
  13657. position: Vector3;
  13658. /**
  13659. * 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)).
  13660. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13661. */
  13662. rotation: Vector3;
  13663. /**
  13664. * 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)).
  13665. */
  13666. scaling: Vector3;
  13667. /**
  13668. * 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).
  13669. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13670. */
  13671. rotationQuaternion: Nullable<Quaternion>;
  13672. /**
  13673. * The forward direction of that transform in world space.
  13674. */
  13675. readonly forward: Vector3;
  13676. /**
  13677. * The up direction of that transform in world space.
  13678. */
  13679. readonly up: Vector3;
  13680. /**
  13681. * The right direction of that transform in world space.
  13682. */
  13683. readonly right: Vector3;
  13684. /**
  13685. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13686. * @param matrix the matrix to copy the pose from
  13687. * @returns this TransformNode.
  13688. */
  13689. updatePoseMatrix(matrix: Matrix): TransformNode;
  13690. /**
  13691. * Returns the mesh Pose matrix.
  13692. * @returns the pose matrix
  13693. */
  13694. getPoseMatrix(): Matrix;
  13695. /** @hidden */ private _isSynchronized(): boolean;
  13696. /** @hidden */ private _initCache(): void;
  13697. /**
  13698. * Flag the transform node as dirty (Forcing it to update everything)
  13699. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13700. * @returns this transform node
  13701. */
  13702. markAsDirty(property: string): TransformNode;
  13703. /**
  13704. * Returns the current mesh absolute position.
  13705. * Returns a Vector3.
  13706. */
  13707. readonly absolutePosition: Vector3;
  13708. /**
  13709. * Returns the current mesh absolute scaling.
  13710. * Returns a Vector3.
  13711. */
  13712. readonly absoluteScaling: Vector3;
  13713. /**
  13714. * Returns the current mesh absolute rotation.
  13715. * Returns a Quaternion.
  13716. */
  13717. readonly absoluteRotationQuaternion: Quaternion;
  13718. /**
  13719. * Sets a new matrix to apply before all other transformation
  13720. * @param matrix defines the transform matrix
  13721. * @returns the current TransformNode
  13722. */
  13723. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13724. /**
  13725. * Sets a new pivot matrix to the current node
  13726. * @param matrix defines the new pivot matrix to use
  13727. * @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
  13728. * @returns the current TransformNode
  13729. */
  13730. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13731. /**
  13732. * Returns the mesh pivot matrix.
  13733. * Default : Identity.
  13734. * @returns the matrix
  13735. */
  13736. getPivotMatrix(): Matrix;
  13737. /**
  13738. * Instantiate (when possible) or clone that node with its hierarchy
  13739. * @param newParent defines the new parent to use for the instance (or clone)
  13740. * @returns an instance (or a clone) of the current node with its hiearchy
  13741. */
  13742. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13743. /**
  13744. * Prevents the World matrix to be computed any longer
  13745. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13746. * @returns the TransformNode.
  13747. */
  13748. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13749. /**
  13750. * Allows back the World matrix computation.
  13751. * @returns the TransformNode.
  13752. */
  13753. unfreezeWorldMatrix(): this;
  13754. /**
  13755. * True if the World matrix has been frozen.
  13756. */
  13757. readonly isWorldMatrixFrozen: boolean;
  13758. /**
  13759. * Retuns the mesh absolute position in the World.
  13760. * @returns a Vector3.
  13761. */
  13762. getAbsolutePosition(): Vector3;
  13763. /**
  13764. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13765. * @param absolutePosition the absolute position to set
  13766. * @returns the TransformNode.
  13767. */
  13768. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13769. /**
  13770. * Sets the mesh position in its local space.
  13771. * @param vector3 the position to set in localspace
  13772. * @returns the TransformNode.
  13773. */
  13774. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13775. /**
  13776. * Returns the mesh position in the local space from the current World matrix values.
  13777. * @returns a new Vector3.
  13778. */
  13779. getPositionExpressedInLocalSpace(): Vector3;
  13780. /**
  13781. * Translates the mesh along the passed Vector3 in its local space.
  13782. * @param vector3 the distance to translate in localspace
  13783. * @returns the TransformNode.
  13784. */
  13785. locallyTranslate(vector3: Vector3): TransformNode;
  13786. private static _lookAtVectorCache;
  13787. /**
  13788. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13789. * @param targetPoint the position (must be in same space as current mesh) to look at
  13790. * @param yawCor optional yaw (y-axis) correction in radians
  13791. * @param pitchCor optional pitch (x-axis) correction in radians
  13792. * @param rollCor optional roll (z-axis) correction in radians
  13793. * @param space the choosen space of the target
  13794. * @returns the TransformNode.
  13795. */
  13796. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13797. /**
  13798. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13799. * This Vector3 is expressed in the World space.
  13800. * @param localAxis axis to rotate
  13801. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13802. */
  13803. getDirection(localAxis: Vector3): Vector3;
  13804. /**
  13805. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13806. * localAxis is expressed in the mesh local space.
  13807. * result is computed in the Wordl space from the mesh World matrix.
  13808. * @param localAxis axis to rotate
  13809. * @param result the resulting transformnode
  13810. * @returns this TransformNode.
  13811. */
  13812. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13813. /**
  13814. * Sets this transform node rotation to the given local axis.
  13815. * @param localAxis the axis in local space
  13816. * @param yawCor optional yaw (y-axis) correction in radians
  13817. * @param pitchCor optional pitch (x-axis) correction in radians
  13818. * @param rollCor optional roll (z-axis) correction in radians
  13819. * @returns this TransformNode
  13820. */
  13821. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13822. /**
  13823. * Sets a new pivot point to the current node
  13824. * @param point defines the new pivot point to use
  13825. * @param space defines if the point is in world or local space (local by default)
  13826. * @returns the current TransformNode
  13827. */
  13828. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13829. /**
  13830. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13831. * @returns the pivot point
  13832. */
  13833. getPivotPoint(): Vector3;
  13834. /**
  13835. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13836. * @param result the vector3 to store the result
  13837. * @returns this TransformNode.
  13838. */
  13839. getPivotPointToRef(result: Vector3): TransformNode;
  13840. /**
  13841. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13842. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13843. */
  13844. getAbsolutePivotPoint(): Vector3;
  13845. /**
  13846. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13847. * @param result vector3 to store the result
  13848. * @returns this TransformNode.
  13849. */
  13850. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13851. /**
  13852. * Defines the passed node as the parent of the current node.
  13853. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13854. * @see https://doc.babylonjs.com/how_to/parenting
  13855. * @param node the node ot set as the parent
  13856. * @returns this TransformNode.
  13857. */
  13858. setParent(node: Nullable<Node>): TransformNode;
  13859. private _nonUniformScaling;
  13860. /**
  13861. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13862. */
  13863. readonly nonUniformScaling: boolean;
  13864. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  13865. /**
  13866. * Attach the current TransformNode to another TransformNode associated with a bone
  13867. * @param bone Bone affecting the TransformNode
  13868. * @param affectedTransformNode TransformNode associated with the bone
  13869. * @returns this object
  13870. */
  13871. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13872. /**
  13873. * Detach the transform node if its associated with a bone
  13874. * @returns this object
  13875. */
  13876. detachFromBone(): TransformNode;
  13877. private static _rotationAxisCache;
  13878. /**
  13879. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13880. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13881. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13882. * The passed axis is also normalized.
  13883. * @param axis the axis to rotate around
  13884. * @param amount the amount to rotate in radians
  13885. * @param space Space to rotate in (Default: local)
  13886. * @returns the TransformNode.
  13887. */
  13888. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13889. /**
  13890. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13891. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13892. * The passed axis is also normalized. .
  13893. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13894. * @param point the point to rotate around
  13895. * @param axis the axis to rotate around
  13896. * @param amount the amount to rotate in radians
  13897. * @returns the TransformNode
  13898. */
  13899. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13900. /**
  13901. * Translates the mesh along the axis vector for the passed distance in the given space.
  13902. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13903. * @param axis the axis to translate in
  13904. * @param distance the distance to translate
  13905. * @param space Space to rotate in (Default: local)
  13906. * @returns the TransformNode.
  13907. */
  13908. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13909. /**
  13910. * Adds a rotation step to the mesh current rotation.
  13911. * x, y, z are Euler angles expressed in radians.
  13912. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13913. * This means this rotation is made in the mesh local space only.
  13914. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13915. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13916. * ```javascript
  13917. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13918. * ```
  13919. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13920. * 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.
  13921. * @param x Rotation to add
  13922. * @param y Rotation to add
  13923. * @param z Rotation to add
  13924. * @returns the TransformNode.
  13925. */
  13926. addRotation(x: number, y: number, z: number): TransformNode;
  13927. /**
  13928. * @hidden
  13929. */
  13930. protected _getEffectiveParent(): Nullable<Node>;
  13931. /**
  13932. * Computes the world matrix of the node
  13933. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13934. * @returns the world matrix
  13935. */
  13936. computeWorldMatrix(force?: boolean): Matrix;
  13937. protected _afterComputeWorldMatrix(): void;
  13938. /**
  13939. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13940. * @param func callback function to add
  13941. *
  13942. * @returns the TransformNode.
  13943. */
  13944. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13945. /**
  13946. * Removes a registered callback function.
  13947. * @param func callback function to remove
  13948. * @returns the TransformNode.
  13949. */
  13950. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13951. /**
  13952. * Gets the position of the current mesh in camera space
  13953. * @param camera defines the camera to use
  13954. * @returns a position
  13955. */
  13956. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13957. /**
  13958. * Returns the distance from the mesh to the active camera
  13959. * @param camera defines the camera to use
  13960. * @returns the distance
  13961. */
  13962. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13963. /**
  13964. * Clone the current transform node
  13965. * @param name Name of the new clone
  13966. * @param newParent New parent for the clone
  13967. * @param doNotCloneChildren Do not clone children hierarchy
  13968. * @returns the new transform node
  13969. */
  13970. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13971. /**
  13972. * Serializes the objects information.
  13973. * @param currentSerializationObject defines the object to serialize in
  13974. * @returns the serialized object
  13975. */
  13976. serialize(currentSerializationObject?: any): any;
  13977. /**
  13978. * Returns a new TransformNode object parsed from the source provided.
  13979. * @param parsedTransformNode is the source.
  13980. * @param scene the scne the object belongs to
  13981. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13982. * @returns a new TransformNode object parsed from the source provided.
  13983. */
  13984. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13985. /**
  13986. * Get all child-transformNodes of this node
  13987. * @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
  13988. * @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
  13989. * @returns an array of TransformNode
  13990. */
  13991. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13992. /**
  13993. * Releases resources associated with this transform node.
  13994. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13995. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13996. */
  13997. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13998. /**
  13999. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14000. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14001. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14002. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14003. * @returns the current mesh
  14004. */
  14005. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14006. private _syncAbsoluteScalingAndRotation;
  14007. }
  14008. }
  14009. declare module BABYLON {
  14010. /**
  14011. * Defines the types of pose enabled controllers that are supported
  14012. */
  14013. export enum PoseEnabledControllerType {
  14014. /**
  14015. * HTC Vive
  14016. */
  14017. VIVE = 0,
  14018. /**
  14019. * Oculus Rift
  14020. */
  14021. OCULUS = 1,
  14022. /**
  14023. * Windows mixed reality
  14024. */
  14025. WINDOWS = 2,
  14026. /**
  14027. * Samsung gear VR
  14028. */
  14029. GEAR_VR = 3,
  14030. /**
  14031. * Google Daydream
  14032. */
  14033. DAYDREAM = 4,
  14034. /**
  14035. * Generic
  14036. */
  14037. GENERIC = 5
  14038. }
  14039. /**
  14040. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14041. */
  14042. export interface MutableGamepadButton {
  14043. /**
  14044. * Value of the button/trigger
  14045. */
  14046. value: number;
  14047. /**
  14048. * If the button/trigger is currently touched
  14049. */
  14050. touched: boolean;
  14051. /**
  14052. * If the button/trigger is currently pressed
  14053. */
  14054. pressed: boolean;
  14055. }
  14056. /**
  14057. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14058. * @hidden
  14059. */
  14060. export interface ExtendedGamepadButton extends GamepadButton {
  14061. /**
  14062. * If the button/trigger is currently pressed
  14063. */
  14064. readonly pressed: boolean;
  14065. /**
  14066. * If the button/trigger is currently touched
  14067. */
  14068. readonly touched: boolean;
  14069. /**
  14070. * Value of the button/trigger
  14071. */
  14072. readonly value: number;
  14073. }
  14074. /** @hidden */
  14075. export interface _GamePadFactory {
  14076. /**
  14077. * Returns wether or not the current gamepad can be created for this type of controller.
  14078. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14079. * @returns true if it can be created, otherwise false
  14080. */
  14081. canCreate(gamepadInfo: any): boolean;
  14082. /**
  14083. * Creates a new instance of the Gamepad.
  14084. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14085. * @returns the new gamepad instance
  14086. */
  14087. create(gamepadInfo: any): Gamepad;
  14088. }
  14089. /**
  14090. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14091. */
  14092. export class PoseEnabledControllerHelper {
  14093. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14094. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14095. /**
  14096. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14097. * @param vrGamepad the gamepad to initialized
  14098. * @returns a vr controller of the type the gamepad identified as
  14099. */
  14100. static InitiateController(vrGamepad: any): Gamepad;
  14101. }
  14102. /**
  14103. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14104. */
  14105. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14106. /**
  14107. * If the controller is used in a webXR session
  14108. */
  14109. isXR: boolean;
  14110. private _deviceRoomPosition;
  14111. private _deviceRoomRotationQuaternion;
  14112. /**
  14113. * The device position in babylon space
  14114. */
  14115. devicePosition: Vector3;
  14116. /**
  14117. * The device rotation in babylon space
  14118. */
  14119. deviceRotationQuaternion: Quaternion;
  14120. /**
  14121. * The scale factor of the device in babylon space
  14122. */
  14123. deviceScaleFactor: number;
  14124. /**
  14125. * (Likely devicePosition should be used instead) The device position in its room space
  14126. */
  14127. position: Vector3;
  14128. /**
  14129. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14130. */
  14131. rotationQuaternion: Quaternion;
  14132. /**
  14133. * The type of controller (Eg. Windows mixed reality)
  14134. */
  14135. controllerType: PoseEnabledControllerType;
  14136. protected _calculatedPosition: Vector3;
  14137. private _calculatedRotation;
  14138. /**
  14139. * The raw pose from the device
  14140. */
  14141. rawPose: DevicePose;
  14142. private _trackPosition;
  14143. private _maxRotationDistFromHeadset;
  14144. private _draggedRoomRotation;
  14145. /**
  14146. * @hidden
  14147. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14148. /**
  14149. * Internal, the mesh attached to the controller
  14150. * @hidden
  14151. */ private _mesh: Nullable<AbstractMesh>;
  14152. private _poseControlledCamera;
  14153. private _leftHandSystemQuaternion;
  14154. /**
  14155. * Internal, matrix used to convert room space to babylon space
  14156. * @hidden
  14157. */ private _deviceToWorld: Matrix;
  14158. /**
  14159. * Node to be used when casting a ray from the controller
  14160. * @hidden
  14161. */ private _pointingPoseNode: Nullable<TransformNode>;
  14162. /**
  14163. * Name of the child mesh that can be used to cast a ray from the controller
  14164. */
  14165. static readonly POINTING_POSE: string;
  14166. /**
  14167. * Creates a new PoseEnabledController from a gamepad
  14168. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14169. */
  14170. constructor(browserGamepad: any);
  14171. private _workingMatrix;
  14172. /**
  14173. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14174. */
  14175. update(): void;
  14176. /**
  14177. * Updates only the pose device and mesh without doing any button event checking
  14178. */
  14179. protected _updatePoseAndMesh(): void;
  14180. /**
  14181. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14182. * @param poseData raw pose fromthe device
  14183. */
  14184. updateFromDevice(poseData: DevicePose): void;
  14185. /**
  14186. * @hidden
  14187. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14188. /**
  14189. * Attaches a mesh to the controller
  14190. * @param mesh the mesh to be attached
  14191. */
  14192. attachToMesh(mesh: AbstractMesh): void;
  14193. /**
  14194. * Attaches the controllers mesh to a camera
  14195. * @param camera the camera the mesh should be attached to
  14196. */
  14197. attachToPoseControlledCamera(camera: TargetCamera): void;
  14198. /**
  14199. * Disposes of the controller
  14200. */
  14201. dispose(): void;
  14202. /**
  14203. * The mesh that is attached to the controller
  14204. */
  14205. readonly mesh: Nullable<AbstractMesh>;
  14206. /**
  14207. * Gets the ray of the controller in the direction the controller is pointing
  14208. * @param length the length the resulting ray should be
  14209. * @returns a ray in the direction the controller is pointing
  14210. */
  14211. getForwardRay(length?: number): Ray;
  14212. }
  14213. }
  14214. declare module BABYLON {
  14215. /**
  14216. * Defines the WebVRController object that represents controllers tracked in 3D space
  14217. */
  14218. export abstract class WebVRController extends PoseEnabledController {
  14219. /**
  14220. * Internal, the default controller model for the controller
  14221. */
  14222. protected _defaultModel: AbstractMesh;
  14223. /**
  14224. * Fired when the trigger state has changed
  14225. */
  14226. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14227. /**
  14228. * Fired when the main button state has changed
  14229. */
  14230. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14231. /**
  14232. * Fired when the secondary button state has changed
  14233. */
  14234. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14235. /**
  14236. * Fired when the pad state has changed
  14237. */
  14238. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14239. /**
  14240. * Fired when controllers stick values have changed
  14241. */
  14242. onPadValuesChangedObservable: Observable<StickValues>;
  14243. /**
  14244. * Array of button availible on the controller
  14245. */
  14246. protected _buttons: Array<MutableGamepadButton>;
  14247. private _onButtonStateChange;
  14248. /**
  14249. * Fired when a controller button's state has changed
  14250. * @param callback the callback containing the button that was modified
  14251. */
  14252. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14253. /**
  14254. * X and Y axis corresponding to the controllers joystick
  14255. */
  14256. pad: StickValues;
  14257. /**
  14258. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14259. */
  14260. hand: string;
  14261. /**
  14262. * The default controller model for the controller
  14263. */
  14264. readonly defaultModel: AbstractMesh;
  14265. /**
  14266. * Creates a new WebVRController from a gamepad
  14267. * @param vrGamepad the gamepad that the WebVRController should be created from
  14268. */
  14269. constructor(vrGamepad: any);
  14270. /**
  14271. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14272. */
  14273. update(): void;
  14274. /**
  14275. * Function to be called when a button is modified
  14276. */
  14277. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14278. /**
  14279. * Loads a mesh and attaches it to the controller
  14280. * @param scene the scene the mesh should be added to
  14281. * @param meshLoaded callback for when the mesh has been loaded
  14282. */
  14283. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14284. private _setButtonValue;
  14285. private _changes;
  14286. private _checkChanges;
  14287. /**
  14288. * Disposes of th webVRCOntroller
  14289. */
  14290. dispose(): void;
  14291. }
  14292. }
  14293. declare module BABYLON {
  14294. /**
  14295. * The HemisphericLight simulates the ambient environment light,
  14296. * so the passed direction is the light reflection direction, not the incoming direction.
  14297. */
  14298. export class HemisphericLight extends Light {
  14299. /**
  14300. * The groundColor is the light in the opposite direction to the one specified during creation.
  14301. * 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.
  14302. */
  14303. groundColor: Color3;
  14304. /**
  14305. * The light reflection direction, not the incoming direction.
  14306. */
  14307. direction: Vector3;
  14308. /**
  14309. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14310. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14311. * The HemisphericLight can't cast shadows.
  14312. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14313. * @param name The friendly name of the light
  14314. * @param direction The direction of the light reflection
  14315. * @param scene The scene the light belongs to
  14316. */
  14317. constructor(name: string, direction: Vector3, scene: Scene);
  14318. protected _buildUniformLayout(): void;
  14319. /**
  14320. * Returns the string "HemisphericLight".
  14321. * @return The class name
  14322. */
  14323. getClassName(): string;
  14324. /**
  14325. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14326. * Returns the updated direction.
  14327. * @param target The target the direction should point to
  14328. * @return The computed direction
  14329. */
  14330. setDirectionToTarget(target: Vector3): Vector3;
  14331. /**
  14332. * Returns the shadow generator associated to the light.
  14333. * @returns Always null for hemispheric lights because it does not support shadows.
  14334. */
  14335. getShadowGenerator(): Nullable<IShadowGenerator>;
  14336. /**
  14337. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14338. * @param effect The effect to update
  14339. * @param lightIndex The index of the light in the effect to update
  14340. * @returns The hemispheric light
  14341. */
  14342. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14343. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14344. /**
  14345. * Computes the world matrix of the node
  14346. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14347. * @param useWasUpdatedFlag defines a reserved property
  14348. * @returns the world matrix
  14349. */
  14350. computeWorldMatrix(): Matrix;
  14351. /**
  14352. * Returns the integer 3.
  14353. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14354. */
  14355. getTypeID(): number;
  14356. /**
  14357. * Prepares the list of defines specific to the light type.
  14358. * @param defines the list of defines
  14359. * @param lightIndex defines the index of the light for the effect
  14360. */
  14361. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14362. }
  14363. }
  14364. declare module BABYLON {
  14365. /** @hidden */
  14366. export var vrMultiviewToSingleviewPixelShader: {
  14367. name: string;
  14368. shader: string;
  14369. };
  14370. }
  14371. declare module BABYLON {
  14372. /**
  14373. * Renders to multiple views with a single draw call
  14374. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14375. */
  14376. export class MultiviewRenderTarget extends RenderTargetTexture {
  14377. /**
  14378. * Creates a multiview render target
  14379. * @param scene scene used with the render target
  14380. * @param size the size of the render target (used for each view)
  14381. */
  14382. constructor(scene: Scene, size?: number | {
  14383. width: number;
  14384. height: number;
  14385. } | {
  14386. ratio: number;
  14387. });
  14388. /**
  14389. * @hidden
  14390. * @param faceIndex the face index, if its a cube texture
  14391. */ private _bindFrameBuffer(faceIndex?: number): void;
  14392. /**
  14393. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14394. * @returns the view count
  14395. */
  14396. getViewCount(): number;
  14397. }
  14398. }
  14399. declare module BABYLON {
  14400. /**
  14401. * Represents a camera frustum
  14402. */
  14403. export class Frustum {
  14404. /**
  14405. * Gets the planes representing the frustum
  14406. * @param transform matrix to be applied to the returned planes
  14407. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14408. */
  14409. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14410. /**
  14411. * Gets the near frustum plane transformed by the transform matrix
  14412. * @param transform transformation matrix to be applied to the resulting frustum plane
  14413. * @param frustumPlane the resuling frustum plane
  14414. */
  14415. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14416. /**
  14417. * Gets the far frustum plane transformed by the transform matrix
  14418. * @param transform transformation matrix to be applied to the resulting frustum plane
  14419. * @param frustumPlane the resuling frustum plane
  14420. */
  14421. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14422. /**
  14423. * Gets the left frustum plane transformed by the transform matrix
  14424. * @param transform transformation matrix to be applied to the resulting frustum plane
  14425. * @param frustumPlane the resuling frustum plane
  14426. */
  14427. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14428. /**
  14429. * Gets the right frustum plane transformed by the transform matrix
  14430. * @param transform transformation matrix to be applied to the resulting frustum plane
  14431. * @param frustumPlane the resuling frustum plane
  14432. */
  14433. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14434. /**
  14435. * Gets the top frustum plane transformed by the transform matrix
  14436. * @param transform transformation matrix to be applied to the resulting frustum plane
  14437. * @param frustumPlane the resuling frustum plane
  14438. */
  14439. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14440. /**
  14441. * Gets the bottom frustum plane transformed by the transform matrix
  14442. * @param transform transformation matrix to be applied to the resulting frustum plane
  14443. * @param frustumPlane the resuling frustum plane
  14444. */
  14445. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14446. /**
  14447. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14448. * @param transform transformation matrix to be applied to the resulting frustum planes
  14449. * @param frustumPlanes the resuling frustum planes
  14450. */
  14451. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14452. }
  14453. }
  14454. declare module BABYLON {
  14455. interface Engine {
  14456. /**
  14457. * Creates a new multiview render target
  14458. * @param width defines the width of the texture
  14459. * @param height defines the height of the texture
  14460. * @returns the created multiview texture
  14461. */
  14462. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14463. /**
  14464. * Binds a multiview framebuffer to be drawn to
  14465. * @param multiviewTexture texture to bind
  14466. */
  14467. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14468. }
  14469. interface Camera {
  14470. /**
  14471. * @hidden
  14472. * 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)
  14473. */ private _useMultiviewToSingleView: boolean;
  14474. /**
  14475. * @hidden
  14476. * 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)
  14477. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14478. /**
  14479. * @hidden
  14480. * ensures the multiview texture of the camera exists and has the specified width/height
  14481. * @param width height to set on the multiview texture
  14482. * @param height width to set on the multiview texture
  14483. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14484. }
  14485. interface Scene {
  14486. /** @hidden */ private _transformMatrixR: Matrix;
  14487. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14488. /** @hidden */ private _createMultiviewUbo(): void;
  14489. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14490. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14491. }
  14492. }
  14493. declare module BABYLON {
  14494. /**
  14495. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14496. * This will not be used for webXR as it supports displaying texture arrays directly
  14497. */
  14498. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14499. /**
  14500. * Initializes a VRMultiviewToSingleview
  14501. * @param name name of the post process
  14502. * @param camera camera to be applied to
  14503. * @param scaleFactor scaling factor to the size of the output texture
  14504. */
  14505. constructor(name: string, camera: Camera, scaleFactor: number);
  14506. }
  14507. }
  14508. declare module BABYLON {
  14509. interface Engine {
  14510. /** @hidden */ private _vrDisplay: any;
  14511. /** @hidden */ private _vrSupported: boolean;
  14512. /** @hidden */ private _oldSize: Size;
  14513. /** @hidden */ private _oldHardwareScaleFactor: number;
  14514. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14515. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14516. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14517. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14518. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14519. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14520. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14521. /**
  14522. * Observable signaled when VR display mode changes
  14523. */
  14524. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14525. /**
  14526. * Observable signaled when VR request present is complete
  14527. */
  14528. onVRRequestPresentComplete: Observable<boolean>;
  14529. /**
  14530. * Observable signaled when VR request present starts
  14531. */
  14532. onVRRequestPresentStart: Observable<Engine>;
  14533. /**
  14534. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14535. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14536. */
  14537. isInVRExclusivePointerMode: boolean;
  14538. /**
  14539. * Gets a boolean indicating if a webVR device was detected
  14540. * @returns true if a webVR device was detected
  14541. */
  14542. isVRDevicePresent(): boolean;
  14543. /**
  14544. * Gets the current webVR device
  14545. * @returns the current webVR device (or null)
  14546. */
  14547. getVRDevice(): any;
  14548. /**
  14549. * Initializes a webVR display and starts listening to display change events
  14550. * The onVRDisplayChangedObservable will be notified upon these changes
  14551. * @returns A promise containing a VRDisplay and if vr is supported
  14552. */
  14553. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14554. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14555. /**
  14556. * Call this function to switch to webVR mode
  14557. * Will do nothing if webVR is not supported or if there is no webVR device
  14558. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14559. */
  14560. enableVR(): void;
  14561. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14562. }
  14563. }
  14564. declare module BABYLON {
  14565. /**
  14566. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14567. * IMPORTANT!! The data is right-hand data.
  14568. * @export
  14569. * @interface DevicePose
  14570. */
  14571. export interface DevicePose {
  14572. /**
  14573. * The position of the device, values in array are [x,y,z].
  14574. */
  14575. readonly position: Nullable<Float32Array>;
  14576. /**
  14577. * The linearVelocity of the device, values in array are [x,y,z].
  14578. */
  14579. readonly linearVelocity: Nullable<Float32Array>;
  14580. /**
  14581. * The linearAcceleration of the device, values in array are [x,y,z].
  14582. */
  14583. readonly linearAcceleration: Nullable<Float32Array>;
  14584. /**
  14585. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14586. */
  14587. readonly orientation: Nullable<Float32Array>;
  14588. /**
  14589. * The angularVelocity of the device, values in array are [x,y,z].
  14590. */
  14591. readonly angularVelocity: Nullable<Float32Array>;
  14592. /**
  14593. * The angularAcceleration of the device, values in array are [x,y,z].
  14594. */
  14595. readonly angularAcceleration: Nullable<Float32Array>;
  14596. }
  14597. /**
  14598. * Interface representing a pose controlled object in Babylon.
  14599. * A pose controlled object has both regular pose values as well as pose values
  14600. * from an external device such as a VR head mounted display
  14601. */
  14602. export interface PoseControlled {
  14603. /**
  14604. * The position of the object in babylon space.
  14605. */
  14606. position: Vector3;
  14607. /**
  14608. * The rotation quaternion of the object in babylon space.
  14609. */
  14610. rotationQuaternion: Quaternion;
  14611. /**
  14612. * The position of the device in babylon space.
  14613. */
  14614. devicePosition?: Vector3;
  14615. /**
  14616. * The rotation quaternion of the device in babylon space.
  14617. */
  14618. deviceRotationQuaternion: Quaternion;
  14619. /**
  14620. * The raw pose coming from the device.
  14621. */
  14622. rawPose: Nullable<DevicePose>;
  14623. /**
  14624. * The scale of the device to be used when translating from device space to babylon space.
  14625. */
  14626. deviceScaleFactor: number;
  14627. /**
  14628. * Updates the poseControlled values based on the input device pose.
  14629. * @param poseData the pose data to update the object with
  14630. */
  14631. updateFromDevice(poseData: DevicePose): void;
  14632. }
  14633. /**
  14634. * Set of options to customize the webVRCamera
  14635. */
  14636. export interface WebVROptions {
  14637. /**
  14638. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14639. */
  14640. trackPosition?: boolean;
  14641. /**
  14642. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14643. */
  14644. positionScale?: number;
  14645. /**
  14646. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14647. */
  14648. displayName?: string;
  14649. /**
  14650. * Should the native controller meshes be initialized. (default: true)
  14651. */
  14652. controllerMeshes?: boolean;
  14653. /**
  14654. * Creating a default HemiLight only on controllers. (default: true)
  14655. */
  14656. defaultLightingOnControllers?: boolean;
  14657. /**
  14658. * If you don't want to use the default VR button of the helper. (default: false)
  14659. */
  14660. useCustomVRButton?: boolean;
  14661. /**
  14662. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14663. */
  14664. customVRButton?: HTMLButtonElement;
  14665. /**
  14666. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14667. */
  14668. rayLength?: number;
  14669. /**
  14670. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14671. */
  14672. defaultHeight?: number;
  14673. /**
  14674. * If multiview should be used if availible (default: false)
  14675. */
  14676. useMultiview?: boolean;
  14677. }
  14678. /**
  14679. * This represents a WebVR camera.
  14680. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14681. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14682. */
  14683. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14684. private webVROptions;
  14685. /**
  14686. * @hidden
  14687. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14688. */ private _vrDevice: any;
  14689. /**
  14690. * The rawPose of the vrDevice.
  14691. */
  14692. rawPose: Nullable<DevicePose>;
  14693. private _onVREnabled;
  14694. private _specsVersion;
  14695. private _attached;
  14696. private _frameData;
  14697. protected _descendants: Array<Node>;
  14698. private _deviceRoomPosition;
  14699. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14700. private _standingMatrix;
  14701. /**
  14702. * Represents device position in babylon space.
  14703. */
  14704. devicePosition: Vector3;
  14705. /**
  14706. * Represents device rotation in babylon space.
  14707. */
  14708. deviceRotationQuaternion: Quaternion;
  14709. /**
  14710. * The scale of the device to be used when translating from device space to babylon space.
  14711. */
  14712. deviceScaleFactor: number;
  14713. private _deviceToWorld;
  14714. private _worldToDevice;
  14715. /**
  14716. * References to the webVR controllers for the vrDevice.
  14717. */
  14718. controllers: Array<WebVRController>;
  14719. /**
  14720. * Emits an event when a controller is attached.
  14721. */
  14722. onControllersAttachedObservable: Observable<WebVRController[]>;
  14723. /**
  14724. * Emits an event when a controller's mesh has been loaded;
  14725. */
  14726. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14727. /**
  14728. * Emits an event when the HMD's pose has been updated.
  14729. */
  14730. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14731. private _poseSet;
  14732. /**
  14733. * If the rig cameras be used as parent instead of this camera.
  14734. */
  14735. rigParenting: boolean;
  14736. private _lightOnControllers;
  14737. private _defaultHeight?;
  14738. /**
  14739. * Instantiates a WebVRFreeCamera.
  14740. * @param name The name of the WebVRFreeCamera
  14741. * @param position The starting anchor position for the camera
  14742. * @param scene The scene the camera belongs to
  14743. * @param webVROptions a set of customizable options for the webVRCamera
  14744. */
  14745. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14746. /**
  14747. * Gets the device distance from the ground in meters.
  14748. * @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.
  14749. */
  14750. deviceDistanceToRoomGround(): number;
  14751. /**
  14752. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14753. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14754. */
  14755. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14756. /**
  14757. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14758. * @returns A promise with a boolean set to if the standing matrix is supported.
  14759. */
  14760. useStandingMatrixAsync(): Promise<boolean>;
  14761. /**
  14762. * Disposes the camera
  14763. */
  14764. dispose(): void;
  14765. /**
  14766. * Gets a vrController by name.
  14767. * @param name The name of the controller to retreive
  14768. * @returns the controller matching the name specified or null if not found
  14769. */
  14770. getControllerByName(name: string): Nullable<WebVRController>;
  14771. private _leftController;
  14772. /**
  14773. * The controller corresponding to the users left hand.
  14774. */
  14775. readonly leftController: Nullable<WebVRController>;
  14776. private _rightController;
  14777. /**
  14778. * The controller corresponding to the users right hand.
  14779. */
  14780. readonly rightController: Nullable<WebVRController>;
  14781. /**
  14782. * Casts a ray forward from the vrCamera's gaze.
  14783. * @param length Length of the ray (default: 100)
  14784. * @returns the ray corresponding to the gaze
  14785. */
  14786. getForwardRay(length?: number): Ray;
  14787. /**
  14788. * @hidden
  14789. * Updates the camera based on device's frame data
  14790. */ private _checkInputs(): void;
  14791. /**
  14792. * Updates the poseControlled values based on the input device pose.
  14793. * @param poseData Pose coming from the device
  14794. */
  14795. updateFromDevice(poseData: DevicePose): void;
  14796. private _htmlElementAttached;
  14797. private _detachIfAttached;
  14798. /**
  14799. * WebVR's attach control will start broadcasting frames to the device.
  14800. * Note that in certain browsers (chrome for example) this function must be called
  14801. * within a user-interaction callback. Example:
  14802. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14803. *
  14804. * @param element html element to attach the vrDevice to
  14805. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14806. */
  14807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14808. /**
  14809. * Detaches the camera from the html element and disables VR
  14810. *
  14811. * @param element html element to detach from
  14812. */
  14813. detachControl(element: HTMLElement): void;
  14814. /**
  14815. * @returns the name of this class
  14816. */
  14817. getClassName(): string;
  14818. /**
  14819. * Calls resetPose on the vrDisplay
  14820. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14821. */
  14822. resetToCurrentRotation(): void;
  14823. /**
  14824. * @hidden
  14825. * Updates the rig cameras (left and right eye)
  14826. */ private _updateRigCameras(): void;
  14827. private _workingVector;
  14828. private _oneVector;
  14829. private _workingMatrix;
  14830. private updateCacheCalled;
  14831. private _correctPositionIfNotTrackPosition;
  14832. /**
  14833. * @hidden
  14834. * Updates the cached values of the camera
  14835. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14836. */ private _updateCache(ignoreParentClass?: boolean): void;
  14837. /**
  14838. * @hidden
  14839. * Get current device position in babylon world
  14840. */ private _computeDevicePosition(): void;
  14841. /**
  14842. * Updates the current device position and rotation in the babylon world
  14843. */
  14844. update(): void;
  14845. /**
  14846. * @hidden
  14847. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14848. * @returns an identity matrix
  14849. */ private _getViewMatrix(): Matrix;
  14850. private _tmpMatrix;
  14851. /**
  14852. * This function is called by the two RIG cameras.
  14853. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14854. * @hidden
  14855. */ private _getWebVRViewMatrix(): Matrix;
  14856. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  14857. private _onGamepadConnectedObserver;
  14858. private _onGamepadDisconnectedObserver;
  14859. private _updateCacheWhenTrackingDisabledObserver;
  14860. /**
  14861. * Initializes the controllers and their meshes
  14862. */
  14863. initControllers(): void;
  14864. }
  14865. }
  14866. declare module BABYLON {
  14867. /**
  14868. * Size options for a post process
  14869. */
  14870. export type PostProcessOptions = {
  14871. width: number;
  14872. height: number;
  14873. };
  14874. /**
  14875. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14876. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14877. */
  14878. export class PostProcess {
  14879. /** Name of the PostProcess. */
  14880. name: string;
  14881. /**
  14882. * Gets or sets the unique id of the post process
  14883. */
  14884. uniqueId: number;
  14885. /**
  14886. * Width of the texture to apply the post process on
  14887. */
  14888. width: number;
  14889. /**
  14890. * Height of the texture to apply the post process on
  14891. */
  14892. height: number;
  14893. /**
  14894. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14895. * @hidden
  14896. */ private _outputTexture: Nullable<InternalTexture>;
  14897. /**
  14898. * Sampling mode used by the shader
  14899. * See https://doc.babylonjs.com/classes/3.1/texture
  14900. */
  14901. renderTargetSamplingMode: number;
  14902. /**
  14903. * Clear color to use when screen clearing
  14904. */
  14905. clearColor: Color4;
  14906. /**
  14907. * If the buffer needs to be cleared before applying the post process. (default: true)
  14908. * Should be set to false if shader will overwrite all previous pixels.
  14909. */
  14910. autoClear: boolean;
  14911. /**
  14912. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14913. */
  14914. alphaMode: number;
  14915. /**
  14916. * Sets the setAlphaBlendConstants of the babylon engine
  14917. */
  14918. alphaConstants: Color4;
  14919. /**
  14920. * Animations to be used for the post processing
  14921. */
  14922. animations: Animation[];
  14923. /**
  14924. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14925. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14926. */
  14927. enablePixelPerfectMode: boolean;
  14928. /**
  14929. * Force the postprocess to be applied without taking in account viewport
  14930. */
  14931. forceFullscreenViewport: boolean;
  14932. /**
  14933. * List of inspectable custom properties (used by the Inspector)
  14934. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14935. */
  14936. inspectableCustomProperties: IInspectable[];
  14937. /**
  14938. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14939. *
  14940. * | Value | Type | Description |
  14941. * | ----- | ----------------------------------- | ----------- |
  14942. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14943. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14944. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14945. *
  14946. */
  14947. scaleMode: number;
  14948. /**
  14949. * Force textures to be a power of two (default: false)
  14950. */
  14951. alwaysForcePOT: boolean;
  14952. private _samples;
  14953. /**
  14954. * Number of sample textures (default: 1)
  14955. */
  14956. samples: number;
  14957. /**
  14958. * Modify the scale of the post process to be the same as the viewport (default: false)
  14959. */
  14960. adaptScaleToCurrentViewport: boolean;
  14961. private _camera;
  14962. private _scene;
  14963. private _engine;
  14964. private _options;
  14965. private _reusable;
  14966. private _textureType;
  14967. /**
  14968. * Smart array of input and output textures for the post process.
  14969. * @hidden
  14970. */ private _textures: SmartArray<InternalTexture>;
  14971. /**
  14972. * The index in _textures that corresponds to the output texture.
  14973. * @hidden
  14974. */ private _currentRenderTextureInd: number;
  14975. private _effect;
  14976. private _samplers;
  14977. private _fragmentUrl;
  14978. private _vertexUrl;
  14979. private _parameters;
  14980. private _scaleRatio;
  14981. protected _indexParameters: any;
  14982. private _shareOutputWithPostProcess;
  14983. private _texelSize;
  14984. private _forcedOutputTexture;
  14985. /**
  14986. * Returns the fragment url or shader name used in the post process.
  14987. * @returns the fragment url or name in the shader store.
  14988. */
  14989. getEffectName(): string;
  14990. /**
  14991. * An event triggered when the postprocess is activated.
  14992. */
  14993. onActivateObservable: Observable<Camera>;
  14994. private _onActivateObserver;
  14995. /**
  14996. * A function that is added to the onActivateObservable
  14997. */
  14998. onActivate: Nullable<(camera: Camera) => void>;
  14999. /**
  15000. * An event triggered when the postprocess changes its size.
  15001. */
  15002. onSizeChangedObservable: Observable<PostProcess>;
  15003. private _onSizeChangedObserver;
  15004. /**
  15005. * A function that is added to the onSizeChangedObservable
  15006. */
  15007. onSizeChanged: (postProcess: PostProcess) => void;
  15008. /**
  15009. * An event triggered when the postprocess applies its effect.
  15010. */
  15011. onApplyObservable: Observable<Effect>;
  15012. private _onApplyObserver;
  15013. /**
  15014. * A function that is added to the onApplyObservable
  15015. */
  15016. onApply: (effect: Effect) => void;
  15017. /**
  15018. * An event triggered before rendering the postprocess
  15019. */
  15020. onBeforeRenderObservable: Observable<Effect>;
  15021. private _onBeforeRenderObserver;
  15022. /**
  15023. * A function that is added to the onBeforeRenderObservable
  15024. */
  15025. onBeforeRender: (effect: Effect) => void;
  15026. /**
  15027. * An event triggered after rendering the postprocess
  15028. */
  15029. onAfterRenderObservable: Observable<Effect>;
  15030. private _onAfterRenderObserver;
  15031. /**
  15032. * A function that is added to the onAfterRenderObservable
  15033. */
  15034. onAfterRender: (efect: Effect) => void;
  15035. /**
  15036. * 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
  15037. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15038. */
  15039. inputTexture: InternalTexture;
  15040. /**
  15041. * Gets the camera which post process is applied to.
  15042. * @returns The camera the post process is applied to.
  15043. */
  15044. getCamera(): Camera;
  15045. /**
  15046. * Gets the texel size of the postprocess.
  15047. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15048. */
  15049. readonly texelSize: Vector2;
  15050. /**
  15051. * Creates a new instance PostProcess
  15052. * @param name The name of the PostProcess.
  15053. * @param fragmentUrl The url of the fragment shader to be used.
  15054. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15055. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15056. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15057. * @param camera The camera to apply the render pass to.
  15058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15059. * @param engine The engine which the post process will be applied. (default: current engine)
  15060. * @param reusable If the post process can be reused on the same frame. (default: false)
  15061. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15062. * @param textureType Type of textures used when performing the post process. (default: 0)
  15063. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15064. * @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
  15065. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15066. */
  15067. constructor(
  15068. /** Name of the PostProcess. */
  15069. 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);
  15070. /**
  15071. * Gets a string idenfifying the name of the class
  15072. * @returns "PostProcess" string
  15073. */
  15074. getClassName(): string;
  15075. /**
  15076. * Gets the engine which this post process belongs to.
  15077. * @returns The engine the post process was enabled with.
  15078. */
  15079. getEngine(): Engine;
  15080. /**
  15081. * The effect that is created when initializing the post process.
  15082. * @returns The created effect corresponding the the postprocess.
  15083. */
  15084. getEffect(): Effect;
  15085. /**
  15086. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15087. * @param postProcess The post process to share the output with.
  15088. * @returns This post process.
  15089. */
  15090. shareOutputWith(postProcess: PostProcess): PostProcess;
  15091. /**
  15092. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15093. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15094. */
  15095. useOwnOutput(): void;
  15096. /**
  15097. * Updates the effect with the current post process compile time values and recompiles the shader.
  15098. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15099. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15100. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15101. * @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
  15102. * @param onCompiled Called when the shader has been compiled.
  15103. * @param onError Called if there is an error when compiling a shader.
  15104. */
  15105. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15106. /**
  15107. * The post process is reusable if it can be used multiple times within one frame.
  15108. * @returns If the post process is reusable
  15109. */
  15110. isReusable(): boolean;
  15111. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15112. markTextureDirty(): void;
  15113. /**
  15114. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15115. * 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.
  15116. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15117. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15118. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15119. * @returns The target texture that was bound to be written to.
  15120. */
  15121. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15122. /**
  15123. * If the post process is supported.
  15124. */
  15125. readonly isSupported: boolean;
  15126. /**
  15127. * The aspect ratio of the output texture.
  15128. */
  15129. readonly aspectRatio: number;
  15130. /**
  15131. * Get a value indicating if the post-process is ready to be used
  15132. * @returns true if the post-process is ready (shader is compiled)
  15133. */
  15134. isReady(): boolean;
  15135. /**
  15136. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15137. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15138. */
  15139. apply(): Nullable<Effect>;
  15140. private _disposeTextures;
  15141. /**
  15142. * Disposes the post process.
  15143. * @param camera The camera to dispose the post process on.
  15144. */
  15145. dispose(camera?: Camera): void;
  15146. }
  15147. }
  15148. declare module BABYLON {
  15149. /** @hidden */
  15150. export var kernelBlurVaryingDeclaration: {
  15151. name: string;
  15152. shader: string;
  15153. };
  15154. }
  15155. declare module BABYLON {
  15156. /** @hidden */
  15157. export var kernelBlurFragment: {
  15158. name: string;
  15159. shader: string;
  15160. };
  15161. }
  15162. declare module BABYLON {
  15163. /** @hidden */
  15164. export var kernelBlurFragment2: {
  15165. name: string;
  15166. shader: string;
  15167. };
  15168. }
  15169. declare module BABYLON {
  15170. /** @hidden */
  15171. export var kernelBlurPixelShader: {
  15172. name: string;
  15173. shader: string;
  15174. };
  15175. }
  15176. declare module BABYLON {
  15177. /** @hidden */
  15178. export var kernelBlurVertex: {
  15179. name: string;
  15180. shader: string;
  15181. };
  15182. }
  15183. declare module BABYLON {
  15184. /** @hidden */
  15185. export var kernelBlurVertexShader: {
  15186. name: string;
  15187. shader: string;
  15188. };
  15189. }
  15190. declare module BABYLON {
  15191. /**
  15192. * The Blur Post Process which blurs an image based on a kernel and direction.
  15193. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15194. */
  15195. export class BlurPostProcess extends PostProcess {
  15196. /** The direction in which to blur the image. */
  15197. direction: Vector2;
  15198. private blockCompilation;
  15199. protected _kernel: number;
  15200. protected _idealKernel: number;
  15201. protected _packedFloat: boolean;
  15202. private _staticDefines;
  15203. /**
  15204. * Sets the length in pixels of the blur sample region
  15205. */
  15206. /**
  15207. * Gets the length in pixels of the blur sample region
  15208. */
  15209. kernel: number;
  15210. /**
  15211. * Sets wether or not the blur needs to unpack/repack floats
  15212. */
  15213. /**
  15214. * Gets wether or not the blur is unpacking/repacking floats
  15215. */
  15216. packedFloat: boolean;
  15217. /**
  15218. * Creates a new instance BlurPostProcess
  15219. * @param name The name of the effect.
  15220. * @param direction The direction in which to blur the image.
  15221. * @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.
  15222. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15223. * @param camera The camera to apply the render pass to.
  15224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15225. * @param engine The engine which the post process will be applied. (default: current engine)
  15226. * @param reusable If the post process can be reused on the same frame. (default: false)
  15227. * @param textureType Type of textures used when performing the post process. (default: 0)
  15228. * @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)
  15229. */
  15230. constructor(name: string,
  15231. /** The direction in which to blur the image. */
  15232. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15233. /**
  15234. * Updates the effect with the current post process compile time values and recompiles the shader.
  15235. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15236. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15237. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15238. * @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
  15239. * @param onCompiled Called when the shader has been compiled.
  15240. * @param onError Called if there is an error when compiling a shader.
  15241. */
  15242. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15243. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15244. /**
  15245. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15246. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15247. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15248. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15249. * The gaps between physical kernels are compensated for in the weighting of the samples
  15250. * @param idealKernel Ideal blur kernel.
  15251. * @return Nearest best kernel.
  15252. */
  15253. protected _nearestBestKernel(idealKernel: number): number;
  15254. /**
  15255. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15256. * @param x The point on the Gaussian distribution to sample.
  15257. * @return the value of the Gaussian function at x.
  15258. */
  15259. protected _gaussianWeight(x: number): number;
  15260. /**
  15261. * Generates a string that can be used as a floating point number in GLSL.
  15262. * @param x Value to print.
  15263. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15264. * @return GLSL float string.
  15265. */
  15266. protected _glslFloat(x: number, decimalFigures?: number): string;
  15267. }
  15268. }
  15269. declare module BABYLON {
  15270. /**
  15271. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15272. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15273. * You can then easily use it as a reflectionTexture on a flat surface.
  15274. * In case the surface is not a plane, please consider relying on reflection probes.
  15275. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15276. */
  15277. export class MirrorTexture extends RenderTargetTexture {
  15278. private scene;
  15279. /**
  15280. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15281. * 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.
  15282. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15283. */
  15284. mirrorPlane: Plane;
  15285. /**
  15286. * Define the blur ratio used to blur the reflection if needed.
  15287. */
  15288. blurRatio: number;
  15289. /**
  15290. * Define the adaptive blur kernel used to blur the reflection if needed.
  15291. * This will autocompute the closest best match for the `blurKernel`
  15292. */
  15293. adaptiveBlurKernel: number;
  15294. /**
  15295. * Define the blur kernel used to blur the reflection if needed.
  15296. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15297. */
  15298. blurKernel: number;
  15299. /**
  15300. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15301. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15302. */
  15303. blurKernelX: number;
  15304. /**
  15305. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15306. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15307. */
  15308. blurKernelY: number;
  15309. private _autoComputeBlurKernel;
  15310. protected _onRatioRescale(): void;
  15311. private _updateGammaSpace;
  15312. private _imageProcessingConfigChangeObserver;
  15313. private _transformMatrix;
  15314. private _mirrorMatrix;
  15315. private _savedViewMatrix;
  15316. private _blurX;
  15317. private _blurY;
  15318. private _adaptiveBlurKernel;
  15319. private _blurKernelX;
  15320. private _blurKernelY;
  15321. private _blurRatio;
  15322. /**
  15323. * Instantiates a Mirror Texture.
  15324. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15325. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15326. * You can then easily use it as a reflectionTexture on a flat surface.
  15327. * In case the surface is not a plane, please consider relying on reflection probes.
  15328. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15329. * @param name
  15330. * @param size
  15331. * @param scene
  15332. * @param generateMipMaps
  15333. * @param type
  15334. * @param samplingMode
  15335. * @param generateDepthBuffer
  15336. */
  15337. constructor(name: string, size: number | {
  15338. width: number;
  15339. height: number;
  15340. } | {
  15341. ratio: number;
  15342. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15343. private _preparePostProcesses;
  15344. /**
  15345. * Clone the mirror texture.
  15346. * @returns the cloned texture
  15347. */
  15348. clone(): MirrorTexture;
  15349. /**
  15350. * Serialize the texture to a JSON representation you could use in Parse later on
  15351. * @returns the serialized JSON representation
  15352. */
  15353. serialize(): any;
  15354. /**
  15355. * Dispose the texture and release its associated resources.
  15356. */
  15357. dispose(): void;
  15358. }
  15359. }
  15360. declare module BABYLON {
  15361. /**
  15362. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15363. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15364. */
  15365. export class Texture extends BaseTexture {
  15366. /**
  15367. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15368. */
  15369. static SerializeBuffers: boolean;
  15370. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15371. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15372. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15373. /** nearest is mag = nearest and min = nearest and mip = linear */
  15374. static readonly NEAREST_SAMPLINGMODE: number;
  15375. /** nearest is mag = nearest and min = nearest and mip = linear */
  15376. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15377. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15378. static readonly BILINEAR_SAMPLINGMODE: number;
  15379. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15380. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15381. /** Trilinear is mag = linear and min = linear and mip = linear */
  15382. static readonly TRILINEAR_SAMPLINGMODE: number;
  15383. /** Trilinear is mag = linear and min = linear and mip = linear */
  15384. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15385. /** mag = nearest and min = nearest and mip = nearest */
  15386. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15387. /** mag = nearest and min = linear and mip = nearest */
  15388. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15389. /** mag = nearest and min = linear and mip = linear */
  15390. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15391. /** mag = nearest and min = linear and mip = none */
  15392. static readonly NEAREST_LINEAR: number;
  15393. /** mag = nearest and min = nearest and mip = none */
  15394. static readonly NEAREST_NEAREST: number;
  15395. /** mag = linear and min = nearest and mip = nearest */
  15396. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15397. /** mag = linear and min = nearest and mip = linear */
  15398. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15399. /** mag = linear and min = linear and mip = none */
  15400. static readonly LINEAR_LINEAR: number;
  15401. /** mag = linear and min = nearest and mip = none */
  15402. static readonly LINEAR_NEAREST: number;
  15403. /** Explicit coordinates mode */
  15404. static readonly EXPLICIT_MODE: number;
  15405. /** Spherical coordinates mode */
  15406. static readonly SPHERICAL_MODE: number;
  15407. /** Planar coordinates mode */
  15408. static readonly PLANAR_MODE: number;
  15409. /** Cubic coordinates mode */
  15410. static readonly CUBIC_MODE: number;
  15411. /** Projection coordinates mode */
  15412. static readonly PROJECTION_MODE: number;
  15413. /** Inverse Cubic coordinates mode */
  15414. static readonly SKYBOX_MODE: number;
  15415. /** Inverse Cubic coordinates mode */
  15416. static readonly INVCUBIC_MODE: number;
  15417. /** Equirectangular coordinates mode */
  15418. static readonly EQUIRECTANGULAR_MODE: number;
  15419. /** Equirectangular Fixed coordinates mode */
  15420. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15421. /** Equirectangular Fixed Mirrored coordinates mode */
  15422. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15423. /** Texture is not repeating outside of 0..1 UVs */
  15424. static readonly CLAMP_ADDRESSMODE: number;
  15425. /** Texture is repeating outside of 0..1 UVs */
  15426. static readonly WRAP_ADDRESSMODE: number;
  15427. /** Texture is repeating and mirrored */
  15428. static readonly MIRROR_ADDRESSMODE: number;
  15429. /**
  15430. * 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
  15431. */
  15432. static UseSerializedUrlIfAny: boolean;
  15433. /**
  15434. * Define the url of the texture.
  15435. */
  15436. url: Nullable<string>;
  15437. /**
  15438. * Define an offset on the texture to offset the u coordinates of the UVs
  15439. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15440. */
  15441. uOffset: number;
  15442. /**
  15443. * Define an offset on the texture to offset the v coordinates of the UVs
  15444. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15445. */
  15446. vOffset: number;
  15447. /**
  15448. * Define an offset on the texture to scale the u coordinates of the UVs
  15449. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15450. */
  15451. uScale: number;
  15452. /**
  15453. * Define an offset on the texture to scale the v coordinates of the UVs
  15454. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15455. */
  15456. vScale: number;
  15457. /**
  15458. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15459. * @see http://doc.babylonjs.com/how_to/more_materials
  15460. */
  15461. uAng: number;
  15462. /**
  15463. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15464. * @see http://doc.babylonjs.com/how_to/more_materials
  15465. */
  15466. vAng: number;
  15467. /**
  15468. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15469. * @see http://doc.babylonjs.com/how_to/more_materials
  15470. */
  15471. wAng: number;
  15472. /**
  15473. * Defines the center of rotation (U)
  15474. */
  15475. uRotationCenter: number;
  15476. /**
  15477. * Defines the center of rotation (V)
  15478. */
  15479. vRotationCenter: number;
  15480. /**
  15481. * Defines the center of rotation (W)
  15482. */
  15483. wRotationCenter: number;
  15484. /**
  15485. * Are mip maps generated for this texture or not.
  15486. */
  15487. readonly noMipmap: boolean;
  15488. /**
  15489. * List of inspectable custom properties (used by the Inspector)
  15490. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15491. */
  15492. inspectableCustomProperties: Nullable<IInspectable[]>;
  15493. private _noMipmap;
  15494. /** @hidden */ private _invertY: boolean;
  15495. private _rowGenerationMatrix;
  15496. private _cachedTextureMatrix;
  15497. private _projectionModeMatrix;
  15498. private _t0;
  15499. private _t1;
  15500. private _t2;
  15501. private _cachedUOffset;
  15502. private _cachedVOffset;
  15503. private _cachedUScale;
  15504. private _cachedVScale;
  15505. private _cachedUAng;
  15506. private _cachedVAng;
  15507. private _cachedWAng;
  15508. private _cachedProjectionMatrixId;
  15509. private _cachedCoordinatesMode;
  15510. /** @hidden */
  15511. protected _initialSamplingMode: number;
  15512. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15513. private _deleteBuffer;
  15514. protected _format: Nullable<number>;
  15515. private _delayedOnLoad;
  15516. private _delayedOnError;
  15517. /**
  15518. * Observable triggered once the texture has been loaded.
  15519. */
  15520. onLoadObservable: Observable<Texture>;
  15521. protected _isBlocking: boolean;
  15522. /**
  15523. * Is the texture preventing material to render while loading.
  15524. * If false, a default texture will be used instead of the loading one during the preparation step.
  15525. */
  15526. isBlocking: boolean;
  15527. /**
  15528. * Get the current sampling mode associated with the texture.
  15529. */
  15530. readonly samplingMode: number;
  15531. /**
  15532. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15533. */
  15534. readonly invertY: boolean;
  15535. /**
  15536. * Instantiates a new texture.
  15537. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15538. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15539. * @param url define the url of the picture to load as a texture
  15540. * @param scene define the scene or engine the texture will belong to
  15541. * @param noMipmap define if the texture will require mip maps or not
  15542. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15543. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15544. * @param onLoad define a callback triggered when the texture has been loaded
  15545. * @param onError define a callback triggered when an error occurred during the loading session
  15546. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15547. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15548. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15549. */
  15550. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15551. /**
  15552. * Update the url (and optional buffer) of this texture if url was null during construction.
  15553. * @param url the url of the texture
  15554. * @param buffer the buffer of the texture (defaults to null)
  15555. * @param onLoad callback called when the texture is loaded (defaults to null)
  15556. */
  15557. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15558. /**
  15559. * Finish the loading sequence of a texture flagged as delayed load.
  15560. * @hidden
  15561. */
  15562. delayLoad(): void;
  15563. private _prepareRowForTextureGeneration;
  15564. /**
  15565. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15566. * @returns the transform matrix of the texture.
  15567. */
  15568. getTextureMatrix(): Matrix;
  15569. /**
  15570. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15571. * @returns The reflection texture transform
  15572. */
  15573. getReflectionTextureMatrix(): Matrix;
  15574. /**
  15575. * Clones the texture.
  15576. * @returns the cloned texture
  15577. */
  15578. clone(): Texture;
  15579. /**
  15580. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15581. * @returns The JSON representation of the texture
  15582. */
  15583. serialize(): any;
  15584. /**
  15585. * Get the current class name of the texture useful for serialization or dynamic coding.
  15586. * @returns "Texture"
  15587. */
  15588. getClassName(): string;
  15589. /**
  15590. * Dispose the texture and release its associated resources.
  15591. */
  15592. dispose(): void;
  15593. /**
  15594. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15595. * @param parsedTexture Define the JSON representation of the texture
  15596. * @param scene Define the scene the parsed texture should be instantiated in
  15597. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15598. * @returns The parsed texture if successful
  15599. */
  15600. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15601. /**
  15602. * Creates a texture from its base 64 representation.
  15603. * @param data Define the base64 payload without the data: prefix
  15604. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15605. * @param scene Define the scene the texture should belong to
  15606. * @param noMipmap Forces the texture to not create mip map information if true
  15607. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15608. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15609. * @param onLoad define a callback triggered when the texture has been loaded
  15610. * @param onError define a callback triggered when an error occurred during the loading session
  15611. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15612. * @returns the created texture
  15613. */
  15614. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15615. /**
  15616. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15617. * @param data Define the base64 payload without the data: prefix
  15618. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15619. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15620. * @param scene Define the scene the texture should belong to
  15621. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15622. * @param noMipmap Forces the texture to not create mip map information if true
  15623. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15624. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15625. * @param onLoad define a callback triggered when the texture has been loaded
  15626. * @param onError define a callback triggered when an error occurred during the loading session
  15627. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15628. * @returns the created texture
  15629. */
  15630. 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;
  15631. }
  15632. }
  15633. declare module BABYLON {
  15634. /**
  15635. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15636. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15637. */
  15638. export class PostProcessManager {
  15639. private _scene;
  15640. private _indexBuffer;
  15641. private _vertexBuffers;
  15642. /**
  15643. * Creates a new instance PostProcess
  15644. * @param scene The scene that the post process is associated with.
  15645. */
  15646. constructor(scene: Scene);
  15647. private _prepareBuffers;
  15648. private _buildIndexBuffer;
  15649. /**
  15650. * Rebuilds the vertex buffers of the manager.
  15651. * @hidden
  15652. */ private _rebuild(): void;
  15653. /**
  15654. * Prepares a frame to be run through a post process.
  15655. * @param sourceTexture The input texture to the post procesess. (default: null)
  15656. * @param postProcesses An array of post processes to be run. (default: null)
  15657. * @returns True if the post processes were able to be run.
  15658. * @hidden
  15659. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15660. /**
  15661. * Manually render a set of post processes to a texture.
  15662. * @param postProcesses An array of post processes to be run.
  15663. * @param targetTexture The target texture to render to.
  15664. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15665. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15666. * @param lodLevel defines which lod of the texture to render to
  15667. */
  15668. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15669. /**
  15670. * Finalize the result of the output of the postprocesses.
  15671. * @param doNotPresent If true the result will not be displayed to the screen.
  15672. * @param targetTexture The target texture to render to.
  15673. * @param faceIndex The index of the face to bind the target texture to.
  15674. * @param postProcesses The array of post processes to render.
  15675. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15676. * @hidden
  15677. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15678. /**
  15679. * Disposes of the post process manager.
  15680. */
  15681. dispose(): void;
  15682. }
  15683. }
  15684. declare module BABYLON {
  15685. /** Interface used by value gradients (color, factor, ...) */
  15686. export interface IValueGradient {
  15687. /**
  15688. * Gets or sets the gradient value (between 0 and 1)
  15689. */
  15690. gradient: number;
  15691. }
  15692. /** Class used to store color4 gradient */
  15693. export class ColorGradient implements IValueGradient {
  15694. /**
  15695. * Gets or sets the gradient value (between 0 and 1)
  15696. */
  15697. gradient: number;
  15698. /**
  15699. * Gets or sets first associated color
  15700. */
  15701. color1: Color4;
  15702. /**
  15703. * Gets or sets second associated color
  15704. */
  15705. color2?: Color4;
  15706. /**
  15707. * Will get a color picked randomly between color1 and color2.
  15708. * If color2 is undefined then color1 will be used
  15709. * @param result defines the target Color4 to store the result in
  15710. */
  15711. getColorToRef(result: Color4): void;
  15712. }
  15713. /** Class used to store color 3 gradient */
  15714. export class Color3Gradient implements IValueGradient {
  15715. /**
  15716. * Gets or sets the gradient value (between 0 and 1)
  15717. */
  15718. gradient: number;
  15719. /**
  15720. * Gets or sets the associated color
  15721. */
  15722. color: Color3;
  15723. }
  15724. /** Class used to store factor gradient */
  15725. export class FactorGradient implements IValueGradient {
  15726. /**
  15727. * Gets or sets the gradient value (between 0 and 1)
  15728. */
  15729. gradient: number;
  15730. /**
  15731. * Gets or sets first associated factor
  15732. */
  15733. factor1: number;
  15734. /**
  15735. * Gets or sets second associated factor
  15736. */
  15737. factor2?: number;
  15738. /**
  15739. * Will get a number picked randomly between factor1 and factor2.
  15740. * If factor2 is undefined then factor1 will be used
  15741. * @returns the picked number
  15742. */
  15743. getFactor(): number;
  15744. }
  15745. /**
  15746. * Helper used to simplify some generic gradient tasks
  15747. */
  15748. export class GradientHelper {
  15749. /**
  15750. * Gets the current gradient from an array of IValueGradient
  15751. * @param ratio defines the current ratio to get
  15752. * @param gradients defines the array of IValueGradient
  15753. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15754. */
  15755. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15756. }
  15757. }
  15758. declare module BABYLON {
  15759. /**
  15760. * A class extending Texture allowing drawing on a texture
  15761. * @see http://doc.babylonjs.com/how_to/dynamictexture
  15762. */
  15763. export class DynamicTexture extends Texture {
  15764. private _generateMipMaps;
  15765. private _canvas;
  15766. private _context;
  15767. private _engine;
  15768. /**
  15769. * Creates a DynamicTexture
  15770. * @param name defines the name of the texture
  15771. * @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
  15772. * @param scene defines the scene where you want the texture
  15773. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  15774. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  15775. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  15776. */
  15777. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  15778. /**
  15779. * Get the current class name of the texture useful for serialization or dynamic coding.
  15780. * @returns "DynamicTexture"
  15781. */
  15782. getClassName(): string;
  15783. /**
  15784. * Gets the current state of canRescale
  15785. */
  15786. readonly canRescale: boolean;
  15787. private _recreate;
  15788. /**
  15789. * Scales the texture
  15790. * @param ratio the scale factor to apply to both width and height
  15791. */
  15792. scale(ratio: number): void;
  15793. /**
  15794. * Resizes the texture
  15795. * @param width the new width
  15796. * @param height the new height
  15797. */
  15798. scaleTo(width: number, height: number): void;
  15799. /**
  15800. * Gets the context of the canvas used by the texture
  15801. * @returns the canvas context of the dynamic texture
  15802. */
  15803. getContext(): CanvasRenderingContext2D;
  15804. /**
  15805. * Clears the texture
  15806. */
  15807. clear(): void;
  15808. /**
  15809. * Updates the texture
  15810. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15811. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  15812. */
  15813. update(invertY?: boolean, premulAlpha?: boolean): void;
  15814. /**
  15815. * Draws text onto the texture
  15816. * @param text defines the text to be drawn
  15817. * @param x defines the placement of the text from the left
  15818. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  15819. * @param font defines the font to be used with font-style, font-size, font-name
  15820. * @param color defines the color used for the text
  15821. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  15822. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15823. * @param update defines whether texture is immediately update (default is true)
  15824. */
  15825. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  15826. /**
  15827. * Clones the texture
  15828. * @returns the clone of the texture.
  15829. */
  15830. clone(): DynamicTexture;
  15831. /**
  15832. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  15833. * @returns a serialized dynamic texture object
  15834. */
  15835. serialize(): any;
  15836. /** @hidden */ private _rebuild(): void;
  15837. }
  15838. }
  15839. declare module BABYLON {
  15840. interface AbstractScene {
  15841. /**
  15842. * The list of procedural textures added to the scene
  15843. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15844. */
  15845. proceduralTextures: Array<ProceduralTexture>;
  15846. }
  15847. /**
  15848. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15849. * in a given scene.
  15850. */
  15851. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15852. /**
  15853. * The component name helpfull to identify the component in the list of scene components.
  15854. */
  15855. readonly name: string;
  15856. /**
  15857. * The scene the component belongs to.
  15858. */
  15859. scene: Scene;
  15860. /**
  15861. * Creates a new instance of the component for the given scene
  15862. * @param scene Defines the scene to register the component in
  15863. */
  15864. constructor(scene: Scene);
  15865. /**
  15866. * Registers the component in a given scene
  15867. */
  15868. register(): void;
  15869. /**
  15870. * Rebuilds the elements related to this component in case of
  15871. * context lost for instance.
  15872. */
  15873. rebuild(): void;
  15874. /**
  15875. * Disposes the component and the associated ressources.
  15876. */
  15877. dispose(): void;
  15878. private _beforeClear;
  15879. }
  15880. }
  15881. declare module BABYLON {
  15882. interface Engine {
  15883. /**
  15884. * Creates a new render target cube texture
  15885. * @param size defines the size of the texture
  15886. * @param options defines the options used to create the texture
  15887. * @returns a new render target cube texture stored in an InternalTexture
  15888. */
  15889. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15890. }
  15891. }
  15892. declare module BABYLON {
  15893. /** @hidden */
  15894. export var proceduralVertexShader: {
  15895. name: string;
  15896. shader: string;
  15897. };
  15898. }
  15899. declare module BABYLON {
  15900. /**
  15901. * 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.
  15902. * This is the base class of any Procedural texture and contains most of the shareable code.
  15903. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15904. */
  15905. export class ProceduralTexture extends Texture {
  15906. isCube: boolean;
  15907. /**
  15908. * Define if the texture is enabled or not (disabled texture will not render)
  15909. */
  15910. isEnabled: boolean;
  15911. /**
  15912. * Define if the texture must be cleared before rendering (default is true)
  15913. */
  15914. autoClear: boolean;
  15915. /**
  15916. * Callback called when the texture is generated
  15917. */
  15918. onGenerated: () => void;
  15919. /**
  15920. * Event raised when the texture is generated
  15921. */
  15922. onGeneratedObservable: Observable<ProceduralTexture>;
  15923. /** @hidden */ private _generateMipMaps: boolean;
  15924. /** @hidden **/ private _effect: Effect;
  15925. /** @hidden */ private _textures: {
  15926. [key: string]: Texture;
  15927. };
  15928. private _size;
  15929. private _currentRefreshId;
  15930. private _refreshRate;
  15931. private _vertexBuffers;
  15932. private _indexBuffer;
  15933. private _uniforms;
  15934. private _samplers;
  15935. private _fragment;
  15936. private _floats;
  15937. private _ints;
  15938. private _floatsArrays;
  15939. private _colors3;
  15940. private _colors4;
  15941. private _vectors2;
  15942. private _vectors3;
  15943. private _matrices;
  15944. private _fallbackTexture;
  15945. private _fallbackTextureUsed;
  15946. private _engine;
  15947. private _cachedDefines;
  15948. private _contentUpdateId;
  15949. private _contentData;
  15950. /**
  15951. * Instantiates a new procedural texture.
  15952. * 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.
  15953. * This is the base class of any Procedural texture and contains most of the shareable code.
  15954. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15955. * @param name Define the name of the texture
  15956. * @param size Define the size of the texture to create
  15957. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15958. * @param scene Define the scene the texture belongs to
  15959. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15960. * @param generateMipMaps Define if the texture should creates mip maps or not
  15961. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15962. */
  15963. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  15964. /**
  15965. * The effect that is created when initializing the post process.
  15966. * @returns The created effect corresponding the the postprocess.
  15967. */
  15968. getEffect(): Effect;
  15969. /**
  15970. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15971. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  15972. */
  15973. getContent(): Nullable<ArrayBufferView>;
  15974. private _createIndexBuffer;
  15975. /** @hidden */ private _rebuild(): void;
  15976. /**
  15977. * Resets the texture in order to recreate its associated resources.
  15978. * This can be called in case of context loss
  15979. */
  15980. reset(): void;
  15981. protected _getDefines(): string;
  15982. /**
  15983. * Is the texture ready to be used ? (rendered at least once)
  15984. * @returns true if ready, otherwise, false.
  15985. */
  15986. isReady(): boolean;
  15987. /**
  15988. * Resets the refresh counter of the texture and start bak from scratch.
  15989. * Could be useful to regenerate the texture if it is setup to render only once.
  15990. */
  15991. resetRefreshCounter(): void;
  15992. /**
  15993. * Set the fragment shader to use in order to render the texture.
  15994. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15995. */
  15996. setFragment(fragment: any): void;
  15997. /**
  15998. * Define the refresh rate of the texture or the rendering frequency.
  15999. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16000. */
  16001. refreshRate: number;
  16002. /** @hidden */ private _shouldRender(): boolean;
  16003. /**
  16004. * Get the size the texture is rendering at.
  16005. * @returns the size (texture is always squared)
  16006. */
  16007. getRenderSize(): number;
  16008. /**
  16009. * Resize the texture to new value.
  16010. * @param size Define the new size the texture should have
  16011. * @param generateMipMaps Define whether the new texture should create mip maps
  16012. */
  16013. resize(size: number, generateMipMaps: boolean): void;
  16014. private _checkUniform;
  16015. /**
  16016. * Set a texture in the shader program used to render.
  16017. * @param name Define the name of the uniform samplers as defined in the shader
  16018. * @param texture Define the texture to bind to this sampler
  16019. * @return the texture itself allowing "fluent" like uniform updates
  16020. */
  16021. setTexture(name: string, texture: Texture): ProceduralTexture;
  16022. /**
  16023. * Set a float in the shader.
  16024. * @param name Define the name of the uniform as defined in the shader
  16025. * @param value Define the value to give to the uniform
  16026. * @return the texture itself allowing "fluent" like uniform updates
  16027. */
  16028. setFloat(name: string, value: number): ProceduralTexture;
  16029. /**
  16030. * Set a int in the shader.
  16031. * @param name Define the name of the uniform as defined in the shader
  16032. * @param value Define the value to give to the uniform
  16033. * @return the texture itself allowing "fluent" like uniform updates
  16034. */
  16035. setInt(name: string, value: number): ProceduralTexture;
  16036. /**
  16037. * Set an array of floats in the shader.
  16038. * @param name Define the name of the uniform as defined in the shader
  16039. * @param value Define the value to give to the uniform
  16040. * @return the texture itself allowing "fluent" like uniform updates
  16041. */
  16042. setFloats(name: string, value: number[]): ProceduralTexture;
  16043. /**
  16044. * Set a vec3 in the shader from a Color3.
  16045. * @param name Define the name of the uniform as defined in the shader
  16046. * @param value Define the value to give to the uniform
  16047. * @return the texture itself allowing "fluent" like uniform updates
  16048. */
  16049. setColor3(name: string, value: Color3): ProceduralTexture;
  16050. /**
  16051. * Set a vec4 in the shader from a Color4.
  16052. * @param name Define the name of the uniform as defined in the shader
  16053. * @param value Define the value to give to the uniform
  16054. * @return the texture itself allowing "fluent" like uniform updates
  16055. */
  16056. setColor4(name: string, value: Color4): ProceduralTexture;
  16057. /**
  16058. * Set a vec2 in the shader from a Vector2.
  16059. * @param name Define the name of the uniform as defined in the shader
  16060. * @param value Define the value to give to the uniform
  16061. * @return the texture itself allowing "fluent" like uniform updates
  16062. */
  16063. setVector2(name: string, value: Vector2): ProceduralTexture;
  16064. /**
  16065. * Set a vec3 in the shader from a Vector3.
  16066. * @param name Define the name of the uniform as defined in the shader
  16067. * @param value Define the value to give to the uniform
  16068. * @return the texture itself allowing "fluent" like uniform updates
  16069. */
  16070. setVector3(name: string, value: Vector3): ProceduralTexture;
  16071. /**
  16072. * Set a mat4 in the shader from a MAtrix.
  16073. * @param name Define the name of the uniform as defined in the shader
  16074. * @param value Define the value to give to the uniform
  16075. * @return the texture itself allowing "fluent" like uniform updates
  16076. */
  16077. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16078. /**
  16079. * Render the texture to its associated render target.
  16080. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16081. */
  16082. render(useCameraPostProcess?: boolean): void;
  16083. /**
  16084. * Clone the texture.
  16085. * @returns the cloned texture
  16086. */
  16087. clone(): ProceduralTexture;
  16088. /**
  16089. * Dispose the texture and release its asoociated resources.
  16090. */
  16091. dispose(): void;
  16092. }
  16093. }
  16094. declare module BABYLON {
  16095. /**
  16096. * This represents the base class for particle system in Babylon.
  16097. * 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.
  16098. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16099. * @example https://doc.babylonjs.com/babylon101/particles
  16100. */
  16101. export class BaseParticleSystem {
  16102. /**
  16103. * Source color is added to the destination color without alpha affecting the result
  16104. */
  16105. static BLENDMODE_ONEONE: number;
  16106. /**
  16107. * Blend current color and particle color using particle’s alpha
  16108. */
  16109. static BLENDMODE_STANDARD: number;
  16110. /**
  16111. * Add current color and particle color multiplied by particle’s alpha
  16112. */
  16113. static BLENDMODE_ADD: number;
  16114. /**
  16115. * Multiply current color with particle color
  16116. */
  16117. static BLENDMODE_MULTIPLY: number;
  16118. /**
  16119. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16120. */
  16121. static BLENDMODE_MULTIPLYADD: number;
  16122. /**
  16123. * List of animations used by the particle system.
  16124. */
  16125. animations: Animation[];
  16126. /**
  16127. * The id of the Particle system.
  16128. */
  16129. id: string;
  16130. /**
  16131. * The friendly name of the Particle system.
  16132. */
  16133. name: string;
  16134. /**
  16135. * The rendering group used by the Particle system to chose when to render.
  16136. */
  16137. renderingGroupId: number;
  16138. /**
  16139. * The emitter represents the Mesh or position we are attaching the particle system to.
  16140. */
  16141. emitter: Nullable<AbstractMesh | Vector3>;
  16142. /**
  16143. * The maximum number of particles to emit per frame
  16144. */
  16145. emitRate: number;
  16146. /**
  16147. * If you want to launch only a few particles at once, that can be done, as well.
  16148. */
  16149. manualEmitCount: number;
  16150. /**
  16151. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16152. */
  16153. updateSpeed: number;
  16154. /**
  16155. * The amount of time the particle system is running (depends of the overall update speed).
  16156. */
  16157. targetStopDuration: number;
  16158. /**
  16159. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16160. */
  16161. disposeOnStop: boolean;
  16162. /**
  16163. * Minimum power of emitting particles.
  16164. */
  16165. minEmitPower: number;
  16166. /**
  16167. * Maximum power of emitting particles.
  16168. */
  16169. maxEmitPower: number;
  16170. /**
  16171. * Minimum life time of emitting particles.
  16172. */
  16173. minLifeTime: number;
  16174. /**
  16175. * Maximum life time of emitting particles.
  16176. */
  16177. maxLifeTime: number;
  16178. /**
  16179. * Minimum Size of emitting particles.
  16180. */
  16181. minSize: number;
  16182. /**
  16183. * Maximum Size of emitting particles.
  16184. */
  16185. maxSize: number;
  16186. /**
  16187. * Minimum scale of emitting particles on X axis.
  16188. */
  16189. minScaleX: number;
  16190. /**
  16191. * Maximum scale of emitting particles on X axis.
  16192. */
  16193. maxScaleX: number;
  16194. /**
  16195. * Minimum scale of emitting particles on Y axis.
  16196. */
  16197. minScaleY: number;
  16198. /**
  16199. * Maximum scale of emitting particles on Y axis.
  16200. */
  16201. maxScaleY: number;
  16202. /**
  16203. * Gets or sets the minimal initial rotation in radians.
  16204. */
  16205. minInitialRotation: number;
  16206. /**
  16207. * Gets or sets the maximal initial rotation in radians.
  16208. */
  16209. maxInitialRotation: number;
  16210. /**
  16211. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16212. */
  16213. minAngularSpeed: number;
  16214. /**
  16215. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16216. */
  16217. maxAngularSpeed: number;
  16218. /**
  16219. * The texture used to render each particle. (this can be a spritesheet)
  16220. */
  16221. particleTexture: Nullable<Texture>;
  16222. /**
  16223. * The layer mask we are rendering the particles through.
  16224. */
  16225. layerMask: number;
  16226. /**
  16227. * This can help using your own shader to render the particle system.
  16228. * The according effect will be created
  16229. */
  16230. customShader: any;
  16231. /**
  16232. * By default particle system starts as soon as they are created. This prevents the
  16233. * automatic start to happen and let you decide when to start emitting particles.
  16234. */
  16235. preventAutoStart: boolean;
  16236. private _noiseTexture;
  16237. /**
  16238. * Gets or sets a texture used to add random noise to particle positions
  16239. */
  16240. noiseTexture: Nullable<ProceduralTexture>;
  16241. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16242. noiseStrength: Vector3;
  16243. /**
  16244. * Callback triggered when the particle animation is ending.
  16245. */
  16246. onAnimationEnd: Nullable<() => void>;
  16247. /**
  16248. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16249. */
  16250. blendMode: number;
  16251. /**
  16252. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16253. * to override the particles.
  16254. */
  16255. forceDepthWrite: boolean;
  16256. /** 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 */
  16257. preWarmCycles: number;
  16258. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16259. preWarmStepOffset: number;
  16260. /**
  16261. * 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)
  16262. */
  16263. spriteCellChangeSpeed: number;
  16264. /**
  16265. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16266. */
  16267. startSpriteCellID: number;
  16268. /**
  16269. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16270. */
  16271. endSpriteCellID: number;
  16272. /**
  16273. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16274. */
  16275. spriteCellWidth: number;
  16276. /**
  16277. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16278. */
  16279. spriteCellHeight: number;
  16280. /**
  16281. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16282. */
  16283. spriteRandomStartCell: boolean;
  16284. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16285. translationPivot: Vector2;
  16286. /** @hidden */
  16287. protected _isAnimationSheetEnabled: boolean;
  16288. /**
  16289. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16290. */
  16291. beginAnimationOnStart: boolean;
  16292. /**
  16293. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16294. */
  16295. beginAnimationFrom: number;
  16296. /**
  16297. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16298. */
  16299. beginAnimationTo: number;
  16300. /**
  16301. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16302. */
  16303. beginAnimationLoop: boolean;
  16304. /**
  16305. * Gets or sets a world offset applied to all particles
  16306. */
  16307. worldOffset: Vector3;
  16308. /**
  16309. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16310. */
  16311. isAnimationSheetEnabled: boolean;
  16312. /**
  16313. * Get hosting scene
  16314. * @returns the scene
  16315. */
  16316. getScene(): Scene;
  16317. /**
  16318. * You can use gravity if you want to give an orientation to your particles.
  16319. */
  16320. gravity: Vector3;
  16321. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16322. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16323. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16324. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16325. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16326. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16327. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16328. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16329. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16330. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16331. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16332. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16333. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16334. /**
  16335. * Defines the delay in milliseconds before starting the system (0 by default)
  16336. */
  16337. startDelay: number;
  16338. /**
  16339. * Gets the current list of drag gradients.
  16340. * You must use addDragGradient and removeDragGradient to udpate this list
  16341. * @returns the list of drag gradients
  16342. */
  16343. getDragGradients(): Nullable<Array<FactorGradient>>;
  16344. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16345. limitVelocityDamping: number;
  16346. /**
  16347. * Gets the current list of limit velocity gradients.
  16348. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16349. * @returns the list of limit velocity gradients
  16350. */
  16351. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16352. /**
  16353. * Gets the current list of color gradients.
  16354. * You must use addColorGradient and removeColorGradient to udpate this list
  16355. * @returns the list of color gradients
  16356. */
  16357. getColorGradients(): Nullable<Array<ColorGradient>>;
  16358. /**
  16359. * Gets the current list of size gradients.
  16360. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16361. * @returns the list of size gradients
  16362. */
  16363. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16364. /**
  16365. * Gets the current list of color remap gradients.
  16366. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16367. * @returns the list of color remap gradients
  16368. */
  16369. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16370. /**
  16371. * Gets the current list of alpha remap gradients.
  16372. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16373. * @returns the list of alpha remap gradients
  16374. */
  16375. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16376. /**
  16377. * Gets the current list of life time gradients.
  16378. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16379. * @returns the list of life time gradients
  16380. */
  16381. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16382. /**
  16383. * Gets the current list of angular speed gradients.
  16384. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16385. * @returns the list of angular speed gradients
  16386. */
  16387. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16388. /**
  16389. * Gets the current list of velocity gradients.
  16390. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16391. * @returns the list of velocity gradients
  16392. */
  16393. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16394. /**
  16395. * Gets the current list of start size gradients.
  16396. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16397. * @returns the list of start size gradients
  16398. */
  16399. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16400. /**
  16401. * Gets the current list of emit rate gradients.
  16402. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16403. * @returns the list of emit rate gradients
  16404. */
  16405. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16406. /**
  16407. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16408. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16409. */
  16410. direction1: Vector3;
  16411. /**
  16412. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16413. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16414. */
  16415. direction2: Vector3;
  16416. /**
  16417. * 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.
  16418. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16419. */
  16420. minEmitBox: Vector3;
  16421. /**
  16422. * 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.
  16423. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16424. */
  16425. maxEmitBox: Vector3;
  16426. /**
  16427. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16428. */
  16429. color1: Color4;
  16430. /**
  16431. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16432. */
  16433. color2: Color4;
  16434. /**
  16435. * Color the particle will have at the end of its lifetime
  16436. */
  16437. colorDead: Color4;
  16438. /**
  16439. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16440. */
  16441. textureMask: Color4;
  16442. /**
  16443. * The particle emitter type defines the emitter used by the particle system.
  16444. * It can be for example box, sphere, or cone...
  16445. */
  16446. particleEmitterType: IParticleEmitterType;
  16447. /** @hidden */ private _isSubEmitter: boolean;
  16448. /**
  16449. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16450. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16451. */
  16452. billboardMode: number;
  16453. protected _isBillboardBased: boolean;
  16454. /**
  16455. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16456. */
  16457. isBillboardBased: boolean;
  16458. /**
  16459. * The scene the particle system belongs to.
  16460. */
  16461. protected _scene: Scene;
  16462. /**
  16463. * Local cache of defines for image processing.
  16464. */
  16465. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16466. /**
  16467. * Default configuration related to image processing available in the standard Material.
  16468. */
  16469. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16470. /**
  16471. * Gets the image processing configuration used either in this material.
  16472. */
  16473. /**
  16474. * Sets the Default image processing configuration used either in the this material.
  16475. *
  16476. * If sets to null, the scene one is in use.
  16477. */
  16478. imageProcessingConfiguration: ImageProcessingConfiguration;
  16479. /**
  16480. * Attaches a new image processing configuration to the Standard Material.
  16481. * @param configuration
  16482. */
  16483. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16484. /** @hidden */
  16485. protected _reset(): void;
  16486. /** @hidden */
  16487. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16488. /**
  16489. * Instantiates a particle system.
  16490. * 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.
  16491. * @param name The name of the particle system
  16492. */
  16493. constructor(name: string);
  16494. /**
  16495. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16496. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16497. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16498. * @returns the emitter
  16499. */
  16500. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16501. /**
  16502. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16503. * @param radius The radius of the hemisphere to emit from
  16504. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16505. * @returns the emitter
  16506. */
  16507. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16508. /**
  16509. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16510. * @param radius The radius of the sphere to emit from
  16511. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16512. * @returns the emitter
  16513. */
  16514. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16515. /**
  16516. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16517. * @param radius The radius of the sphere to emit from
  16518. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16519. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16520. * @returns the emitter
  16521. */
  16522. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16523. /**
  16524. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16525. * @param radius The radius of the emission cylinder
  16526. * @param height The height of the emission cylinder
  16527. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16528. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16529. * @returns the emitter
  16530. */
  16531. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16532. /**
  16533. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16534. * @param radius The radius of the cylinder to emit from
  16535. * @param height The height of the emission cylinder
  16536. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16537. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16538. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16539. * @returns the emitter
  16540. */
  16541. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16542. /**
  16543. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16544. * @param radius The radius of the cone to emit from
  16545. * @param angle The base angle of the cone
  16546. * @returns the emitter
  16547. */
  16548. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16549. /**
  16550. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16551. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16552. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16553. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16554. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16555. * @returns the emitter
  16556. */
  16557. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16558. }
  16559. }
  16560. declare module BABYLON {
  16561. /**
  16562. * Type of sub emitter
  16563. */
  16564. export enum SubEmitterType {
  16565. /**
  16566. * Attached to the particle over it's lifetime
  16567. */
  16568. ATTACHED = 0,
  16569. /**
  16570. * Created when the particle dies
  16571. */
  16572. END = 1
  16573. }
  16574. /**
  16575. * Sub emitter class used to emit particles from an existing particle
  16576. */
  16577. export class SubEmitter {
  16578. /**
  16579. * the particle system to be used by the sub emitter
  16580. */
  16581. particleSystem: ParticleSystem;
  16582. /**
  16583. * Type of the submitter (Default: END)
  16584. */
  16585. type: SubEmitterType;
  16586. /**
  16587. * 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)
  16588. * Note: This only is supported when using an emitter of type Mesh
  16589. */
  16590. inheritDirection: boolean;
  16591. /**
  16592. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16593. */
  16594. inheritedVelocityAmount: number;
  16595. /**
  16596. * Creates a sub emitter
  16597. * @param particleSystem the particle system to be used by the sub emitter
  16598. */
  16599. constructor(
  16600. /**
  16601. * the particle system to be used by the sub emitter
  16602. */
  16603. particleSystem: ParticleSystem);
  16604. /**
  16605. * Clones the sub emitter
  16606. * @returns the cloned sub emitter
  16607. */
  16608. clone(): SubEmitter;
  16609. /**
  16610. * Serialize current object to a JSON object
  16611. * @returns the serialized object
  16612. */
  16613. serialize(): any;
  16614. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16615. /**
  16616. * Creates a new SubEmitter from a serialized JSON version
  16617. * @param serializationObject defines the JSON object to read from
  16618. * @param scene defines the hosting scene
  16619. * @param rootUrl defines the rootUrl for data loading
  16620. * @returns a new SubEmitter
  16621. */
  16622. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16623. /** Release associated resources */
  16624. dispose(): void;
  16625. }
  16626. }
  16627. declare module BABYLON {
  16628. /** @hidden */
  16629. export var clipPlaneFragmentDeclaration: {
  16630. name: string;
  16631. shader: string;
  16632. };
  16633. }
  16634. declare module BABYLON {
  16635. /** @hidden */
  16636. export var imageProcessingDeclaration: {
  16637. name: string;
  16638. shader: string;
  16639. };
  16640. }
  16641. declare module BABYLON {
  16642. /** @hidden */
  16643. export var imageProcessingFunctions: {
  16644. name: string;
  16645. shader: string;
  16646. };
  16647. }
  16648. declare module BABYLON {
  16649. /** @hidden */
  16650. export var clipPlaneFragment: {
  16651. name: string;
  16652. shader: string;
  16653. };
  16654. }
  16655. declare module BABYLON {
  16656. /** @hidden */
  16657. export var particlesPixelShader: {
  16658. name: string;
  16659. shader: string;
  16660. };
  16661. }
  16662. declare module BABYLON {
  16663. /** @hidden */
  16664. export var clipPlaneVertexDeclaration: {
  16665. name: string;
  16666. shader: string;
  16667. };
  16668. }
  16669. declare module BABYLON {
  16670. /** @hidden */
  16671. export var clipPlaneVertex: {
  16672. name: string;
  16673. shader: string;
  16674. };
  16675. }
  16676. declare module BABYLON {
  16677. /** @hidden */
  16678. export var particlesVertexShader: {
  16679. name: string;
  16680. shader: string;
  16681. };
  16682. }
  16683. declare module BABYLON {
  16684. /**
  16685. * This represents a particle system in Babylon.
  16686. * 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.
  16687. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16688. * @example https://doc.babylonjs.com/babylon101/particles
  16689. */
  16690. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16691. /**
  16692. * Billboard mode will only apply to Y axis
  16693. */
  16694. static readonly BILLBOARDMODE_Y: number;
  16695. /**
  16696. * Billboard mode will apply to all axes
  16697. */
  16698. static readonly BILLBOARDMODE_ALL: number;
  16699. /**
  16700. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16701. */
  16702. static readonly BILLBOARDMODE_STRETCHED: number;
  16703. /**
  16704. * This function can be defined to provide custom update for active particles.
  16705. * This function will be called instead of regular update (age, position, color, etc.).
  16706. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16707. */
  16708. updateFunction: (particles: Particle[]) => void;
  16709. private _emitterWorldMatrix;
  16710. /**
  16711. * This function can be defined to specify initial direction for every new particle.
  16712. * It by default use the emitterType defined function
  16713. */
  16714. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16715. /**
  16716. * This function can be defined to specify initial position for every new particle.
  16717. * It by default use the emitterType defined function
  16718. */
  16719. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16720. /**
  16721. * @hidden
  16722. */ private _inheritedVelocityOffset: Vector3;
  16723. /**
  16724. * An event triggered when the system is disposed
  16725. */
  16726. onDisposeObservable: Observable<ParticleSystem>;
  16727. private _onDisposeObserver;
  16728. /**
  16729. * Sets a callback that will be triggered when the system is disposed
  16730. */
  16731. onDispose: () => void;
  16732. private _particles;
  16733. private _epsilon;
  16734. private _capacity;
  16735. private _stockParticles;
  16736. private _newPartsExcess;
  16737. private _vertexData;
  16738. private _vertexBuffer;
  16739. private _vertexBuffers;
  16740. private _spriteBuffer;
  16741. private _indexBuffer;
  16742. private _effect;
  16743. private _customEffect;
  16744. private _cachedDefines;
  16745. private _scaledColorStep;
  16746. private _colorDiff;
  16747. private _scaledDirection;
  16748. private _scaledGravity;
  16749. private _currentRenderId;
  16750. private _alive;
  16751. private _useInstancing;
  16752. private _started;
  16753. private _stopped;
  16754. private _actualFrame;
  16755. private _scaledUpdateSpeed;
  16756. private _vertexBufferSize;
  16757. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16758. /** @hidden */ private _currentEmitRate1: number;
  16759. /** @hidden */ private _currentEmitRate2: number;
  16760. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16761. /** @hidden */ private _currentStartSize1: number;
  16762. /** @hidden */ private _currentStartSize2: number;
  16763. private readonly _rawTextureWidth;
  16764. private _rampGradientsTexture;
  16765. private _useRampGradients;
  16766. /** Gets or sets a boolean indicating that ramp gradients must be used
  16767. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16768. */
  16769. useRampGradients: boolean;
  16770. /**
  16771. * 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.
  16772. * 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: [])
  16773. */
  16774. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16775. private _subEmitters;
  16776. /**
  16777. * @hidden
  16778. * If the particle systems emitter should be disposed when the particle system is disposed
  16779. */ private _disposeEmitterOnDispose: boolean;
  16780. /**
  16781. * The current active Sub-systems, this property is used by the root particle system only.
  16782. */
  16783. activeSubSystems: Array<ParticleSystem>;
  16784. private _rootParticleSystem;
  16785. /**
  16786. * Gets the current list of active particles
  16787. */
  16788. readonly particles: Particle[];
  16789. /**
  16790. * Returns the string "ParticleSystem"
  16791. * @returns a string containing the class name
  16792. */
  16793. getClassName(): string;
  16794. /**
  16795. * Instantiates a particle system.
  16796. * 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.
  16797. * @param name The name of the particle system
  16798. * @param capacity The max number of particles alive at the same time
  16799. * @param scene The scene the particle system belongs to
  16800. * @param customEffect a custom effect used to change the way particles are rendered by default
  16801. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16802. * @param epsilon Offset used to render the particles
  16803. */
  16804. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16805. private _addFactorGradient;
  16806. private _removeFactorGradient;
  16807. /**
  16808. * Adds a new life time gradient
  16809. * @param gradient defines the gradient to use (between 0 and 1)
  16810. * @param factor defines the life time factor to affect to the specified gradient
  16811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16812. * @returns the current particle system
  16813. */
  16814. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16815. /**
  16816. * Remove a specific life time gradient
  16817. * @param gradient defines the gradient to remove
  16818. * @returns the current particle system
  16819. */
  16820. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16821. /**
  16822. * Adds a new size gradient
  16823. * @param gradient defines the gradient to use (between 0 and 1)
  16824. * @param factor defines the size factor to affect to the specified gradient
  16825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16826. * @returns the current particle system
  16827. */
  16828. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16829. /**
  16830. * Remove a specific size gradient
  16831. * @param gradient defines the gradient to remove
  16832. * @returns the current particle system
  16833. */
  16834. removeSizeGradient(gradient: number): IParticleSystem;
  16835. /**
  16836. * Adds a new color remap gradient
  16837. * @param gradient defines the gradient to use (between 0 and 1)
  16838. * @param min defines the color remap minimal range
  16839. * @param max defines the color remap maximal range
  16840. * @returns the current particle system
  16841. */
  16842. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16843. /**
  16844. * Remove a specific color remap gradient
  16845. * @param gradient defines the gradient to remove
  16846. * @returns the current particle system
  16847. */
  16848. removeColorRemapGradient(gradient: number): IParticleSystem;
  16849. /**
  16850. * Adds a new alpha remap gradient
  16851. * @param gradient defines the gradient to use (between 0 and 1)
  16852. * @param min defines the alpha remap minimal range
  16853. * @param max defines the alpha remap maximal range
  16854. * @returns the current particle system
  16855. */
  16856. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16857. /**
  16858. * Remove a specific alpha remap gradient
  16859. * @param gradient defines the gradient to remove
  16860. * @returns the current particle system
  16861. */
  16862. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16863. /**
  16864. * Adds a new angular speed gradient
  16865. * @param gradient defines the gradient to use (between 0 and 1)
  16866. * @param factor defines the angular speed to affect to the specified gradient
  16867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16868. * @returns the current particle system
  16869. */
  16870. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16871. /**
  16872. * Remove a specific angular speed gradient
  16873. * @param gradient defines the gradient to remove
  16874. * @returns the current particle system
  16875. */
  16876. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16877. /**
  16878. * Adds a new velocity gradient
  16879. * @param gradient defines the gradient to use (between 0 and 1)
  16880. * @param factor defines the velocity to affect to the specified gradient
  16881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16882. * @returns the current particle system
  16883. */
  16884. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16885. /**
  16886. * Remove a specific velocity gradient
  16887. * @param gradient defines the gradient to remove
  16888. * @returns the current particle system
  16889. */
  16890. removeVelocityGradient(gradient: number): IParticleSystem;
  16891. /**
  16892. * Adds a new limit velocity gradient
  16893. * @param gradient defines the gradient to use (between 0 and 1)
  16894. * @param factor defines the limit velocity value to affect to the specified gradient
  16895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16896. * @returns the current particle system
  16897. */
  16898. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16899. /**
  16900. * Remove a specific limit velocity gradient
  16901. * @param gradient defines the gradient to remove
  16902. * @returns the current particle system
  16903. */
  16904. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16905. /**
  16906. * Adds a new drag gradient
  16907. * @param gradient defines the gradient to use (between 0 and 1)
  16908. * @param factor defines the drag value to affect to the specified gradient
  16909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16910. * @returns the current particle system
  16911. */
  16912. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16913. /**
  16914. * Remove a specific drag gradient
  16915. * @param gradient defines the gradient to remove
  16916. * @returns the current particle system
  16917. */
  16918. removeDragGradient(gradient: number): IParticleSystem;
  16919. /**
  16920. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16921. * @param gradient defines the gradient to use (between 0 and 1)
  16922. * @param factor defines the emit rate value to affect to the specified gradient
  16923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16924. * @returns the current particle system
  16925. */
  16926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16927. /**
  16928. * Remove a specific emit rate gradient
  16929. * @param gradient defines the gradient to remove
  16930. * @returns the current particle system
  16931. */
  16932. removeEmitRateGradient(gradient: number): IParticleSystem;
  16933. /**
  16934. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16935. * @param gradient defines the gradient to use (between 0 and 1)
  16936. * @param factor defines the start size value to affect to the specified gradient
  16937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16938. * @returns the current particle system
  16939. */
  16940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16941. /**
  16942. * Remove a specific start size gradient
  16943. * @param gradient defines the gradient to remove
  16944. * @returns the current particle system
  16945. */
  16946. removeStartSizeGradient(gradient: number): IParticleSystem;
  16947. private _createRampGradientTexture;
  16948. /**
  16949. * Gets the current list of ramp gradients.
  16950. * You must use addRampGradient and removeRampGradient to udpate this list
  16951. * @returns the list of ramp gradients
  16952. */
  16953. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16954. /**
  16955. * Adds a new ramp gradient used to remap particle colors
  16956. * @param gradient defines the gradient to use (between 0 and 1)
  16957. * @param color defines the color to affect to the specified gradient
  16958. * @returns the current particle system
  16959. */
  16960. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16961. /**
  16962. * Remove a specific ramp gradient
  16963. * @param gradient defines the gradient to remove
  16964. * @returns the current particle system
  16965. */
  16966. removeRampGradient(gradient: number): ParticleSystem;
  16967. /**
  16968. * Adds a new color gradient
  16969. * @param gradient defines the gradient to use (between 0 and 1)
  16970. * @param color1 defines the color to affect to the specified gradient
  16971. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16972. * @returns this particle system
  16973. */
  16974. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16975. /**
  16976. * Remove a specific color gradient
  16977. * @param gradient defines the gradient to remove
  16978. * @returns this particle system
  16979. */
  16980. removeColorGradient(gradient: number): IParticleSystem;
  16981. private _fetchR;
  16982. protected _reset(): void;
  16983. private _resetEffect;
  16984. private _createVertexBuffers;
  16985. private _createIndexBuffer;
  16986. /**
  16987. * Gets the maximum number of particles active at the same time.
  16988. * @returns The max number of active particles.
  16989. */
  16990. getCapacity(): number;
  16991. /**
  16992. * Gets whether there are still active particles in the system.
  16993. * @returns True if it is alive, otherwise false.
  16994. */
  16995. isAlive(): boolean;
  16996. /**
  16997. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16998. * @returns True if it has been started, otherwise false.
  16999. */
  17000. isStarted(): boolean;
  17001. private _prepareSubEmitterInternalArray;
  17002. /**
  17003. * Starts the particle system and begins to emit
  17004. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17005. */
  17006. start(delay?: number): void;
  17007. /**
  17008. * Stops the particle system.
  17009. * @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.
  17010. */
  17011. stop(stopSubEmitters?: boolean): void;
  17012. /**
  17013. * Remove all active particles
  17014. */
  17015. reset(): void;
  17016. /**
  17017. * @hidden (for internal use only)
  17018. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17019. /**
  17020. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17021. * Its lifetime will start back at 0.
  17022. */
  17023. recycleParticle: (particle: Particle) => void;
  17024. private _stopSubEmitters;
  17025. private _createParticle;
  17026. private _removeFromRoot;
  17027. private _emitFromParticle;
  17028. private _update;
  17029. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17030. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17031. /** @hidden */
  17032. private _getEffect;
  17033. /**
  17034. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17035. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17036. */
  17037. animate(preWarmOnly?: boolean): void;
  17038. private _appendParticleVertices;
  17039. /**
  17040. * Rebuilds the particle system.
  17041. */
  17042. rebuild(): void;
  17043. /**
  17044. * Is this system ready to be used/rendered
  17045. * @return true if the system is ready
  17046. */
  17047. isReady(): boolean;
  17048. private _render;
  17049. /**
  17050. * Renders the particle system in its current state.
  17051. * @returns the current number of particles
  17052. */
  17053. render(): number;
  17054. /**
  17055. * Disposes the particle system and free the associated resources
  17056. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17057. */
  17058. dispose(disposeTexture?: boolean): void;
  17059. /**
  17060. * Clones the particle system.
  17061. * @param name The name of the cloned object
  17062. * @param newEmitter The new emitter to use
  17063. * @returns the cloned particle system
  17064. */
  17065. clone(name: string, newEmitter: any): ParticleSystem;
  17066. /**
  17067. * Serializes the particle system to a JSON object.
  17068. * @returns the JSON object
  17069. */
  17070. serialize(): any;
  17071. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17072. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17073. /**
  17074. * Parses a JSON object to create a particle system.
  17075. * @param parsedParticleSystem The JSON object to parse
  17076. * @param scene The scene to create the particle system in
  17077. * @param rootUrl The root url to use to load external dependencies like texture
  17078. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17079. * @returns the Parsed particle system
  17080. */
  17081. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17082. }
  17083. }
  17084. declare module BABYLON {
  17085. /**
  17086. * A particle represents one of the element emitted by a particle system.
  17087. * This is mainly define by its coordinates, direction, velocity and age.
  17088. */
  17089. export class Particle {
  17090. /**
  17091. * The particle system the particle belongs to.
  17092. */
  17093. particleSystem: ParticleSystem;
  17094. private static _Count;
  17095. /**
  17096. * Unique ID of the particle
  17097. */
  17098. id: number;
  17099. /**
  17100. * The world position of the particle in the scene.
  17101. */
  17102. position: Vector3;
  17103. /**
  17104. * The world direction of the particle in the scene.
  17105. */
  17106. direction: Vector3;
  17107. /**
  17108. * The color of the particle.
  17109. */
  17110. color: Color4;
  17111. /**
  17112. * The color change of the particle per step.
  17113. */
  17114. colorStep: Color4;
  17115. /**
  17116. * Defines how long will the life of the particle be.
  17117. */
  17118. lifeTime: number;
  17119. /**
  17120. * The current age of the particle.
  17121. */
  17122. age: number;
  17123. /**
  17124. * The current size of the particle.
  17125. */
  17126. size: number;
  17127. /**
  17128. * The current scale of the particle.
  17129. */
  17130. scale: Vector2;
  17131. /**
  17132. * The current angle of the particle.
  17133. */
  17134. angle: number;
  17135. /**
  17136. * Defines how fast is the angle changing.
  17137. */
  17138. angularSpeed: number;
  17139. /**
  17140. * Defines the cell index used by the particle to be rendered from a sprite.
  17141. */
  17142. cellIndex: number;
  17143. /**
  17144. * The information required to support color remapping
  17145. */
  17146. remapData: Vector4;
  17147. /** @hidden */ private _randomCellOffset?: number;
  17148. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17149. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17150. /** @hidden */ private _initialStartSpriteCellID: number;
  17151. /** @hidden */ private _initialEndSpriteCellID: number;
  17152. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17153. /** @hidden */ private _currentColor1: Color4;
  17154. /** @hidden */ private _currentColor2: Color4;
  17155. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17156. /** @hidden */ private _currentSize1: number;
  17157. /** @hidden */ private _currentSize2: number;
  17158. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17159. /** @hidden */ private _currentAngularSpeed1: number;
  17160. /** @hidden */ private _currentAngularSpeed2: number;
  17161. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17162. /** @hidden */ private _currentVelocity1: number;
  17163. /** @hidden */ private _currentVelocity2: number;
  17164. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17165. /** @hidden */ private _currentLimitVelocity1: number;
  17166. /** @hidden */ private _currentLimitVelocity2: number;
  17167. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17168. /** @hidden */ private _currentDrag1: number;
  17169. /** @hidden */ private _currentDrag2: number;
  17170. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17171. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17172. /**
  17173. * Creates a new instance Particle
  17174. * @param particleSystem the particle system the particle belongs to
  17175. */
  17176. constructor(
  17177. /**
  17178. * The particle system the particle belongs to.
  17179. */
  17180. particleSystem: ParticleSystem);
  17181. private updateCellInfoFromSystem;
  17182. /**
  17183. * Defines how the sprite cell index is updated for the particle
  17184. */
  17185. updateCellIndex(): void;
  17186. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17187. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17188. /** @hidden */ private _reset(): void;
  17189. /**
  17190. * Copy the properties of particle to another one.
  17191. * @param other the particle to copy the information to.
  17192. */
  17193. copyTo(other: Particle): void;
  17194. }
  17195. }
  17196. declare module BABYLON {
  17197. /**
  17198. * Particle emitter represents a volume emitting particles.
  17199. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17200. */
  17201. export interface IParticleEmitterType {
  17202. /**
  17203. * Called by the particle System when the direction is computed for the created particle.
  17204. * @param worldMatrix is the world matrix of the particle system
  17205. * @param directionToUpdate is the direction vector to update with the result
  17206. * @param particle is the particle we are computed the direction for
  17207. */
  17208. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17209. /**
  17210. * Called by the particle System when the position is computed for the created particle.
  17211. * @param worldMatrix is the world matrix of the particle system
  17212. * @param positionToUpdate is the position vector to update with the result
  17213. * @param particle is the particle we are computed the position for
  17214. */
  17215. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17216. /**
  17217. * Clones the current emitter and returns a copy of it
  17218. * @returns the new emitter
  17219. */
  17220. clone(): IParticleEmitterType;
  17221. /**
  17222. * Called by the GPUParticleSystem to setup the update shader
  17223. * @param effect defines the update shader
  17224. */
  17225. applyToShader(effect: Effect): void;
  17226. /**
  17227. * Returns a string to use to update the GPU particles update shader
  17228. * @returns the effect defines string
  17229. */
  17230. getEffectDefines(): string;
  17231. /**
  17232. * Returns a string representing the class name
  17233. * @returns a string containing the class name
  17234. */
  17235. getClassName(): string;
  17236. /**
  17237. * Serializes the particle system to a JSON object.
  17238. * @returns the JSON object
  17239. */
  17240. serialize(): any;
  17241. /**
  17242. * Parse properties from a JSON object
  17243. * @param serializationObject defines the JSON object
  17244. */
  17245. parse(serializationObject: any): void;
  17246. }
  17247. }
  17248. declare module BABYLON {
  17249. /**
  17250. * Particle emitter emitting particles from the inside of a box.
  17251. * It emits the particles randomly between 2 given directions.
  17252. */
  17253. export class BoxParticleEmitter implements IParticleEmitterType {
  17254. /**
  17255. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17256. */
  17257. direction1: Vector3;
  17258. /**
  17259. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17260. */
  17261. direction2: Vector3;
  17262. /**
  17263. * 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.
  17264. */
  17265. minEmitBox: Vector3;
  17266. /**
  17267. * 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.
  17268. */
  17269. maxEmitBox: Vector3;
  17270. /**
  17271. * Creates a new instance BoxParticleEmitter
  17272. */
  17273. constructor();
  17274. /**
  17275. * Called by the particle System when the direction is computed for the created particle.
  17276. * @param worldMatrix is the world matrix of the particle system
  17277. * @param directionToUpdate is the direction vector to update with the result
  17278. * @param particle is the particle we are computed the direction for
  17279. */
  17280. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17281. /**
  17282. * Called by the particle System when the position is computed for the created particle.
  17283. * @param worldMatrix is the world matrix of the particle system
  17284. * @param positionToUpdate is the position vector to update with the result
  17285. * @param particle is the particle we are computed the position for
  17286. */
  17287. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17288. /**
  17289. * Clones the current emitter and returns a copy of it
  17290. * @returns the new emitter
  17291. */
  17292. clone(): BoxParticleEmitter;
  17293. /**
  17294. * Called by the GPUParticleSystem to setup the update shader
  17295. * @param effect defines the update shader
  17296. */
  17297. applyToShader(effect: Effect): void;
  17298. /**
  17299. * Returns a string to use to update the GPU particles update shader
  17300. * @returns a string containng the defines string
  17301. */
  17302. getEffectDefines(): string;
  17303. /**
  17304. * Returns the string "BoxParticleEmitter"
  17305. * @returns a string containing the class name
  17306. */
  17307. getClassName(): string;
  17308. /**
  17309. * Serializes the particle system to a JSON object.
  17310. * @returns the JSON object
  17311. */
  17312. serialize(): any;
  17313. /**
  17314. * Parse properties from a JSON object
  17315. * @param serializationObject defines the JSON object
  17316. */
  17317. parse(serializationObject: any): void;
  17318. }
  17319. }
  17320. declare module BABYLON {
  17321. /**
  17322. * Particle emitter emitting particles from the inside of a cone.
  17323. * It emits the particles alongside the cone volume from the base to the particle.
  17324. * The emission direction might be randomized.
  17325. */
  17326. export class ConeParticleEmitter implements IParticleEmitterType {
  17327. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17328. directionRandomizer: number;
  17329. private _radius;
  17330. private _angle;
  17331. private _height;
  17332. /**
  17333. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17334. */
  17335. radiusRange: number;
  17336. /**
  17337. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17338. */
  17339. heightRange: number;
  17340. /**
  17341. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17342. */
  17343. emitFromSpawnPointOnly: boolean;
  17344. /**
  17345. * Gets or sets the radius of the emission cone
  17346. */
  17347. radius: number;
  17348. /**
  17349. * Gets or sets the angle of the emission cone
  17350. */
  17351. angle: number;
  17352. private _buildHeight;
  17353. /**
  17354. * Creates a new instance ConeParticleEmitter
  17355. * @param radius the radius of the emission cone (1 by default)
  17356. * @param angle the cone base angle (PI by default)
  17357. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17358. */
  17359. constructor(radius?: number, angle?: number,
  17360. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17361. directionRandomizer?: number);
  17362. /**
  17363. * Called by the particle System when the direction is computed for the created particle.
  17364. * @param worldMatrix is the world matrix of the particle system
  17365. * @param directionToUpdate is the direction vector to update with the result
  17366. * @param particle is the particle we are computed the direction for
  17367. */
  17368. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17369. /**
  17370. * Called by the particle System when the position is computed for the created particle.
  17371. * @param worldMatrix is the world matrix of the particle system
  17372. * @param positionToUpdate is the position vector to update with the result
  17373. * @param particle is the particle we are computed the position for
  17374. */
  17375. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17376. /**
  17377. * Clones the current emitter and returns a copy of it
  17378. * @returns the new emitter
  17379. */
  17380. clone(): ConeParticleEmitter;
  17381. /**
  17382. * Called by the GPUParticleSystem to setup the update shader
  17383. * @param effect defines the update shader
  17384. */
  17385. applyToShader(effect: Effect): void;
  17386. /**
  17387. * Returns a string to use to update the GPU particles update shader
  17388. * @returns a string containng the defines string
  17389. */
  17390. getEffectDefines(): string;
  17391. /**
  17392. * Returns the string "ConeParticleEmitter"
  17393. * @returns a string containing the class name
  17394. */
  17395. getClassName(): string;
  17396. /**
  17397. * Serializes the particle system to a JSON object.
  17398. * @returns the JSON object
  17399. */
  17400. serialize(): any;
  17401. /**
  17402. * Parse properties from a JSON object
  17403. * @param serializationObject defines the JSON object
  17404. */
  17405. parse(serializationObject: any): void;
  17406. }
  17407. }
  17408. declare module BABYLON {
  17409. /**
  17410. * Particle emitter emitting particles from the inside of a cylinder.
  17411. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17412. */
  17413. export class CylinderParticleEmitter implements IParticleEmitterType {
  17414. /**
  17415. * The radius of the emission cylinder.
  17416. */
  17417. radius: number;
  17418. /**
  17419. * The height of the emission cylinder.
  17420. */
  17421. height: number;
  17422. /**
  17423. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17424. */
  17425. radiusRange: number;
  17426. /**
  17427. * How much to randomize the particle direction [0-1].
  17428. */
  17429. directionRandomizer: number;
  17430. /**
  17431. * Creates a new instance CylinderParticleEmitter
  17432. * @param radius the radius of the emission cylinder (1 by default)
  17433. * @param height the height of the emission cylinder (1 by default)
  17434. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17435. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17436. */
  17437. constructor(
  17438. /**
  17439. * The radius of the emission cylinder.
  17440. */
  17441. radius?: number,
  17442. /**
  17443. * The height of the emission cylinder.
  17444. */
  17445. height?: number,
  17446. /**
  17447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17448. */
  17449. radiusRange?: number,
  17450. /**
  17451. * How much to randomize the particle direction [0-1].
  17452. */
  17453. directionRandomizer?: number);
  17454. /**
  17455. * Called by the particle System when the direction is computed for the created particle.
  17456. * @param worldMatrix is the world matrix of the particle system
  17457. * @param directionToUpdate is the direction vector to update with the result
  17458. * @param particle is the particle we are computed the direction for
  17459. */
  17460. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17461. /**
  17462. * Called by the particle System when the position is computed for the created particle.
  17463. * @param worldMatrix is the world matrix of the particle system
  17464. * @param positionToUpdate is the position vector to update with the result
  17465. * @param particle is the particle we are computed the position for
  17466. */
  17467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17468. /**
  17469. * Clones the current emitter and returns a copy of it
  17470. * @returns the new emitter
  17471. */
  17472. clone(): CylinderParticleEmitter;
  17473. /**
  17474. * Called by the GPUParticleSystem to setup the update shader
  17475. * @param effect defines the update shader
  17476. */
  17477. applyToShader(effect: Effect): void;
  17478. /**
  17479. * Returns a string to use to update the GPU particles update shader
  17480. * @returns a string containng the defines string
  17481. */
  17482. getEffectDefines(): string;
  17483. /**
  17484. * Returns the string "CylinderParticleEmitter"
  17485. * @returns a string containing the class name
  17486. */
  17487. getClassName(): string;
  17488. /**
  17489. * Serializes the particle system to a JSON object.
  17490. * @returns the JSON object
  17491. */
  17492. serialize(): any;
  17493. /**
  17494. * Parse properties from a JSON object
  17495. * @param serializationObject defines the JSON object
  17496. */
  17497. parse(serializationObject: any): void;
  17498. }
  17499. /**
  17500. * Particle emitter emitting particles from the inside of a cylinder.
  17501. * It emits the particles randomly between two vectors.
  17502. */
  17503. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17504. /**
  17505. * The min limit of the emission direction.
  17506. */
  17507. direction1: Vector3;
  17508. /**
  17509. * The max limit of the emission direction.
  17510. */
  17511. direction2: Vector3;
  17512. /**
  17513. * Creates a new instance CylinderDirectedParticleEmitter
  17514. * @param radius the radius of the emission cylinder (1 by default)
  17515. * @param height the height of the emission cylinder (1 by default)
  17516. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17517. * @param direction1 the min limit of the emission direction (up vector by default)
  17518. * @param direction2 the max limit of the emission direction (up vector by default)
  17519. */
  17520. constructor(radius?: number, height?: number, radiusRange?: number,
  17521. /**
  17522. * The min limit of the emission direction.
  17523. */
  17524. direction1?: Vector3,
  17525. /**
  17526. * The max limit of the emission direction.
  17527. */
  17528. direction2?: Vector3);
  17529. /**
  17530. * Called by the particle System when the direction is computed for the created particle.
  17531. * @param worldMatrix is the world matrix of the particle system
  17532. * @param directionToUpdate is the direction vector to update with the result
  17533. * @param particle is the particle we are computed the direction for
  17534. */
  17535. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17536. /**
  17537. * Clones the current emitter and returns a copy of it
  17538. * @returns the new emitter
  17539. */
  17540. clone(): CylinderDirectedParticleEmitter;
  17541. /**
  17542. * Called by the GPUParticleSystem to setup the update shader
  17543. * @param effect defines the update shader
  17544. */
  17545. applyToShader(effect: Effect): void;
  17546. /**
  17547. * Returns a string to use to update the GPU particles update shader
  17548. * @returns a string containng the defines string
  17549. */
  17550. getEffectDefines(): string;
  17551. /**
  17552. * Returns the string "CylinderDirectedParticleEmitter"
  17553. * @returns a string containing the class name
  17554. */
  17555. getClassName(): string;
  17556. /**
  17557. * Serializes the particle system to a JSON object.
  17558. * @returns the JSON object
  17559. */
  17560. serialize(): any;
  17561. /**
  17562. * Parse properties from a JSON object
  17563. * @param serializationObject defines the JSON object
  17564. */
  17565. parse(serializationObject: any): void;
  17566. }
  17567. }
  17568. declare module BABYLON {
  17569. /**
  17570. * Particle emitter emitting particles from the inside of a hemisphere.
  17571. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17572. */
  17573. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17574. /**
  17575. * The radius of the emission hemisphere.
  17576. */
  17577. radius: number;
  17578. /**
  17579. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17580. */
  17581. radiusRange: number;
  17582. /**
  17583. * How much to randomize the particle direction [0-1].
  17584. */
  17585. directionRandomizer: number;
  17586. /**
  17587. * Creates a new instance HemisphericParticleEmitter
  17588. * @param radius the radius of the emission hemisphere (1 by default)
  17589. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17590. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17591. */
  17592. constructor(
  17593. /**
  17594. * The radius of the emission hemisphere.
  17595. */
  17596. radius?: number,
  17597. /**
  17598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17599. */
  17600. radiusRange?: number,
  17601. /**
  17602. * How much to randomize the particle direction [0-1].
  17603. */
  17604. directionRandomizer?: number);
  17605. /**
  17606. * Called by the particle System when the direction is computed for the created particle.
  17607. * @param worldMatrix is the world matrix of the particle system
  17608. * @param directionToUpdate is the direction vector to update with the result
  17609. * @param particle is the particle we are computed the direction for
  17610. */
  17611. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17612. /**
  17613. * Called by the particle System when the position is computed for the created particle.
  17614. * @param worldMatrix is the world matrix of the particle system
  17615. * @param positionToUpdate is the position vector to update with the result
  17616. * @param particle is the particle we are computed the position for
  17617. */
  17618. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17619. /**
  17620. * Clones the current emitter and returns a copy of it
  17621. * @returns the new emitter
  17622. */
  17623. clone(): HemisphericParticleEmitter;
  17624. /**
  17625. * Called by the GPUParticleSystem to setup the update shader
  17626. * @param effect defines the update shader
  17627. */
  17628. applyToShader(effect: Effect): void;
  17629. /**
  17630. * Returns a string to use to update the GPU particles update shader
  17631. * @returns a string containng the defines string
  17632. */
  17633. getEffectDefines(): string;
  17634. /**
  17635. * Returns the string "HemisphericParticleEmitter"
  17636. * @returns a string containing the class name
  17637. */
  17638. getClassName(): string;
  17639. /**
  17640. * Serializes the particle system to a JSON object.
  17641. * @returns the JSON object
  17642. */
  17643. serialize(): any;
  17644. /**
  17645. * Parse properties from a JSON object
  17646. * @param serializationObject defines the JSON object
  17647. */
  17648. parse(serializationObject: any): void;
  17649. }
  17650. }
  17651. declare module BABYLON {
  17652. /**
  17653. * Particle emitter emitting particles from a point.
  17654. * It emits the particles randomly between 2 given directions.
  17655. */
  17656. export class PointParticleEmitter implements IParticleEmitterType {
  17657. /**
  17658. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17659. */
  17660. direction1: Vector3;
  17661. /**
  17662. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17663. */
  17664. direction2: Vector3;
  17665. /**
  17666. * Creates a new instance PointParticleEmitter
  17667. */
  17668. constructor();
  17669. /**
  17670. * Called by the particle System when the direction is computed for the created particle.
  17671. * @param worldMatrix is the world matrix of the particle system
  17672. * @param directionToUpdate is the direction vector to update with the result
  17673. * @param particle is the particle we are computed the direction for
  17674. */
  17675. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17676. /**
  17677. * Called by the particle System when the position is computed for the created particle.
  17678. * @param worldMatrix is the world matrix of the particle system
  17679. * @param positionToUpdate is the position vector to update with the result
  17680. * @param particle is the particle we are computed the position for
  17681. */
  17682. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17683. /**
  17684. * Clones the current emitter and returns a copy of it
  17685. * @returns the new emitter
  17686. */
  17687. clone(): PointParticleEmitter;
  17688. /**
  17689. * Called by the GPUParticleSystem to setup the update shader
  17690. * @param effect defines the update shader
  17691. */
  17692. applyToShader(effect: Effect): void;
  17693. /**
  17694. * Returns a string to use to update the GPU particles update shader
  17695. * @returns a string containng the defines string
  17696. */
  17697. getEffectDefines(): string;
  17698. /**
  17699. * Returns the string "PointParticleEmitter"
  17700. * @returns a string containing the class name
  17701. */
  17702. getClassName(): string;
  17703. /**
  17704. * Serializes the particle system to a JSON object.
  17705. * @returns the JSON object
  17706. */
  17707. serialize(): any;
  17708. /**
  17709. * Parse properties from a JSON object
  17710. * @param serializationObject defines the JSON object
  17711. */
  17712. parse(serializationObject: any): void;
  17713. }
  17714. }
  17715. declare module BABYLON {
  17716. /**
  17717. * Particle emitter emitting particles from the inside of a sphere.
  17718. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17719. */
  17720. export class SphereParticleEmitter implements IParticleEmitterType {
  17721. /**
  17722. * The radius of the emission sphere.
  17723. */
  17724. radius: number;
  17725. /**
  17726. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17727. */
  17728. radiusRange: number;
  17729. /**
  17730. * How much to randomize the particle direction [0-1].
  17731. */
  17732. directionRandomizer: number;
  17733. /**
  17734. * Creates a new instance SphereParticleEmitter
  17735. * @param radius the radius of the emission sphere (1 by default)
  17736. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17737. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17738. */
  17739. constructor(
  17740. /**
  17741. * The radius of the emission sphere.
  17742. */
  17743. radius?: number,
  17744. /**
  17745. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17746. */
  17747. radiusRange?: number,
  17748. /**
  17749. * How much to randomize the particle direction [0-1].
  17750. */
  17751. directionRandomizer?: number);
  17752. /**
  17753. * Called by the particle System when the direction is computed for the created particle.
  17754. * @param worldMatrix is the world matrix of the particle system
  17755. * @param directionToUpdate is the direction vector to update with the result
  17756. * @param particle is the particle we are computed the direction for
  17757. */
  17758. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17759. /**
  17760. * Called by the particle System when the position is computed for the created particle.
  17761. * @param worldMatrix is the world matrix of the particle system
  17762. * @param positionToUpdate is the position vector to update with the result
  17763. * @param particle is the particle we are computed the position for
  17764. */
  17765. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17766. /**
  17767. * Clones the current emitter and returns a copy of it
  17768. * @returns the new emitter
  17769. */
  17770. clone(): SphereParticleEmitter;
  17771. /**
  17772. * Called by the GPUParticleSystem to setup the update shader
  17773. * @param effect defines the update shader
  17774. */
  17775. applyToShader(effect: Effect): void;
  17776. /**
  17777. * Returns a string to use to update the GPU particles update shader
  17778. * @returns a string containng the defines string
  17779. */
  17780. getEffectDefines(): string;
  17781. /**
  17782. * Returns the string "SphereParticleEmitter"
  17783. * @returns a string containing the class name
  17784. */
  17785. getClassName(): string;
  17786. /**
  17787. * Serializes the particle system to a JSON object.
  17788. * @returns the JSON object
  17789. */
  17790. serialize(): any;
  17791. /**
  17792. * Parse properties from a JSON object
  17793. * @param serializationObject defines the JSON object
  17794. */
  17795. parse(serializationObject: any): void;
  17796. }
  17797. /**
  17798. * Particle emitter emitting particles from the inside of a sphere.
  17799. * It emits the particles randomly between two vectors.
  17800. */
  17801. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17802. /**
  17803. * The min limit of the emission direction.
  17804. */
  17805. direction1: Vector3;
  17806. /**
  17807. * The max limit of the emission direction.
  17808. */
  17809. direction2: Vector3;
  17810. /**
  17811. * Creates a new instance SphereDirectedParticleEmitter
  17812. * @param radius the radius of the emission sphere (1 by default)
  17813. * @param direction1 the min limit of the emission direction (up vector by default)
  17814. * @param direction2 the max limit of the emission direction (up vector by default)
  17815. */
  17816. constructor(radius?: number,
  17817. /**
  17818. * The min limit of the emission direction.
  17819. */
  17820. direction1?: Vector3,
  17821. /**
  17822. * The max limit of the emission direction.
  17823. */
  17824. direction2?: Vector3);
  17825. /**
  17826. * Called by the particle System when the direction is computed for the created particle.
  17827. * @param worldMatrix is the world matrix of the particle system
  17828. * @param directionToUpdate is the direction vector to update with the result
  17829. * @param particle is the particle we are computed the direction for
  17830. */
  17831. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17832. /**
  17833. * Clones the current emitter and returns a copy of it
  17834. * @returns the new emitter
  17835. */
  17836. clone(): SphereDirectedParticleEmitter;
  17837. /**
  17838. * Called by the GPUParticleSystem to setup the update shader
  17839. * @param effect defines the update shader
  17840. */
  17841. applyToShader(effect: Effect): void;
  17842. /**
  17843. * Returns a string to use to update the GPU particles update shader
  17844. * @returns a string containng the defines string
  17845. */
  17846. getEffectDefines(): string;
  17847. /**
  17848. * Returns the string "SphereDirectedParticleEmitter"
  17849. * @returns a string containing the class name
  17850. */
  17851. getClassName(): string;
  17852. /**
  17853. * Serializes the particle system to a JSON object.
  17854. * @returns the JSON object
  17855. */
  17856. serialize(): any;
  17857. /**
  17858. * Parse properties from a JSON object
  17859. * @param serializationObject defines the JSON object
  17860. */
  17861. parse(serializationObject: any): void;
  17862. }
  17863. }
  17864. declare module BABYLON {
  17865. /**
  17866. * Interface representing a particle system in Babylon.js.
  17867. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17868. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17869. */
  17870. export interface IParticleSystem {
  17871. /**
  17872. * List of animations used by the particle system.
  17873. */
  17874. animations: Animation[];
  17875. /**
  17876. * The id of the Particle system.
  17877. */
  17878. id: string;
  17879. /**
  17880. * The name of the Particle system.
  17881. */
  17882. name: string;
  17883. /**
  17884. * The emitter represents the Mesh or position we are attaching the particle system to.
  17885. */
  17886. emitter: Nullable<AbstractMesh | Vector3>;
  17887. /**
  17888. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17889. */
  17890. isBillboardBased: boolean;
  17891. /**
  17892. * The rendering group used by the Particle system to chose when to render.
  17893. */
  17894. renderingGroupId: number;
  17895. /**
  17896. * The layer mask we are rendering the particles through.
  17897. */
  17898. layerMask: number;
  17899. /**
  17900. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17901. */
  17902. updateSpeed: number;
  17903. /**
  17904. * The amount of time the particle system is running (depends of the overall update speed).
  17905. */
  17906. targetStopDuration: number;
  17907. /**
  17908. * The texture used to render each particle. (this can be a spritesheet)
  17909. */
  17910. particleTexture: Nullable<Texture>;
  17911. /**
  17912. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17913. */
  17914. blendMode: number;
  17915. /**
  17916. * Minimum life time of emitting particles.
  17917. */
  17918. minLifeTime: number;
  17919. /**
  17920. * Maximum life time of emitting particles.
  17921. */
  17922. maxLifeTime: number;
  17923. /**
  17924. * Minimum Size of emitting particles.
  17925. */
  17926. minSize: number;
  17927. /**
  17928. * Maximum Size of emitting particles.
  17929. */
  17930. maxSize: number;
  17931. /**
  17932. * Minimum scale of emitting particles on X axis.
  17933. */
  17934. minScaleX: number;
  17935. /**
  17936. * Maximum scale of emitting particles on X axis.
  17937. */
  17938. maxScaleX: number;
  17939. /**
  17940. * Minimum scale of emitting particles on Y axis.
  17941. */
  17942. minScaleY: number;
  17943. /**
  17944. * Maximum scale of emitting particles on Y axis.
  17945. */
  17946. maxScaleY: number;
  17947. /**
  17948. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17949. */
  17950. color1: Color4;
  17951. /**
  17952. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17953. */
  17954. color2: Color4;
  17955. /**
  17956. * Color the particle will have at the end of its lifetime.
  17957. */
  17958. colorDead: Color4;
  17959. /**
  17960. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17961. */
  17962. emitRate: number;
  17963. /**
  17964. * You can use gravity if you want to give an orientation to your particles.
  17965. */
  17966. gravity: Vector3;
  17967. /**
  17968. * Minimum power of emitting particles.
  17969. */
  17970. minEmitPower: number;
  17971. /**
  17972. * Maximum power of emitting particles.
  17973. */
  17974. maxEmitPower: number;
  17975. /**
  17976. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17977. */
  17978. minAngularSpeed: number;
  17979. /**
  17980. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17981. */
  17982. maxAngularSpeed: number;
  17983. /**
  17984. * Gets or sets the minimal initial rotation in radians.
  17985. */
  17986. minInitialRotation: number;
  17987. /**
  17988. * Gets or sets the maximal initial rotation in radians.
  17989. */
  17990. maxInitialRotation: number;
  17991. /**
  17992. * The particle emitter type defines the emitter used by the particle system.
  17993. * It can be for example box, sphere, or cone...
  17994. */
  17995. particleEmitterType: Nullable<IParticleEmitterType>;
  17996. /**
  17997. * Defines the delay in milliseconds before starting the system (0 by default)
  17998. */
  17999. startDelay: number;
  18000. /**
  18001. * 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
  18002. */
  18003. preWarmCycles: number;
  18004. /**
  18005. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18006. */
  18007. preWarmStepOffset: number;
  18008. /**
  18009. * 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)
  18010. */
  18011. spriteCellChangeSpeed: number;
  18012. /**
  18013. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18014. */
  18015. startSpriteCellID: number;
  18016. /**
  18017. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18018. */
  18019. endSpriteCellID: number;
  18020. /**
  18021. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18022. */
  18023. spriteCellWidth: number;
  18024. /**
  18025. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18026. */
  18027. spriteCellHeight: number;
  18028. /**
  18029. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18030. */
  18031. spriteRandomStartCell: boolean;
  18032. /**
  18033. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18034. */
  18035. isAnimationSheetEnabled: boolean;
  18036. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18037. translationPivot: Vector2;
  18038. /**
  18039. * Gets or sets a texture used to add random noise to particle positions
  18040. */
  18041. noiseTexture: Nullable<BaseTexture>;
  18042. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18043. noiseStrength: Vector3;
  18044. /**
  18045. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18046. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18047. */
  18048. billboardMode: number;
  18049. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18050. limitVelocityDamping: number;
  18051. /**
  18052. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18053. */
  18054. beginAnimationOnStart: boolean;
  18055. /**
  18056. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18057. */
  18058. beginAnimationFrom: number;
  18059. /**
  18060. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18061. */
  18062. beginAnimationTo: number;
  18063. /**
  18064. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18065. */
  18066. beginAnimationLoop: boolean;
  18067. /**
  18068. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18069. */
  18070. disposeOnStop: boolean;
  18071. /**
  18072. * Gets the maximum number of particles active at the same time.
  18073. * @returns The max number of active particles.
  18074. */
  18075. getCapacity(): number;
  18076. /**
  18077. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18078. * @returns True if it has been started, otherwise false.
  18079. */
  18080. isStarted(): boolean;
  18081. /**
  18082. * Animates the particle system for this frame.
  18083. */
  18084. animate(): void;
  18085. /**
  18086. * Renders the particle system in its current state.
  18087. * @returns the current number of particles
  18088. */
  18089. render(): number;
  18090. /**
  18091. * Dispose the particle system and frees its associated resources.
  18092. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18093. */
  18094. dispose(disposeTexture?: boolean): void;
  18095. /**
  18096. * Clones the particle system.
  18097. * @param name The name of the cloned object
  18098. * @param newEmitter The new emitter to use
  18099. * @returns the cloned particle system
  18100. */
  18101. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18102. /**
  18103. * Serializes the particle system to a JSON object.
  18104. * @returns the JSON object
  18105. */
  18106. serialize(): any;
  18107. /**
  18108. * Rebuild the particle system
  18109. */
  18110. rebuild(): void;
  18111. /**
  18112. * Starts the particle system and begins to emit
  18113. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18114. */
  18115. start(delay?: number): void;
  18116. /**
  18117. * Stops the particle system.
  18118. */
  18119. stop(): void;
  18120. /**
  18121. * Remove all active particles
  18122. */
  18123. reset(): void;
  18124. /**
  18125. * Is this system ready to be used/rendered
  18126. * @return true if the system is ready
  18127. */
  18128. isReady(): boolean;
  18129. /**
  18130. * Adds a new color gradient
  18131. * @param gradient defines the gradient to use (between 0 and 1)
  18132. * @param color1 defines the color to affect to the specified gradient
  18133. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18134. * @returns the current particle system
  18135. */
  18136. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18137. /**
  18138. * Remove a specific color gradient
  18139. * @param gradient defines the gradient to remove
  18140. * @returns the current particle system
  18141. */
  18142. removeColorGradient(gradient: number): IParticleSystem;
  18143. /**
  18144. * Adds a new size gradient
  18145. * @param gradient defines the gradient to use (between 0 and 1)
  18146. * @param factor defines the size factor to affect to the specified gradient
  18147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18148. * @returns the current particle system
  18149. */
  18150. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18151. /**
  18152. * Remove a specific size gradient
  18153. * @param gradient defines the gradient to remove
  18154. * @returns the current particle system
  18155. */
  18156. removeSizeGradient(gradient: number): IParticleSystem;
  18157. /**
  18158. * Gets the current list of color gradients.
  18159. * You must use addColorGradient and removeColorGradient to udpate this list
  18160. * @returns the list of color gradients
  18161. */
  18162. getColorGradients(): Nullable<Array<ColorGradient>>;
  18163. /**
  18164. * Gets the current list of size gradients.
  18165. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18166. * @returns the list of size gradients
  18167. */
  18168. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18169. /**
  18170. * Gets the current list of angular speed gradients.
  18171. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18172. * @returns the list of angular speed gradients
  18173. */
  18174. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18175. /**
  18176. * Adds a new angular speed gradient
  18177. * @param gradient defines the gradient to use (between 0 and 1)
  18178. * @param factor defines the angular speed to affect to the specified gradient
  18179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18180. * @returns the current particle system
  18181. */
  18182. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18183. /**
  18184. * Remove a specific angular speed gradient
  18185. * @param gradient defines the gradient to remove
  18186. * @returns the current particle system
  18187. */
  18188. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18189. /**
  18190. * Gets the current list of velocity gradients.
  18191. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18192. * @returns the list of velocity gradients
  18193. */
  18194. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18195. /**
  18196. * Adds a new velocity gradient
  18197. * @param gradient defines the gradient to use (between 0 and 1)
  18198. * @param factor defines the velocity to affect to the specified gradient
  18199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18200. * @returns the current particle system
  18201. */
  18202. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18203. /**
  18204. * Remove a specific velocity gradient
  18205. * @param gradient defines the gradient to remove
  18206. * @returns the current particle system
  18207. */
  18208. removeVelocityGradient(gradient: number): IParticleSystem;
  18209. /**
  18210. * Gets the current list of limit velocity gradients.
  18211. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18212. * @returns the list of limit velocity gradients
  18213. */
  18214. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18215. /**
  18216. * Adds a new limit velocity gradient
  18217. * @param gradient defines the gradient to use (between 0 and 1)
  18218. * @param factor defines the limit velocity to affect to the specified gradient
  18219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18220. * @returns the current particle system
  18221. */
  18222. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18223. /**
  18224. * Remove a specific limit velocity gradient
  18225. * @param gradient defines the gradient to remove
  18226. * @returns the current particle system
  18227. */
  18228. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18229. /**
  18230. * Adds a new drag gradient
  18231. * @param gradient defines the gradient to use (between 0 and 1)
  18232. * @param factor defines the drag to affect to the specified gradient
  18233. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18234. * @returns the current particle system
  18235. */
  18236. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18237. /**
  18238. * Remove a specific drag gradient
  18239. * @param gradient defines the gradient to remove
  18240. * @returns the current particle system
  18241. */
  18242. removeDragGradient(gradient: number): IParticleSystem;
  18243. /**
  18244. * Gets the current list of drag gradients.
  18245. * You must use addDragGradient and removeDragGradient to udpate this list
  18246. * @returns the list of drag gradients
  18247. */
  18248. getDragGradients(): Nullable<Array<FactorGradient>>;
  18249. /**
  18250. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18251. * @param gradient defines the gradient to use (between 0 and 1)
  18252. * @param factor defines the emit rate to affect to the specified gradient
  18253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18254. * @returns the current particle system
  18255. */
  18256. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18257. /**
  18258. * Remove a specific emit rate gradient
  18259. * @param gradient defines the gradient to remove
  18260. * @returns the current particle system
  18261. */
  18262. removeEmitRateGradient(gradient: number): IParticleSystem;
  18263. /**
  18264. * Gets the current list of emit rate gradients.
  18265. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18266. * @returns the list of emit rate gradients
  18267. */
  18268. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18269. /**
  18270. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18271. * @param gradient defines the gradient to use (between 0 and 1)
  18272. * @param factor defines the start size to affect to the specified gradient
  18273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18274. * @returns the current particle system
  18275. */
  18276. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18277. /**
  18278. * Remove a specific start size gradient
  18279. * @param gradient defines the gradient to remove
  18280. * @returns the current particle system
  18281. */
  18282. removeStartSizeGradient(gradient: number): IParticleSystem;
  18283. /**
  18284. * Gets the current list of start size gradients.
  18285. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18286. * @returns the list of start size gradients
  18287. */
  18288. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18289. /**
  18290. * Adds a new life time gradient
  18291. * @param gradient defines the gradient to use (between 0 and 1)
  18292. * @param factor defines the life time factor to affect to the specified gradient
  18293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18294. * @returns the current particle system
  18295. */
  18296. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18297. /**
  18298. * Remove a specific life time gradient
  18299. * @param gradient defines the gradient to remove
  18300. * @returns the current particle system
  18301. */
  18302. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18303. /**
  18304. * Gets the current list of life time gradients.
  18305. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18306. * @returns the list of life time gradients
  18307. */
  18308. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18309. /**
  18310. * Gets the current list of color gradients.
  18311. * You must use addColorGradient and removeColorGradient to udpate this list
  18312. * @returns the list of color gradients
  18313. */
  18314. getColorGradients(): Nullable<Array<ColorGradient>>;
  18315. /**
  18316. * Adds a new ramp gradient used to remap particle colors
  18317. * @param gradient defines the gradient to use (between 0 and 1)
  18318. * @param color defines the color to affect to the specified gradient
  18319. * @returns the current particle system
  18320. */
  18321. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18322. /**
  18323. * Gets the current list of ramp gradients.
  18324. * You must use addRampGradient and removeRampGradient to udpate this list
  18325. * @returns the list of ramp gradients
  18326. */
  18327. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18328. /** Gets or sets a boolean indicating that ramp gradients must be used
  18329. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18330. */
  18331. useRampGradients: boolean;
  18332. /**
  18333. * Adds a new color remap gradient
  18334. * @param gradient defines the gradient to use (between 0 and 1)
  18335. * @param min defines the color remap minimal range
  18336. * @param max defines the color remap maximal range
  18337. * @returns the current particle system
  18338. */
  18339. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18340. /**
  18341. * Gets the current list of color remap gradients.
  18342. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18343. * @returns the list of color remap gradients
  18344. */
  18345. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18346. /**
  18347. * Adds a new alpha remap gradient
  18348. * @param gradient defines the gradient to use (between 0 and 1)
  18349. * @param min defines the alpha remap minimal range
  18350. * @param max defines the alpha remap maximal range
  18351. * @returns the current particle system
  18352. */
  18353. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18354. /**
  18355. * Gets the current list of alpha remap gradients.
  18356. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18357. * @returns the list of alpha remap gradients
  18358. */
  18359. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18360. /**
  18361. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18364. * @returns the emitter
  18365. */
  18366. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18367. /**
  18368. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18369. * @param radius The radius of the hemisphere to emit from
  18370. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18371. * @returns the emitter
  18372. */
  18373. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18374. /**
  18375. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18376. * @param radius The radius of the sphere to emit from
  18377. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18378. * @returns the emitter
  18379. */
  18380. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18381. /**
  18382. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18383. * @param radius The radius of the sphere to emit from
  18384. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18385. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18386. * @returns the emitter
  18387. */
  18388. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18389. /**
  18390. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18391. * @param radius The radius of the emission cylinder
  18392. * @param height The height of the emission cylinder
  18393. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18394. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18395. * @returns the emitter
  18396. */
  18397. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18398. /**
  18399. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18400. * @param radius The radius of the cylinder to emit from
  18401. * @param height The height of the emission cylinder
  18402. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18405. * @returns the emitter
  18406. */
  18407. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18408. /**
  18409. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18410. * @param radius The radius of the cone to emit from
  18411. * @param angle The base angle of the cone
  18412. * @returns the emitter
  18413. */
  18414. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18415. /**
  18416. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18417. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18418. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18419. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18420. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18421. * @returns the emitter
  18422. */
  18423. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18424. /**
  18425. * Get hosting scene
  18426. * @returns the scene
  18427. */
  18428. getScene(): Scene;
  18429. }
  18430. }
  18431. declare module BABYLON {
  18432. /**
  18433. * Creates an instance based on a source mesh.
  18434. */
  18435. export class InstancedMesh extends AbstractMesh {
  18436. private _sourceMesh;
  18437. private _currentLOD;
  18438. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18439. constructor(name: string, source: Mesh);
  18440. /**
  18441. * Returns the string "InstancedMesh".
  18442. */
  18443. getClassName(): string;
  18444. /** Gets the list of lights affecting that mesh */
  18445. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light, dispose: boolean): void;
  18446. /**
  18447. * If the source mesh receives shadows
  18448. */
  18449. readonly receiveShadows: boolean;
  18450. /**
  18451. * The material of the source mesh
  18452. */
  18453. readonly material: Nullable<Material>;
  18454. /**
  18455. * Visibility of the source mesh
  18456. */
  18457. readonly visibility: number;
  18458. /**
  18459. * Skeleton of the source mesh
  18460. */
  18461. readonly skeleton: Nullable<Skeleton>;
  18462. /**
  18463. * Rendering ground id of the source mesh
  18464. */
  18465. renderingGroupId: number;
  18466. /**
  18467. * Returns the total number of vertices (integer).
  18468. */
  18469. getTotalVertices(): number;
  18470. /**
  18471. * Returns a positive integer : the total number of indices in this mesh geometry.
  18472. * @returns the numner of indices or zero if the mesh has no geometry.
  18473. */
  18474. getTotalIndices(): number;
  18475. /**
  18476. * The source mesh of the instance
  18477. */
  18478. readonly sourceMesh: Mesh;
  18479. /**
  18480. * Is this node ready to be used/rendered
  18481. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18482. * @return {boolean} is it ready
  18483. */
  18484. isReady(completeCheck?: boolean): boolean;
  18485. /**
  18486. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18487. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18488. * @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.
  18489. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18490. */
  18491. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18492. /**
  18493. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18494. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18495. * The `data` are either a numeric array either a Float32Array.
  18496. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18497. * 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).
  18498. * Note that a new underlying VertexBuffer object is created each call.
  18499. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18500. *
  18501. * Possible `kind` values :
  18502. * - VertexBuffer.PositionKind
  18503. * - VertexBuffer.UVKind
  18504. * - VertexBuffer.UV2Kind
  18505. * - VertexBuffer.UV3Kind
  18506. * - VertexBuffer.UV4Kind
  18507. * - VertexBuffer.UV5Kind
  18508. * - VertexBuffer.UV6Kind
  18509. * - VertexBuffer.ColorKind
  18510. * - VertexBuffer.MatricesIndicesKind
  18511. * - VertexBuffer.MatricesIndicesExtraKind
  18512. * - VertexBuffer.MatricesWeightsKind
  18513. * - VertexBuffer.MatricesWeightsExtraKind
  18514. *
  18515. * Returns the Mesh.
  18516. */
  18517. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18518. /**
  18519. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18520. * If the mesh has no geometry, it is simply returned as it is.
  18521. * The `data` are either a numeric array either a Float32Array.
  18522. * No new underlying VertexBuffer object is created.
  18523. * 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.
  18524. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18525. *
  18526. * Possible `kind` values :
  18527. * - VertexBuffer.PositionKind
  18528. * - VertexBuffer.UVKind
  18529. * - VertexBuffer.UV2Kind
  18530. * - VertexBuffer.UV3Kind
  18531. * - VertexBuffer.UV4Kind
  18532. * - VertexBuffer.UV5Kind
  18533. * - VertexBuffer.UV6Kind
  18534. * - VertexBuffer.ColorKind
  18535. * - VertexBuffer.MatricesIndicesKind
  18536. * - VertexBuffer.MatricesIndicesExtraKind
  18537. * - VertexBuffer.MatricesWeightsKind
  18538. * - VertexBuffer.MatricesWeightsExtraKind
  18539. *
  18540. * Returns the Mesh.
  18541. */
  18542. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18543. /**
  18544. * Sets the mesh indices.
  18545. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18546. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18547. * This method creates a new index buffer each call.
  18548. * Returns the Mesh.
  18549. */
  18550. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18551. /**
  18552. * Boolean : True if the mesh owns the requested kind of data.
  18553. */
  18554. isVerticesDataPresent(kind: string): boolean;
  18555. /**
  18556. * Returns an array of indices (IndicesArray).
  18557. */
  18558. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18559. /**
  18560. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18561. * This means the mesh underlying bounding box and sphere are recomputed.
  18562. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18563. * @returns the current mesh
  18564. */
  18565. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18566. /** @hidden */ private _preActivate(): InstancedMesh;
  18567. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18568. /** @hidden */ private _postActivate(): void;
  18569. getWorldMatrix(): Matrix;
  18570. readonly isAnInstance: boolean;
  18571. /**
  18572. * Returns the current associated LOD AbstractMesh.
  18573. */
  18574. getLOD(camera: Camera): AbstractMesh;
  18575. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18576. /** @hidden */ private _generatePointsArray(): boolean;
  18577. /**
  18578. * Creates a new InstancedMesh from the current mesh.
  18579. * - name (string) : the cloned mesh name
  18580. * - newParent (optional Node) : the optional Node to parent the clone to.
  18581. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18582. *
  18583. * Returns the clone.
  18584. */
  18585. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18586. /**
  18587. * Disposes the InstancedMesh.
  18588. * Returns nothing.
  18589. */
  18590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18591. }
  18592. }
  18593. declare module BABYLON {
  18594. /**
  18595. * Defines the options associated with the creation of a shader material.
  18596. */
  18597. export interface IShaderMaterialOptions {
  18598. /**
  18599. * Does the material work in alpha blend mode
  18600. */
  18601. needAlphaBlending: boolean;
  18602. /**
  18603. * Does the material work in alpha test mode
  18604. */
  18605. needAlphaTesting: boolean;
  18606. /**
  18607. * The list of attribute names used in the shader
  18608. */
  18609. attributes: string[];
  18610. /**
  18611. * The list of unifrom names used in the shader
  18612. */
  18613. uniforms: string[];
  18614. /**
  18615. * The list of UBO names used in the shader
  18616. */
  18617. uniformBuffers: string[];
  18618. /**
  18619. * The list of sampler names used in the shader
  18620. */
  18621. samplers: string[];
  18622. /**
  18623. * The list of defines used in the shader
  18624. */
  18625. defines: string[];
  18626. }
  18627. /**
  18628. * 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.
  18629. *
  18630. * This returned material effects how the mesh will look based on the code in the shaders.
  18631. *
  18632. * @see http://doc.babylonjs.com/how_to/shader_material
  18633. */
  18634. export class ShaderMaterial extends Material {
  18635. private _shaderPath;
  18636. private _options;
  18637. private _textures;
  18638. private _textureArrays;
  18639. private _floats;
  18640. private _ints;
  18641. private _floatsArrays;
  18642. private _colors3;
  18643. private _colors3Arrays;
  18644. private _colors4;
  18645. private _colors4Arrays;
  18646. private _vectors2;
  18647. private _vectors3;
  18648. private _vectors4;
  18649. private _matrices;
  18650. private _matrices3x3;
  18651. private _matrices2x2;
  18652. private _vectors2Arrays;
  18653. private _vectors3Arrays;
  18654. private _vectors4Arrays;
  18655. private _cachedWorldViewMatrix;
  18656. private _cachedWorldViewProjectionMatrix;
  18657. private _renderId;
  18658. /**
  18659. * Instantiate a new shader material.
  18660. * 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.
  18661. * This returned material effects how the mesh will look based on the code in the shaders.
  18662. * @see http://doc.babylonjs.com/how_to/shader_material
  18663. * @param name Define the name of the material in the scene
  18664. * @param scene Define the scene the material belongs to
  18665. * @param shaderPath Defines the route to the shader code in one of three ways:
  18666. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18667. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18668. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18669. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18670. * @param options Define the options used to create the shader
  18671. */
  18672. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18673. /**
  18674. * Gets the options used to compile the shader.
  18675. * They can be modified to trigger a new compilation
  18676. */
  18677. readonly options: IShaderMaterialOptions;
  18678. /**
  18679. * Gets the current class name of the material e.g. "ShaderMaterial"
  18680. * Mainly use in serialization.
  18681. * @returns the class name
  18682. */
  18683. getClassName(): string;
  18684. /**
  18685. * Specifies if the material will require alpha blending
  18686. * @returns a boolean specifying if alpha blending is needed
  18687. */
  18688. needAlphaBlending(): boolean;
  18689. /**
  18690. * Specifies if this material should be rendered in alpha test mode
  18691. * @returns a boolean specifying if an alpha test is needed.
  18692. */
  18693. needAlphaTesting(): boolean;
  18694. private _checkUniform;
  18695. /**
  18696. * Set a texture in the shader.
  18697. * @param name Define the name of the uniform samplers as defined in the shader
  18698. * @param texture Define the texture to bind to this sampler
  18699. * @return the material itself allowing "fluent" like uniform updates
  18700. */
  18701. setTexture(name: string, texture: Texture): ShaderMaterial;
  18702. /**
  18703. * Set a texture array in the shader.
  18704. * @param name Define the name of the uniform sampler array as defined in the shader
  18705. * @param textures Define the list of textures to bind to this sampler
  18706. * @return the material itself allowing "fluent" like uniform updates
  18707. */
  18708. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18709. /**
  18710. * Set a float in the shader.
  18711. * @param name Define the name of the uniform as defined in the shader
  18712. * @param value Define the value to give to the uniform
  18713. * @return the material itself allowing "fluent" like uniform updates
  18714. */
  18715. setFloat(name: string, value: number): ShaderMaterial;
  18716. /**
  18717. * Set a int in the shader.
  18718. * @param name Define the name of the uniform as defined in the shader
  18719. * @param value Define the value to give to the uniform
  18720. * @return the material itself allowing "fluent" like uniform updates
  18721. */
  18722. setInt(name: string, value: number): ShaderMaterial;
  18723. /**
  18724. * Set an array of floats in the shader.
  18725. * @param name Define the name of the uniform as defined in the shader
  18726. * @param value Define the value to give to the uniform
  18727. * @return the material itself allowing "fluent" like uniform updates
  18728. */
  18729. setFloats(name: string, value: number[]): ShaderMaterial;
  18730. /**
  18731. * Set a vec3 in the shader from a Color3.
  18732. * @param name Define the name of the uniform as defined in the shader
  18733. * @param value Define the value to give to the uniform
  18734. * @return the material itself allowing "fluent" like uniform updates
  18735. */
  18736. setColor3(name: string, value: Color3): ShaderMaterial;
  18737. /**
  18738. * Set a vec3 array in the shader from a Color3 array.
  18739. * @param name Define the name of the uniform as defined in the shader
  18740. * @param value Define the value to give to the uniform
  18741. * @return the material itself allowing "fluent" like uniform updates
  18742. */
  18743. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18744. /**
  18745. * Set a vec4 in the shader from a Color4.
  18746. * @param name Define the name of the uniform as defined in the shader
  18747. * @param value Define the value to give to the uniform
  18748. * @return the material itself allowing "fluent" like uniform updates
  18749. */
  18750. setColor4(name: string, value: Color4): ShaderMaterial;
  18751. /**
  18752. * Set a vec4 array in the shader from a Color4 array.
  18753. * @param name Define the name of the uniform as defined in the shader
  18754. * @param value Define the value to give to the uniform
  18755. * @return the material itself allowing "fluent" like uniform updates
  18756. */
  18757. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18758. /**
  18759. * Set a vec2 in the shader from a Vector2.
  18760. * @param name Define the name of the uniform as defined in the shader
  18761. * @param value Define the value to give to the uniform
  18762. * @return the material itself allowing "fluent" like uniform updates
  18763. */
  18764. setVector2(name: string, value: Vector2): ShaderMaterial;
  18765. /**
  18766. * Set a vec3 in the shader from a Vector3.
  18767. * @param name Define the name of the uniform as defined in the shader
  18768. * @param value Define the value to give to the uniform
  18769. * @return the material itself allowing "fluent" like uniform updates
  18770. */
  18771. setVector3(name: string, value: Vector3): ShaderMaterial;
  18772. /**
  18773. * Set a vec4 in the shader from a Vector4.
  18774. * @param name Define the name of the uniform as defined in the shader
  18775. * @param value Define the value to give to the uniform
  18776. * @return the material itself allowing "fluent" like uniform updates
  18777. */
  18778. setVector4(name: string, value: Vector4): ShaderMaterial;
  18779. /**
  18780. * Set a mat4 in the shader from a Matrix.
  18781. * @param name Define the name of the uniform as defined in the shader
  18782. * @param value Define the value to give to the uniform
  18783. * @return the material itself allowing "fluent" like uniform updates
  18784. */
  18785. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18786. /**
  18787. * Set a mat3 in the shader from a Float32Array.
  18788. * @param name Define the name of the uniform as defined in the shader
  18789. * @param value Define the value to give to the uniform
  18790. * @return the material itself allowing "fluent" like uniform updates
  18791. */
  18792. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18793. /**
  18794. * Set a mat2 in the shader from a Float32Array.
  18795. * @param name Define the name of the uniform as defined in the shader
  18796. * @param value Define the value to give to the uniform
  18797. * @return the material itself allowing "fluent" like uniform updates
  18798. */
  18799. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18800. /**
  18801. * Set a vec2 array in the shader from a number array.
  18802. * @param name Define the name of the uniform as defined in the shader
  18803. * @param value Define the value to give to the uniform
  18804. * @return the material itself allowing "fluent" like uniform updates
  18805. */
  18806. setArray2(name: string, value: number[]): ShaderMaterial;
  18807. /**
  18808. * Set a vec3 array in the shader from a number array.
  18809. * @param name Define the name of the uniform as defined in the shader
  18810. * @param value Define the value to give to the uniform
  18811. * @return the material itself allowing "fluent" like uniform updates
  18812. */
  18813. setArray3(name: string, value: number[]): ShaderMaterial;
  18814. /**
  18815. * Set a vec4 array in the shader from a number array.
  18816. * @param name Define the name of the uniform as defined in the shader
  18817. * @param value Define the value to give to the uniform
  18818. * @return the material itself allowing "fluent" like uniform updates
  18819. */
  18820. setArray4(name: string, value: number[]): ShaderMaterial;
  18821. private _checkCache;
  18822. /**
  18823. * Specifies that the submesh is ready to be used
  18824. * @param mesh defines the mesh to check
  18825. * @param subMesh defines which submesh to check
  18826. * @param useInstances specifies that instances should be used
  18827. * @returns a boolean indicating that the submesh is ready or not
  18828. */
  18829. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18830. /**
  18831. * Checks if the material is ready to render the requested mesh
  18832. * @param mesh Define the mesh to render
  18833. * @param useInstances Define whether or not the material is used with instances
  18834. * @returns true if ready, otherwise false
  18835. */
  18836. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18837. /**
  18838. * Binds the world matrix to the material
  18839. * @param world defines the world transformation matrix
  18840. */
  18841. bindOnlyWorldMatrix(world: Matrix): void;
  18842. /**
  18843. * Binds the material to the mesh
  18844. * @param world defines the world transformation matrix
  18845. * @param mesh defines the mesh to bind the material to
  18846. */
  18847. bind(world: Matrix, mesh?: Mesh): void;
  18848. /**
  18849. * Gets the active textures from the material
  18850. * @returns an array of textures
  18851. */
  18852. getActiveTextures(): BaseTexture[];
  18853. /**
  18854. * Specifies if the material uses a texture
  18855. * @param texture defines the texture to check against the material
  18856. * @returns a boolean specifying if the material uses the texture
  18857. */
  18858. hasTexture(texture: BaseTexture): boolean;
  18859. /**
  18860. * Makes a duplicate of the material, and gives it a new name
  18861. * @param name defines the new name for the duplicated material
  18862. * @returns the cloned material
  18863. */
  18864. clone(name: string): ShaderMaterial;
  18865. /**
  18866. * Disposes the material
  18867. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18868. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18869. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18870. */
  18871. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18872. /**
  18873. * Serializes this material in a JSON representation
  18874. * @returns the serialized material object
  18875. */
  18876. serialize(): any;
  18877. /**
  18878. * Creates a shader material from parsed shader material data
  18879. * @param source defines the JSON represnetation of the material
  18880. * @param scene defines the hosting scene
  18881. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18882. * @returns a new material
  18883. */
  18884. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18885. }
  18886. }
  18887. declare module BABYLON {
  18888. /** @hidden */
  18889. export var colorPixelShader: {
  18890. name: string;
  18891. shader: string;
  18892. };
  18893. }
  18894. declare module BABYLON {
  18895. /** @hidden */
  18896. export var colorVertexShader: {
  18897. name: string;
  18898. shader: string;
  18899. };
  18900. }
  18901. declare module BABYLON {
  18902. /**
  18903. * Line mesh
  18904. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18905. */
  18906. export class LinesMesh extends Mesh {
  18907. /**
  18908. * If vertex color should be applied to the mesh
  18909. */
  18910. readonly useVertexColor?: boolean | undefined;
  18911. /**
  18912. * If vertex alpha should be applied to the mesh
  18913. */
  18914. readonly useVertexAlpha?: boolean | undefined;
  18915. /**
  18916. * Color of the line (Default: White)
  18917. */
  18918. color: Color3;
  18919. /**
  18920. * Alpha of the line (Default: 1)
  18921. */
  18922. alpha: number;
  18923. /**
  18924. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18925. * This margin is expressed in world space coordinates, so its value may vary.
  18926. * Default value is 0.1
  18927. */
  18928. intersectionThreshold: number;
  18929. private _colorShader;
  18930. private color4;
  18931. /**
  18932. * Creates a new LinesMesh
  18933. * @param name defines the name
  18934. * @param scene defines the hosting scene
  18935. * @param parent defines the parent mesh if any
  18936. * @param source defines the optional source LinesMesh used to clone data from
  18937. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18938. * When false, achieved by calling a clone(), also passing False.
  18939. * This will make creation of children, recursive.
  18940. * @param useVertexColor defines if this LinesMesh supports vertex color
  18941. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18942. */
  18943. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  18944. /**
  18945. * If vertex color should be applied to the mesh
  18946. */
  18947. useVertexColor?: boolean | undefined,
  18948. /**
  18949. * If vertex alpha should be applied to the mesh
  18950. */
  18951. useVertexAlpha?: boolean | undefined);
  18952. private _addClipPlaneDefine;
  18953. private _removeClipPlaneDefine;
  18954. isReady(): boolean;
  18955. /**
  18956. * Returns the string "LineMesh"
  18957. */
  18958. getClassName(): string;
  18959. /**
  18960. * @hidden
  18961. */
  18962. /**
  18963. * @hidden
  18964. */
  18965. material: Material;
  18966. /**
  18967. * @hidden
  18968. */
  18969. readonly checkCollisions: boolean;
  18970. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  18971. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  18972. /**
  18973. * Disposes of the line mesh
  18974. * @param doNotRecurse If children should be disposed
  18975. */
  18976. dispose(doNotRecurse?: boolean): void;
  18977. /**
  18978. * Returns a new LineMesh object cloned from the current one.
  18979. */
  18980. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18981. /**
  18982. * Creates a new InstancedLinesMesh object from the mesh model.
  18983. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18984. * @param name defines the name of the new instance
  18985. * @returns a new InstancedLinesMesh
  18986. */
  18987. createInstance(name: string): InstancedLinesMesh;
  18988. }
  18989. /**
  18990. * Creates an instance based on a source LinesMesh
  18991. */
  18992. export class InstancedLinesMesh extends InstancedMesh {
  18993. /**
  18994. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18995. * This margin is expressed in world space coordinates, so its value may vary.
  18996. * Initilized with the intersectionThreshold value of the source LinesMesh
  18997. */
  18998. intersectionThreshold: number;
  18999. constructor(name: string, source: LinesMesh);
  19000. /**
  19001. * Returns the string "InstancedLinesMesh".
  19002. */
  19003. getClassName(): string;
  19004. }
  19005. }
  19006. declare module BABYLON {
  19007. /** @hidden */
  19008. export var linePixelShader: {
  19009. name: string;
  19010. shader: string;
  19011. };
  19012. }
  19013. declare module BABYLON {
  19014. /** @hidden */
  19015. export var lineVertexShader: {
  19016. name: string;
  19017. shader: string;
  19018. };
  19019. }
  19020. declare module BABYLON {
  19021. interface AbstractMesh {
  19022. /**
  19023. * Gets the edgesRenderer associated with the mesh
  19024. */
  19025. edgesRenderer: Nullable<EdgesRenderer>;
  19026. }
  19027. interface LinesMesh {
  19028. /**
  19029. * Enables the edge rendering mode on the mesh.
  19030. * This mode makes the mesh edges visible
  19031. * @param epsilon defines the maximal distance between two angles to detect a face
  19032. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19033. * @returns the currentAbstractMesh
  19034. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19035. */
  19036. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19037. }
  19038. interface InstancedLinesMesh {
  19039. /**
  19040. * Enables the edge rendering mode on the mesh.
  19041. * This mode makes the mesh edges visible
  19042. * @param epsilon defines the maximal distance between two angles to detect a face
  19043. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19044. * @returns the current InstancedLinesMesh
  19045. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19046. */
  19047. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19048. }
  19049. /**
  19050. * Defines the minimum contract an Edges renderer should follow.
  19051. */
  19052. export interface IEdgesRenderer extends IDisposable {
  19053. /**
  19054. * Gets or sets a boolean indicating if the edgesRenderer is active
  19055. */
  19056. isEnabled: boolean;
  19057. /**
  19058. * Renders the edges of the attached mesh,
  19059. */
  19060. render(): void;
  19061. /**
  19062. * Checks wether or not the edges renderer is ready to render.
  19063. * @return true if ready, otherwise false.
  19064. */
  19065. isReady(): boolean;
  19066. }
  19067. /**
  19068. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19069. */
  19070. export class EdgesRenderer implements IEdgesRenderer {
  19071. /**
  19072. * Define the size of the edges with an orthographic camera
  19073. */
  19074. edgesWidthScalerForOrthographic: number;
  19075. /**
  19076. * Define the size of the edges with a perspective camera
  19077. */
  19078. edgesWidthScalerForPerspective: number;
  19079. protected _source: AbstractMesh;
  19080. protected _linesPositions: number[];
  19081. protected _linesNormals: number[];
  19082. protected _linesIndices: number[];
  19083. protected _epsilon: number;
  19084. protected _indicesCount: number;
  19085. protected _lineShader: ShaderMaterial;
  19086. protected _ib: DataBuffer;
  19087. protected _buffers: {
  19088. [key: string]: Nullable<VertexBuffer>;
  19089. };
  19090. protected _checkVerticesInsteadOfIndices: boolean;
  19091. private _meshRebuildObserver;
  19092. private _meshDisposeObserver;
  19093. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19094. isEnabled: boolean;
  19095. /**
  19096. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19097. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19098. * @param source Mesh used to create edges
  19099. * @param epsilon sum of angles in adjacency to check for edge
  19100. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19101. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19102. */
  19103. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19104. protected _prepareRessources(): void;
  19105. /** @hidden */ private _rebuild(): void;
  19106. /**
  19107. * Releases the required resources for the edges renderer
  19108. */
  19109. dispose(): void;
  19110. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19111. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19112. /**
  19113. * Checks if the pair of p0 and p1 is en edge
  19114. * @param faceIndex
  19115. * @param edge
  19116. * @param faceNormals
  19117. * @param p0
  19118. * @param p1
  19119. * @private
  19120. */
  19121. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19122. /**
  19123. * push line into the position, normal and index buffer
  19124. * @protected
  19125. */
  19126. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19127. /**
  19128. * Generates lines edges from adjacencjes
  19129. * @private
  19130. */ private _generateEdgesLines(): void;
  19131. /**
  19132. * Checks wether or not the edges renderer is ready to render.
  19133. * @return true if ready, otherwise false.
  19134. */
  19135. isReady(): boolean;
  19136. /**
  19137. * Renders the edges of the attached mesh,
  19138. */
  19139. render(): void;
  19140. }
  19141. /**
  19142. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19143. */
  19144. export class LineEdgesRenderer extends EdgesRenderer {
  19145. /**
  19146. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19147. * @param source LineMesh used to generate edges
  19148. * @param epsilon not important (specified angle for edge detection)
  19149. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19150. */
  19151. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19152. /**
  19153. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19154. */ private _generateEdgesLines(): void;
  19155. }
  19156. }
  19157. declare module BABYLON {
  19158. /**
  19159. * This represents the object necessary to create a rendering group.
  19160. * This is exclusively used and created by the rendering manager.
  19161. * To modify the behavior, you use the available helpers in your scene or meshes.
  19162. * @hidden
  19163. */
  19164. export class RenderingGroup {
  19165. index: number;
  19166. private static _zeroVector;
  19167. private _scene;
  19168. private _opaqueSubMeshes;
  19169. private _transparentSubMeshes;
  19170. private _alphaTestSubMeshes;
  19171. private _depthOnlySubMeshes;
  19172. private _particleSystems;
  19173. private _spriteManagers;
  19174. private _opaqueSortCompareFn;
  19175. private _alphaTestSortCompareFn;
  19176. private _transparentSortCompareFn;
  19177. private _renderOpaque;
  19178. private _renderAlphaTest;
  19179. private _renderTransparent;
  19180. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19181. onBeforeTransparentRendering: () => void;
  19182. /**
  19183. * Set the opaque sort comparison function.
  19184. * If null the sub meshes will be render in the order they were created
  19185. */
  19186. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19187. /**
  19188. * Set the alpha test sort comparison function.
  19189. * If null the sub meshes will be render in the order they were created
  19190. */
  19191. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19192. /**
  19193. * Set the transparent sort comparison function.
  19194. * If null the sub meshes will be render in the order they were created
  19195. */
  19196. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19197. /**
  19198. * Creates a new rendering group.
  19199. * @param index The rendering group index
  19200. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19201. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19202. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19203. */
  19204. 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>);
  19205. /**
  19206. * Render all the sub meshes contained in the group.
  19207. * @param customRenderFunction Used to override the default render behaviour of the group.
  19208. * @returns true if rendered some submeshes.
  19209. */
  19210. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19211. /**
  19212. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19213. * @param subMeshes The submeshes to render
  19214. */
  19215. private renderOpaqueSorted;
  19216. /**
  19217. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19218. * @param subMeshes The submeshes to render
  19219. */
  19220. private renderAlphaTestSorted;
  19221. /**
  19222. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19223. * @param subMeshes The submeshes to render
  19224. */
  19225. private renderTransparentSorted;
  19226. /**
  19227. * Renders the submeshes in a specified order.
  19228. * @param subMeshes The submeshes to sort before render
  19229. * @param sortCompareFn The comparison function use to sort
  19230. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19231. * @param transparent Specifies to activate blending if true
  19232. */
  19233. private static renderSorted;
  19234. /**
  19235. * Renders the submeshes in the order they were dispatched (no sort applied).
  19236. * @param subMeshes The submeshes to render
  19237. */
  19238. private static renderUnsorted;
  19239. /**
  19240. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19241. * are rendered back to front if in the same alpha index.
  19242. *
  19243. * @param a The first submesh
  19244. * @param b The second submesh
  19245. * @returns The result of the comparison
  19246. */
  19247. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19248. /**
  19249. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19250. * are rendered back to front.
  19251. *
  19252. * @param a The first submesh
  19253. * @param b The second submesh
  19254. * @returns The result of the comparison
  19255. */
  19256. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19257. /**
  19258. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19259. * are rendered front to back (prevent overdraw).
  19260. *
  19261. * @param a The first submesh
  19262. * @param b The second submesh
  19263. * @returns The result of the comparison
  19264. */
  19265. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19266. /**
  19267. * Resets the different lists of submeshes to prepare a new frame.
  19268. */
  19269. prepare(): void;
  19270. dispose(): void;
  19271. /**
  19272. * Inserts the submesh in its correct queue depending on its material.
  19273. * @param subMesh The submesh to dispatch
  19274. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19275. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19276. */
  19277. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19278. dispatchSprites(spriteManager: ISpriteManager): void;
  19279. dispatchParticles(particleSystem: IParticleSystem): void;
  19280. private _renderParticles;
  19281. private _renderSprites;
  19282. }
  19283. }
  19284. declare module BABYLON {
  19285. /**
  19286. * Interface describing the different options available in the rendering manager
  19287. * regarding Auto Clear between groups.
  19288. */
  19289. export interface IRenderingManagerAutoClearSetup {
  19290. /**
  19291. * Defines whether or not autoclear is enable.
  19292. */
  19293. autoClear: boolean;
  19294. /**
  19295. * Defines whether or not to autoclear the depth buffer.
  19296. */
  19297. depth: boolean;
  19298. /**
  19299. * Defines whether or not to autoclear the stencil buffer.
  19300. */
  19301. stencil: boolean;
  19302. }
  19303. /**
  19304. * This class is used by the onRenderingGroupObservable
  19305. */
  19306. export class RenderingGroupInfo {
  19307. /**
  19308. * The Scene that being rendered
  19309. */
  19310. scene: Scene;
  19311. /**
  19312. * The camera currently used for the rendering pass
  19313. */
  19314. camera: Nullable<Camera>;
  19315. /**
  19316. * The ID of the renderingGroup being processed
  19317. */
  19318. renderingGroupId: number;
  19319. }
  19320. /**
  19321. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19322. * It is enable to manage the different groups as well as the different necessary sort functions.
  19323. * This should not be used directly aside of the few static configurations
  19324. */
  19325. export class RenderingManager {
  19326. /**
  19327. * The max id used for rendering groups (not included)
  19328. */
  19329. static MAX_RENDERINGGROUPS: number;
  19330. /**
  19331. * The min id used for rendering groups (included)
  19332. */
  19333. static MIN_RENDERINGGROUPS: number;
  19334. /**
  19335. * Used to globally prevent autoclearing scenes.
  19336. */
  19337. static AUTOCLEAR: boolean;
  19338. /**
  19339. * @hidden
  19340. */ private _useSceneAutoClearSetup: boolean;
  19341. private _scene;
  19342. private _renderingGroups;
  19343. private _depthStencilBufferAlreadyCleaned;
  19344. private _autoClearDepthStencil;
  19345. private _customOpaqueSortCompareFn;
  19346. private _customAlphaTestSortCompareFn;
  19347. private _customTransparentSortCompareFn;
  19348. private _renderingGroupInfo;
  19349. /**
  19350. * Instantiates a new rendering group for a particular scene
  19351. * @param scene Defines the scene the groups belongs to
  19352. */
  19353. constructor(scene: Scene);
  19354. private _clearDepthStencilBuffer;
  19355. /**
  19356. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19357. * @hidden
  19358. */
  19359. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19360. /**
  19361. * Resets the different information of the group to prepare a new frame
  19362. * @hidden
  19363. */
  19364. reset(): void;
  19365. /**
  19366. * Dispose and release the group and its associated resources.
  19367. * @hidden
  19368. */
  19369. dispose(): void;
  19370. /**
  19371. * Clear the info related to rendering groups preventing retention points during dispose.
  19372. */
  19373. freeRenderingGroups(): void;
  19374. private _prepareRenderingGroup;
  19375. /**
  19376. * Add a sprite manager to the rendering manager in order to render it this frame.
  19377. * @param spriteManager Define the sprite manager to render
  19378. */
  19379. dispatchSprites(spriteManager: ISpriteManager): void;
  19380. /**
  19381. * Add a particle system to the rendering manager in order to render it this frame.
  19382. * @param particleSystem Define the particle system to render
  19383. */
  19384. dispatchParticles(particleSystem: IParticleSystem): void;
  19385. /**
  19386. * Add a submesh to the manager in order to render it this frame
  19387. * @param subMesh The submesh to dispatch
  19388. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19389. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19390. */
  19391. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19392. /**
  19393. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19394. * This allowed control for front to back rendering or reversly depending of the special needs.
  19395. *
  19396. * @param renderingGroupId The rendering group id corresponding to its index
  19397. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19398. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19399. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19400. */
  19401. 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;
  19402. /**
  19403. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19404. *
  19405. * @param renderingGroupId The rendering group id corresponding to its index
  19406. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19407. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19408. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19409. */
  19410. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19411. /**
  19412. * Gets the current auto clear configuration for one rendering group of the rendering
  19413. * manager.
  19414. * @param index the rendering group index to get the information for
  19415. * @returns The auto clear setup for the requested rendering group
  19416. */
  19417. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19418. }
  19419. }
  19420. declare module BABYLON {
  19421. /**
  19422. * This Helps creating a texture that will be created from a camera in your scene.
  19423. * It is basically a dynamic texture that could be used to create special effects for instance.
  19424. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19425. */
  19426. export class RenderTargetTexture extends Texture {
  19427. isCube: boolean;
  19428. /**
  19429. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19430. */
  19431. static readonly REFRESHRATE_RENDER_ONCE: number;
  19432. /**
  19433. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19434. */
  19435. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19436. /**
  19437. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19438. * the central point of your effect and can save a lot of performances.
  19439. */
  19440. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19441. /**
  19442. * Use this predicate to dynamically define the list of mesh you want to render.
  19443. * If set, the renderList property will be overwritten.
  19444. */
  19445. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19446. private _renderList;
  19447. /**
  19448. * Use this list to define the list of mesh you want to render.
  19449. */
  19450. renderList: Nullable<Array<AbstractMesh>>;
  19451. private _hookArray;
  19452. /**
  19453. * Define if particles should be rendered in your texture.
  19454. */
  19455. renderParticles: boolean;
  19456. /**
  19457. * Define if sprites should be rendered in your texture.
  19458. */
  19459. renderSprites: boolean;
  19460. /**
  19461. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19462. */
  19463. coordinatesMode: number;
  19464. /**
  19465. * Define the camera used to render the texture.
  19466. */
  19467. activeCamera: Nullable<Camera>;
  19468. /**
  19469. * Override the render function of the texture with your own one.
  19470. */
  19471. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19472. /**
  19473. * Define if camera post processes should be use while rendering the texture.
  19474. */
  19475. useCameraPostProcesses: boolean;
  19476. /**
  19477. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19478. */
  19479. ignoreCameraViewport: boolean;
  19480. private _postProcessManager;
  19481. private _postProcesses;
  19482. private _resizeObserver;
  19483. /**
  19484. * An event triggered when the texture is unbind.
  19485. */
  19486. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19487. /**
  19488. * An event triggered when the texture is unbind.
  19489. */
  19490. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19491. private _onAfterUnbindObserver;
  19492. /**
  19493. * Set a after unbind callback in the texture.
  19494. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19495. */
  19496. onAfterUnbind: () => void;
  19497. /**
  19498. * An event triggered before rendering the texture
  19499. */
  19500. onBeforeRenderObservable: Observable<number>;
  19501. private _onBeforeRenderObserver;
  19502. /**
  19503. * Set a before render callback in the texture.
  19504. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19505. */
  19506. onBeforeRender: (faceIndex: number) => void;
  19507. /**
  19508. * An event triggered after rendering the texture
  19509. */
  19510. onAfterRenderObservable: Observable<number>;
  19511. private _onAfterRenderObserver;
  19512. /**
  19513. * Set a after render callback in the texture.
  19514. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19515. */
  19516. onAfterRender: (faceIndex: number) => void;
  19517. /**
  19518. * An event triggered after the texture clear
  19519. */
  19520. onClearObservable: Observable<Engine>;
  19521. private _onClearObserver;
  19522. /**
  19523. * Set a clear callback in the texture.
  19524. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19525. */
  19526. onClear: (Engine: Engine) => void;
  19527. /**
  19528. * An event triggered when the texture is resized.
  19529. */
  19530. onResizeObservable: Observable<RenderTargetTexture>;
  19531. /**
  19532. * Define the clear color of the Render Target if it should be different from the scene.
  19533. */
  19534. clearColor: Color4;
  19535. protected _size: number | {
  19536. width: number;
  19537. height: number;
  19538. };
  19539. protected _initialSizeParameter: number | {
  19540. width: number;
  19541. height: number;
  19542. } | {
  19543. ratio: number;
  19544. };
  19545. protected _sizeRatio: Nullable<number>;
  19546. /** @hidden */ private _generateMipMaps: boolean;
  19547. protected _renderingManager: RenderingManager;
  19548. /** @hidden */ private _waitingRenderList: string[];
  19549. protected _doNotChangeAspectRatio: boolean;
  19550. protected _currentRefreshId: number;
  19551. protected _refreshRate: number;
  19552. protected _textureMatrix: Matrix;
  19553. protected _samples: number;
  19554. protected _renderTargetOptions: RenderTargetCreationOptions;
  19555. /**
  19556. * Gets render target creation options that were used.
  19557. */
  19558. readonly renderTargetOptions: RenderTargetCreationOptions;
  19559. protected _engine: Engine;
  19560. protected _onRatioRescale(): void;
  19561. /**
  19562. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19563. * It must define where the camera used to render the texture is set
  19564. */
  19565. boundingBoxPosition: Vector3;
  19566. private _boundingBoxSize;
  19567. /**
  19568. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19569. * When defined, the cubemap will switch to local mode
  19570. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19571. * @example https://www.babylonjs-playground.com/#RNASML
  19572. */
  19573. boundingBoxSize: Vector3;
  19574. /**
  19575. * In case the RTT has been created with a depth texture, get the associated
  19576. * depth texture.
  19577. * Otherwise, return null.
  19578. */
  19579. depthStencilTexture: Nullable<InternalTexture>;
  19580. /**
  19581. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19582. * or used a shadow, depth texture...
  19583. * @param name The friendly name of the texture
  19584. * @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)
  19585. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19586. * @param generateMipMaps True if mip maps need to be generated after render.
  19587. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19588. * @param type The type of the buffer in the RTT (int, half float, float...)
  19589. * @param isCube True if a cube texture needs to be created
  19590. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19591. * @param generateDepthBuffer True to generate a depth buffer
  19592. * @param generateStencilBuffer True to generate a stencil buffer
  19593. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19594. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19595. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19596. */
  19597. constructor(name: string, size: number | {
  19598. width: number;
  19599. height: number;
  19600. } | {
  19601. ratio: number;
  19602. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19603. /**
  19604. * Creates a depth stencil texture.
  19605. * This is only available in WebGL 2 or with the depth texture extension available.
  19606. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19607. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19608. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19609. */
  19610. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19611. private _processSizeParameter;
  19612. /**
  19613. * Define the number of samples to use in case of MSAA.
  19614. * It defaults to one meaning no MSAA has been enabled.
  19615. */
  19616. samples: number;
  19617. /**
  19618. * Resets the refresh counter of the texture and start bak from scratch.
  19619. * Could be useful to regenerate the texture if it is setup to render only once.
  19620. */
  19621. resetRefreshCounter(): void;
  19622. /**
  19623. * Define the refresh rate of the texture or the rendering frequency.
  19624. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19625. */
  19626. refreshRate: number;
  19627. /**
  19628. * Adds a post process to the render target rendering passes.
  19629. * @param postProcess define the post process to add
  19630. */
  19631. addPostProcess(postProcess: PostProcess): void;
  19632. /**
  19633. * Clear all the post processes attached to the render target
  19634. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19635. */
  19636. clearPostProcesses(dispose?: boolean): void;
  19637. /**
  19638. * Remove one of the post process from the list of attached post processes to the texture
  19639. * @param postProcess define the post process to remove from the list
  19640. */
  19641. removePostProcess(postProcess: PostProcess): void;
  19642. /** @hidden */ private _shouldRender(): boolean;
  19643. /**
  19644. * Gets the actual render size of the texture.
  19645. * @returns the width of the render size
  19646. */
  19647. getRenderSize(): number;
  19648. /**
  19649. * Gets the actual render width of the texture.
  19650. * @returns the width of the render size
  19651. */
  19652. getRenderWidth(): number;
  19653. /**
  19654. * Gets the actual render height of the texture.
  19655. * @returns the height of the render size
  19656. */
  19657. getRenderHeight(): number;
  19658. /**
  19659. * Get if the texture can be rescaled or not.
  19660. */
  19661. readonly canRescale: boolean;
  19662. /**
  19663. * Resize the texture using a ratio.
  19664. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19665. */
  19666. scale(ratio: number): void;
  19667. /**
  19668. * Get the texture reflection matrix used to rotate/transform the reflection.
  19669. * @returns the reflection matrix
  19670. */
  19671. getReflectionTextureMatrix(): Matrix;
  19672. /**
  19673. * Resize the texture to a new desired size.
  19674. * Be carrefull as it will recreate all the data in the new texture.
  19675. * @param size Define the new size. It can be:
  19676. * - a number for squared texture,
  19677. * - an object containing { width: number, height: number }
  19678. * - or an object containing a ratio { ratio: number }
  19679. */
  19680. resize(size: number | {
  19681. width: number;
  19682. height: number;
  19683. } | {
  19684. ratio: number;
  19685. }): void;
  19686. /**
  19687. * Renders all the objects from the render list into the texture.
  19688. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19689. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19690. */
  19691. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19692. private _bestReflectionRenderTargetDimension;
  19693. /**
  19694. * @hidden
  19695. * @param faceIndex face index to bind to if this is a cubetexture
  19696. */ private _bindFrameBuffer(faceIndex?: number): void;
  19697. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19698. private renderToTarget;
  19699. /**
  19700. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19701. * This allowed control for front to back rendering or reversly depending of the special needs.
  19702. *
  19703. * @param renderingGroupId The rendering group id corresponding to its index
  19704. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19705. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19706. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19707. */
  19708. 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;
  19709. /**
  19710. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19711. *
  19712. * @param renderingGroupId The rendering group id corresponding to its index
  19713. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19714. */
  19715. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19716. /**
  19717. * Clones the texture.
  19718. * @returns the cloned texture
  19719. */
  19720. clone(): RenderTargetTexture;
  19721. /**
  19722. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19723. * @returns The JSON representation of the texture
  19724. */
  19725. serialize(): any;
  19726. /**
  19727. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19728. */
  19729. disposeFramebufferObjects(): void;
  19730. /**
  19731. * Dispose the texture and release its associated resources.
  19732. */
  19733. dispose(): void;
  19734. /** @hidden */ private _rebuild(): void;
  19735. /**
  19736. * Clear the info related to rendering groups preventing retention point in material dispose.
  19737. */
  19738. freeRenderingGroups(): void;
  19739. /**
  19740. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19741. * @returns the view count
  19742. */
  19743. getViewCount(): number;
  19744. }
  19745. }
  19746. declare module BABYLON {
  19747. /**
  19748. * Base class for the main features of a material in Babylon.js
  19749. */
  19750. export class Material implements IAnimatable {
  19751. /**
  19752. * Returns the triangle fill mode
  19753. */
  19754. static readonly TriangleFillMode: number;
  19755. /**
  19756. * Returns the wireframe mode
  19757. */
  19758. static readonly WireFrameFillMode: number;
  19759. /**
  19760. * Returns the point fill mode
  19761. */
  19762. static readonly PointFillMode: number;
  19763. /**
  19764. * Returns the point list draw mode
  19765. */
  19766. static readonly PointListDrawMode: number;
  19767. /**
  19768. * Returns the line list draw mode
  19769. */
  19770. static readonly LineListDrawMode: number;
  19771. /**
  19772. * Returns the line loop draw mode
  19773. */
  19774. static readonly LineLoopDrawMode: number;
  19775. /**
  19776. * Returns the line strip draw mode
  19777. */
  19778. static readonly LineStripDrawMode: number;
  19779. /**
  19780. * Returns the triangle strip draw mode
  19781. */
  19782. static readonly TriangleStripDrawMode: number;
  19783. /**
  19784. * Returns the triangle fan draw mode
  19785. */
  19786. static readonly TriangleFanDrawMode: number;
  19787. /**
  19788. * Stores the clock-wise side orientation
  19789. */
  19790. static readonly ClockWiseSideOrientation: number;
  19791. /**
  19792. * Stores the counter clock-wise side orientation
  19793. */
  19794. static readonly CounterClockWiseSideOrientation: number;
  19795. /**
  19796. * The dirty texture flag value
  19797. */
  19798. static readonly TextureDirtyFlag: number;
  19799. /**
  19800. * The dirty light flag value
  19801. */
  19802. static readonly LightDirtyFlag: number;
  19803. /**
  19804. * The dirty fresnel flag value
  19805. */
  19806. static readonly FresnelDirtyFlag: number;
  19807. /**
  19808. * The dirty attribute flag value
  19809. */
  19810. static readonly AttributesDirtyFlag: number;
  19811. /**
  19812. * The dirty misc flag value
  19813. */
  19814. static readonly MiscDirtyFlag: number;
  19815. /**
  19816. * The all dirty flag value
  19817. */
  19818. static readonly AllDirtyFlag: number;
  19819. /**
  19820. * The ID of the material
  19821. */
  19822. id: string;
  19823. /**
  19824. * Gets or sets the unique id of the material
  19825. */
  19826. uniqueId: number;
  19827. /**
  19828. * The name of the material
  19829. */
  19830. name: string;
  19831. /**
  19832. * Gets or sets user defined metadata
  19833. */
  19834. metadata: any;
  19835. /**
  19836. * For internal use only. Please do not use.
  19837. */
  19838. reservedDataStore: any;
  19839. /**
  19840. * Specifies if the ready state should be checked on each call
  19841. */
  19842. checkReadyOnEveryCall: boolean;
  19843. /**
  19844. * Specifies if the ready state should be checked once
  19845. */
  19846. checkReadyOnlyOnce: boolean;
  19847. /**
  19848. * The state of the material
  19849. */
  19850. state: string;
  19851. /**
  19852. * The alpha value of the material
  19853. */
  19854. protected _alpha: number;
  19855. /**
  19856. * List of inspectable custom properties (used by the Inspector)
  19857. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19858. */
  19859. inspectableCustomProperties: IInspectable[];
  19860. /**
  19861. * Sets the alpha value of the material
  19862. */
  19863. /**
  19864. * Gets the alpha value of the material
  19865. */
  19866. alpha: number;
  19867. /**
  19868. * Specifies if back face culling is enabled
  19869. */
  19870. protected _backFaceCulling: boolean;
  19871. /**
  19872. * Sets the back-face culling state
  19873. */
  19874. /**
  19875. * Gets the back-face culling state
  19876. */
  19877. backFaceCulling: boolean;
  19878. /**
  19879. * Stores the value for side orientation
  19880. */
  19881. sideOrientation: number;
  19882. /**
  19883. * Callback triggered when the material is compiled
  19884. */
  19885. onCompiled: Nullable<(effect: Effect) => void>;
  19886. /**
  19887. * Callback triggered when an error occurs
  19888. */
  19889. onError: Nullable<(effect: Effect, errors: string) => void>;
  19890. /**
  19891. * Callback triggered to get the render target textures
  19892. */
  19893. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19894. /**
  19895. * Gets a boolean indicating that current material needs to register RTT
  19896. */
  19897. readonly hasRenderTargetTextures: boolean;
  19898. /**
  19899. * Specifies if the material should be serialized
  19900. */
  19901. doNotSerialize: boolean;
  19902. /**
  19903. * @hidden
  19904. */ private _storeEffectOnSubMeshes: boolean;
  19905. /**
  19906. * Stores the animations for the material
  19907. */
  19908. animations: Nullable<Array<Animation>>;
  19909. /**
  19910. * An event triggered when the material is disposed
  19911. */
  19912. onDisposeObservable: Observable<Material>;
  19913. /**
  19914. * An observer which watches for dispose events
  19915. */
  19916. private _onDisposeObserver;
  19917. private _onUnBindObservable;
  19918. /**
  19919. * Called during a dispose event
  19920. */
  19921. onDispose: () => void;
  19922. private _onBindObservable;
  19923. /**
  19924. * An event triggered when the material is bound
  19925. */
  19926. readonly onBindObservable: Observable<AbstractMesh>;
  19927. /**
  19928. * An observer which watches for bind events
  19929. */
  19930. private _onBindObserver;
  19931. /**
  19932. * Called during a bind event
  19933. */
  19934. onBind: (Mesh: AbstractMesh) => void;
  19935. /**
  19936. * An event triggered when the material is unbound
  19937. */
  19938. readonly onUnBindObservable: Observable<Material>;
  19939. /**
  19940. * Stores the value of the alpha mode
  19941. */
  19942. private _alphaMode;
  19943. /**
  19944. * Sets the value of the alpha mode.
  19945. *
  19946. * | Value | Type | Description |
  19947. * | --- | --- | --- |
  19948. * | 0 | ALPHA_DISABLE | |
  19949. * | 1 | ALPHA_ADD | |
  19950. * | 2 | ALPHA_COMBINE | |
  19951. * | 3 | ALPHA_SUBTRACT | |
  19952. * | 4 | ALPHA_MULTIPLY | |
  19953. * | 5 | ALPHA_MAXIMIZED | |
  19954. * | 6 | ALPHA_ONEONE | |
  19955. * | 7 | ALPHA_PREMULTIPLIED | |
  19956. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  19957. * | 9 | ALPHA_INTERPOLATE | |
  19958. * | 10 | ALPHA_SCREENMODE | |
  19959. *
  19960. */
  19961. /**
  19962. * Gets the value of the alpha mode
  19963. */
  19964. alphaMode: number;
  19965. /**
  19966. * Stores the state of the need depth pre-pass value
  19967. */
  19968. private _needDepthPrePass;
  19969. /**
  19970. * Sets the need depth pre-pass value
  19971. */
  19972. /**
  19973. * Gets the depth pre-pass value
  19974. */
  19975. needDepthPrePass: boolean;
  19976. /**
  19977. * Specifies if depth writing should be disabled
  19978. */
  19979. disableDepthWrite: boolean;
  19980. /**
  19981. * Specifies if depth writing should be forced
  19982. */
  19983. forceDepthWrite: boolean;
  19984. /**
  19985. * Specifies if there should be a separate pass for culling
  19986. */
  19987. separateCullingPass: boolean;
  19988. /**
  19989. * Stores the state specifing if fog should be enabled
  19990. */
  19991. private _fogEnabled;
  19992. /**
  19993. * Sets the state for enabling fog
  19994. */
  19995. /**
  19996. * Gets the value of the fog enabled state
  19997. */
  19998. fogEnabled: boolean;
  19999. /**
  20000. * Stores the size of points
  20001. */
  20002. pointSize: number;
  20003. /**
  20004. * Stores the z offset value
  20005. */
  20006. zOffset: number;
  20007. /**
  20008. * Gets a value specifying if wireframe mode is enabled
  20009. */
  20010. /**
  20011. * Sets the state of wireframe mode
  20012. */
  20013. wireframe: boolean;
  20014. /**
  20015. * Gets the value specifying if point clouds are enabled
  20016. */
  20017. /**
  20018. * Sets the state of point cloud mode
  20019. */
  20020. pointsCloud: boolean;
  20021. /**
  20022. * Gets the material fill mode
  20023. */
  20024. /**
  20025. * Sets the material fill mode
  20026. */
  20027. fillMode: number;
  20028. /**
  20029. * @hidden
  20030. * Stores the effects for the material
  20031. */ private _effect: Nullable<Effect>;
  20032. /**
  20033. * @hidden
  20034. * Specifies if the material was previously ready
  20035. */ private _wasPreviouslyReady: boolean;
  20036. /**
  20037. * Specifies if uniform buffers should be used
  20038. */
  20039. private _useUBO;
  20040. /**
  20041. * Stores a reference to the scene
  20042. */
  20043. private _scene;
  20044. /**
  20045. * Stores the fill mode state
  20046. */
  20047. private _fillMode;
  20048. /**
  20049. * Specifies if the depth write state should be cached
  20050. */
  20051. private _cachedDepthWriteState;
  20052. /**
  20053. * Stores the uniform buffer
  20054. */
  20055. protected _uniformBuffer: UniformBuffer;
  20056. /** @hidden */ private _indexInSceneMaterialArray: number;
  20057. /** @hidden */
  20058. meshMap: Nullable<{
  20059. [id: string]: AbstractMesh | undefined;
  20060. }>;
  20061. /**
  20062. * Creates a material instance
  20063. * @param name defines the name of the material
  20064. * @param scene defines the scene to reference
  20065. * @param doNotAdd specifies if the material should be added to the scene
  20066. */
  20067. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20068. /**
  20069. * Returns a string representation of the current material
  20070. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20071. * @returns a string with material information
  20072. */
  20073. toString(fullDetails?: boolean): string;
  20074. /**
  20075. * Gets the class name of the material
  20076. * @returns a string with the class name of the material
  20077. */
  20078. getClassName(): string;
  20079. /**
  20080. * Specifies if updates for the material been locked
  20081. */
  20082. readonly isFrozen: boolean;
  20083. /**
  20084. * Locks updates for the material
  20085. */
  20086. freeze(): void;
  20087. /**
  20088. * Unlocks updates for the material
  20089. */
  20090. unfreeze(): void;
  20091. /**
  20092. * Specifies if the material is ready to be used
  20093. * @param mesh defines the mesh to check
  20094. * @param useInstances specifies if instances should be used
  20095. * @returns a boolean indicating if the material is ready to be used
  20096. */
  20097. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20098. /**
  20099. * Specifies that the submesh is ready to be used
  20100. * @param mesh defines the mesh to check
  20101. * @param subMesh defines which submesh to check
  20102. * @param useInstances specifies that instances should be used
  20103. * @returns a boolean indicating that the submesh is ready or not
  20104. */
  20105. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20106. /**
  20107. * Returns the material effect
  20108. * @returns the effect associated with the material
  20109. */
  20110. getEffect(): Nullable<Effect>;
  20111. /**
  20112. * Returns the current scene
  20113. * @returns a Scene
  20114. */
  20115. getScene(): Scene;
  20116. /**
  20117. * Specifies if the material will require alpha blending
  20118. * @returns a boolean specifying if alpha blending is needed
  20119. */
  20120. needAlphaBlending(): boolean;
  20121. /**
  20122. * Specifies if the mesh will require alpha blending
  20123. * @param mesh defines the mesh to check
  20124. * @returns a boolean specifying if alpha blending is needed for the mesh
  20125. */
  20126. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20127. /**
  20128. * Specifies if this material should be rendered in alpha test mode
  20129. * @returns a boolean specifying if an alpha test is needed.
  20130. */
  20131. needAlphaTesting(): boolean;
  20132. /**
  20133. * Gets the texture used for the alpha test
  20134. * @returns the texture to use for alpha testing
  20135. */
  20136. getAlphaTestTexture(): Nullable<BaseTexture>;
  20137. /**
  20138. * Marks the material to indicate that it needs to be re-calculated
  20139. */
  20140. markDirty(): void;
  20141. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20142. /**
  20143. * Binds the material to the mesh
  20144. * @param world defines the world transformation matrix
  20145. * @param mesh defines the mesh to bind the material to
  20146. */
  20147. bind(world: Matrix, mesh?: Mesh): void;
  20148. /**
  20149. * Binds the submesh to the material
  20150. * @param world defines the world transformation matrix
  20151. * @param mesh defines the mesh containing the submesh
  20152. * @param subMesh defines the submesh to bind the material to
  20153. */
  20154. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20155. /**
  20156. * Binds the world matrix to the material
  20157. * @param world defines the world transformation matrix
  20158. */
  20159. bindOnlyWorldMatrix(world: Matrix): void;
  20160. /**
  20161. * Binds the scene's uniform buffer to the effect.
  20162. * @param effect defines the effect to bind to the scene uniform buffer
  20163. * @param sceneUbo defines the uniform buffer storing scene data
  20164. */
  20165. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20166. /**
  20167. * Binds the view matrix to the effect
  20168. * @param effect defines the effect to bind the view matrix to
  20169. */
  20170. bindView(effect: Effect): void;
  20171. /**
  20172. * Binds the view projection matrix to the effect
  20173. * @param effect defines the effect to bind the view projection matrix to
  20174. */
  20175. bindViewProjection(effect: Effect): void;
  20176. /**
  20177. * Specifies if material alpha testing should be turned on for the mesh
  20178. * @param mesh defines the mesh to check
  20179. */
  20180. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20181. /**
  20182. * Processes to execute after binding the material to a mesh
  20183. * @param mesh defines the rendered mesh
  20184. */
  20185. protected _afterBind(mesh?: Mesh): void;
  20186. /**
  20187. * Unbinds the material from the mesh
  20188. */
  20189. unbind(): void;
  20190. /**
  20191. * Gets the active textures from the material
  20192. * @returns an array of textures
  20193. */
  20194. getActiveTextures(): BaseTexture[];
  20195. /**
  20196. * Specifies if the material uses a texture
  20197. * @param texture defines the texture to check against the material
  20198. * @returns a boolean specifying if the material uses the texture
  20199. */
  20200. hasTexture(texture: BaseTexture): boolean;
  20201. /**
  20202. * Makes a duplicate of the material, and gives it a new name
  20203. * @param name defines the new name for the duplicated material
  20204. * @returns the cloned material
  20205. */
  20206. clone(name: string): Nullable<Material>;
  20207. /**
  20208. * Gets the meshes bound to the material
  20209. * @returns an array of meshes bound to the material
  20210. */
  20211. getBindedMeshes(): AbstractMesh[];
  20212. /**
  20213. * Force shader compilation
  20214. * @param mesh defines the mesh associated with this material
  20215. * @param onCompiled defines a function to execute once the material is compiled
  20216. * @param options defines the options to configure the compilation
  20217. */
  20218. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20219. clipPlane: boolean;
  20220. }>): void;
  20221. /**
  20222. * Force shader compilation
  20223. * @param mesh defines the mesh that will use this material
  20224. * @param options defines additional options for compiling the shaders
  20225. * @returns a promise that resolves when the compilation completes
  20226. */
  20227. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20228. clipPlane: boolean;
  20229. }>): Promise<void>;
  20230. private static readonly _AllDirtyCallBack;
  20231. private static readonly _ImageProcessingDirtyCallBack;
  20232. private static readonly _TextureDirtyCallBack;
  20233. private static readonly _FresnelDirtyCallBack;
  20234. private static readonly _MiscDirtyCallBack;
  20235. private static readonly _LightsDirtyCallBack;
  20236. private static readonly _AttributeDirtyCallBack;
  20237. private static _FresnelAndMiscDirtyCallBack;
  20238. private static _TextureAndMiscDirtyCallBack;
  20239. private static readonly _DirtyCallbackArray;
  20240. private static readonly _RunDirtyCallBacks;
  20241. /**
  20242. * Marks a define in the material to indicate that it needs to be re-computed
  20243. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20244. */
  20245. markAsDirty(flag: number): void;
  20246. /**
  20247. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20248. * @param func defines a function which checks material defines against the submeshes
  20249. */
  20250. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20251. /**
  20252. * Indicates that we need to re-calculated for all submeshes
  20253. */
  20254. protected _markAllSubMeshesAsAllDirty(): void;
  20255. /**
  20256. * Indicates that image processing needs to be re-calculated for all submeshes
  20257. */
  20258. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20259. /**
  20260. * Indicates that textures need to be re-calculated for all submeshes
  20261. */
  20262. protected _markAllSubMeshesAsTexturesDirty(): void;
  20263. /**
  20264. * Indicates that fresnel needs to be re-calculated for all submeshes
  20265. */
  20266. protected _markAllSubMeshesAsFresnelDirty(): void;
  20267. /**
  20268. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20269. */
  20270. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20271. /**
  20272. * Indicates that lights need to be re-calculated for all submeshes
  20273. */
  20274. protected _markAllSubMeshesAsLightsDirty(): void;
  20275. /**
  20276. * Indicates that attributes need to be re-calculated for all submeshes
  20277. */
  20278. protected _markAllSubMeshesAsAttributesDirty(): void;
  20279. /**
  20280. * Indicates that misc needs to be re-calculated for all submeshes
  20281. */
  20282. protected _markAllSubMeshesAsMiscDirty(): void;
  20283. /**
  20284. * Indicates that textures and misc need to be re-calculated for all submeshes
  20285. */
  20286. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20287. /**
  20288. * Disposes the material
  20289. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20290. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20291. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20292. */
  20293. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20294. /** @hidden */
  20295. private releaseVertexArrayObject;
  20296. /**
  20297. * Serializes this material
  20298. * @returns the serialized material object
  20299. */
  20300. serialize(): any;
  20301. /**
  20302. * Creates a material from parsed material data
  20303. * @param parsedMaterial defines parsed material data
  20304. * @param scene defines the hosting scene
  20305. * @param rootUrl defines the root URL to use to load textures
  20306. * @returns a new material
  20307. */
  20308. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20309. }
  20310. }
  20311. declare module BABYLON {
  20312. /**
  20313. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20314. * separate meshes. This can be use to improve performances.
  20315. * @see http://doc.babylonjs.com/how_to/multi_materials
  20316. */
  20317. export class MultiMaterial extends Material {
  20318. private _subMaterials;
  20319. /**
  20320. * Gets or Sets the list of Materials used within the multi material.
  20321. * They need to be ordered according to the submeshes order in the associated mesh
  20322. */
  20323. subMaterials: Nullable<Material>[];
  20324. /**
  20325. * Function used to align with Node.getChildren()
  20326. * @returns the list of Materials used within the multi material
  20327. */
  20328. getChildren(): Nullable<Material>[];
  20329. /**
  20330. * Instantiates a new Multi Material
  20331. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20332. * separate meshes. This can be use to improve performances.
  20333. * @see http://doc.babylonjs.com/how_to/multi_materials
  20334. * @param name Define the name in the scene
  20335. * @param scene Define the scene the material belongs to
  20336. */
  20337. constructor(name: string, scene: Scene);
  20338. private _hookArray;
  20339. /**
  20340. * Get one of the submaterial by its index in the submaterials array
  20341. * @param index The index to look the sub material at
  20342. * @returns The Material if the index has been defined
  20343. */
  20344. getSubMaterial(index: number): Nullable<Material>;
  20345. /**
  20346. * Get the list of active textures for the whole sub materials list.
  20347. * @returns All the textures that will be used during the rendering
  20348. */
  20349. getActiveTextures(): BaseTexture[];
  20350. /**
  20351. * Gets the current class name of the material e.g. "MultiMaterial"
  20352. * Mainly use in serialization.
  20353. * @returns the class name
  20354. */
  20355. getClassName(): string;
  20356. /**
  20357. * Checks if the material is ready to render the requested sub mesh
  20358. * @param mesh Define the mesh the submesh belongs to
  20359. * @param subMesh Define the sub mesh to look readyness for
  20360. * @param useInstances Define whether or not the material is used with instances
  20361. * @returns true if ready, otherwise false
  20362. */
  20363. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20364. /**
  20365. * Clones the current material and its related sub materials
  20366. * @param name Define the name of the newly cloned material
  20367. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20368. * @returns the cloned material
  20369. */
  20370. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20371. /**
  20372. * Serializes the materials into a JSON representation.
  20373. * @returns the JSON representation
  20374. */
  20375. serialize(): any;
  20376. /**
  20377. * Dispose the material and release its associated resources
  20378. * @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)
  20379. * @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)
  20380. * @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)
  20381. */
  20382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20383. /**
  20384. * Creates a MultiMaterial from parsed MultiMaterial data.
  20385. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20386. * @param scene defines the hosting scene
  20387. * @returns a new MultiMaterial
  20388. */
  20389. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20390. }
  20391. }
  20392. declare module BABYLON {
  20393. /**
  20394. * Base class for submeshes
  20395. */
  20396. export class BaseSubMesh {
  20397. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20398. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20399. /**
  20400. * Gets associated effect
  20401. */
  20402. readonly effect: Nullable<Effect>;
  20403. /**
  20404. * Sets associated effect (effect used to render this submesh)
  20405. * @param effect defines the effect to associate with
  20406. * @param defines defines the set of defines used to compile this effect
  20407. */
  20408. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20409. }
  20410. /**
  20411. * Defines a subdivision inside a mesh
  20412. */
  20413. export class SubMesh extends BaseSubMesh implements ICullable {
  20414. /** the material index to use */
  20415. materialIndex: number;
  20416. /** vertex index start */
  20417. verticesStart: number;
  20418. /** vertices count */
  20419. verticesCount: number;
  20420. /** index start */
  20421. indexStart: number;
  20422. /** indices count */
  20423. indexCount: number;
  20424. /** @hidden */ private _linesIndexCount: number;
  20425. private _mesh;
  20426. private _renderingMesh;
  20427. private _boundingInfo;
  20428. private _linesIndexBuffer;
  20429. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20430. /** @hidden */ private _trianglePlanes: Plane[];
  20431. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20432. /** @hidden */ private _renderId: number;
  20433. /** @hidden */ private _alphaIndex: number;
  20434. /** @hidden */ private _distanceToCamera: number;
  20435. /** @hidden */ private _id: number;
  20436. private _currentMaterial;
  20437. /**
  20438. * Add a new submesh to a mesh
  20439. * @param materialIndex defines the material index to use
  20440. * @param verticesStart defines vertex index start
  20441. * @param verticesCount defines vertices count
  20442. * @param indexStart defines index start
  20443. * @param indexCount defines indices count
  20444. * @param mesh defines the parent mesh
  20445. * @param renderingMesh defines an optional rendering mesh
  20446. * @param createBoundingBox defines if bounding box should be created for this submesh
  20447. * @returns the new submesh
  20448. */
  20449. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20450. /**
  20451. * Creates a new submesh
  20452. * @param materialIndex defines the material index to use
  20453. * @param verticesStart defines vertex index start
  20454. * @param verticesCount defines vertices count
  20455. * @param indexStart defines index start
  20456. * @param indexCount defines indices count
  20457. * @param mesh defines the parent mesh
  20458. * @param renderingMesh defines an optional rendering mesh
  20459. * @param createBoundingBox defines if bounding box should be created for this submesh
  20460. */
  20461. constructor(
  20462. /** the material index to use */
  20463. materialIndex: number,
  20464. /** vertex index start */
  20465. verticesStart: number,
  20466. /** vertices count */
  20467. verticesCount: number,
  20468. /** index start */
  20469. indexStart: number,
  20470. /** indices count */
  20471. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20472. /**
  20473. * Returns true if this submesh covers the entire parent mesh
  20474. * @ignorenaming
  20475. */
  20476. readonly IsGlobal: boolean;
  20477. /**
  20478. * Returns the submesh BoudingInfo object
  20479. * @returns current bounding info (or mesh's one if the submesh is global)
  20480. */
  20481. getBoundingInfo(): BoundingInfo;
  20482. /**
  20483. * Sets the submesh BoundingInfo
  20484. * @param boundingInfo defines the new bounding info to use
  20485. * @returns the SubMesh
  20486. */
  20487. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20488. /**
  20489. * Returns the mesh of the current submesh
  20490. * @return the parent mesh
  20491. */
  20492. getMesh(): AbstractMesh;
  20493. /**
  20494. * Returns the rendering mesh of the submesh
  20495. * @returns the rendering mesh (could be different from parent mesh)
  20496. */
  20497. getRenderingMesh(): Mesh;
  20498. /**
  20499. * Returns the submesh material
  20500. * @returns null or the current material
  20501. */
  20502. getMaterial(): Nullable<Material>;
  20503. /**
  20504. * Sets a new updated BoundingInfo object to the submesh
  20505. * @param data defines an optional position array to use to determine the bounding info
  20506. * @returns the SubMesh
  20507. */
  20508. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20509. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20510. /**
  20511. * Updates the submesh BoundingInfo
  20512. * @param world defines the world matrix to use to update the bounding info
  20513. * @returns the submesh
  20514. */
  20515. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20516. /**
  20517. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20518. * @param frustumPlanes defines the frustum planes
  20519. * @returns true if the submesh is intersecting with the frustum
  20520. */
  20521. isInFrustum(frustumPlanes: Plane[]): boolean;
  20522. /**
  20523. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20524. * @param frustumPlanes defines the frustum planes
  20525. * @returns true if the submesh is inside the frustum
  20526. */
  20527. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20528. /**
  20529. * Renders the submesh
  20530. * @param enableAlphaMode defines if alpha needs to be used
  20531. * @returns the submesh
  20532. */
  20533. render(enableAlphaMode: boolean): SubMesh;
  20534. /**
  20535. * @hidden
  20536. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20537. /**
  20538. * Checks if the submesh intersects with a ray
  20539. * @param ray defines the ray to test
  20540. * @returns true is the passed ray intersects the submesh bounding box
  20541. */
  20542. canIntersects(ray: Ray): boolean;
  20543. /**
  20544. * Intersects current submesh with a ray
  20545. * @param ray defines the ray to test
  20546. * @param positions defines mesh's positions array
  20547. * @param indices defines mesh's indices array
  20548. * @param fastCheck defines if only bounding info should be used
  20549. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20550. * @returns intersection info or null if no intersection
  20551. */
  20552. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20553. /** @hidden */
  20554. private _intersectLines;
  20555. /** @hidden */
  20556. private _intersectUnIndexedLines;
  20557. /** @hidden */
  20558. private _intersectTriangles;
  20559. /** @hidden */
  20560. private _intersectUnIndexedTriangles;
  20561. /** @hidden */ private _rebuild(): void;
  20562. /**
  20563. * Creates a new submesh from the passed mesh
  20564. * @param newMesh defines the new hosting mesh
  20565. * @param newRenderingMesh defines an optional rendering mesh
  20566. * @returns the new submesh
  20567. */
  20568. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20569. /**
  20570. * Release associated resources
  20571. */
  20572. dispose(): void;
  20573. /**
  20574. * Gets the class name
  20575. * @returns the string "SubMesh".
  20576. */
  20577. getClassName(): string;
  20578. /**
  20579. * Creates a new submesh from indices data
  20580. * @param materialIndex the index of the main mesh material
  20581. * @param startIndex the index where to start the copy in the mesh indices array
  20582. * @param indexCount the number of indices to copy then from the startIndex
  20583. * @param mesh the main mesh to create the submesh from
  20584. * @param renderingMesh the optional rendering mesh
  20585. * @returns a new submesh
  20586. */
  20587. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20588. }
  20589. }
  20590. declare module BABYLON {
  20591. /**
  20592. * Class used to represent data loading progression
  20593. */
  20594. export class SceneLoaderFlags {
  20595. private static _ForceFullSceneLoadingForIncremental;
  20596. private static _ShowLoadingScreen;
  20597. private static _CleanBoneMatrixWeights;
  20598. private static _loggingLevel;
  20599. /**
  20600. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20601. */
  20602. static ForceFullSceneLoadingForIncremental: boolean;
  20603. /**
  20604. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20605. */
  20606. static ShowLoadingScreen: boolean;
  20607. /**
  20608. * Defines the current logging level (while loading the scene)
  20609. * @ignorenaming
  20610. */
  20611. static loggingLevel: number;
  20612. /**
  20613. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20614. */
  20615. static CleanBoneMatrixWeights: boolean;
  20616. }
  20617. }
  20618. declare module BABYLON {
  20619. /**
  20620. * Class used to store geometry data (vertex buffers + index buffer)
  20621. */
  20622. export class Geometry implements IGetSetVerticesData {
  20623. /**
  20624. * Gets or sets the ID of the geometry
  20625. */
  20626. id: string;
  20627. /**
  20628. * Gets or sets the unique ID of the geometry
  20629. */
  20630. uniqueId: number;
  20631. /**
  20632. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20633. */
  20634. delayLoadState: number;
  20635. /**
  20636. * Gets the file containing the data to load when running in delay load state
  20637. */
  20638. delayLoadingFile: Nullable<string>;
  20639. /**
  20640. * Callback called when the geometry is updated
  20641. */
  20642. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20643. private _scene;
  20644. private _engine;
  20645. private _meshes;
  20646. private _totalVertices;
  20647. /** @hidden */ private _indices: IndicesArray;
  20648. /** @hidden */ private _vertexBuffers: {
  20649. [key: string]: VertexBuffer;
  20650. };
  20651. private _isDisposed;
  20652. private _extend;
  20653. private _boundingBias;
  20654. /** @hidden */ private _delayInfo: Array<string>;
  20655. private _indexBuffer;
  20656. private _indexBufferIsUpdatable;
  20657. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20658. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20659. /** @hidden */ private _softwareSkinningFrameId: number;
  20660. private _vertexArrayObjects;
  20661. private _updatable;
  20662. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20663. /**
  20664. * 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
  20665. */
  20666. /**
  20667. * 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
  20668. */
  20669. boundingBias: Vector2;
  20670. /**
  20671. * Static function used to attach a new empty geometry to a mesh
  20672. * @param mesh defines the mesh to attach the geometry to
  20673. * @returns the new Geometry
  20674. */
  20675. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20676. /**
  20677. * Creates a new geometry
  20678. * @param id defines the unique ID
  20679. * @param scene defines the hosting scene
  20680. * @param vertexData defines the VertexData used to get geometry data
  20681. * @param updatable defines if geometry must be updatable (false by default)
  20682. * @param mesh defines the mesh that will be associated with the geometry
  20683. */
  20684. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20685. /**
  20686. * Gets the current extend of the geometry
  20687. */
  20688. readonly extend: {
  20689. minimum: Vector3;
  20690. maximum: Vector3;
  20691. };
  20692. /**
  20693. * Gets the hosting scene
  20694. * @returns the hosting Scene
  20695. */
  20696. getScene(): Scene;
  20697. /**
  20698. * Gets the hosting engine
  20699. * @returns the hosting Engine
  20700. */
  20701. getEngine(): Engine;
  20702. /**
  20703. * Defines if the geometry is ready to use
  20704. * @returns true if the geometry is ready to be used
  20705. */
  20706. isReady(): boolean;
  20707. /**
  20708. * Gets a value indicating that the geometry should not be serialized
  20709. */
  20710. readonly doNotSerialize: boolean;
  20711. /** @hidden */ private _rebuild(): void;
  20712. /**
  20713. * Affects all geometry data in one call
  20714. * @param vertexData defines the geometry data
  20715. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20716. */
  20717. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20718. /**
  20719. * Set specific vertex data
  20720. * @param kind defines the data kind (Position, normal, etc...)
  20721. * @param data defines the vertex data to use
  20722. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20723. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20724. */
  20725. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20726. /**
  20727. * Removes a specific vertex data
  20728. * @param kind defines the data kind (Position, normal, etc...)
  20729. */
  20730. removeVerticesData(kind: string): void;
  20731. /**
  20732. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20733. * @param buffer defines the vertex buffer to use
  20734. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20735. */
  20736. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20737. /**
  20738. * Update a specific vertex buffer
  20739. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20740. * It will do nothing if the buffer is not updatable
  20741. * @param kind defines the data kind (Position, normal, etc...)
  20742. * @param data defines the data to use
  20743. * @param offset defines the offset in the target buffer where to store the data
  20744. * @param useBytes set to true if the offset is in bytes
  20745. */
  20746. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20747. /**
  20748. * Update a specific vertex buffer
  20749. * This function will create a new buffer if the current one is not updatable
  20750. * @param kind defines the data kind (Position, normal, etc...)
  20751. * @param data defines the data to use
  20752. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20753. */
  20754. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20755. private _updateBoundingInfo;
  20756. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20757. /**
  20758. * Gets total number of vertices
  20759. * @returns the total number of vertices
  20760. */
  20761. getTotalVertices(): number;
  20762. /**
  20763. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20764. * @param kind defines the data kind (Position, normal, etc...)
  20765. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20766. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20767. * @returns a float array containing vertex data
  20768. */
  20769. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20770. /**
  20771. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20772. * @param kind defines the data kind (Position, normal, etc...)
  20773. * @returns true if the vertex buffer with the specified kind is updatable
  20774. */
  20775. isVertexBufferUpdatable(kind: string): boolean;
  20776. /**
  20777. * Gets a specific vertex buffer
  20778. * @param kind defines the data kind (Position, normal, etc...)
  20779. * @returns a VertexBuffer
  20780. */
  20781. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20782. /**
  20783. * Returns all vertex buffers
  20784. * @return an object holding all vertex buffers indexed by kind
  20785. */
  20786. getVertexBuffers(): Nullable<{
  20787. [key: string]: VertexBuffer;
  20788. }>;
  20789. /**
  20790. * Gets a boolean indicating if specific vertex buffer is present
  20791. * @param kind defines the data kind (Position, normal, etc...)
  20792. * @returns true if data is present
  20793. */
  20794. isVerticesDataPresent(kind: string): boolean;
  20795. /**
  20796. * Gets a list of all attached data kinds (Position, normal, etc...)
  20797. * @returns a list of string containing all kinds
  20798. */
  20799. getVerticesDataKinds(): string[];
  20800. /**
  20801. * Update index buffer
  20802. * @param indices defines the indices to store in the index buffer
  20803. * @param offset defines the offset in the target buffer where to store the data
  20804. * @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)
  20805. */
  20806. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20807. /**
  20808. * Creates a new index buffer
  20809. * @param indices defines the indices to store in the index buffer
  20810. * @param totalVertices defines the total number of vertices (could be null)
  20811. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20812. */
  20813. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20814. /**
  20815. * Return the total number of indices
  20816. * @returns the total number of indices
  20817. */
  20818. getTotalIndices(): number;
  20819. /**
  20820. * Gets the index buffer array
  20821. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20822. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20823. * @returns the index buffer array
  20824. */
  20825. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20826. /**
  20827. * Gets the index buffer
  20828. * @return the index buffer
  20829. */
  20830. getIndexBuffer(): Nullable<DataBuffer>;
  20831. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20832. /**
  20833. * Release the associated resources for a specific mesh
  20834. * @param mesh defines the source mesh
  20835. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20836. */
  20837. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20838. /**
  20839. * Apply current geometry to a given mesh
  20840. * @param mesh defines the mesh to apply geometry to
  20841. */
  20842. applyToMesh(mesh: Mesh): void;
  20843. private _updateExtend;
  20844. private _applyToMesh;
  20845. private notifyUpdate;
  20846. /**
  20847. * Load the geometry if it was flagged as delay loaded
  20848. * @param scene defines the hosting scene
  20849. * @param onLoaded defines a callback called when the geometry is loaded
  20850. */
  20851. load(scene: Scene, onLoaded?: () => void): void;
  20852. private _queueLoad;
  20853. /**
  20854. * Invert the geometry to move from a right handed system to a left handed one.
  20855. */
  20856. toLeftHanded(): void;
  20857. /** @hidden */ private _resetPointsArrayCache(): void;
  20858. /** @hidden */ private _generatePointsArray(): boolean;
  20859. /**
  20860. * Gets a value indicating if the geometry is disposed
  20861. * @returns true if the geometry was disposed
  20862. */
  20863. isDisposed(): boolean;
  20864. private _disposeVertexArrayObjects;
  20865. /**
  20866. * Free all associated resources
  20867. */
  20868. dispose(): void;
  20869. /**
  20870. * Clone the current geometry into a new geometry
  20871. * @param id defines the unique ID of the new geometry
  20872. * @returns a new geometry object
  20873. */
  20874. copy(id: string): Geometry;
  20875. /**
  20876. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20877. * @return a JSON representation of the current geometry data (without the vertices data)
  20878. */
  20879. serialize(): any;
  20880. private toNumberArray;
  20881. /**
  20882. * Serialize all vertices data into a JSON oject
  20883. * @returns a JSON representation of the current geometry data
  20884. */
  20885. serializeVerticeData(): any;
  20886. /**
  20887. * Extracts a clone of a mesh geometry
  20888. * @param mesh defines the source mesh
  20889. * @param id defines the unique ID of the new geometry object
  20890. * @returns the new geometry object
  20891. */
  20892. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20893. /**
  20894. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20895. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20896. * Be aware Math.random() could cause collisions, but:
  20897. * "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"
  20898. * @returns a string containing a new GUID
  20899. */
  20900. static RandomId(): string;
  20901. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20902. private static _CleanMatricesWeights;
  20903. /**
  20904. * Create a new geometry from persisted data (Using .babylon file format)
  20905. * @param parsedVertexData defines the persisted data
  20906. * @param scene defines the hosting scene
  20907. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20908. * @returns the new geometry object
  20909. */
  20910. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20911. }
  20912. }
  20913. declare module BABYLON {
  20914. /**
  20915. * Define an interface for all classes that will get and set the data on vertices
  20916. */
  20917. export interface IGetSetVerticesData {
  20918. /**
  20919. * Gets a boolean indicating if specific vertex data is present
  20920. * @param kind defines the vertex data kind to use
  20921. * @returns true is data kind is present
  20922. */
  20923. isVerticesDataPresent(kind: string): boolean;
  20924. /**
  20925. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20926. * @param kind defines the data kind (Position, normal, etc...)
  20927. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20928. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20929. * @returns a float array containing vertex data
  20930. */
  20931. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20932. /**
  20933. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20934. * @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.
  20935. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20936. * @returns the indices array or an empty array if the mesh has no geometry
  20937. */
  20938. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20939. /**
  20940. * Set specific vertex data
  20941. * @param kind defines the data kind (Position, normal, etc...)
  20942. * @param data defines the vertex data to use
  20943. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20944. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20945. */
  20946. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20947. /**
  20948. * Update a specific associated vertex buffer
  20949. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20950. * - VertexBuffer.PositionKind
  20951. * - VertexBuffer.UVKind
  20952. * - VertexBuffer.UV2Kind
  20953. * - VertexBuffer.UV3Kind
  20954. * - VertexBuffer.UV4Kind
  20955. * - VertexBuffer.UV5Kind
  20956. * - VertexBuffer.UV6Kind
  20957. * - VertexBuffer.ColorKind
  20958. * - VertexBuffer.MatricesIndicesKind
  20959. * - VertexBuffer.MatricesIndicesExtraKind
  20960. * - VertexBuffer.MatricesWeightsKind
  20961. * - VertexBuffer.MatricesWeightsExtraKind
  20962. * @param data defines the data source
  20963. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20964. * @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)
  20965. */
  20966. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20967. /**
  20968. * Creates a new index buffer
  20969. * @param indices defines the indices to store in the index buffer
  20970. * @param totalVertices defines the total number of vertices (could be null)
  20971. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20972. */
  20973. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  20974. }
  20975. /**
  20976. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  20977. */
  20978. export class VertexData {
  20979. /**
  20980. * Mesh side orientation : usually the external or front surface
  20981. */
  20982. static readonly FRONTSIDE: number;
  20983. /**
  20984. * Mesh side orientation : usually the internal or back surface
  20985. */
  20986. static readonly BACKSIDE: number;
  20987. /**
  20988. * Mesh side orientation : both internal and external or front and back surfaces
  20989. */
  20990. static readonly DOUBLESIDE: number;
  20991. /**
  20992. * Mesh side orientation : by default, `FRONTSIDE`
  20993. */
  20994. static readonly DEFAULTSIDE: number;
  20995. /**
  20996. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  20997. */
  20998. positions: Nullable<FloatArray>;
  20999. /**
  21000. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21001. */
  21002. normals: Nullable<FloatArray>;
  21003. /**
  21004. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21005. */
  21006. tangents: Nullable<FloatArray>;
  21007. /**
  21008. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21009. */
  21010. uvs: Nullable<FloatArray>;
  21011. /**
  21012. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21013. */
  21014. uvs2: Nullable<FloatArray>;
  21015. /**
  21016. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21017. */
  21018. uvs3: Nullable<FloatArray>;
  21019. /**
  21020. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21021. */
  21022. uvs4: Nullable<FloatArray>;
  21023. /**
  21024. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21025. */
  21026. uvs5: Nullable<FloatArray>;
  21027. /**
  21028. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21029. */
  21030. uvs6: Nullable<FloatArray>;
  21031. /**
  21032. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21033. */
  21034. colors: Nullable<FloatArray>;
  21035. /**
  21036. * 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).
  21037. */
  21038. matricesIndices: Nullable<FloatArray>;
  21039. /**
  21040. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21041. */
  21042. matricesWeights: Nullable<FloatArray>;
  21043. /**
  21044. * An array extending the number of possible indices
  21045. */
  21046. matricesIndicesExtra: Nullable<FloatArray>;
  21047. /**
  21048. * An array extending the number of possible weights when the number of indices is extended
  21049. */
  21050. matricesWeightsExtra: Nullable<FloatArray>;
  21051. /**
  21052. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21053. */
  21054. indices: Nullable<IndicesArray>;
  21055. /**
  21056. * Uses the passed data array to set the set the values for the specified kind of data
  21057. * @param data a linear array of floating numbers
  21058. * @param kind the type of data that is being set, eg positions, colors etc
  21059. */
  21060. set(data: FloatArray, kind: string): void;
  21061. /**
  21062. * Associates the vertexData to the passed Mesh.
  21063. * Sets it as updatable or not (default `false`)
  21064. * @param mesh the mesh the vertexData is applied to
  21065. * @param updatable when used and having the value true allows new data to update the vertexData
  21066. * @returns the VertexData
  21067. */
  21068. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21069. /**
  21070. * Associates the vertexData to the passed Geometry.
  21071. * Sets it as updatable or not (default `false`)
  21072. * @param geometry the geometry the vertexData is applied to
  21073. * @param updatable when used and having the value true allows new data to update the vertexData
  21074. * @returns VertexData
  21075. */
  21076. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21077. /**
  21078. * Updates the associated mesh
  21079. * @param mesh the mesh to be updated
  21080. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21081. * @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
  21082. * @returns VertexData
  21083. */
  21084. updateMesh(mesh: Mesh): VertexData;
  21085. /**
  21086. * Updates the associated geometry
  21087. * @param geometry the geometry to be updated
  21088. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21089. * @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
  21090. * @returns VertexData.
  21091. */
  21092. updateGeometry(geometry: Geometry): VertexData;
  21093. private _applyTo;
  21094. private _update;
  21095. /**
  21096. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21097. * @param matrix the transforming matrix
  21098. * @returns the VertexData
  21099. */
  21100. transform(matrix: Matrix): VertexData;
  21101. /**
  21102. * Merges the passed VertexData into the current one
  21103. * @param other the VertexData to be merged into the current one
  21104. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21105. * @returns the modified VertexData
  21106. */
  21107. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21108. private _mergeElement;
  21109. private _validate;
  21110. /**
  21111. * Serializes the VertexData
  21112. * @returns a serialized object
  21113. */
  21114. serialize(): any;
  21115. /**
  21116. * Extracts the vertexData from a mesh
  21117. * @param mesh the mesh from which to extract the VertexData
  21118. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21119. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21120. * @returns the object VertexData associated to the passed mesh
  21121. */
  21122. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21123. /**
  21124. * Extracts the vertexData from the geometry
  21125. * @param geometry the geometry from which to extract the VertexData
  21126. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21127. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21128. * @returns the object VertexData associated to the passed mesh
  21129. */
  21130. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21131. private static _ExtractFrom;
  21132. /**
  21133. * Creates the VertexData for a Ribbon
  21134. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21135. * * pathArray array of paths, each of which an array of successive Vector3
  21136. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21137. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21138. * * 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
  21139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21140. * * 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)
  21141. * * 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)
  21142. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21143. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21144. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21145. * @returns the VertexData of the ribbon
  21146. */
  21147. static CreateRibbon(options: {
  21148. pathArray: Vector3[][];
  21149. closeArray?: boolean;
  21150. closePath?: boolean;
  21151. offset?: number;
  21152. sideOrientation?: number;
  21153. frontUVs?: Vector4;
  21154. backUVs?: Vector4;
  21155. invertUV?: boolean;
  21156. uvs?: Vector2[];
  21157. colors?: Color4[];
  21158. }): VertexData;
  21159. /**
  21160. * Creates the VertexData for a box
  21161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21162. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21163. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21164. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21165. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21166. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21167. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21169. * * 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)
  21170. * * 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)
  21171. * @returns the VertexData of the box
  21172. */
  21173. static CreateBox(options: {
  21174. size?: number;
  21175. width?: number;
  21176. height?: number;
  21177. depth?: number;
  21178. faceUV?: Vector4[];
  21179. faceColors?: Color4[];
  21180. sideOrientation?: number;
  21181. frontUVs?: Vector4;
  21182. backUVs?: Vector4;
  21183. }): VertexData;
  21184. /**
  21185. * Creates the VertexData for a tiled box
  21186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21187. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21188. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21189. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21191. * @returns the VertexData of the box
  21192. */
  21193. static CreateTiledBox(options: {
  21194. pattern?: number;
  21195. width?: number;
  21196. height?: number;
  21197. depth?: number;
  21198. tileSize?: number;
  21199. tileWidth?: number;
  21200. tileHeight?: number;
  21201. alignHorizontal?: number;
  21202. alignVertical?: number;
  21203. faceUV?: Vector4[];
  21204. faceColors?: Color4[];
  21205. sideOrientation?: number;
  21206. }): VertexData;
  21207. /**
  21208. * Creates the VertexData for a tiled plane
  21209. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21210. * * pattern a limited pattern arrangement depending on the number
  21211. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21212. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21213. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21215. * * 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)
  21216. * * 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)
  21217. * @returns the VertexData of the tiled plane
  21218. */
  21219. static CreateTiledPlane(options: {
  21220. pattern?: number;
  21221. tileSize?: number;
  21222. tileWidth?: number;
  21223. tileHeight?: number;
  21224. size?: number;
  21225. width?: number;
  21226. height?: number;
  21227. alignHorizontal?: number;
  21228. alignVertical?: number;
  21229. sideOrientation?: number;
  21230. frontUVs?: Vector4;
  21231. backUVs?: Vector4;
  21232. }): VertexData;
  21233. /**
  21234. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21235. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21236. * * segments sets the number of horizontal strips optional, default 32
  21237. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21238. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21239. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21240. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21241. * * 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
  21242. * * 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
  21243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21244. * * 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)
  21245. * * 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)
  21246. * @returns the VertexData of the ellipsoid
  21247. */
  21248. static CreateSphere(options: {
  21249. segments?: number;
  21250. diameter?: number;
  21251. diameterX?: number;
  21252. diameterY?: number;
  21253. diameterZ?: number;
  21254. arc?: number;
  21255. slice?: number;
  21256. sideOrientation?: number;
  21257. frontUVs?: Vector4;
  21258. backUVs?: Vector4;
  21259. }): VertexData;
  21260. /**
  21261. * Creates the VertexData for a cylinder, cone or prism
  21262. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21263. * * height sets the height (y direction) of the cylinder, optional, default 2
  21264. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21265. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21266. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21267. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21268. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21269. * * 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
  21270. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21271. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21272. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21273. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21275. * * 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)
  21276. * * 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)
  21277. * @returns the VertexData of the cylinder, cone or prism
  21278. */
  21279. static CreateCylinder(options: {
  21280. height?: number;
  21281. diameterTop?: number;
  21282. diameterBottom?: number;
  21283. diameter?: number;
  21284. tessellation?: number;
  21285. subdivisions?: number;
  21286. arc?: number;
  21287. faceColors?: Color4[];
  21288. faceUV?: Vector4[];
  21289. hasRings?: boolean;
  21290. enclose?: boolean;
  21291. sideOrientation?: number;
  21292. frontUVs?: Vector4;
  21293. backUVs?: Vector4;
  21294. }): VertexData;
  21295. /**
  21296. * Creates the VertexData for a torus
  21297. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21298. * * diameter the diameter of the torus, optional default 1
  21299. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21300. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21302. * * 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)
  21303. * * 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)
  21304. * @returns the VertexData of the torus
  21305. */
  21306. static CreateTorus(options: {
  21307. diameter?: number;
  21308. thickness?: number;
  21309. tessellation?: number;
  21310. sideOrientation?: number;
  21311. frontUVs?: Vector4;
  21312. backUVs?: Vector4;
  21313. }): VertexData;
  21314. /**
  21315. * Creates the VertexData of the LineSystem
  21316. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21317. * - lines an array of lines, each line being an array of successive Vector3
  21318. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21319. * @returns the VertexData of the LineSystem
  21320. */
  21321. static CreateLineSystem(options: {
  21322. lines: Vector3[][];
  21323. colors?: Nullable<Color4[][]>;
  21324. }): VertexData;
  21325. /**
  21326. * Create the VertexData for a DashedLines
  21327. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21328. * - points an array successive Vector3
  21329. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21330. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21331. * - dashNb the intended total number of dashes, optional, default 200
  21332. * @returns the VertexData for the DashedLines
  21333. */
  21334. static CreateDashedLines(options: {
  21335. points: Vector3[];
  21336. dashSize?: number;
  21337. gapSize?: number;
  21338. dashNb?: number;
  21339. }): VertexData;
  21340. /**
  21341. * Creates the VertexData for a Ground
  21342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21343. * - width the width (x direction) of the ground, optional, default 1
  21344. * - height the height (z direction) of the ground, optional, default 1
  21345. * - subdivisions the number of subdivisions per side, optional, default 1
  21346. * @returns the VertexData of the Ground
  21347. */
  21348. static CreateGround(options: {
  21349. width?: number;
  21350. height?: number;
  21351. subdivisions?: number;
  21352. subdivisionsX?: number;
  21353. subdivisionsY?: number;
  21354. }): VertexData;
  21355. /**
  21356. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21357. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21358. * * xmin the ground minimum X coordinate, optional, default -1
  21359. * * zmin the ground minimum Z coordinate, optional, default -1
  21360. * * xmax the ground maximum X coordinate, optional, default 1
  21361. * * zmax the ground maximum Z coordinate, optional, default 1
  21362. * * 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}
  21363. * * 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}
  21364. * @returns the VertexData of the TiledGround
  21365. */
  21366. static CreateTiledGround(options: {
  21367. xmin: number;
  21368. zmin: number;
  21369. xmax: number;
  21370. zmax: number;
  21371. subdivisions?: {
  21372. w: number;
  21373. h: number;
  21374. };
  21375. precision?: {
  21376. w: number;
  21377. h: number;
  21378. };
  21379. }): VertexData;
  21380. /**
  21381. * Creates the VertexData of the Ground designed from a heightmap
  21382. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21383. * * width the width (x direction) of the ground
  21384. * * height the height (z direction) of the ground
  21385. * * subdivisions the number of subdivisions per side
  21386. * * minHeight the minimum altitude on the ground, optional, default 0
  21387. * * maxHeight the maximum altitude on the ground, optional default 1
  21388. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21389. * * buffer the array holding the image color data
  21390. * * bufferWidth the width of image
  21391. * * bufferHeight the height of image
  21392. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21393. * @returns the VertexData of the Ground designed from a heightmap
  21394. */
  21395. static CreateGroundFromHeightMap(options: {
  21396. width: number;
  21397. height: number;
  21398. subdivisions: number;
  21399. minHeight: number;
  21400. maxHeight: number;
  21401. colorFilter: Color3;
  21402. buffer: Uint8Array;
  21403. bufferWidth: number;
  21404. bufferHeight: number;
  21405. alphaFilter: number;
  21406. }): VertexData;
  21407. /**
  21408. * Creates the VertexData for a Plane
  21409. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21410. * * size sets the width and height of the plane to the value of size, optional default 1
  21411. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21412. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21414. * * 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)
  21415. * * 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)
  21416. * @returns the VertexData of the box
  21417. */
  21418. static CreatePlane(options: {
  21419. size?: number;
  21420. width?: number;
  21421. height?: number;
  21422. sideOrientation?: number;
  21423. frontUVs?: Vector4;
  21424. backUVs?: Vector4;
  21425. }): VertexData;
  21426. /**
  21427. * Creates the VertexData of the Disc or regular Polygon
  21428. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21429. * * radius the radius of the disc, optional default 0.5
  21430. * * tessellation the number of polygon sides, optional, default 64
  21431. * * 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
  21432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21433. * * 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)
  21434. * * 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)
  21435. * @returns the VertexData of the box
  21436. */
  21437. static CreateDisc(options: {
  21438. radius?: number;
  21439. tessellation?: number;
  21440. arc?: number;
  21441. sideOrientation?: number;
  21442. frontUVs?: Vector4;
  21443. backUVs?: Vector4;
  21444. }): VertexData;
  21445. /**
  21446. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21447. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21448. * @param polygon a mesh built from polygonTriangulation.build()
  21449. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21450. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21451. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21452. * @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)
  21453. * @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)
  21454. * @returns the VertexData of the Polygon
  21455. */
  21456. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21457. /**
  21458. * Creates the VertexData of the IcoSphere
  21459. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21460. * * radius the radius of the IcoSphere, optional default 1
  21461. * * radiusX allows stretching in the x direction, optional, default radius
  21462. * * radiusY allows stretching in the y direction, optional, default radius
  21463. * * radiusZ allows stretching in the z direction, optional, default radius
  21464. * * flat when true creates a flat shaded mesh, optional, default true
  21465. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21467. * * 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)
  21468. * * 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)
  21469. * @returns the VertexData of the IcoSphere
  21470. */
  21471. static CreateIcoSphere(options: {
  21472. radius?: number;
  21473. radiusX?: number;
  21474. radiusY?: number;
  21475. radiusZ?: number;
  21476. flat?: boolean;
  21477. subdivisions?: number;
  21478. sideOrientation?: number;
  21479. frontUVs?: Vector4;
  21480. backUVs?: Vector4;
  21481. }): VertexData;
  21482. /**
  21483. * Creates the VertexData for a Polyhedron
  21484. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21485. * * type provided types are:
  21486. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21487. * * 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)
  21488. * * size the size of the IcoSphere, optional default 1
  21489. * * sizeX allows stretching in the x direction, optional, default size
  21490. * * sizeY allows stretching in the y direction, optional, default size
  21491. * * sizeZ allows stretching in the z direction, optional, default size
  21492. * * 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
  21493. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21494. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21495. * * flat when true creates a flat shaded mesh, optional, default true
  21496. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21498. * * 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)
  21499. * * 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)
  21500. * @returns the VertexData of the Polyhedron
  21501. */
  21502. static CreatePolyhedron(options: {
  21503. type?: number;
  21504. size?: number;
  21505. sizeX?: number;
  21506. sizeY?: number;
  21507. sizeZ?: number;
  21508. custom?: any;
  21509. faceUV?: Vector4[];
  21510. faceColors?: Color4[];
  21511. flat?: boolean;
  21512. sideOrientation?: number;
  21513. frontUVs?: Vector4;
  21514. backUVs?: Vector4;
  21515. }): VertexData;
  21516. /**
  21517. * Creates the VertexData for a TorusKnot
  21518. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21519. * * radius the radius of the torus knot, optional, default 2
  21520. * * tube the thickness of the tube, optional, default 0.5
  21521. * * radialSegments the number of sides on each tube segments, optional, default 32
  21522. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21523. * * p the number of windings around the z axis, optional, default 2
  21524. * * q the number of windings around the x axis, optional, default 3
  21525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21526. * * 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)
  21527. * * 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)
  21528. * @returns the VertexData of the Torus Knot
  21529. */
  21530. static CreateTorusKnot(options: {
  21531. radius?: number;
  21532. tube?: number;
  21533. radialSegments?: number;
  21534. tubularSegments?: number;
  21535. p?: number;
  21536. q?: number;
  21537. sideOrientation?: number;
  21538. frontUVs?: Vector4;
  21539. backUVs?: Vector4;
  21540. }): VertexData;
  21541. /**
  21542. * Compute normals for given positions and indices
  21543. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21544. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21545. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21546. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21547. * * facetNormals : optional array of facet normals (vector3)
  21548. * * facetPositions : optional array of facet positions (vector3)
  21549. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21550. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21551. * * bInfo : optional bounding info, required for facetPartitioning computation
  21552. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21553. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21554. * * useRightHandedSystem: optional boolean to for right handed system computation
  21555. * * depthSort : optional boolean to enable the facet depth sort computation
  21556. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21557. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21558. */
  21559. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21560. facetNormals?: any;
  21561. facetPositions?: any;
  21562. facetPartitioning?: any;
  21563. ratio?: number;
  21564. bInfo?: any;
  21565. bbSize?: Vector3;
  21566. subDiv?: any;
  21567. useRightHandedSystem?: boolean;
  21568. depthSort?: boolean;
  21569. distanceTo?: Vector3;
  21570. depthSortedFacets?: any;
  21571. }): void;
  21572. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21573. /**
  21574. * Applies VertexData created from the imported parameters to the geometry
  21575. * @param parsedVertexData the parsed data from an imported file
  21576. * @param geometry the geometry to apply the VertexData to
  21577. */
  21578. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21579. }
  21580. }
  21581. declare module BABYLON {
  21582. /**
  21583. * Defines a target to use with MorphTargetManager
  21584. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21585. */
  21586. export class MorphTarget implements IAnimatable {
  21587. /** defines the name of the target */
  21588. name: string;
  21589. /**
  21590. * Gets or sets the list of animations
  21591. */
  21592. animations: Animation[];
  21593. private _scene;
  21594. private _positions;
  21595. private _normals;
  21596. private _tangents;
  21597. private _uvs;
  21598. private _influence;
  21599. /**
  21600. * Observable raised when the influence changes
  21601. */
  21602. onInfluenceChanged: Observable<boolean>;
  21603. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21604. /**
  21605. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21606. */
  21607. influence: number;
  21608. /**
  21609. * Gets or sets the id of the morph Target
  21610. */
  21611. id: string;
  21612. private _animationPropertiesOverride;
  21613. /**
  21614. * Gets or sets the animation properties override
  21615. */
  21616. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21617. /**
  21618. * Creates a new MorphTarget
  21619. * @param name defines the name of the target
  21620. * @param influence defines the influence to use
  21621. * @param scene defines the scene the morphtarget belongs to
  21622. */
  21623. constructor(
  21624. /** defines the name of the target */
  21625. name: string, influence?: number, scene?: Nullable<Scene>);
  21626. /**
  21627. * Gets a boolean defining if the target contains position data
  21628. */
  21629. readonly hasPositions: boolean;
  21630. /**
  21631. * Gets a boolean defining if the target contains normal data
  21632. */
  21633. readonly hasNormals: boolean;
  21634. /**
  21635. * Gets a boolean defining if the target contains tangent data
  21636. */
  21637. readonly hasTangents: boolean;
  21638. /**
  21639. * Gets a boolean defining if the target contains texture coordinates data
  21640. */
  21641. readonly hasUVs: boolean;
  21642. /**
  21643. * Affects position data to this target
  21644. * @param data defines the position data to use
  21645. */
  21646. setPositions(data: Nullable<FloatArray>): void;
  21647. /**
  21648. * Gets the position data stored in this target
  21649. * @returns a FloatArray containing the position data (or null if not present)
  21650. */
  21651. getPositions(): Nullable<FloatArray>;
  21652. /**
  21653. * Affects normal data to this target
  21654. * @param data defines the normal data to use
  21655. */
  21656. setNormals(data: Nullable<FloatArray>): void;
  21657. /**
  21658. * Gets the normal data stored in this target
  21659. * @returns a FloatArray containing the normal data (or null if not present)
  21660. */
  21661. getNormals(): Nullable<FloatArray>;
  21662. /**
  21663. * Affects tangent data to this target
  21664. * @param data defines the tangent data to use
  21665. */
  21666. setTangents(data: Nullable<FloatArray>): void;
  21667. /**
  21668. * Gets the tangent data stored in this target
  21669. * @returns a FloatArray containing the tangent data (or null if not present)
  21670. */
  21671. getTangents(): Nullable<FloatArray>;
  21672. /**
  21673. * Affects texture coordinates data to this target
  21674. * @param data defines the texture coordinates data to use
  21675. */
  21676. setUVs(data: Nullable<FloatArray>): void;
  21677. /**
  21678. * Gets the texture coordinates data stored in this target
  21679. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21680. */
  21681. getUVs(): Nullable<FloatArray>;
  21682. /**
  21683. * Serializes the current target into a Serialization object
  21684. * @returns the serialized object
  21685. */
  21686. serialize(): any;
  21687. /**
  21688. * Returns the string "MorphTarget"
  21689. * @returns "MorphTarget"
  21690. */
  21691. getClassName(): string;
  21692. /**
  21693. * Creates a new target from serialized data
  21694. * @param serializationObject defines the serialized data to use
  21695. * @returns a new MorphTarget
  21696. */
  21697. static Parse(serializationObject: any): MorphTarget;
  21698. /**
  21699. * Creates a MorphTarget from mesh data
  21700. * @param mesh defines the source mesh
  21701. * @param name defines the name to use for the new target
  21702. * @param influence defines the influence to attach to the target
  21703. * @returns a new MorphTarget
  21704. */
  21705. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21706. }
  21707. }
  21708. declare module BABYLON {
  21709. /**
  21710. * This class is used to deform meshes using morphing between different targets
  21711. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21712. */
  21713. export class MorphTargetManager {
  21714. private _targets;
  21715. private _targetInfluenceChangedObservers;
  21716. private _targetDataLayoutChangedObservers;
  21717. private _activeTargets;
  21718. private _scene;
  21719. private _influences;
  21720. private _supportsNormals;
  21721. private _supportsTangents;
  21722. private _supportsUVs;
  21723. private _vertexCount;
  21724. private _uniqueId;
  21725. private _tempInfluences;
  21726. /**
  21727. * Gets or sets a boolean indicating if normals must be morphed
  21728. */
  21729. enableNormalMorphing: boolean;
  21730. /**
  21731. * Gets or sets a boolean indicating if tangents must be morphed
  21732. */
  21733. enableTangentMorphing: boolean;
  21734. /**
  21735. * Gets or sets a boolean indicating if UV must be morphed
  21736. */
  21737. enableUVMorphing: boolean;
  21738. /**
  21739. * Creates a new MorphTargetManager
  21740. * @param scene defines the current scene
  21741. */
  21742. constructor(scene?: Nullable<Scene>);
  21743. /**
  21744. * Gets the unique ID of this manager
  21745. */
  21746. readonly uniqueId: number;
  21747. /**
  21748. * Gets the number of vertices handled by this manager
  21749. */
  21750. readonly vertexCount: number;
  21751. /**
  21752. * Gets a boolean indicating if this manager supports morphing of normals
  21753. */
  21754. readonly supportsNormals: boolean;
  21755. /**
  21756. * Gets a boolean indicating if this manager supports morphing of tangents
  21757. */
  21758. readonly supportsTangents: boolean;
  21759. /**
  21760. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21761. */
  21762. readonly supportsUVs: boolean;
  21763. /**
  21764. * Gets the number of targets stored in this manager
  21765. */
  21766. readonly numTargets: number;
  21767. /**
  21768. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21769. */
  21770. readonly numInfluencers: number;
  21771. /**
  21772. * Gets the list of influences (one per target)
  21773. */
  21774. readonly influences: Float32Array;
  21775. /**
  21776. * Gets the active target at specified index. An active target is a target with an influence > 0
  21777. * @param index defines the index to check
  21778. * @returns the requested target
  21779. */
  21780. getActiveTarget(index: number): MorphTarget;
  21781. /**
  21782. * Gets the target at specified index
  21783. * @param index defines the index to check
  21784. * @returns the requested target
  21785. */
  21786. getTarget(index: number): MorphTarget;
  21787. /**
  21788. * Add a new target to this manager
  21789. * @param target defines the target to add
  21790. */
  21791. addTarget(target: MorphTarget): void;
  21792. /**
  21793. * Removes a target from the manager
  21794. * @param target defines the target to remove
  21795. */
  21796. removeTarget(target: MorphTarget): void;
  21797. /**
  21798. * Serializes the current manager into a Serialization object
  21799. * @returns the serialized object
  21800. */
  21801. serialize(): any;
  21802. private _syncActiveTargets;
  21803. /**
  21804. * Syncrhonize the targets with all the meshes using this morph target manager
  21805. */
  21806. synchronize(): void;
  21807. /**
  21808. * Creates a new MorphTargetManager from serialized data
  21809. * @param serializationObject defines the serialized data
  21810. * @param scene defines the hosting scene
  21811. * @returns the new MorphTargetManager
  21812. */
  21813. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21814. }
  21815. }
  21816. declare module BABYLON {
  21817. /**
  21818. * Class used to represent a specific level of detail of a mesh
  21819. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21820. */
  21821. export class MeshLODLevel {
  21822. /** Defines the distance where this level should start being displayed */
  21823. distance: number;
  21824. /** Defines the mesh to use to render this level */
  21825. mesh: Nullable<Mesh>;
  21826. /**
  21827. * Creates a new LOD level
  21828. * @param distance defines the distance where this level should star being displayed
  21829. * @param mesh defines the mesh to use to render this level
  21830. */
  21831. constructor(
  21832. /** Defines the distance where this level should start being displayed */
  21833. distance: number,
  21834. /** Defines the mesh to use to render this level */
  21835. mesh: Nullable<Mesh>);
  21836. }
  21837. }
  21838. declare module BABYLON {
  21839. /**
  21840. * Mesh representing the gorund
  21841. */
  21842. export class GroundMesh extends Mesh {
  21843. /** If octree should be generated */
  21844. generateOctree: boolean;
  21845. private _heightQuads;
  21846. /** @hidden */ private _subdivisionsX: number;
  21847. /** @hidden */ private _subdivisionsY: number;
  21848. /** @hidden */ private _width: number;
  21849. /** @hidden */ private _height: number;
  21850. /** @hidden */ private _minX: number;
  21851. /** @hidden */ private _maxX: number;
  21852. /** @hidden */ private _minZ: number;
  21853. /** @hidden */ private _maxZ: number;
  21854. constructor(name: string, scene: Scene);
  21855. /**
  21856. * "GroundMesh"
  21857. * @returns "GroundMesh"
  21858. */
  21859. getClassName(): string;
  21860. /**
  21861. * The minimum of x and y subdivisions
  21862. */
  21863. readonly subdivisions: number;
  21864. /**
  21865. * X subdivisions
  21866. */
  21867. readonly subdivisionsX: number;
  21868. /**
  21869. * Y subdivisions
  21870. */
  21871. readonly subdivisionsY: number;
  21872. /**
  21873. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  21874. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21875. * @param chunksCount the number of subdivisions for x and y
  21876. * @param octreeBlocksSize (Default: 32)
  21877. */
  21878. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21879. /**
  21880. * Returns a height (y) value in the Worl system :
  21881. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21882. * @param x x coordinate
  21883. * @param z z coordinate
  21884. * @returns the ground y position if (x, z) are outside the ground surface.
  21885. */
  21886. getHeightAtCoordinates(x: number, z: number): number;
  21887. /**
  21888. * Returns a normalized vector (Vector3) orthogonal to the ground
  21889. * at the ground coordinates (x, z) expressed in the World system.
  21890. * @param x x coordinate
  21891. * @param z z coordinate
  21892. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21893. */
  21894. getNormalAtCoordinates(x: number, z: number): Vector3;
  21895. /**
  21896. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21897. * at the ground coordinates (x, z) expressed in the World system.
  21898. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21899. * @param x x coordinate
  21900. * @param z z coordinate
  21901. * @param ref vector to store the result
  21902. * @returns the GroundMesh.
  21903. */
  21904. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21905. /**
  21906. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21907. * if the ground has been updated.
  21908. * This can be used in the render loop.
  21909. * @returns the GroundMesh.
  21910. */
  21911. updateCoordinateHeights(): GroundMesh;
  21912. private _getFacetAt;
  21913. private _initHeightQuads;
  21914. private _computeHeightQuads;
  21915. /**
  21916. * Serializes this ground mesh
  21917. * @param serializationObject object to write serialization to
  21918. */
  21919. serialize(serializationObject: any): void;
  21920. /**
  21921. * Parses a serialized ground mesh
  21922. * @param parsedMesh the serialized mesh
  21923. * @param scene the scene to create the ground mesh in
  21924. * @returns the created ground mesh
  21925. */
  21926. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21927. }
  21928. }
  21929. declare module BABYLON {
  21930. /**
  21931. * Interface for Physics-Joint data
  21932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21933. */
  21934. export interface PhysicsJointData {
  21935. /**
  21936. * The main pivot of the joint
  21937. */
  21938. mainPivot?: Vector3;
  21939. /**
  21940. * The connected pivot of the joint
  21941. */
  21942. connectedPivot?: Vector3;
  21943. /**
  21944. * The main axis of the joint
  21945. */
  21946. mainAxis?: Vector3;
  21947. /**
  21948. * The connected axis of the joint
  21949. */
  21950. connectedAxis?: Vector3;
  21951. /**
  21952. * The collision of the joint
  21953. */
  21954. collision?: boolean;
  21955. /**
  21956. * Native Oimo/Cannon/Energy data
  21957. */
  21958. nativeParams?: any;
  21959. }
  21960. /**
  21961. * This is a holder class for the physics joint created by the physics plugin
  21962. * It holds a set of functions to control the underlying joint
  21963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21964. */
  21965. export class PhysicsJoint {
  21966. /**
  21967. * The type of the physics joint
  21968. */
  21969. type: number;
  21970. /**
  21971. * The data for the physics joint
  21972. */
  21973. jointData: PhysicsJointData;
  21974. private _physicsJoint;
  21975. protected _physicsPlugin: IPhysicsEnginePlugin;
  21976. /**
  21977. * Initializes the physics joint
  21978. * @param type The type of the physics joint
  21979. * @param jointData The data for the physics joint
  21980. */
  21981. constructor(
  21982. /**
  21983. * The type of the physics joint
  21984. */
  21985. type: number,
  21986. /**
  21987. * The data for the physics joint
  21988. */
  21989. jointData: PhysicsJointData);
  21990. /**
  21991. * Gets the physics joint
  21992. */
  21993. /**
  21994. * Sets the physics joint
  21995. */
  21996. physicsJoint: any;
  21997. /**
  21998. * Sets the physics plugin
  21999. */
  22000. physicsPlugin: IPhysicsEnginePlugin;
  22001. /**
  22002. * Execute a function that is physics-plugin specific.
  22003. * @param {Function} func the function that will be executed.
  22004. * It accepts two parameters: the physics world and the physics joint
  22005. */
  22006. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22007. /**
  22008. * Distance-Joint type
  22009. */
  22010. static DistanceJoint: number;
  22011. /**
  22012. * Hinge-Joint type
  22013. */
  22014. static HingeJoint: number;
  22015. /**
  22016. * Ball-and-Socket joint type
  22017. */
  22018. static BallAndSocketJoint: number;
  22019. /**
  22020. * Wheel-Joint type
  22021. */
  22022. static WheelJoint: number;
  22023. /**
  22024. * Slider-Joint type
  22025. */
  22026. static SliderJoint: number;
  22027. /**
  22028. * Prismatic-Joint type
  22029. */
  22030. static PrismaticJoint: number;
  22031. /**
  22032. * Universal-Joint type
  22033. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22034. */
  22035. static UniversalJoint: number;
  22036. /**
  22037. * Hinge-Joint 2 type
  22038. */
  22039. static Hinge2Joint: number;
  22040. /**
  22041. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22042. */
  22043. static PointToPointJoint: number;
  22044. /**
  22045. * Spring-Joint type
  22046. */
  22047. static SpringJoint: number;
  22048. /**
  22049. * Lock-Joint type
  22050. */
  22051. static LockJoint: number;
  22052. }
  22053. /**
  22054. * A class representing a physics distance joint
  22055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22056. */
  22057. export class DistanceJoint extends PhysicsJoint {
  22058. /**
  22059. *
  22060. * @param jointData The data for the Distance-Joint
  22061. */
  22062. constructor(jointData: DistanceJointData);
  22063. /**
  22064. * Update the predefined distance.
  22065. * @param maxDistance The maximum preferred distance
  22066. * @param minDistance The minimum preferred distance
  22067. */
  22068. updateDistance(maxDistance: number, minDistance?: number): void;
  22069. }
  22070. /**
  22071. * Represents a Motor-Enabled Joint
  22072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22073. */
  22074. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22075. /**
  22076. * Initializes the Motor-Enabled Joint
  22077. * @param type The type of the joint
  22078. * @param jointData The physica joint data for the joint
  22079. */
  22080. constructor(type: number, jointData: PhysicsJointData);
  22081. /**
  22082. * Set the motor values.
  22083. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22084. * @param force the force to apply
  22085. * @param maxForce max force for this motor.
  22086. */
  22087. setMotor(force?: number, maxForce?: number): void;
  22088. /**
  22089. * Set the motor's limits.
  22090. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22091. * @param upperLimit The upper limit of the motor
  22092. * @param lowerLimit The lower limit of the motor
  22093. */
  22094. setLimit(upperLimit: number, lowerLimit?: number): void;
  22095. }
  22096. /**
  22097. * This class represents a single physics Hinge-Joint
  22098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22099. */
  22100. export class HingeJoint extends MotorEnabledJoint {
  22101. /**
  22102. * Initializes the Hinge-Joint
  22103. * @param jointData The joint data for the Hinge-Joint
  22104. */
  22105. constructor(jointData: PhysicsJointData);
  22106. /**
  22107. * Set the motor values.
  22108. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22109. * @param {number} force the force to apply
  22110. * @param {number} maxForce max force for this motor.
  22111. */
  22112. setMotor(force?: number, maxForce?: number): void;
  22113. /**
  22114. * Set the motor's limits.
  22115. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22116. * @param upperLimit The upper limit of the motor
  22117. * @param lowerLimit The lower limit of the motor
  22118. */
  22119. setLimit(upperLimit: number, lowerLimit?: number): void;
  22120. }
  22121. /**
  22122. * This class represents a dual hinge physics joint (same as wheel joint)
  22123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22124. */
  22125. export class Hinge2Joint extends MotorEnabledJoint {
  22126. /**
  22127. * Initializes the Hinge2-Joint
  22128. * @param jointData The joint data for the Hinge2-Joint
  22129. */
  22130. constructor(jointData: PhysicsJointData);
  22131. /**
  22132. * Set the motor values.
  22133. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22134. * @param {number} targetSpeed the speed the motor is to reach
  22135. * @param {number} maxForce max force for this motor.
  22136. * @param {motorIndex} the motor's index, 0 or 1.
  22137. */
  22138. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22139. /**
  22140. * Set the motor limits.
  22141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22142. * @param {number} upperLimit the upper limit
  22143. * @param {number} lowerLimit lower limit
  22144. * @param {motorIndex} the motor's index, 0 or 1.
  22145. */
  22146. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22147. }
  22148. /**
  22149. * Interface for a motor enabled joint
  22150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22151. */
  22152. export interface IMotorEnabledJoint {
  22153. /**
  22154. * Physics joint
  22155. */
  22156. physicsJoint: any;
  22157. /**
  22158. * Sets the motor of the motor-enabled joint
  22159. * @param force The force of the motor
  22160. * @param maxForce The maximum force of the motor
  22161. * @param motorIndex The index of the motor
  22162. */
  22163. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22164. /**
  22165. * Sets the limit of the motor
  22166. * @param upperLimit The upper limit of the motor
  22167. * @param lowerLimit The lower limit of the motor
  22168. * @param motorIndex The index of the motor
  22169. */
  22170. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22171. }
  22172. /**
  22173. * Joint data for a Distance-Joint
  22174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22175. */
  22176. export interface DistanceJointData extends PhysicsJointData {
  22177. /**
  22178. * Max distance the 2 joint objects can be apart
  22179. */
  22180. maxDistance: number;
  22181. }
  22182. /**
  22183. * Joint data from a spring joint
  22184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22185. */
  22186. export interface SpringJointData extends PhysicsJointData {
  22187. /**
  22188. * Length of the spring
  22189. */
  22190. length: number;
  22191. /**
  22192. * Stiffness of the spring
  22193. */
  22194. stiffness: number;
  22195. /**
  22196. * Damping of the spring
  22197. */
  22198. damping: number;
  22199. /** this callback will be called when applying the force to the impostors. */
  22200. forceApplicationCallback: () => void;
  22201. }
  22202. }
  22203. declare module BABYLON {
  22204. /**
  22205. * Holds the data for the raycast result
  22206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22207. */
  22208. export class PhysicsRaycastResult {
  22209. private _hasHit;
  22210. private _hitDistance;
  22211. private _hitNormalWorld;
  22212. private _hitPointWorld;
  22213. private _rayFromWorld;
  22214. private _rayToWorld;
  22215. /**
  22216. * Gets if there was a hit
  22217. */
  22218. readonly hasHit: boolean;
  22219. /**
  22220. * Gets the distance from the hit
  22221. */
  22222. readonly hitDistance: number;
  22223. /**
  22224. * Gets the hit normal/direction in the world
  22225. */
  22226. readonly hitNormalWorld: Vector3;
  22227. /**
  22228. * Gets the hit point in the world
  22229. */
  22230. readonly hitPointWorld: Vector3;
  22231. /**
  22232. * Gets the ray "start point" of the ray in the world
  22233. */
  22234. readonly rayFromWorld: Vector3;
  22235. /**
  22236. * Gets the ray "end point" of the ray in the world
  22237. */
  22238. readonly rayToWorld: Vector3;
  22239. /**
  22240. * Sets the hit data (normal & point in world space)
  22241. * @param hitNormalWorld defines the normal in world space
  22242. * @param hitPointWorld defines the point in world space
  22243. */
  22244. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22245. /**
  22246. * Sets the distance from the start point to the hit point
  22247. * @param distance
  22248. */
  22249. setHitDistance(distance: number): void;
  22250. /**
  22251. * Calculates the distance manually
  22252. */
  22253. calculateHitDistance(): void;
  22254. /**
  22255. * Resets all the values to default
  22256. * @param from The from point on world space
  22257. * @param to The to point on world space
  22258. */
  22259. reset(from?: Vector3, to?: Vector3): void;
  22260. }
  22261. /**
  22262. * Interface for the size containing width and height
  22263. */
  22264. interface IXYZ {
  22265. /**
  22266. * X
  22267. */
  22268. x: number;
  22269. /**
  22270. * Y
  22271. */
  22272. y: number;
  22273. /**
  22274. * Z
  22275. */
  22276. z: number;
  22277. }
  22278. }
  22279. declare module BABYLON {
  22280. /**
  22281. * Interface used to describe a physics joint
  22282. */
  22283. export interface PhysicsImpostorJoint {
  22284. /** Defines the main impostor to which the joint is linked */
  22285. mainImpostor: PhysicsImpostor;
  22286. /** Defines the impostor that is connected to the main impostor using this joint */
  22287. connectedImpostor: PhysicsImpostor;
  22288. /** Defines the joint itself */
  22289. joint: PhysicsJoint;
  22290. }
  22291. /** @hidden */
  22292. export interface IPhysicsEnginePlugin {
  22293. world: any;
  22294. name: string;
  22295. setGravity(gravity: Vector3): void;
  22296. setTimeStep(timeStep: number): void;
  22297. getTimeStep(): number;
  22298. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22299. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22300. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22301. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22302. removePhysicsBody(impostor: PhysicsImpostor): void;
  22303. generateJoint(joint: PhysicsImpostorJoint): void;
  22304. removeJoint(joint: PhysicsImpostorJoint): void;
  22305. isSupported(): boolean;
  22306. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22307. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22308. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22309. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22310. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22311. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22312. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22313. getBodyMass(impostor: PhysicsImpostor): number;
  22314. getBodyFriction(impostor: PhysicsImpostor): number;
  22315. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22316. getBodyRestitution(impostor: PhysicsImpostor): number;
  22317. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22318. getBodyPressure?(impostor: PhysicsImpostor): number;
  22319. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22320. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22321. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22322. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22323. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22324. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22325. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22326. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22327. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22328. sleepBody(impostor: PhysicsImpostor): void;
  22329. wakeUpBody(impostor: PhysicsImpostor): void;
  22330. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22331. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22332. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22333. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22334. getRadius(impostor: PhysicsImpostor): number;
  22335. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22336. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22337. dispose(): void;
  22338. }
  22339. /**
  22340. * Interface used to define a physics engine
  22341. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22342. */
  22343. export interface IPhysicsEngine {
  22344. /**
  22345. * Gets the gravity vector used by the simulation
  22346. */
  22347. gravity: Vector3;
  22348. /**
  22349. * Sets the gravity vector used by the simulation
  22350. * @param gravity defines the gravity vector to use
  22351. */
  22352. setGravity(gravity: Vector3): void;
  22353. /**
  22354. * Set the time step of the physics engine.
  22355. * Default is 1/60.
  22356. * To slow it down, enter 1/600 for example.
  22357. * To speed it up, 1/30
  22358. * @param newTimeStep the new timestep to apply to this world.
  22359. */
  22360. setTimeStep(newTimeStep: number): void;
  22361. /**
  22362. * Get the time step of the physics engine.
  22363. * @returns the current time step
  22364. */
  22365. getTimeStep(): number;
  22366. /**
  22367. * Release all resources
  22368. */
  22369. dispose(): void;
  22370. /**
  22371. * Gets the name of the current physics plugin
  22372. * @returns the name of the plugin
  22373. */
  22374. getPhysicsPluginName(): string;
  22375. /**
  22376. * Adding a new impostor for the impostor tracking.
  22377. * This will be done by the impostor itself.
  22378. * @param impostor the impostor to add
  22379. */
  22380. addImpostor(impostor: PhysicsImpostor): void;
  22381. /**
  22382. * Remove an impostor from the engine.
  22383. * This impostor and its mesh will not longer be updated by the physics engine.
  22384. * @param impostor the impostor to remove
  22385. */
  22386. removeImpostor(impostor: PhysicsImpostor): void;
  22387. /**
  22388. * Add a joint to the physics engine
  22389. * @param mainImpostor defines the main impostor to which the joint is added.
  22390. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22391. * @param joint defines the joint that will connect both impostors.
  22392. */
  22393. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22394. /**
  22395. * Removes a joint from the simulation
  22396. * @param mainImpostor defines the impostor used with the joint
  22397. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22398. * @param joint defines the joint to remove
  22399. */
  22400. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22401. /**
  22402. * Gets the current plugin used to run the simulation
  22403. * @returns current plugin
  22404. */
  22405. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22406. /**
  22407. * Gets the list of physic impostors
  22408. * @returns an array of PhysicsImpostor
  22409. */
  22410. getImpostors(): Array<PhysicsImpostor>;
  22411. /**
  22412. * Gets the impostor for a physics enabled object
  22413. * @param object defines the object impersonated by the impostor
  22414. * @returns the PhysicsImpostor or null if not found
  22415. */
  22416. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22417. /**
  22418. * Gets the impostor for a physics body object
  22419. * @param body defines physics body used by the impostor
  22420. * @returns the PhysicsImpostor or null if not found
  22421. */
  22422. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22423. /**
  22424. * Does a raycast in the physics world
  22425. * @param from when should the ray start?
  22426. * @param to when should the ray end?
  22427. * @returns PhysicsRaycastResult
  22428. */
  22429. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22430. /**
  22431. * Called by the scene. No need to call it.
  22432. * @param delta defines the timespam between frames
  22433. */ private _step(delta: number): void;
  22434. }
  22435. }
  22436. declare module BABYLON {
  22437. /**
  22438. * The interface for the physics imposter parameters
  22439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22440. */
  22441. export interface PhysicsImpostorParameters {
  22442. /**
  22443. * The mass of the physics imposter
  22444. */
  22445. mass: number;
  22446. /**
  22447. * The friction of the physics imposter
  22448. */
  22449. friction?: number;
  22450. /**
  22451. * The coefficient of restitution of the physics imposter
  22452. */
  22453. restitution?: number;
  22454. /**
  22455. * The native options of the physics imposter
  22456. */
  22457. nativeOptions?: any;
  22458. /**
  22459. * Specifies if the parent should be ignored
  22460. */
  22461. ignoreParent?: boolean;
  22462. /**
  22463. * Specifies if bi-directional transformations should be disabled
  22464. */
  22465. disableBidirectionalTransformation?: boolean;
  22466. /**
  22467. * The pressure inside the physics imposter, soft object only
  22468. */
  22469. pressure?: number;
  22470. /**
  22471. * The stiffness the physics imposter, soft object only
  22472. */
  22473. stiffness?: number;
  22474. /**
  22475. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22476. */
  22477. velocityIterations?: number;
  22478. /**
  22479. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22480. */
  22481. positionIterations?: number;
  22482. /**
  22483. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22484. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22485. * Add to fix multiple points
  22486. */
  22487. fixedPoints?: number;
  22488. /**
  22489. * The collision margin around a soft object
  22490. */
  22491. margin?: number;
  22492. /**
  22493. * The collision margin around a soft object
  22494. */
  22495. damping?: number;
  22496. /**
  22497. * The path for a rope based on an extrusion
  22498. */
  22499. path?: any;
  22500. /**
  22501. * The shape of an extrusion used for a rope based on an extrusion
  22502. */
  22503. shape?: any;
  22504. }
  22505. /**
  22506. * Interface for a physics-enabled object
  22507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22508. */
  22509. export interface IPhysicsEnabledObject {
  22510. /**
  22511. * The position of the physics-enabled object
  22512. */
  22513. position: Vector3;
  22514. /**
  22515. * The rotation of the physics-enabled object
  22516. */
  22517. rotationQuaternion: Nullable<Quaternion>;
  22518. /**
  22519. * The scale of the physics-enabled object
  22520. */
  22521. scaling: Vector3;
  22522. /**
  22523. * The rotation of the physics-enabled object
  22524. */
  22525. rotation?: Vector3;
  22526. /**
  22527. * The parent of the physics-enabled object
  22528. */
  22529. parent?: any;
  22530. /**
  22531. * The bounding info of the physics-enabled object
  22532. * @returns The bounding info of the physics-enabled object
  22533. */
  22534. getBoundingInfo(): BoundingInfo;
  22535. /**
  22536. * Computes the world matrix
  22537. * @param force Specifies if the world matrix should be computed by force
  22538. * @returns A world matrix
  22539. */
  22540. computeWorldMatrix(force: boolean): Matrix;
  22541. /**
  22542. * Gets the world matrix
  22543. * @returns A world matrix
  22544. */
  22545. getWorldMatrix?(): Matrix;
  22546. /**
  22547. * Gets the child meshes
  22548. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22549. * @returns An array of abstract meshes
  22550. */
  22551. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22552. /**
  22553. * Gets the vertex data
  22554. * @param kind The type of vertex data
  22555. * @returns A nullable array of numbers, or a float32 array
  22556. */
  22557. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22558. /**
  22559. * Gets the indices from the mesh
  22560. * @returns A nullable array of index arrays
  22561. */
  22562. getIndices?(): Nullable<IndicesArray>;
  22563. /**
  22564. * Gets the scene from the mesh
  22565. * @returns the indices array or null
  22566. */
  22567. getScene?(): Scene;
  22568. /**
  22569. * Gets the absolute position from the mesh
  22570. * @returns the absolute position
  22571. */
  22572. getAbsolutePosition(): Vector3;
  22573. /**
  22574. * Gets the absolute pivot point from the mesh
  22575. * @returns the absolute pivot point
  22576. */
  22577. getAbsolutePivotPoint(): Vector3;
  22578. /**
  22579. * Rotates the mesh
  22580. * @param axis The axis of rotation
  22581. * @param amount The amount of rotation
  22582. * @param space The space of the rotation
  22583. * @returns The rotation transform node
  22584. */
  22585. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22586. /**
  22587. * Translates the mesh
  22588. * @param axis The axis of translation
  22589. * @param distance The distance of translation
  22590. * @param space The space of the translation
  22591. * @returns The transform node
  22592. */
  22593. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22594. /**
  22595. * Sets the absolute position of the mesh
  22596. * @param absolutePosition The absolute position of the mesh
  22597. * @returns The transform node
  22598. */
  22599. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22600. /**
  22601. * Gets the class name of the mesh
  22602. * @returns The class name
  22603. */
  22604. getClassName(): string;
  22605. }
  22606. /**
  22607. * Represents a physics imposter
  22608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22609. */
  22610. export class PhysicsImpostor {
  22611. /**
  22612. * The physics-enabled object used as the physics imposter
  22613. */
  22614. object: IPhysicsEnabledObject;
  22615. /**
  22616. * The type of the physics imposter
  22617. */
  22618. type: number;
  22619. private _options;
  22620. private _scene?;
  22621. /**
  22622. * The default object size of the imposter
  22623. */
  22624. static DEFAULT_OBJECT_SIZE: Vector3;
  22625. /**
  22626. * The identity quaternion of the imposter
  22627. */
  22628. static IDENTITY_QUATERNION: Quaternion;
  22629. /** @hidden */ private _pluginData: any;
  22630. private _physicsEngine;
  22631. private _physicsBody;
  22632. private _bodyUpdateRequired;
  22633. private _onBeforePhysicsStepCallbacks;
  22634. private _onAfterPhysicsStepCallbacks;
  22635. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22636. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22637. otherImpostors: Array<PhysicsImpostor>;
  22638. }>;
  22639. private _deltaPosition;
  22640. private _deltaRotation;
  22641. private _deltaRotationConjugated;
  22642. /** @hidden */ private _isFromLine: boolean;
  22643. private _parent;
  22644. private _isDisposed;
  22645. private static _tmpVecs;
  22646. private static _tmpQuat;
  22647. /**
  22648. * Specifies if the physics imposter is disposed
  22649. */
  22650. readonly isDisposed: boolean;
  22651. /**
  22652. * Gets the mass of the physics imposter
  22653. */
  22654. mass: number;
  22655. /**
  22656. * Gets the coefficient of friction
  22657. */
  22658. /**
  22659. * Sets the coefficient of friction
  22660. */
  22661. friction: number;
  22662. /**
  22663. * Gets the coefficient of restitution
  22664. */
  22665. /**
  22666. * Sets the coefficient of restitution
  22667. */
  22668. restitution: number;
  22669. /**
  22670. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22671. */
  22672. /**
  22673. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22674. */
  22675. pressure: number;
  22676. /**
  22677. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22678. */
  22679. /**
  22680. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22681. */
  22682. stiffness: number;
  22683. /**
  22684. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22685. */
  22686. /**
  22687. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22688. */
  22689. velocityIterations: number;
  22690. /**
  22691. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22692. */
  22693. /**
  22694. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22695. */
  22696. positionIterations: number;
  22697. /**
  22698. * The unique id of the physics imposter
  22699. * set by the physics engine when adding this impostor to the array
  22700. */
  22701. uniqueId: number;
  22702. /**
  22703. * @hidden
  22704. */
  22705. soft: boolean;
  22706. /**
  22707. * @hidden
  22708. */
  22709. segments: number;
  22710. private _joints;
  22711. /**
  22712. * Initializes the physics imposter
  22713. * @param object The physics-enabled object used as the physics imposter
  22714. * @param type The type of the physics imposter
  22715. * @param _options The options for the physics imposter
  22716. * @param _scene The Babylon scene
  22717. */
  22718. constructor(
  22719. /**
  22720. * The physics-enabled object used as the physics imposter
  22721. */
  22722. object: IPhysicsEnabledObject,
  22723. /**
  22724. * The type of the physics imposter
  22725. */
  22726. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22727. /**
  22728. * This function will completly initialize this impostor.
  22729. * It will create a new body - but only if this mesh has no parent.
  22730. * If it has, this impostor will not be used other than to define the impostor
  22731. * of the child mesh.
  22732. * @hidden
  22733. */ private _init(): void;
  22734. private _getPhysicsParent;
  22735. /**
  22736. * Should a new body be generated.
  22737. * @returns boolean specifying if body initialization is required
  22738. */
  22739. isBodyInitRequired(): boolean;
  22740. /**
  22741. * Sets the updated scaling
  22742. * @param updated Specifies if the scaling is updated
  22743. */
  22744. setScalingUpdated(): void;
  22745. /**
  22746. * Force a regeneration of this or the parent's impostor's body.
  22747. * Use under cautious - This will remove all joints already implemented.
  22748. */
  22749. forceUpdate(): void;
  22750. /**
  22751. * Gets the body that holds this impostor. Either its own, or its parent.
  22752. */
  22753. /**
  22754. * Set the physics body. Used mainly by the physics engine/plugin
  22755. */
  22756. physicsBody: any;
  22757. /**
  22758. * Get the parent of the physics imposter
  22759. * @returns Physics imposter or null
  22760. */
  22761. /**
  22762. * Sets the parent of the physics imposter
  22763. */
  22764. parent: Nullable<PhysicsImpostor>;
  22765. /**
  22766. * Resets the update flags
  22767. */
  22768. resetUpdateFlags(): void;
  22769. /**
  22770. * Gets the object extend size
  22771. * @returns the object extend size
  22772. */
  22773. getObjectExtendSize(): Vector3;
  22774. /**
  22775. * Gets the object center
  22776. * @returns The object center
  22777. */
  22778. getObjectCenter(): Vector3;
  22779. /**
  22780. * Get a specific parametes from the options parameter
  22781. * @param paramName The object parameter name
  22782. * @returns The object parameter
  22783. */
  22784. getParam(paramName: string): any;
  22785. /**
  22786. * Sets a specific parameter in the options given to the physics plugin
  22787. * @param paramName The parameter name
  22788. * @param value The value of the parameter
  22789. */
  22790. setParam(paramName: string, value: number): void;
  22791. /**
  22792. * Specifically change the body's mass option. Won't recreate the physics body object
  22793. * @param mass The mass of the physics imposter
  22794. */
  22795. setMass(mass: number): void;
  22796. /**
  22797. * Gets the linear velocity
  22798. * @returns linear velocity or null
  22799. */
  22800. getLinearVelocity(): Nullable<Vector3>;
  22801. /**
  22802. * Sets the linear velocity
  22803. * @param velocity linear velocity or null
  22804. */
  22805. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22806. /**
  22807. * Gets the angular velocity
  22808. * @returns angular velocity or null
  22809. */
  22810. getAngularVelocity(): Nullable<Vector3>;
  22811. /**
  22812. * Sets the angular velocity
  22813. * @param velocity The velocity or null
  22814. */
  22815. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22816. /**
  22817. * Execute a function with the physics plugin native code
  22818. * Provide a function the will have two variables - the world object and the physics body object
  22819. * @param func The function to execute with the physics plugin native code
  22820. */
  22821. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22822. /**
  22823. * Register a function that will be executed before the physics world is stepping forward
  22824. * @param func The function to execute before the physics world is stepped forward
  22825. */
  22826. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22827. /**
  22828. * Unregister a function that will be executed before the physics world is stepping forward
  22829. * @param func The function to execute before the physics world is stepped forward
  22830. */
  22831. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22832. /**
  22833. * Register a function that will be executed after the physics step
  22834. * @param func The function to execute after physics step
  22835. */
  22836. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22837. /**
  22838. * Unregisters a function that will be executed after the physics step
  22839. * @param func The function to execute after physics step
  22840. */
  22841. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22842. /**
  22843. * register a function that will be executed when this impostor collides against a different body
  22844. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22845. * @param func Callback that is executed on collision
  22846. */
  22847. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22848. /**
  22849. * Unregisters the physics imposter on contact
  22850. * @param collideAgainst The physics object to collide against
  22851. * @param func Callback to execute on collision
  22852. */
  22853. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22854. private _tmpQuat;
  22855. private _tmpQuat2;
  22856. /**
  22857. * Get the parent rotation
  22858. * @returns The parent rotation
  22859. */
  22860. getParentsRotation(): Quaternion;
  22861. /**
  22862. * this function is executed by the physics engine.
  22863. */
  22864. beforeStep: () => void;
  22865. /**
  22866. * this function is executed by the physics engine
  22867. */
  22868. afterStep: () => void;
  22869. /**
  22870. * Legacy collision detection event support
  22871. */
  22872. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22873. /**
  22874. * event and body object due to cannon's event-based architecture.
  22875. */
  22876. onCollide: (e: {
  22877. body: any;
  22878. }) => void;
  22879. /**
  22880. * Apply a force
  22881. * @param force The force to apply
  22882. * @param contactPoint The contact point for the force
  22883. * @returns The physics imposter
  22884. */
  22885. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22886. /**
  22887. * Apply an impulse
  22888. * @param force The impulse force
  22889. * @param contactPoint The contact point for the impulse force
  22890. * @returns The physics imposter
  22891. */
  22892. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22893. /**
  22894. * A help function to create a joint
  22895. * @param otherImpostor A physics imposter used to create a joint
  22896. * @param jointType The type of joint
  22897. * @param jointData The data for the joint
  22898. * @returns The physics imposter
  22899. */
  22900. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  22901. /**
  22902. * Add a joint to this impostor with a different impostor
  22903. * @param otherImpostor A physics imposter used to add a joint
  22904. * @param joint The joint to add
  22905. * @returns The physics imposter
  22906. */
  22907. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  22908. /**
  22909. * Add an anchor to a cloth impostor
  22910. * @param otherImpostor rigid impostor to anchor to
  22911. * @param width ratio across width from 0 to 1
  22912. * @param height ratio up height from 0 to 1
  22913. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  22914. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  22915. * @returns impostor the soft imposter
  22916. */
  22917. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22918. /**
  22919. * Add a hook to a rope impostor
  22920. * @param otherImpostor rigid impostor to anchor to
  22921. * @param length ratio across rope from 0 to 1
  22922. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  22923. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  22924. * @returns impostor the rope imposter
  22925. */
  22926. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22927. /**
  22928. * Will keep this body still, in a sleep mode.
  22929. * @returns the physics imposter
  22930. */
  22931. sleep(): PhysicsImpostor;
  22932. /**
  22933. * Wake the body up.
  22934. * @returns The physics imposter
  22935. */
  22936. wakeUp(): PhysicsImpostor;
  22937. /**
  22938. * Clones the physics imposter
  22939. * @param newObject The physics imposter clones to this physics-enabled object
  22940. * @returns A nullable physics imposter
  22941. */
  22942. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22943. /**
  22944. * Disposes the physics imposter
  22945. */
  22946. dispose(): void;
  22947. /**
  22948. * Sets the delta position
  22949. * @param position The delta position amount
  22950. */
  22951. setDeltaPosition(position: Vector3): void;
  22952. /**
  22953. * Sets the delta rotation
  22954. * @param rotation The delta rotation amount
  22955. */
  22956. setDeltaRotation(rotation: Quaternion): void;
  22957. /**
  22958. * Gets the box size of the physics imposter and stores the result in the input parameter
  22959. * @param result Stores the box size
  22960. * @returns The physics imposter
  22961. */
  22962. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  22963. /**
  22964. * Gets the radius of the physics imposter
  22965. * @returns Radius of the physics imposter
  22966. */
  22967. getRadius(): number;
  22968. /**
  22969. * Sync a bone with this impostor
  22970. * @param bone The bone to sync to the impostor.
  22971. * @param boneMesh The mesh that the bone is influencing.
  22972. * @param jointPivot The pivot of the joint / bone in local space.
  22973. * @param distToJoint Optional distance from the impostor to the joint.
  22974. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22975. */
  22976. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  22977. /**
  22978. * Sync impostor to a bone
  22979. * @param bone The bone that the impostor will be synced to.
  22980. * @param boneMesh The mesh that the bone is influencing.
  22981. * @param jointPivot The pivot of the joint / bone in local space.
  22982. * @param distToJoint Optional distance from the impostor to the joint.
  22983. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22984. * @param boneAxis Optional vector3 axis the bone is aligned with
  22985. */
  22986. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  22987. /**
  22988. * No-Imposter type
  22989. */
  22990. static NoImpostor: number;
  22991. /**
  22992. * Sphere-Imposter type
  22993. */
  22994. static SphereImpostor: number;
  22995. /**
  22996. * Box-Imposter type
  22997. */
  22998. static BoxImpostor: number;
  22999. /**
  23000. * Plane-Imposter type
  23001. */
  23002. static PlaneImpostor: number;
  23003. /**
  23004. * Mesh-imposter type
  23005. */
  23006. static MeshImpostor: number;
  23007. /**
  23008. * Capsule-Impostor type (Ammo.js plugin only)
  23009. */
  23010. static CapsuleImpostor: number;
  23011. /**
  23012. * Cylinder-Imposter type
  23013. */
  23014. static CylinderImpostor: number;
  23015. /**
  23016. * Particle-Imposter type
  23017. */
  23018. static ParticleImpostor: number;
  23019. /**
  23020. * Heightmap-Imposter type
  23021. */
  23022. static HeightmapImpostor: number;
  23023. /**
  23024. * ConvexHull-Impostor type (Ammo.js plugin only)
  23025. */
  23026. static ConvexHullImpostor: number;
  23027. /**
  23028. * Rope-Imposter type
  23029. */
  23030. static RopeImpostor: number;
  23031. /**
  23032. * Cloth-Imposter type
  23033. */
  23034. static ClothImpostor: number;
  23035. /**
  23036. * Softbody-Imposter type
  23037. */
  23038. static SoftbodyImpostor: number;
  23039. }
  23040. }
  23041. declare module BABYLON {
  23042. /**
  23043. * @hidden
  23044. **/
  23045. export class _CreationDataStorage {
  23046. closePath?: boolean;
  23047. closeArray?: boolean;
  23048. idx: number[];
  23049. dashSize: number;
  23050. gapSize: number;
  23051. path3D: Path3D;
  23052. pathArray: Vector3[][];
  23053. arc: number;
  23054. radius: number;
  23055. cap: number;
  23056. tessellation: number;
  23057. }
  23058. /**
  23059. * @hidden
  23060. **/ private class _InstanceDataStorage {
  23061. visibleInstances: any;
  23062. batchCache: _InstancesBatch;
  23063. instancesBufferSize: number;
  23064. instancesBuffer: Nullable<Buffer>;
  23065. instancesData: Float32Array;
  23066. overridenInstanceCount: number;
  23067. isFrozen: boolean;
  23068. previousBatch: Nullable<_InstancesBatch>;
  23069. hardwareInstancedRendering: boolean;
  23070. sideOrientation: number;
  23071. }
  23072. /**
  23073. * @hidden
  23074. **/
  23075. export class _InstancesBatch {
  23076. mustReturn: boolean;
  23077. visibleInstances: Nullable<InstancedMesh[]>[];
  23078. renderSelf: boolean[];
  23079. hardwareInstancedRendering: boolean[];
  23080. }
  23081. /**
  23082. * Class used to represent renderable models
  23083. */
  23084. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23085. /**
  23086. * Mesh side orientation : usually the external or front surface
  23087. */
  23088. static readonly FRONTSIDE: number;
  23089. /**
  23090. * Mesh side orientation : usually the internal or back surface
  23091. */
  23092. static readonly BACKSIDE: number;
  23093. /**
  23094. * Mesh side orientation : both internal and external or front and back surfaces
  23095. */
  23096. static readonly DOUBLESIDE: number;
  23097. /**
  23098. * Mesh side orientation : by default, `FRONTSIDE`
  23099. */
  23100. static readonly DEFAULTSIDE: number;
  23101. /**
  23102. * Mesh cap setting : no cap
  23103. */
  23104. static readonly NO_CAP: number;
  23105. /**
  23106. * Mesh cap setting : one cap at the beginning of the mesh
  23107. */
  23108. static readonly CAP_START: number;
  23109. /**
  23110. * Mesh cap setting : one cap at the end of the mesh
  23111. */
  23112. static readonly CAP_END: number;
  23113. /**
  23114. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23115. */
  23116. static readonly CAP_ALL: number;
  23117. /**
  23118. * Mesh pattern setting : no flip or rotate
  23119. */
  23120. static readonly NO_FLIP: number;
  23121. /**
  23122. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23123. */
  23124. static readonly FLIP_TILE: number;
  23125. /**
  23126. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23127. */
  23128. static readonly ROTATE_TILE: number;
  23129. /**
  23130. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23131. */
  23132. static readonly FLIP_ROW: number;
  23133. /**
  23134. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23135. */
  23136. static readonly ROTATE_ROW: number;
  23137. /**
  23138. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23139. */
  23140. static readonly FLIP_N_ROTATE_TILE: number;
  23141. /**
  23142. * Mesh pattern setting : rotate pattern and rotate
  23143. */
  23144. static readonly FLIP_N_ROTATE_ROW: number;
  23145. /**
  23146. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23147. */
  23148. static readonly CENTER: number;
  23149. /**
  23150. * Mesh tile positioning : part tiles on left
  23151. */
  23152. static readonly LEFT: number;
  23153. /**
  23154. * Mesh tile positioning : part tiles on right
  23155. */
  23156. static readonly RIGHT: number;
  23157. /**
  23158. * Mesh tile positioning : part tiles on top
  23159. */
  23160. static readonly TOP: number;
  23161. /**
  23162. * Mesh tile positioning : part tiles on bottom
  23163. */
  23164. static readonly BOTTOM: number;
  23165. /**
  23166. * Gets the default side orientation.
  23167. * @param orientation the orientation to value to attempt to get
  23168. * @returns the default orientation
  23169. * @hidden
  23170. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23171. private _internalMeshDataInfo;
  23172. /**
  23173. * An event triggered before rendering the mesh
  23174. */
  23175. readonly onBeforeRenderObservable: Observable<Mesh>;
  23176. /**
  23177. * An event triggered before binding the mesh
  23178. */
  23179. readonly onBeforeBindObservable: Observable<Mesh>;
  23180. /**
  23181. * An event triggered after rendering the mesh
  23182. */
  23183. readonly onAfterRenderObservable: Observable<Mesh>;
  23184. /**
  23185. * An event triggered before drawing the mesh
  23186. */
  23187. readonly onBeforeDrawObservable: Observable<Mesh>;
  23188. private _onBeforeDrawObserver;
  23189. /**
  23190. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23191. */
  23192. onBeforeDraw: () => void;
  23193. readonly hasInstances: boolean;
  23194. /**
  23195. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23196. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23197. */
  23198. delayLoadState: number;
  23199. /**
  23200. * Gets the list of instances created from this mesh
  23201. * it is not supposed to be modified manually.
  23202. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23203. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23204. */
  23205. instances: InstancedMesh[];
  23206. /**
  23207. * Gets the file containing delay loading data for this mesh
  23208. */
  23209. delayLoadingFile: string;
  23210. /** @hidden */ private _binaryInfo: any;
  23211. /**
  23212. * User defined function used to change how LOD level selection is done
  23213. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23214. */
  23215. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23216. /**
  23217. * Gets or sets the morph target manager
  23218. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23219. */
  23220. morphTargetManager: Nullable<MorphTargetManager>;
  23221. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23222. /** @hidden */ private _geometry: Nullable<Geometry>;
  23223. /** @hidden */ private _delayInfo: Array<string>;
  23224. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23225. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23226. private _effectiveMaterial;
  23227. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23228. /** @hidden */ private _originalBuilderSideOrientation: number;
  23229. /**
  23230. * Use this property to change the original side orientation defined at construction time
  23231. */
  23232. overrideMaterialSideOrientation: Nullable<number>;
  23233. /**
  23234. * Gets the source mesh (the one used to clone this one from)
  23235. */
  23236. readonly source: Nullable<Mesh>;
  23237. /**
  23238. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23239. */
  23240. isUnIndexed: boolean;
  23241. /**
  23242. * @constructor
  23243. * @param name The value used by scene.getMeshByName() to do a lookup.
  23244. * @param scene The scene to add this mesh to.
  23245. * @param parent The parent of this mesh, if it has one
  23246. * @param source An optional Mesh from which geometry is shared, cloned.
  23247. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23248. * When false, achieved by calling a clone(), also passing False.
  23249. * This will make creation of children, recursive.
  23250. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23251. */
  23252. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23253. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23254. /**
  23255. * Gets the class name
  23256. * @returns the string "Mesh".
  23257. */
  23258. getClassName(): string;
  23259. /** @hidden */ protected readonly _isMesh: boolean;
  23260. /**
  23261. * Returns a description of this mesh
  23262. * @param fullDetails define if full details about this mesh must be used
  23263. * @returns a descriptive string representing this mesh
  23264. */
  23265. toString(fullDetails?: boolean): string;
  23266. /** @hidden */ private _unBindEffect(): void;
  23267. /**
  23268. * Gets a boolean indicating if this mesh has LOD
  23269. */
  23270. readonly hasLODLevels: boolean;
  23271. /**
  23272. * Gets the list of MeshLODLevel associated with the current mesh
  23273. * @returns an array of MeshLODLevel
  23274. */
  23275. getLODLevels(): MeshLODLevel[];
  23276. private _sortLODLevels;
  23277. /**
  23278. * Add a mesh as LOD level triggered at the given distance.
  23279. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23280. * @param distance The distance from the center of the object to show this level
  23281. * @param mesh The mesh to be added as LOD level (can be null)
  23282. * @return This mesh (for chaining)
  23283. */
  23284. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23285. /**
  23286. * Returns the LOD level mesh at the passed distance or null if not found.
  23287. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23288. * @param distance The distance from the center of the object to show this level
  23289. * @returns a Mesh or `null`
  23290. */
  23291. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23292. /**
  23293. * Remove a mesh from the LOD array
  23294. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23295. * @param mesh defines the mesh to be removed
  23296. * @return This mesh (for chaining)
  23297. */
  23298. removeLODLevel(mesh: Mesh): Mesh;
  23299. /**
  23300. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23301. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23302. * @param camera defines the camera to use to compute distance
  23303. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23304. * @return This mesh (for chaining)
  23305. */
  23306. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23307. /**
  23308. * Gets the mesh internal Geometry object
  23309. */
  23310. readonly geometry: Nullable<Geometry>;
  23311. /**
  23312. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23313. * @returns the total number of vertices
  23314. */
  23315. getTotalVertices(): number;
  23316. /**
  23317. * Returns the content of an associated vertex buffer
  23318. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23319. * - VertexBuffer.PositionKind
  23320. * - VertexBuffer.UVKind
  23321. * - VertexBuffer.UV2Kind
  23322. * - VertexBuffer.UV3Kind
  23323. * - VertexBuffer.UV4Kind
  23324. * - VertexBuffer.UV5Kind
  23325. * - VertexBuffer.UV6Kind
  23326. * - VertexBuffer.ColorKind
  23327. * - VertexBuffer.MatricesIndicesKind
  23328. * - VertexBuffer.MatricesIndicesExtraKind
  23329. * - VertexBuffer.MatricesWeightsKind
  23330. * - VertexBuffer.MatricesWeightsExtraKind
  23331. * @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
  23332. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23333. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23334. */
  23335. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23336. /**
  23337. * Returns the mesh VertexBuffer object from the requested `kind`
  23338. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23339. * - VertexBuffer.PositionKind
  23340. * - VertexBuffer.NormalKind
  23341. * - VertexBuffer.UVKind
  23342. * - VertexBuffer.UV2Kind
  23343. * - VertexBuffer.UV3Kind
  23344. * - VertexBuffer.UV4Kind
  23345. * - VertexBuffer.UV5Kind
  23346. * - VertexBuffer.UV6Kind
  23347. * - VertexBuffer.ColorKind
  23348. * - VertexBuffer.MatricesIndicesKind
  23349. * - VertexBuffer.MatricesIndicesExtraKind
  23350. * - VertexBuffer.MatricesWeightsKind
  23351. * - VertexBuffer.MatricesWeightsExtraKind
  23352. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23353. */
  23354. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23355. /**
  23356. * Tests if a specific vertex buffer is associated with this mesh
  23357. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23358. * - VertexBuffer.PositionKind
  23359. * - VertexBuffer.NormalKind
  23360. * - VertexBuffer.UVKind
  23361. * - VertexBuffer.UV2Kind
  23362. * - VertexBuffer.UV3Kind
  23363. * - VertexBuffer.UV4Kind
  23364. * - VertexBuffer.UV5Kind
  23365. * - VertexBuffer.UV6Kind
  23366. * - VertexBuffer.ColorKind
  23367. * - VertexBuffer.MatricesIndicesKind
  23368. * - VertexBuffer.MatricesIndicesExtraKind
  23369. * - VertexBuffer.MatricesWeightsKind
  23370. * - VertexBuffer.MatricesWeightsExtraKind
  23371. * @returns a boolean
  23372. */
  23373. isVerticesDataPresent(kind: string): boolean;
  23374. /**
  23375. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23376. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23377. * - VertexBuffer.PositionKind
  23378. * - VertexBuffer.UVKind
  23379. * - VertexBuffer.UV2Kind
  23380. * - VertexBuffer.UV3Kind
  23381. * - VertexBuffer.UV4Kind
  23382. * - VertexBuffer.UV5Kind
  23383. * - VertexBuffer.UV6Kind
  23384. * - VertexBuffer.ColorKind
  23385. * - VertexBuffer.MatricesIndicesKind
  23386. * - VertexBuffer.MatricesIndicesExtraKind
  23387. * - VertexBuffer.MatricesWeightsKind
  23388. * - VertexBuffer.MatricesWeightsExtraKind
  23389. * @returns a boolean
  23390. */
  23391. isVertexBufferUpdatable(kind: string): boolean;
  23392. /**
  23393. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23394. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23395. * - VertexBuffer.PositionKind
  23396. * - VertexBuffer.NormalKind
  23397. * - VertexBuffer.UVKind
  23398. * - VertexBuffer.UV2Kind
  23399. * - VertexBuffer.UV3Kind
  23400. * - VertexBuffer.UV4Kind
  23401. * - VertexBuffer.UV5Kind
  23402. * - VertexBuffer.UV6Kind
  23403. * - VertexBuffer.ColorKind
  23404. * - VertexBuffer.MatricesIndicesKind
  23405. * - VertexBuffer.MatricesIndicesExtraKind
  23406. * - VertexBuffer.MatricesWeightsKind
  23407. * - VertexBuffer.MatricesWeightsExtraKind
  23408. * @returns an array of strings
  23409. */
  23410. getVerticesDataKinds(): string[];
  23411. /**
  23412. * Returns a positive integer : the total number of indices in this mesh geometry.
  23413. * @returns the numner of indices or zero if the mesh has no geometry.
  23414. */
  23415. getTotalIndices(): number;
  23416. /**
  23417. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23418. * @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.
  23419. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23420. * @returns the indices array or an empty array if the mesh has no geometry
  23421. */
  23422. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23423. readonly isBlocked: boolean;
  23424. /**
  23425. * Determine if the current mesh is ready to be rendered
  23426. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23427. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23428. * @returns true if all associated assets are ready (material, textures, shaders)
  23429. */
  23430. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23431. /**
  23432. * 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.
  23433. */
  23434. readonly areNormalsFrozen: boolean;
  23435. /**
  23436. * 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.
  23437. * @returns the current mesh
  23438. */
  23439. freezeNormals(): Mesh;
  23440. /**
  23441. * 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
  23442. * @returns the current mesh
  23443. */
  23444. unfreezeNormals(): Mesh;
  23445. /**
  23446. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23447. */
  23448. overridenInstanceCount: number;
  23449. /** @hidden */ private _preActivate(): Mesh;
  23450. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23451. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23452. /**
  23453. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23454. * This means the mesh underlying bounding box and sphere are recomputed.
  23455. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23456. * @returns the current mesh
  23457. */
  23458. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23459. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23460. /**
  23461. * This function will subdivide the mesh into multiple submeshes
  23462. * @param count defines the expected number of submeshes
  23463. */
  23464. subdivide(count: number): void;
  23465. /**
  23466. * Copy a FloatArray into a specific associated vertex buffer
  23467. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23468. * - VertexBuffer.PositionKind
  23469. * - VertexBuffer.UVKind
  23470. * - VertexBuffer.UV2Kind
  23471. * - VertexBuffer.UV3Kind
  23472. * - VertexBuffer.UV4Kind
  23473. * - VertexBuffer.UV5Kind
  23474. * - VertexBuffer.UV6Kind
  23475. * - VertexBuffer.ColorKind
  23476. * - VertexBuffer.MatricesIndicesKind
  23477. * - VertexBuffer.MatricesIndicesExtraKind
  23478. * - VertexBuffer.MatricesWeightsKind
  23479. * - VertexBuffer.MatricesWeightsExtraKind
  23480. * @param data defines the data source
  23481. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23482. * @param stride defines the data stride size (can be null)
  23483. * @returns the current mesh
  23484. */
  23485. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23486. /**
  23487. * Flags an associated vertex buffer as updatable
  23488. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23489. * - VertexBuffer.PositionKind
  23490. * - VertexBuffer.UVKind
  23491. * - VertexBuffer.UV2Kind
  23492. * - VertexBuffer.UV3Kind
  23493. * - VertexBuffer.UV4Kind
  23494. * - VertexBuffer.UV5Kind
  23495. * - VertexBuffer.UV6Kind
  23496. * - VertexBuffer.ColorKind
  23497. * - VertexBuffer.MatricesIndicesKind
  23498. * - VertexBuffer.MatricesIndicesExtraKind
  23499. * - VertexBuffer.MatricesWeightsKind
  23500. * - VertexBuffer.MatricesWeightsExtraKind
  23501. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23502. */
  23503. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23504. /**
  23505. * Sets the mesh global Vertex Buffer
  23506. * @param buffer defines the buffer to use
  23507. * @returns the current mesh
  23508. */
  23509. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23510. /**
  23511. * Update a specific associated vertex buffer
  23512. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23513. * - VertexBuffer.PositionKind
  23514. * - VertexBuffer.UVKind
  23515. * - VertexBuffer.UV2Kind
  23516. * - VertexBuffer.UV3Kind
  23517. * - VertexBuffer.UV4Kind
  23518. * - VertexBuffer.UV5Kind
  23519. * - VertexBuffer.UV6Kind
  23520. * - VertexBuffer.ColorKind
  23521. * - VertexBuffer.MatricesIndicesKind
  23522. * - VertexBuffer.MatricesIndicesExtraKind
  23523. * - VertexBuffer.MatricesWeightsKind
  23524. * - VertexBuffer.MatricesWeightsExtraKind
  23525. * @param data defines the data source
  23526. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23527. * @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)
  23528. * @returns the current mesh
  23529. */
  23530. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23531. /**
  23532. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23533. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23534. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23535. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23536. * @returns the current mesh
  23537. */
  23538. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23539. /**
  23540. * Creates a un-shared specific occurence of the geometry for the mesh.
  23541. * @returns the current mesh
  23542. */
  23543. makeGeometryUnique(): Mesh;
  23544. /**
  23545. * Set the index buffer of this mesh
  23546. * @param indices defines the source data
  23547. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23548. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23549. * @returns the current mesh
  23550. */
  23551. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23552. /**
  23553. * Update the current index buffer
  23554. * @param indices defines the source data
  23555. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23556. * @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)
  23557. * @returns the current mesh
  23558. */
  23559. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23560. /**
  23561. * Invert the geometry to move from a right handed system to a left handed one.
  23562. * @returns the current mesh
  23563. */
  23564. toLeftHanded(): Mesh;
  23565. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23566. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23567. /**
  23568. * Registers for this mesh a javascript function called just before the rendering process
  23569. * @param func defines the function to call before rendering this mesh
  23570. * @returns the current mesh
  23571. */
  23572. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23573. /**
  23574. * Disposes a previously registered javascript function called before the rendering
  23575. * @param func defines the function to remove
  23576. * @returns the current mesh
  23577. */
  23578. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23579. /**
  23580. * Registers for this mesh a javascript function called just after the rendering is complete
  23581. * @param func defines the function to call after rendering this mesh
  23582. * @returns the current mesh
  23583. */
  23584. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23585. /**
  23586. * Disposes a previously registered javascript function called after the rendering.
  23587. * @param func defines the function to remove
  23588. * @returns the current mesh
  23589. */
  23590. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23591. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23592. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23593. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23594. /** @hidden */ private _rebuild(): void;
  23595. /** @hidden */ private _freeze(): void;
  23596. /** @hidden */ private _unFreeze(): void;
  23597. /**
  23598. * 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
  23599. * @param subMesh defines the subMesh to render
  23600. * @param enableAlphaMode defines if alpha mode can be changed
  23601. * @returns the current mesh
  23602. */
  23603. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23604. private _onBeforeDraw;
  23605. /**
  23606. * Renormalize the mesh and patch it up if there are no weights
  23607. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23608. * However in the case of zero weights then we set just a single influence to 1.
  23609. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23610. */
  23611. cleanMatrixWeights(): void;
  23612. private normalizeSkinFourWeights;
  23613. private normalizeSkinWeightsAndExtra;
  23614. /**
  23615. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23616. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23617. * the user know there was an issue with importing the mesh
  23618. * @returns a validation object with skinned, valid and report string
  23619. */
  23620. validateSkinning(): {
  23621. skinned: boolean;
  23622. valid: boolean;
  23623. report: string;
  23624. };
  23625. /** @hidden */ private _checkDelayState(): Mesh;
  23626. private _queueLoad;
  23627. /**
  23628. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23629. * A mesh is in the frustum if its bounding box intersects the frustum
  23630. * @param frustumPlanes defines the frustum to test
  23631. * @returns true if the mesh is in the frustum planes
  23632. */
  23633. isInFrustum(frustumPlanes: Plane[]): boolean;
  23634. /**
  23635. * Sets the mesh material by the material or multiMaterial `id` property
  23636. * @param id is a string identifying the material or the multiMaterial
  23637. * @returns the current mesh
  23638. */
  23639. setMaterialByID(id: string): Mesh;
  23640. /**
  23641. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23642. * @returns an array of IAnimatable
  23643. */
  23644. getAnimatables(): IAnimatable[];
  23645. /**
  23646. * Modifies the mesh geometry according to the passed transformation matrix.
  23647. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23648. * The mesh normals are modified using the same transformation.
  23649. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23650. * @param transform defines the transform matrix to use
  23651. * @see http://doc.babylonjs.com/resources/baking_transformations
  23652. * @returns the current mesh
  23653. */
  23654. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23655. /**
  23656. * Modifies the mesh geometry according to its own current World Matrix.
  23657. * The mesh World Matrix is then reset.
  23658. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23659. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23660. * @see http://doc.babylonjs.com/resources/baking_transformations
  23661. * @returns the current mesh
  23662. */
  23663. bakeCurrentTransformIntoVertices(): Mesh;
  23664. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23665. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23666. /** @hidden */ private _generatePointsArray(): boolean;
  23667. /**
  23668. * Returns a new Mesh object generated from the current mesh properties.
  23669. * This method must not get confused with createInstance()
  23670. * @param name is a string, the name given to the new mesh
  23671. * @param newParent can be any Node object (default `null`)
  23672. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23673. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23674. * @returns a new mesh
  23675. */
  23676. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23677. /**
  23678. * Releases resources associated with this mesh.
  23679. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23680. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23681. */
  23682. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23683. /**
  23684. * Modifies the mesh geometry according to a displacement map.
  23685. * 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.
  23686. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23687. * @param url is a string, the URL from the image file is to be downloaded.
  23688. * @param minHeight is the lower limit of the displacement.
  23689. * @param maxHeight is the upper limit of the displacement.
  23690. * @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.
  23691. * @param uvOffset is an optional vector2 used to offset UV.
  23692. * @param uvScale is an optional vector2 used to scale UV.
  23693. * @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.
  23694. * @returns the Mesh.
  23695. */
  23696. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23697. /**
  23698. * Modifies the mesh geometry according to a displacementMap buffer.
  23699. * 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.
  23700. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23701. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23702. * @param heightMapWidth is the width of the buffer image.
  23703. * @param heightMapHeight is the height of the buffer image.
  23704. * @param minHeight is the lower limit of the displacement.
  23705. * @param maxHeight is the upper limit of the displacement.
  23706. * @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.
  23707. * @param uvOffset is an optional vector2 used to offset UV.
  23708. * @param uvScale is an optional vector2 used to scale UV.
  23709. * @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.
  23710. * @returns the Mesh.
  23711. */
  23712. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23713. /**
  23714. * Modify the mesh to get a flat shading rendering.
  23715. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23716. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23717. * @returns current mesh
  23718. */
  23719. convertToFlatShadedMesh(): Mesh;
  23720. /**
  23721. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23722. * In other words, more vertices, no more indices and a single bigger VBO.
  23723. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23724. * @returns current mesh
  23725. */
  23726. convertToUnIndexedMesh(): Mesh;
  23727. /**
  23728. * Inverses facet orientations.
  23729. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23730. * @param flipNormals will also inverts the normals
  23731. * @returns current mesh
  23732. */
  23733. flipFaces(flipNormals?: boolean): Mesh;
  23734. /**
  23735. * Increase the number of facets and hence vertices in a mesh
  23736. * Vertex normals are interpolated from existing vertex normals
  23737. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23738. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23739. */
  23740. increaseVertices(numberPerEdge: number): void;
  23741. /**
  23742. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23743. * This will undo any application of covertToFlatShadedMesh
  23744. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23745. */
  23746. forceSharedVertices(): void;
  23747. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23748. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23749. /**
  23750. * Creates a new InstancedMesh object from the mesh model.
  23751. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23752. * @param name defines the name of the new instance
  23753. * @returns a new InstancedMesh
  23754. */
  23755. createInstance(name: string): InstancedMesh;
  23756. /**
  23757. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23758. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23759. * @returns the current mesh
  23760. */
  23761. synchronizeInstances(): Mesh;
  23762. /**
  23763. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23764. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23765. * This should be used together with the simplification to avoid disappearing triangles.
  23766. * @param successCallback an optional success callback to be called after the optimization finished.
  23767. * @returns the current mesh
  23768. */
  23769. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23770. /**
  23771. * Serialize current mesh
  23772. * @param serializationObject defines the object which will receive the serialization data
  23773. */
  23774. serialize(serializationObject: any): void;
  23775. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23776. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23777. /**
  23778. * Returns a new Mesh object parsed from the source provided.
  23779. * @param parsedMesh is the source
  23780. * @param scene defines the hosting scene
  23781. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23782. * @returns a new Mesh
  23783. */
  23784. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23785. /**
  23786. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23787. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23788. * @param name defines the name of the mesh to create
  23789. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23790. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23791. * @param closePath creates a seam between the first and the last points of each path of the path array
  23792. * @param offset is taken in account only if the `pathArray` is containing a single path
  23793. * @param scene defines the hosting scene
  23794. * @param updatable defines if the mesh must be flagged as updatable
  23795. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23796. * @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)
  23797. * @returns a new Mesh
  23798. */
  23799. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23800. /**
  23801. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23802. * @param name defines the name of the mesh to create
  23803. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23804. * @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
  23805. * @param scene defines the hosting scene
  23806. * @param updatable defines if the mesh must be flagged as updatable
  23807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23808. * @returns a new Mesh
  23809. */
  23810. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23811. /**
  23812. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23813. * @param name defines the name of the mesh to create
  23814. * @param size sets the size (float) of each box side (default 1)
  23815. * @param scene defines the hosting scene
  23816. * @param updatable defines if the mesh must be flagged as updatable
  23817. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23818. * @returns a new Mesh
  23819. */
  23820. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23821. /**
  23822. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23823. * @param name defines the name of the mesh to create
  23824. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23825. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23826. * @param scene defines the hosting scene
  23827. * @param updatable defines if the mesh must be flagged as updatable
  23828. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23829. * @returns a new Mesh
  23830. */
  23831. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23832. /**
  23833. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  23834. * @param name defines the name of the mesh to create
  23835. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23836. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23837. * @param scene defines the hosting scene
  23838. * @returns a new Mesh
  23839. */
  23840. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  23841. /**
  23842. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  23843. * @param name defines the name of the mesh to create
  23844. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  23845. * @param diameterTop set the top cap diameter (floats, default 1)
  23846. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  23847. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  23848. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  23849. * @param scene defines the hosting scene
  23850. * @param updatable defines if the mesh must be flagged as updatable
  23851. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23852. * @returns a new Mesh
  23853. */
  23854. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  23855. /**
  23856. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  23857. * @param name defines the name of the mesh to create
  23858. * @param diameter sets the diameter size (float) of the torus (default 1)
  23859. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  23860. * @param tessellation sets the number of torus sides (postive integer, default 16)
  23861. * @param scene defines the hosting scene
  23862. * @param updatable defines if the mesh must be flagged as updatable
  23863. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23864. * @returns a new Mesh
  23865. */
  23866. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23867. /**
  23868. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  23869. * @param name defines the name of the mesh to create
  23870. * @param radius sets the global radius size (float) of the torus knot (default 2)
  23871. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  23872. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  23873. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  23874. * @param p the number of windings on X axis (positive integers, default 2)
  23875. * @param q the number of windings on Y axis (positive integers, default 3)
  23876. * @param scene defines the hosting scene
  23877. * @param updatable defines if the mesh must be flagged as updatable
  23878. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23879. * @returns a new Mesh
  23880. */
  23881. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23882. /**
  23883. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  23884. * @param name defines the name of the mesh to create
  23885. * @param points is an array successive Vector3
  23886. * @param scene defines the hosting scene
  23887. * @param updatable defines if the mesh must be flagged as updatable
  23888. * @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).
  23889. * @returns a new Mesh
  23890. */
  23891. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  23892. /**
  23893. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  23894. * @param name defines the name of the mesh to create
  23895. * @param points is an array successive Vector3
  23896. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  23897. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23898. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  23899. * @param scene defines the hosting scene
  23900. * @param updatable defines if the mesh must be flagged as updatable
  23901. * @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)
  23902. * @returns a new Mesh
  23903. */
  23904. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  23905. /**
  23906. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  23907. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  23908. * 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.
  23909. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23910. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23911. * Remember you can only change the shape positions, not their number when updating a polygon.
  23912. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23913. * @param name defines the name of the mesh to create
  23914. * @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
  23915. * @param scene defines the hosting scene
  23916. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23917. * @param updatable defines if the mesh must be flagged as updatable
  23918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23919. * @param earcutInjection can be used to inject your own earcut reference
  23920. * @returns a new Mesh
  23921. */
  23922. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23923. /**
  23924. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  23925. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  23926. * @param name defines the name of the mesh to create
  23927. * @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
  23928. * @param depth defines the height of extrusion
  23929. * @param scene defines the hosting scene
  23930. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23931. * @param updatable defines if the mesh must be flagged as updatable
  23932. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23933. * @param earcutInjection can be used to inject your own earcut reference
  23934. * @returns a new Mesh
  23935. */
  23936. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23937. /**
  23938. * Creates an extruded shape mesh.
  23939. * 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
  23940. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23941. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23942. * @param name defines the name of the mesh to create
  23943. * @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
  23944. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23945. * @param scale is the value to scale the shape
  23946. * @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
  23947. * @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
  23948. * @param scene defines the hosting scene
  23949. * @param updatable defines if the mesh must be flagged as updatable
  23950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23951. * @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)
  23952. * @returns a new Mesh
  23953. */
  23954. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23955. /**
  23956. * Creates an custom extruded shape mesh.
  23957. * The custom extrusion is a parametric shape.
  23958. * It has no predefined shape. Its final shape will depend on the input parameters.
  23959. * Please consider using the same method from the MeshBuilder class instead
  23960. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23961. * @param name defines the name of the mesh to create
  23962. * @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
  23963. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23964. * @param scaleFunction is a custom Javascript function called on each path point
  23965. * @param rotationFunction is a custom Javascript function called on each path point
  23966. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23967. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  23968. * @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
  23969. * @param scene defines the hosting scene
  23970. * @param updatable defines if the mesh must be flagged as updatable
  23971. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23972. * @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)
  23973. * @returns a new Mesh
  23974. */
  23975. 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;
  23976. /**
  23977. * Creates lathe mesh.
  23978. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  23979. * Please consider using the same method from the MeshBuilder class instead
  23980. * @param name defines the name of the mesh to create
  23981. * @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
  23982. * @param radius is the radius value of the lathe
  23983. * @param tessellation is the side number of the lathe.
  23984. * @param scene defines the hosting scene
  23985. * @param updatable defines if the mesh must be flagged as updatable
  23986. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23987. * @returns a new Mesh
  23988. */
  23989. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23990. /**
  23991. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  23992. * @param name defines the name of the mesh to create
  23993. * @param size sets the size (float) of both sides of the plane at once (default 1)
  23994. * @param scene defines the hosting scene
  23995. * @param updatable defines if the mesh must be flagged as updatable
  23996. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23997. * @returns a new Mesh
  23998. */
  23999. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24000. /**
  24001. * Creates a ground mesh.
  24002. * Please consider using the same method from the MeshBuilder class instead
  24003. * @param name defines the name of the mesh to create
  24004. * @param width set the width of the ground
  24005. * @param height set the height of the ground
  24006. * @param subdivisions sets the number of subdivisions per side
  24007. * @param scene defines the hosting scene
  24008. * @param updatable defines if the mesh must be flagged as updatable
  24009. * @returns a new Mesh
  24010. */
  24011. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24012. /**
  24013. * Creates a tiled ground mesh.
  24014. * Please consider using the same method from the MeshBuilder class instead
  24015. * @param name defines the name of the mesh to create
  24016. * @param xmin set the ground minimum X coordinate
  24017. * @param zmin set the ground minimum Y coordinate
  24018. * @param xmax set the ground maximum X coordinate
  24019. * @param zmax set the ground maximum Z coordinate
  24020. * @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
  24021. * @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
  24022. * @param scene defines the hosting scene
  24023. * @param updatable defines if the mesh must be flagged as updatable
  24024. * @returns a new Mesh
  24025. */
  24026. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24027. w: number;
  24028. h: number;
  24029. }, precision: {
  24030. w: number;
  24031. h: number;
  24032. }, scene: Scene, updatable?: boolean): Mesh;
  24033. /**
  24034. * Creates a ground mesh from a height map.
  24035. * Please consider using the same method from the MeshBuilder class instead
  24036. * @see http://doc.babylonjs.com/babylon101/height_map
  24037. * @param name defines the name of the mesh to create
  24038. * @param url sets the URL of the height map image resource
  24039. * @param width set the ground width size
  24040. * @param height set the ground height size
  24041. * @param subdivisions sets the number of subdivision per side
  24042. * @param minHeight is the minimum altitude on the ground
  24043. * @param maxHeight is the maximum altitude on the ground
  24044. * @param scene defines the hosting scene
  24045. * @param updatable defines if the mesh must be flagged as updatable
  24046. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24047. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24048. * @returns a new Mesh
  24049. */
  24050. 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;
  24051. /**
  24052. * Creates a tube mesh.
  24053. * The tube is a parametric shape.
  24054. * It has no predefined shape. Its final shape will depend on the input parameters.
  24055. * Please consider using the same method from the MeshBuilder class instead
  24056. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24057. * @param name defines the name of the mesh to create
  24058. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24059. * @param radius sets the tube radius size
  24060. * @param tessellation is the number of sides on the tubular surface
  24061. * @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
  24062. * @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
  24063. * @param scene defines the hosting scene
  24064. * @param updatable defines if the mesh must be flagged as updatable
  24065. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24066. * @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)
  24067. * @returns a new Mesh
  24068. */
  24069. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24070. (i: number, distance: number): number;
  24071. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24072. /**
  24073. * Creates a polyhedron mesh.
  24074. * Please consider using the same method from the MeshBuilder class instead.
  24075. * * 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
  24076. * * The parameter `size` (positive float, default 1) sets the polygon size
  24077. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24078. * * 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`
  24079. * * 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
  24080. * * 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)`)
  24081. * * 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
  24082. * * 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
  24083. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24084. * * 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
  24085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24086. * @param name defines the name of the mesh to create
  24087. * @param options defines the options used to create the mesh
  24088. * @param scene defines the hosting scene
  24089. * @returns a new Mesh
  24090. */
  24091. static CreatePolyhedron(name: string, options: {
  24092. type?: number;
  24093. size?: number;
  24094. sizeX?: number;
  24095. sizeY?: number;
  24096. sizeZ?: number;
  24097. custom?: any;
  24098. faceUV?: Vector4[];
  24099. faceColors?: Color4[];
  24100. updatable?: boolean;
  24101. sideOrientation?: number;
  24102. }, scene: Scene): Mesh;
  24103. /**
  24104. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24105. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24106. * * 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`)
  24107. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24108. * * 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
  24109. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24110. * * 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
  24111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24112. * @param name defines the name of the mesh
  24113. * @param options defines the options used to create the mesh
  24114. * @param scene defines the hosting scene
  24115. * @returns a new Mesh
  24116. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24117. */
  24118. static CreateIcoSphere(name: string, options: {
  24119. radius?: number;
  24120. flat?: boolean;
  24121. subdivisions?: number;
  24122. sideOrientation?: number;
  24123. updatable?: boolean;
  24124. }, scene: Scene): Mesh;
  24125. /**
  24126. * Creates a decal mesh.
  24127. * Please consider using the same method from the MeshBuilder class instead.
  24128. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24129. * @param name defines the name of the mesh
  24130. * @param sourceMesh defines the mesh receiving the decal
  24131. * @param position sets the position of the decal in world coordinates
  24132. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24133. * @param size sets the decal scaling
  24134. * @param angle sets the angle to rotate the decal
  24135. * @returns a new Mesh
  24136. */
  24137. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24138. /**
  24139. * Prepare internal position array for software CPU skinning
  24140. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24141. */
  24142. setPositionsForCPUSkinning(): Float32Array;
  24143. /**
  24144. * Prepare internal normal array for software CPU skinning
  24145. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24146. */
  24147. setNormalsForCPUSkinning(): Float32Array;
  24148. /**
  24149. * Updates the vertex buffer by applying transformation from the bones
  24150. * @param skeleton defines the skeleton to apply to current mesh
  24151. * @returns the current mesh
  24152. */
  24153. applySkeleton(skeleton: Skeleton): Mesh;
  24154. /**
  24155. * 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
  24156. * @param meshes defines the list of meshes to scan
  24157. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24158. */
  24159. static MinMax(meshes: AbstractMesh[]): {
  24160. min: Vector3;
  24161. max: Vector3;
  24162. };
  24163. /**
  24164. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24165. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24166. * @returns a vector3
  24167. */
  24168. static Center(meshesOrMinMaxVector: {
  24169. min: Vector3;
  24170. max: Vector3;
  24171. } | AbstractMesh[]): Vector3;
  24172. /**
  24173. * Merge the array of meshes into a single mesh for performance reasons.
  24174. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24175. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24176. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24177. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24178. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24179. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24180. * @returns a new mesh
  24181. */
  24182. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24183. /** @hidden */
  24184. addInstance(instance: InstancedMesh): void;
  24185. /** @hidden */
  24186. removeInstance(instance: InstancedMesh): void;
  24187. }
  24188. }
  24189. declare module BABYLON {
  24190. /**
  24191. * This is the base class of all the camera used in the application.
  24192. * @see http://doc.babylonjs.com/features/cameras
  24193. */
  24194. export class Camera extends Node {
  24195. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24196. /**
  24197. * This is the default projection mode used by the cameras.
  24198. * It helps recreating a feeling of perspective and better appreciate depth.
  24199. * This is the best way to simulate real life cameras.
  24200. */
  24201. static readonly PERSPECTIVE_CAMERA: number;
  24202. /**
  24203. * This helps creating camera with an orthographic mode.
  24204. * 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.
  24205. */
  24206. static readonly ORTHOGRAPHIC_CAMERA: number;
  24207. /**
  24208. * This is the default FOV mode for perspective cameras.
  24209. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24210. */
  24211. static readonly FOVMODE_VERTICAL_FIXED: number;
  24212. /**
  24213. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24214. */
  24215. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24216. /**
  24217. * This specifies ther is no need for a camera rig.
  24218. * Basically only one eye is rendered corresponding to the camera.
  24219. */
  24220. static readonly RIG_MODE_NONE: number;
  24221. /**
  24222. * Simulates a camera Rig with one blue eye and one red eye.
  24223. * This can be use with 3d blue and red glasses.
  24224. */
  24225. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24226. /**
  24227. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24228. */
  24229. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24230. /**
  24231. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24232. */
  24233. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24234. /**
  24235. * Defines that both eyes of the camera will be rendered over under each other.
  24236. */
  24237. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24238. /**
  24239. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24240. */
  24241. static readonly RIG_MODE_VR: number;
  24242. /**
  24243. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24244. */
  24245. static readonly RIG_MODE_WEBVR: number;
  24246. /**
  24247. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24248. */
  24249. static readonly RIG_MODE_CUSTOM: number;
  24250. /**
  24251. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24252. */
  24253. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24254. /**
  24255. * Define the input manager associated with the camera.
  24256. */
  24257. inputs: CameraInputsManager<Camera>;
  24258. /** @hidden */ private _position: Vector3;
  24259. /**
  24260. * Define the current local position of the camera in the scene
  24261. */
  24262. position: Vector3;
  24263. /**
  24264. * The vector the camera should consider as up.
  24265. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24266. */
  24267. upVector: Vector3;
  24268. /**
  24269. * Define the current limit on the left side for an orthographic camera
  24270. * In scene unit
  24271. */
  24272. orthoLeft: Nullable<number>;
  24273. /**
  24274. * Define the current limit on the right side for an orthographic camera
  24275. * In scene unit
  24276. */
  24277. orthoRight: Nullable<number>;
  24278. /**
  24279. * Define the current limit on the bottom side for an orthographic camera
  24280. * In scene unit
  24281. */
  24282. orthoBottom: Nullable<number>;
  24283. /**
  24284. * Define the current limit on the top side for an orthographic camera
  24285. * In scene unit
  24286. */
  24287. orthoTop: Nullable<number>;
  24288. /**
  24289. * Field Of View is set in Radians. (default is 0.8)
  24290. */
  24291. fov: number;
  24292. /**
  24293. * Define the minimum distance the camera can see from.
  24294. * This is important to note that the depth buffer are not infinite and the closer it starts
  24295. * the more your scene might encounter depth fighting issue.
  24296. */
  24297. minZ: number;
  24298. /**
  24299. * Define the maximum distance the camera can see to.
  24300. * This is important to note that the depth buffer are not infinite and the further it end
  24301. * the more your scene might encounter depth fighting issue.
  24302. */
  24303. maxZ: number;
  24304. /**
  24305. * Define the default inertia of the camera.
  24306. * This helps giving a smooth feeling to the camera movement.
  24307. */
  24308. inertia: number;
  24309. /**
  24310. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24311. */
  24312. mode: number;
  24313. /**
  24314. * Define wether the camera is intermediate.
  24315. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24316. */
  24317. isIntermediate: boolean;
  24318. /**
  24319. * Define the viewport of the camera.
  24320. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24321. */
  24322. viewport: Viewport;
  24323. /**
  24324. * Restricts the camera to viewing objects with the same layerMask.
  24325. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24326. */
  24327. layerMask: number;
  24328. /**
  24329. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24330. */
  24331. fovMode: number;
  24332. /**
  24333. * Rig mode of the camera.
  24334. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24335. * This is normally controlled byt the camera themselves as internal use.
  24336. */
  24337. cameraRigMode: number;
  24338. /**
  24339. * Defines the distance between both "eyes" in case of a RIG
  24340. */
  24341. interaxialDistance: number;
  24342. /**
  24343. * Defines if stereoscopic rendering is done side by side or over under.
  24344. */
  24345. isStereoscopicSideBySide: boolean;
  24346. /**
  24347. * 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
  24348. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24349. * else in the scene. (Eg. security camera)
  24350. *
  24351. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24352. */
  24353. customRenderTargets: RenderTargetTexture[];
  24354. /**
  24355. * When set, the camera will render to this render target instead of the default canvas
  24356. *
  24357. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24358. */
  24359. outputRenderTarget: Nullable<RenderTargetTexture>;
  24360. /**
  24361. * Observable triggered when the camera view matrix has changed.
  24362. */
  24363. onViewMatrixChangedObservable: Observable<Camera>;
  24364. /**
  24365. * Observable triggered when the camera Projection matrix has changed.
  24366. */
  24367. onProjectionMatrixChangedObservable: Observable<Camera>;
  24368. /**
  24369. * Observable triggered when the inputs have been processed.
  24370. */
  24371. onAfterCheckInputsObservable: Observable<Camera>;
  24372. /**
  24373. * Observable triggered when reset has been called and applied to the camera.
  24374. */
  24375. onRestoreStateObservable: Observable<Camera>;
  24376. /** @hidden */ private _cameraRigParams: any;
  24377. /** @hidden */ private _rigCameras: Camera[];
  24378. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24379. protected _webvrViewMatrix: Matrix;
  24380. /** @hidden */ private _skipRendering: boolean;
  24381. /** @hidden */ private _projectionMatrix: Matrix;
  24382. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24383. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24384. protected _globalPosition: Vector3;
  24385. /** @hidden */ private _computedViewMatrix: Matrix;
  24386. private _doNotComputeProjectionMatrix;
  24387. private _transformMatrix;
  24388. private _frustumPlanes;
  24389. private _refreshFrustumPlanes;
  24390. private _storedFov;
  24391. private _stateStored;
  24392. /**
  24393. * Instantiates a new camera object.
  24394. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24395. * @see http://doc.babylonjs.com/features/cameras
  24396. * @param name Defines the name of the camera in the scene
  24397. * @param position Defines the position of the camera
  24398. * @param scene Defines the scene the camera belongs too
  24399. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24400. */
  24401. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24402. /**
  24403. * Store current camera state (fov, position, etc..)
  24404. * @returns the camera
  24405. */
  24406. storeState(): Camera;
  24407. /**
  24408. * Restores the camera state values if it has been stored. You must call storeState() first
  24409. */
  24410. protected _restoreStateValues(): boolean;
  24411. /**
  24412. * Restored camera state. You must call storeState() first.
  24413. * @returns true if restored and false otherwise
  24414. */
  24415. restoreState(): boolean;
  24416. /**
  24417. * Gets the class name of the camera.
  24418. * @returns the class name
  24419. */
  24420. getClassName(): string;
  24421. /** @hidden */ protected readonly _isCamera: boolean;
  24422. /**
  24423. * Gets a string representation of the camera useful for debug purpose.
  24424. * @param fullDetails Defines that a more verboe level of logging is required
  24425. * @returns the string representation
  24426. */
  24427. toString(fullDetails?: boolean): string;
  24428. /**
  24429. * Gets the current world space position of the camera.
  24430. */
  24431. readonly globalPosition: Vector3;
  24432. /**
  24433. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24434. * @returns the active meshe list
  24435. */
  24436. getActiveMeshes(): SmartArray<AbstractMesh>;
  24437. /**
  24438. * Check wether a mesh is part of the current active mesh list of the camera
  24439. * @param mesh Defines the mesh to check
  24440. * @returns true if active, false otherwise
  24441. */
  24442. isActiveMesh(mesh: Mesh): boolean;
  24443. /**
  24444. * Is this camera ready to be used/rendered
  24445. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24446. * @return true if the camera is ready
  24447. */
  24448. isReady(completeCheck?: boolean): boolean;
  24449. /** @hidden */ private _initCache(): void;
  24450. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24451. /** @hidden */ private _isSynchronized(): boolean;
  24452. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24453. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24454. /**
  24455. * Attach the input controls to a specific dom element to get the input from.
  24456. * @param element Defines the element the controls should be listened from
  24457. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24458. */
  24459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24460. /**
  24461. * Detach the current controls from the specified dom element.
  24462. * @param element Defines the element to stop listening the inputs from
  24463. */
  24464. detachControl(element: HTMLElement): void;
  24465. /**
  24466. * Update the camera state according to the different inputs gathered during the frame.
  24467. */
  24468. update(): void;
  24469. /** @hidden */ private _checkInputs(): void;
  24470. /** @hidden */
  24471. readonly rigCameras: Camera[];
  24472. /**
  24473. * Gets the post process used by the rig cameras
  24474. */
  24475. readonly rigPostProcess: Nullable<PostProcess>;
  24476. /**
  24477. * Internal, gets the first post proces.
  24478. * @returns the first post process to be run on this camera.
  24479. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24480. private _cascadePostProcessesToRigCams;
  24481. /**
  24482. * Attach a post process to the camera.
  24483. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24484. * @param postProcess The post process to attach to the camera
  24485. * @param insertAt The position of the post process in case several of them are in use in the scene
  24486. * @returns the position the post process has been inserted at
  24487. */
  24488. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24489. /**
  24490. * Detach a post process to the camera.
  24491. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24492. * @param postProcess The post process to detach from the camera
  24493. */
  24494. detachPostProcess(postProcess: PostProcess): void;
  24495. /**
  24496. * Gets the current world matrix of the camera
  24497. */
  24498. getWorldMatrix(): Matrix;
  24499. /** @hidden */ private _getViewMatrix(): Matrix;
  24500. /**
  24501. * Gets the current view matrix of the camera.
  24502. * @param force forces the camera to recompute the matrix without looking at the cached state
  24503. * @returns the view matrix
  24504. */
  24505. getViewMatrix(force?: boolean): Matrix;
  24506. /**
  24507. * Freeze the projection matrix.
  24508. * It will prevent the cache check of the camera projection compute and can speed up perf
  24509. * if no parameter of the camera are meant to change
  24510. * @param projection Defines manually a projection if necessary
  24511. */
  24512. freezeProjectionMatrix(projection?: Matrix): void;
  24513. /**
  24514. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24515. */
  24516. unfreezeProjectionMatrix(): void;
  24517. /**
  24518. * Gets the current projection matrix of the camera.
  24519. * @param force forces the camera to recompute the matrix without looking at the cached state
  24520. * @returns the projection matrix
  24521. */
  24522. getProjectionMatrix(force?: boolean): Matrix;
  24523. /**
  24524. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24525. * @returns a Matrix
  24526. */
  24527. getTransformationMatrix(): Matrix;
  24528. private _updateFrustumPlanes;
  24529. /**
  24530. * Checks if a cullable object (mesh...) is in the camera frustum
  24531. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24532. * @param target The object to check
  24533. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24534. * @returns true if the object is in frustum otherwise false
  24535. */
  24536. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24537. /**
  24538. * Checks if a cullable object (mesh...) is in the camera frustum
  24539. * Unlike isInFrustum this cheks the full bounding box
  24540. * @param target The object to check
  24541. * @returns true if the object is in frustum otherwise false
  24542. */
  24543. isCompletelyInFrustum(target: ICullable): boolean;
  24544. /**
  24545. * Gets a ray in the forward direction from the camera.
  24546. * @param length Defines the length of the ray to create
  24547. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24548. * @param origin Defines the start point of the ray which defaults to the camera position
  24549. * @returns the forward ray
  24550. */
  24551. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24552. /**
  24553. * Releases resources associated with this node.
  24554. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24555. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24556. */
  24557. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24558. /** @hidden */ private _isLeftCamera: boolean;
  24559. /**
  24560. * Gets the left camera of a rig setup in case of Rigged Camera
  24561. */
  24562. readonly isLeftCamera: boolean;
  24563. /** @hidden */ private _isRightCamera: boolean;
  24564. /**
  24565. * Gets the right camera of a rig setup in case of Rigged Camera
  24566. */
  24567. readonly isRightCamera: boolean;
  24568. /**
  24569. * Gets the left camera of a rig setup in case of Rigged Camera
  24570. */
  24571. readonly leftCamera: Nullable<FreeCamera>;
  24572. /**
  24573. * Gets the right camera of a rig setup in case of Rigged Camera
  24574. */
  24575. readonly rightCamera: Nullable<FreeCamera>;
  24576. /**
  24577. * Gets the left camera target of a rig setup in case of Rigged Camera
  24578. * @returns the target position
  24579. */
  24580. getLeftTarget(): Nullable<Vector3>;
  24581. /**
  24582. * Gets the right camera target of a rig setup in case of Rigged Camera
  24583. * @returns the target position
  24584. */
  24585. getRightTarget(): Nullable<Vector3>;
  24586. /**
  24587. * @hidden
  24588. */
  24589. setCameraRigMode(mode: number, rigParams: any): void;
  24590. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24591. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24592. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24593. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24594. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24595. protected _updateCameraRotationMatrix(): void;
  24596. protected _updateWebVRCameraRotationMatrix(): void;
  24597. /**
  24598. * This function MUST be overwritten by the different WebVR cameras available.
  24599. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24600. * @hidden
  24601. */ private _getWebVRProjectionMatrix(): Matrix;
  24602. /**
  24603. * This function MUST be overwritten by the different WebVR cameras available.
  24604. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24605. * @hidden
  24606. */ private _getWebVRViewMatrix(): Matrix;
  24607. /** @hidden */
  24608. setCameraRigParameter(name: string, value: any): void;
  24609. /**
  24610. * needs to be overridden by children so sub has required properties to be copied
  24611. * @hidden
  24612. */
  24613. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24614. /**
  24615. * May need to be overridden by children
  24616. * @hidden
  24617. */ private _updateRigCameras(): void;
  24618. /** @hidden */ private _setupInputs(): void;
  24619. /**
  24620. * Serialiaze the camera setup to a json represention
  24621. * @returns the JSON representation
  24622. */
  24623. serialize(): any;
  24624. /**
  24625. * Clones the current camera.
  24626. * @param name The cloned camera name
  24627. * @returns the cloned camera
  24628. */
  24629. clone(name: string): Camera;
  24630. /**
  24631. * Gets the direction of the camera relative to a given local axis.
  24632. * @param localAxis Defines the reference axis to provide a relative direction.
  24633. * @return the direction
  24634. */
  24635. getDirection(localAxis: Vector3): Vector3;
  24636. /**
  24637. * Returns the current camera absolute rotation
  24638. */
  24639. readonly absoluteRotation: Quaternion;
  24640. /**
  24641. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24642. * @param localAxis Defines the reference axis to provide a relative direction.
  24643. * @param result Defines the vector to store the result in
  24644. */
  24645. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24646. /**
  24647. * Gets a camera constructor for a given camera type
  24648. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24649. * @param name The name of the camera the result will be able to instantiate
  24650. * @param scene The scene the result will construct the camera in
  24651. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24652. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24653. * @returns a factory method to construc the camera
  24654. */
  24655. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24656. /**
  24657. * Compute the world matrix of the camera.
  24658. * @returns the camera workd matrix
  24659. */
  24660. computeWorldMatrix(): Matrix;
  24661. /**
  24662. * Parse a JSON and creates the camera from the parsed information
  24663. * @param parsedCamera The JSON to parse
  24664. * @param scene The scene to instantiate the camera in
  24665. * @returns the newly constructed camera
  24666. */
  24667. static Parse(parsedCamera: any, scene: Scene): Camera;
  24668. }
  24669. }
  24670. declare module BABYLON {
  24671. /**
  24672. * Class containing static functions to help procedurally build meshes
  24673. */
  24674. export class DiscBuilder {
  24675. /**
  24676. * Creates a plane polygonal mesh. By default, this is a disc
  24677. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24678. * * 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
  24679. * * 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
  24680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24681. * * 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
  24682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24683. * @param name defines the name of the mesh
  24684. * @param options defines the options used to create the mesh
  24685. * @param scene defines the hosting scene
  24686. * @returns the plane polygonal mesh
  24687. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24688. */
  24689. static CreateDisc(name: string, options: {
  24690. radius?: number;
  24691. tessellation?: number;
  24692. arc?: number;
  24693. updatable?: boolean;
  24694. sideOrientation?: number;
  24695. frontUVs?: Vector4;
  24696. backUVs?: Vector4;
  24697. }, scene?: Nullable<Scene>): Mesh;
  24698. }
  24699. }
  24700. declare module BABYLON {
  24701. /**
  24702. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24703. *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.
  24704. * The SPS is also a particle system. It provides some methods to manage the particles.
  24705. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24706. *
  24707. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24708. */
  24709. export class SolidParticleSystem implements IDisposable {
  24710. /**
  24711. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24712. * Example : var p = SPS.particles[i];
  24713. */
  24714. particles: SolidParticle[];
  24715. /**
  24716. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24717. */
  24718. nbParticles: number;
  24719. /**
  24720. * If the particles must ever face the camera (default false). Useful for planar particles.
  24721. */
  24722. billboard: boolean;
  24723. /**
  24724. * Recompute normals when adding a shape
  24725. */
  24726. recomputeNormals: boolean;
  24727. /**
  24728. * This a counter ofr your own usage. It's not set by any SPS functions.
  24729. */
  24730. counter: number;
  24731. /**
  24732. * The SPS name. This name is also given to the underlying mesh.
  24733. */
  24734. name: string;
  24735. /**
  24736. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24737. */
  24738. mesh: Mesh;
  24739. /**
  24740. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24741. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24742. */
  24743. vars: any;
  24744. /**
  24745. * This array is populated when the SPS is set as 'pickable'.
  24746. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24747. * Each element of this array is an object `{idx: int, faceId: int}`.
  24748. * `idx` is the picked particle index in the `SPS.particles` array
  24749. * `faceId` is the picked face index counted within this particle.
  24750. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24751. */
  24752. pickedParticles: {
  24753. idx: number;
  24754. faceId: number;
  24755. }[];
  24756. /**
  24757. * This array is populated when `enableDepthSort` is set to true.
  24758. * Each element of this array is an instance of the class DepthSortedParticle.
  24759. */
  24760. depthSortedParticles: DepthSortedParticle[];
  24761. /**
  24762. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24763. * @hidden
  24764. */ private _bSphereOnly: boolean;
  24765. /**
  24766. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24767. * @hidden
  24768. */ private _bSphereRadiusFactor: number;
  24769. private _scene;
  24770. private _positions;
  24771. private _indices;
  24772. private _normals;
  24773. private _colors;
  24774. private _uvs;
  24775. private _indices32;
  24776. private _positions32;
  24777. private _normals32;
  24778. private _fixedNormal32;
  24779. private _colors32;
  24780. private _uvs32;
  24781. private _index;
  24782. private _updatable;
  24783. private _pickable;
  24784. private _isVisibilityBoxLocked;
  24785. private _alwaysVisible;
  24786. private _depthSort;
  24787. private _shapeCounter;
  24788. private _copy;
  24789. private _color;
  24790. private _computeParticleColor;
  24791. private _computeParticleTexture;
  24792. private _computeParticleRotation;
  24793. private _computeParticleVertex;
  24794. private _computeBoundingBox;
  24795. private _depthSortParticles;
  24796. private _camera;
  24797. private _mustUnrotateFixedNormals;
  24798. private _particlesIntersect;
  24799. private _needs32Bits;
  24800. /**
  24801. * Creates a SPS (Solid Particle System) object.
  24802. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24803. * @param scene (Scene) is the scene in which the SPS is added.
  24804. * @param options defines the options of the sps e.g.
  24805. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24806. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24807. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24808. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24809. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24810. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24811. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24812. */
  24813. constructor(name: string, scene: Scene, options?: {
  24814. updatable?: boolean;
  24815. isPickable?: boolean;
  24816. enableDepthSort?: boolean;
  24817. particleIntersection?: boolean;
  24818. boundingSphereOnly?: boolean;
  24819. bSphereRadiusFactor?: number;
  24820. });
  24821. /**
  24822. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24823. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24824. * @returns the created mesh
  24825. */
  24826. buildMesh(): Mesh;
  24827. /**
  24828. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24829. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24830. * Thus the particles generated from `digest()` have their property `position` set yet.
  24831. * @param mesh ( Mesh ) is the mesh to be digested
  24832. * @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
  24833. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24834. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24835. * @returns the current SPS
  24836. */
  24837. digest(mesh: Mesh, options?: {
  24838. facetNb?: number;
  24839. number?: number;
  24840. delta?: number;
  24841. }): SolidParticleSystem;
  24842. private _unrotateFixedNormals;
  24843. private _resetCopy;
  24844. private _meshBuilder;
  24845. private _posToShape;
  24846. private _uvsToShapeUV;
  24847. private _addParticle;
  24848. /**
  24849. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24850. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  24851. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24852. * @param nb (positive integer) the number of particles to be created from this model
  24853. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24854. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24855. * @returns the number of shapes in the system
  24856. */
  24857. addShape(mesh: Mesh, nb: number, options?: {
  24858. positionFunction?: any;
  24859. vertexFunction?: any;
  24860. }): number;
  24861. private _rebuildParticle;
  24862. /**
  24863. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24864. * @returns the SPS.
  24865. */
  24866. rebuildMesh(): SolidParticleSystem;
  24867. /**
  24868. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24869. * This method calls `updateParticle()` for each particle of the SPS.
  24870. * For an animated SPS, it is usually called within the render loop.
  24871. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24872. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24873. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24874. * @returns the SPS.
  24875. */
  24876. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24877. /**
  24878. * Disposes the SPS.
  24879. */
  24880. dispose(): void;
  24881. /**
  24882. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24883. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24884. * @returns the SPS.
  24885. */
  24886. refreshVisibleSize(): SolidParticleSystem;
  24887. /**
  24888. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24889. * @param size the size (float) of the visibility box
  24890. * note : this doesn't lock the SPS mesh bounding box.
  24891. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24892. */
  24893. setVisibilityBox(size: number): void;
  24894. /**
  24895. * Gets whether the SPS as always visible or not
  24896. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24897. */
  24898. /**
  24899. * Sets the SPS as always visible or not
  24900. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24901. */
  24902. isAlwaysVisible: boolean;
  24903. /**
  24904. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24905. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24906. */
  24907. /**
  24908. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24909. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24910. */
  24911. isVisibilityBoxLocked: boolean;
  24912. /**
  24913. * Tells to `setParticles()` to compute the particle rotations or not.
  24914. * Default value : true. The SPS is faster when it's set to false.
  24915. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24916. */
  24917. /**
  24918. * Gets if `setParticles()` computes the particle rotations or not.
  24919. * Default value : true. The SPS is faster when it's set to false.
  24920. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24921. */
  24922. computeParticleRotation: boolean;
  24923. /**
  24924. * Tells to `setParticles()` to compute the particle colors or not.
  24925. * Default value : true. The SPS is faster when it's set to false.
  24926. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24927. */
  24928. /**
  24929. * Gets if `setParticles()` computes the particle colors or not.
  24930. * Default value : true. The SPS is faster when it's set to false.
  24931. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24932. */
  24933. computeParticleColor: boolean;
  24934. /**
  24935. * Gets if `setParticles()` computes the particle textures or not.
  24936. * Default value : true. The SPS is faster when it's set to false.
  24937. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24938. */
  24939. computeParticleTexture: boolean;
  24940. /**
  24941. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24942. * Default value : false. The SPS is faster when it's set to false.
  24943. * Note : the particle custom vertex positions aren't stored values.
  24944. */
  24945. /**
  24946. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24947. * Default value : false. The SPS is faster when it's set to false.
  24948. * Note : the particle custom vertex positions aren't stored values.
  24949. */
  24950. computeParticleVertex: boolean;
  24951. /**
  24952. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24953. */
  24954. /**
  24955. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24956. */
  24957. computeBoundingBox: boolean;
  24958. /**
  24959. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24960. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24961. * Default : `true`
  24962. */
  24963. /**
  24964. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24965. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24966. * Default : `true`
  24967. */
  24968. depthSortParticles: boolean;
  24969. /**
  24970. * This function does nothing. It may be overwritten to set all the particle first values.
  24971. * The SPS doesn't call this function, you may have to call it by your own.
  24972. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24973. */
  24974. initParticles(): void;
  24975. /**
  24976. * This function does nothing. It may be overwritten to recycle a particle.
  24977. * The SPS doesn't call this function, you may have to call it by your own.
  24978. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24979. * @param particle The particle to recycle
  24980. * @returns the recycled particle
  24981. */
  24982. recycleParticle(particle: SolidParticle): SolidParticle;
  24983. /**
  24984. * Updates a particle : this function should be overwritten by the user.
  24985. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24986. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24987. * @example : just set a particle position or velocity and recycle conditions
  24988. * @param particle The particle to update
  24989. * @returns the updated particle
  24990. */
  24991. updateParticle(particle: SolidParticle): SolidParticle;
  24992. /**
  24993. * Updates a vertex of a particle : it can be overwritten by the user.
  24994. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24995. * @param particle the current particle
  24996. * @param vertex the current index of the current particle
  24997. * @param pt the index of the current vertex in the particle shape
  24998. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  24999. * @example : just set a vertex particle position
  25000. * @returns the updated vertex
  25001. */
  25002. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25003. /**
  25004. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25005. * This does nothing and may be overwritten by the user.
  25006. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25007. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25008. * @param update the boolean update value actually passed to setParticles()
  25009. */
  25010. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25011. /**
  25012. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25013. * This will be passed three parameters.
  25014. * This does nothing and may be overwritten by the user.
  25015. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25016. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25017. * @param update the boolean update value actually passed to setParticles()
  25018. */
  25019. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25020. }
  25021. }
  25022. declare module BABYLON {
  25023. /**
  25024. * Represents one particle of a solid particle system.
  25025. */
  25026. export class SolidParticle {
  25027. /**
  25028. * particle global index
  25029. */
  25030. idx: number;
  25031. /**
  25032. * The color of the particle
  25033. */
  25034. color: Nullable<Color4>;
  25035. /**
  25036. * The world space position of the particle.
  25037. */
  25038. position: Vector3;
  25039. /**
  25040. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25041. */
  25042. rotation: Vector3;
  25043. /**
  25044. * The world space rotation quaternion of the particle.
  25045. */
  25046. rotationQuaternion: Nullable<Quaternion>;
  25047. /**
  25048. * The scaling of the particle.
  25049. */
  25050. scaling: Vector3;
  25051. /**
  25052. * The uvs of the particle.
  25053. */
  25054. uvs: Vector4;
  25055. /**
  25056. * The current speed of the particle.
  25057. */
  25058. velocity: Vector3;
  25059. /**
  25060. * The pivot point in the particle local space.
  25061. */
  25062. pivot: Vector3;
  25063. /**
  25064. * Must the particle be translated from its pivot point in its local space ?
  25065. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25066. * Default : false
  25067. */
  25068. translateFromPivot: boolean;
  25069. /**
  25070. * Is the particle active or not ?
  25071. */
  25072. alive: boolean;
  25073. /**
  25074. * Is the particle visible or not ?
  25075. */
  25076. isVisible: boolean;
  25077. /**
  25078. * Index of this particle in the global "positions" array (Internal use)
  25079. * @hidden
  25080. */ private _pos: number;
  25081. /**
  25082. * @hidden Index of this particle in the global "indices" array (Internal use)
  25083. */ private _ind: number;
  25084. /**
  25085. * @hidden ModelShape of this particle (Internal use)
  25086. */ private _model: ModelShape;
  25087. /**
  25088. * ModelShape id of this particle
  25089. */
  25090. shapeId: number;
  25091. /**
  25092. * Index of the particle in its shape id
  25093. */
  25094. idxInShape: number;
  25095. /**
  25096. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25097. */ private _modelBoundingInfo: BoundingInfo;
  25098. /**
  25099. * @hidden Particle BoundingInfo object (Internal use)
  25100. */ private _boundingInfo: BoundingInfo;
  25101. /**
  25102. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25103. */ private _sps: SolidParticleSystem;
  25104. /**
  25105. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25106. */ private _stillInvisible: boolean;
  25107. /**
  25108. * @hidden Last computed particle rotation matrix
  25109. */ private _rotationMatrix: number[];
  25110. /**
  25111. * Parent particle Id, if any.
  25112. * Default null.
  25113. */
  25114. parentId: Nullable<number>;
  25115. /**
  25116. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25117. * The possible values are :
  25118. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25119. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25120. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25121. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25122. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25123. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25124. * */
  25125. cullingStrategy: number;
  25126. /**
  25127. * @hidden Internal global position in the SPS.
  25128. */ private _globalPosition: Vector3;
  25129. /**
  25130. * Creates a Solid Particle object.
  25131. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25132. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25133. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25134. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25135. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25136. * @param shapeId (integer) is the model shape identifier in the SPS.
  25137. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25138. * @param sps defines the sps it is associated to
  25139. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25140. */
  25141. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25142. /**
  25143. * Legacy support, changed scale to scaling
  25144. */
  25145. /**
  25146. * Legacy support, changed scale to scaling
  25147. */
  25148. scale: Vector3;
  25149. /**
  25150. * Legacy support, changed quaternion to rotationQuaternion
  25151. */
  25152. /**
  25153. * Legacy support, changed quaternion to rotationQuaternion
  25154. */
  25155. quaternion: Nullable<Quaternion>;
  25156. /**
  25157. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25158. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25159. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25160. * @returns true if it intersects
  25161. */
  25162. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25163. /**
  25164. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25165. * A particle is in the frustum if its bounding box intersects the frustum
  25166. * @param frustumPlanes defines the frustum to test
  25167. * @returns true if the particle is in the frustum planes
  25168. */
  25169. isInFrustum(frustumPlanes: Plane[]): boolean;
  25170. /**
  25171. * get the rotation matrix of the particle
  25172. * @hidden
  25173. */
  25174. getRotationMatrix(m: Matrix): void;
  25175. }
  25176. /**
  25177. * Represents the shape of the model used by one particle of a solid particle system.
  25178. * SPS internal tool, don't use it manually.
  25179. */
  25180. export class ModelShape {
  25181. /**
  25182. * The shape id
  25183. * @hidden
  25184. */
  25185. shapeID: number;
  25186. /**
  25187. * flat array of model positions (internal use)
  25188. * @hidden
  25189. */ private _shape: Vector3[];
  25190. /**
  25191. * flat array of model UVs (internal use)
  25192. * @hidden
  25193. */ private _shapeUV: number[];
  25194. /**
  25195. * length of the shape in the model indices array (internal use)
  25196. * @hidden
  25197. */ private _indicesLength: number;
  25198. /**
  25199. * Custom position function (internal use)
  25200. * @hidden
  25201. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25202. /**
  25203. * Custom vertex function (internal use)
  25204. * @hidden
  25205. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25206. /**
  25207. * 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.
  25208. * SPS internal tool, don't use it manually.
  25209. * @hidden
  25210. */
  25211. 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>);
  25212. }
  25213. /**
  25214. * Represents a Depth Sorted Particle in the solid particle system.
  25215. */
  25216. export class DepthSortedParticle {
  25217. /**
  25218. * Index of the particle in the "indices" array
  25219. */
  25220. ind: number;
  25221. /**
  25222. * Length of the particle shape in the "indices" array
  25223. */
  25224. indicesLength: number;
  25225. /**
  25226. * Squared distance from the particle to the camera
  25227. */
  25228. sqDistance: number;
  25229. }
  25230. }
  25231. declare module BABYLON {
  25232. /**
  25233. * @hidden
  25234. */
  25235. export class _MeshCollisionData { private _checkCollisions: boolean; private _collisionMask: number; private _collisionGroup: number; private _collider: Nullable<Collider>; private _oldPositionForCollisions: Vector3; private _diffPositionForCollisions: Vector3; private _onCollideObserver: Nullable<Observer<AbstractMesh>>; private _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25236. }
  25237. }
  25238. declare module BABYLON {
  25239. /** @hidden */ private class _FacetDataStorage {
  25240. facetPositions: Vector3[];
  25241. facetNormals: Vector3[];
  25242. facetPartitioning: number[][];
  25243. facetNb: number;
  25244. partitioningSubdivisions: number;
  25245. partitioningBBoxRatio: number;
  25246. facetDataEnabled: boolean;
  25247. facetParameters: any;
  25248. bbSize: Vector3;
  25249. subDiv: {
  25250. max: number;
  25251. X: number;
  25252. Y: number;
  25253. Z: number;
  25254. };
  25255. facetDepthSort: boolean;
  25256. facetDepthSortEnabled: boolean;
  25257. depthSortedIndices: IndicesArray;
  25258. depthSortedFacets: {
  25259. ind: number;
  25260. sqDistance: number;
  25261. }[];
  25262. facetDepthSortFunction: (f1: {
  25263. ind: number;
  25264. sqDistance: number;
  25265. }, f2: {
  25266. ind: number;
  25267. sqDistance: number;
  25268. }) => number;
  25269. facetDepthSortFrom: Vector3;
  25270. facetDepthSortOrigin: Vector3;
  25271. invertedMatrix: Matrix;
  25272. }
  25273. /**
  25274. * @hidden
  25275. **/ private class _InternalAbstractMeshDataInfo { private _hasVertexAlpha: boolean; private _useVertexColors: boolean; private _numBoneInfluencers: number; private _applyFog: boolean; private _receiveShadows: boolean; private _facetData: _FacetDataStorage; private _visibility: number; private _skeleton: Nullable<Skeleton>; private _layerMask: number; private _computeBonesUsingShaders: boolean; private _isActive: boolean; private _onlyForInstances: boolean; private _isActiveIntermediate: boolean; private _onlyForInstancesIntermediate: boolean;
  25276. }
  25277. /**
  25278. * Class used to store all common mesh properties
  25279. */
  25280. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25281. /** No occlusion */
  25282. static OCCLUSION_TYPE_NONE: number;
  25283. /** Occlusion set to optimisitic */
  25284. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25285. /** Occlusion set to strict */
  25286. static OCCLUSION_TYPE_STRICT: number;
  25287. /** Use an accurante occlusion algorithm */
  25288. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25289. /** Use a conservative occlusion algorithm */
  25290. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25291. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25292. * Test order :
  25293. * Is the bounding sphere outside the frustum ?
  25294. * If not, are the bounding box vertices outside the frustum ?
  25295. * It not, then the cullable object is in the frustum.
  25296. */
  25297. static readonly CULLINGSTRATEGY_STANDARD: number;
  25298. /** Culling strategy : Bounding Sphere Only.
  25299. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25300. * It's also less accurate than the standard because some not visible objects can still be selected.
  25301. * Test : is the bounding sphere outside the frustum ?
  25302. * If not, then the cullable object is in the frustum.
  25303. */
  25304. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25305. /** Culling strategy : Optimistic Inclusion.
  25306. * This in an inclusion test first, then the standard exclusion test.
  25307. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25308. * 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.
  25309. * Anyway, it's as accurate as the standard strategy.
  25310. * Test :
  25311. * Is the cullable object bounding sphere center in the frustum ?
  25312. * If not, apply the default culling strategy.
  25313. */
  25314. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25315. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25316. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25317. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25318. * 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.
  25319. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25320. * Test :
  25321. * Is the cullable object bounding sphere center in the frustum ?
  25322. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25323. */
  25324. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25325. /**
  25326. * No billboard
  25327. */
  25328. static readonly BILLBOARDMODE_NONE: number;
  25329. /** Billboard on X axis */
  25330. static readonly BILLBOARDMODE_X: number;
  25331. /** Billboard on Y axis */
  25332. static readonly BILLBOARDMODE_Y: number;
  25333. /** Billboard on Z axis */
  25334. static readonly BILLBOARDMODE_Z: number;
  25335. /** Billboard on all axes */
  25336. static readonly BILLBOARDMODE_ALL: number;
  25337. /** Billboard on using position instead of orientation */
  25338. static readonly BILLBOARDMODE_USE_POSITION: number;
  25339. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25340. /**
  25341. * The culling strategy to use to check whether the mesh must be rendered or not.
  25342. * This value can be changed at any time and will be used on the next render mesh selection.
  25343. * The possible values are :
  25344. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25345. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25346. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25347. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25348. * Please read each static variable documentation to get details about the culling process.
  25349. * */
  25350. cullingStrategy: number;
  25351. /**
  25352. * Gets the number of facets in the mesh
  25353. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25354. */
  25355. readonly facetNb: number;
  25356. /**
  25357. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25359. */
  25360. partitioningSubdivisions: number;
  25361. /**
  25362. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25363. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25365. */
  25366. partitioningBBoxRatio: number;
  25367. /**
  25368. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25369. * Works only for updatable meshes.
  25370. * Doesn't work with multi-materials
  25371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25372. */
  25373. mustDepthSortFacets: boolean;
  25374. /**
  25375. * The location (Vector3) where the facet depth sort must be computed from.
  25376. * By default, the active camera position.
  25377. * Used only when facet depth sort is enabled
  25378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25379. */
  25380. facetDepthSortFrom: Vector3;
  25381. /**
  25382. * gets a boolean indicating if facetData is enabled
  25383. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25384. */
  25385. readonly isFacetDataEnabled: boolean;
  25386. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25387. /**
  25388. * An event triggered when this mesh collides with another one
  25389. */
  25390. onCollideObservable: Observable<AbstractMesh>;
  25391. /** Set a function to call when this mesh collides with another one */
  25392. onCollide: () => void;
  25393. /**
  25394. * An event triggered when the collision's position changes
  25395. */
  25396. onCollisionPositionChangeObservable: Observable<Vector3>;
  25397. /** Set a function to call when the collision's position changes */
  25398. onCollisionPositionChange: () => void;
  25399. /**
  25400. * An event triggered when material is changed
  25401. */
  25402. onMaterialChangedObservable: Observable<AbstractMesh>;
  25403. /**
  25404. * Gets or sets the orientation for POV movement & rotation
  25405. */
  25406. definedFacingForward: boolean;
  25407. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25408. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25409. /**
  25410. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25411. */
  25412. /**
  25413. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25414. */
  25415. visibility: number;
  25416. /** Gets or sets the alpha index used to sort transparent meshes
  25417. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25418. */
  25419. alphaIndex: number;
  25420. /**
  25421. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25422. */
  25423. isVisible: boolean;
  25424. /**
  25425. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25426. */
  25427. isPickable: boolean;
  25428. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25429. showSubMeshesBoundingBox: boolean;
  25430. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25431. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25432. */
  25433. isBlocker: boolean;
  25434. /**
  25435. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25436. */
  25437. enablePointerMoveEvents: boolean;
  25438. /**
  25439. * Specifies the rendering group id for this mesh (0 by default)
  25440. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25441. */
  25442. renderingGroupId: number;
  25443. private _material;
  25444. /** Gets or sets current material */
  25445. material: Nullable<Material>;
  25446. /**
  25447. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25448. * @see http://doc.babylonjs.com/babylon101/shadows
  25449. */
  25450. receiveShadows: boolean;
  25451. /** Defines color to use when rendering outline */
  25452. outlineColor: Color3;
  25453. /** Define width to use when rendering outline */
  25454. outlineWidth: number;
  25455. /** Defines color to use when rendering overlay */
  25456. overlayColor: Color3;
  25457. /** Defines alpha to use when rendering overlay */
  25458. overlayAlpha: number;
  25459. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25460. hasVertexAlpha: boolean;
  25461. /** 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) */
  25462. useVertexColors: boolean;
  25463. /**
  25464. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25465. */
  25466. computeBonesUsingShaders: boolean;
  25467. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25468. numBoneInfluencers: number;
  25469. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25470. applyFog: boolean;
  25471. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25472. useOctreeForRenderingSelection: boolean;
  25473. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25474. useOctreeForPicking: boolean;
  25475. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25476. useOctreeForCollisions: boolean;
  25477. /**
  25478. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25479. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25480. */
  25481. layerMask: number;
  25482. /**
  25483. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25484. */
  25485. alwaysSelectAsActiveMesh: boolean;
  25486. /**
  25487. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25488. */
  25489. doNotSyncBoundingInfo: boolean;
  25490. /**
  25491. * Gets or sets the current action manager
  25492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25493. */
  25494. actionManager: Nullable<AbstractActionManager>;
  25495. private _meshCollisionData;
  25496. /**
  25497. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25498. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25499. */
  25500. ellipsoid: Vector3;
  25501. /**
  25502. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25503. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25504. */
  25505. ellipsoidOffset: Vector3;
  25506. /**
  25507. * Gets or sets a collision mask used to mask collisions (default is -1).
  25508. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25509. */
  25510. collisionMask: number;
  25511. /**
  25512. * Gets or sets the current collision group mask (-1 by default).
  25513. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25514. */
  25515. collisionGroup: number;
  25516. /**
  25517. * Defines edge width used when edgesRenderer is enabled
  25518. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25519. */
  25520. edgesWidth: number;
  25521. /**
  25522. * Defines edge color used when edgesRenderer is enabled
  25523. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25524. */
  25525. edgesColor: Color4;
  25526. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25527. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25528. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25529. /** @hidden */ private _renderId: number;
  25530. /**
  25531. * Gets or sets the list of subMeshes
  25532. * @see http://doc.babylonjs.com/how_to/multi_materials
  25533. */
  25534. subMeshes: SubMesh[];
  25535. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25536. /** @hidden */ private _unIndexed: boolean;
  25537. /** @hidden */ private _lightSources: Light[];
  25538. /** Gets the list of lights affecting that mesh */
  25539. readonly lightSources: Light[];
  25540. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25541. /** @hidden */ private _waitingData: {
  25542. lods: Nullable<any>;
  25543. actions: Nullable<any>;
  25544. freezeWorldMatrix: Nullable<boolean>;
  25545. };
  25546. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25547. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25548. /**
  25549. * Gets or sets a skeleton to apply skining transformations
  25550. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25551. */
  25552. skeleton: Nullable<Skeleton>;
  25553. /**
  25554. * An event triggered when the mesh is rebuilt.
  25555. */
  25556. onRebuildObservable: Observable<AbstractMesh>;
  25557. /**
  25558. * Creates a new AbstractMesh
  25559. * @param name defines the name of the mesh
  25560. * @param scene defines the hosting scene
  25561. */
  25562. constructor(name: string, scene?: Nullable<Scene>);
  25563. /**
  25564. * Returns the string "AbstractMesh"
  25565. * @returns "AbstractMesh"
  25566. */
  25567. getClassName(): string;
  25568. /**
  25569. * Gets a string representation of the current mesh
  25570. * @param fullDetails defines a boolean indicating if full details must be included
  25571. * @returns a string representation of the current mesh
  25572. */
  25573. toString(fullDetails?: boolean): string;
  25574. /**
  25575. * @hidden
  25576. */
  25577. protected _getEffectiveParent(): Nullable<Node>;
  25578. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25579. /** @hidden */ private _rebuild(): void;
  25580. /** @hidden */ private _resyncLightSources(): void;
  25581. /** @hidden */ private _resyncLighSource(light: Light): void;
  25582. /** @hidden */ private _unBindEffect(): void;
  25583. /** @hidden */ private _removeLightSource(light: Light, dispose: boolean): void;
  25584. private _markSubMeshesAsDirty;
  25585. /** @hidden */ private _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25586. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25587. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25588. /**
  25589. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25590. */
  25591. scaling: Vector3;
  25592. /**
  25593. * Returns true if the mesh is blocked. Implemented by child classes
  25594. */
  25595. readonly isBlocked: boolean;
  25596. /**
  25597. * Returns the mesh itself by default. Implemented by child classes
  25598. * @param camera defines the camera to use to pick the right LOD level
  25599. * @returns the currentAbstractMesh
  25600. */
  25601. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25602. /**
  25603. * Returns 0 by default. Implemented by child classes
  25604. * @returns an integer
  25605. */
  25606. getTotalVertices(): number;
  25607. /**
  25608. * Returns a positive integer : the total number of indices in this mesh geometry.
  25609. * @returns the numner of indices or zero if the mesh has no geometry.
  25610. */
  25611. getTotalIndices(): number;
  25612. /**
  25613. * Returns null by default. Implemented by child classes
  25614. * @returns null
  25615. */
  25616. getIndices(): Nullable<IndicesArray>;
  25617. /**
  25618. * Returns the array of the requested vertex data kind. Implemented by child classes
  25619. * @param kind defines the vertex data kind to use
  25620. * @returns null
  25621. */
  25622. getVerticesData(kind: string): Nullable<FloatArray>;
  25623. /**
  25624. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25625. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25626. * Note that a new underlying VertexBuffer object is created each call.
  25627. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25628. * @param kind defines vertex data kind:
  25629. * * VertexBuffer.PositionKind
  25630. * * VertexBuffer.UVKind
  25631. * * VertexBuffer.UV2Kind
  25632. * * VertexBuffer.UV3Kind
  25633. * * VertexBuffer.UV4Kind
  25634. * * VertexBuffer.UV5Kind
  25635. * * VertexBuffer.UV6Kind
  25636. * * VertexBuffer.ColorKind
  25637. * * VertexBuffer.MatricesIndicesKind
  25638. * * VertexBuffer.MatricesIndicesExtraKind
  25639. * * VertexBuffer.MatricesWeightsKind
  25640. * * VertexBuffer.MatricesWeightsExtraKind
  25641. * @param data defines the data source
  25642. * @param updatable defines if the data must be flagged as updatable (or static)
  25643. * @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
  25644. * @returns the current mesh
  25645. */
  25646. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25647. /**
  25648. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25649. * If the mesh has no geometry, it is simply returned as it is.
  25650. * @param kind defines vertex data kind:
  25651. * * VertexBuffer.PositionKind
  25652. * * VertexBuffer.UVKind
  25653. * * VertexBuffer.UV2Kind
  25654. * * VertexBuffer.UV3Kind
  25655. * * VertexBuffer.UV4Kind
  25656. * * VertexBuffer.UV5Kind
  25657. * * VertexBuffer.UV6Kind
  25658. * * VertexBuffer.ColorKind
  25659. * * VertexBuffer.MatricesIndicesKind
  25660. * * VertexBuffer.MatricesIndicesExtraKind
  25661. * * VertexBuffer.MatricesWeightsKind
  25662. * * VertexBuffer.MatricesWeightsExtraKind
  25663. * @param data defines the data source
  25664. * @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
  25665. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25666. * @returns the current mesh
  25667. */
  25668. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25669. /**
  25670. * Sets the mesh indices,
  25671. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25672. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25673. * @param totalVertices Defines the total number of vertices
  25674. * @returns the current mesh
  25675. */
  25676. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25677. /**
  25678. * Gets a boolean indicating if specific vertex data is present
  25679. * @param kind defines the vertex data kind to use
  25680. * @returns true is data kind is present
  25681. */
  25682. isVerticesDataPresent(kind: string): boolean;
  25683. /**
  25684. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25685. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25686. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25687. * @returns a BoundingInfo
  25688. */
  25689. getBoundingInfo(): BoundingInfo;
  25690. /**
  25691. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25692. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25693. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25694. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25695. * @returns the current mesh
  25696. */
  25697. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25698. /**
  25699. * Overwrite the current bounding info
  25700. * @param boundingInfo defines the new bounding info
  25701. * @returns the current mesh
  25702. */
  25703. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25704. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25705. readonly useBones: boolean;
  25706. /** @hidden */ private _preActivate(): void;
  25707. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25708. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25709. /** @hidden */ private _postActivate(): void;
  25710. /** @hidden */ private _freeze(): void;
  25711. /** @hidden */ private _unFreeze(): void;
  25712. /**
  25713. * Gets the current world matrix
  25714. * @returns a Matrix
  25715. */
  25716. getWorldMatrix(): Matrix;
  25717. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25718. /**
  25719. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25720. */
  25721. readonly isAnInstance: boolean;
  25722. /**
  25723. * Gets a boolean indicating if this mesh has instances
  25724. */
  25725. readonly hasInstances: boolean;
  25726. /**
  25727. * Perform relative position change from the point of view of behind the front of the mesh.
  25728. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25729. * Supports definition of mesh facing forward or backward
  25730. * @param amountRight defines the distance on the right axis
  25731. * @param amountUp defines the distance on the up axis
  25732. * @param amountForward defines the distance on the forward axis
  25733. * @returns the current mesh
  25734. */
  25735. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25736. /**
  25737. * Calculate relative position change from the point of view of behind the front of the mesh.
  25738. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25739. * Supports definition of mesh facing forward or backward
  25740. * @param amountRight defines the distance on the right axis
  25741. * @param amountUp defines the distance on the up axis
  25742. * @param amountForward defines the distance on the forward axis
  25743. * @returns the new displacement vector
  25744. */
  25745. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25746. /**
  25747. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25748. * Supports definition of mesh facing forward or backward
  25749. * @param flipBack defines the flip
  25750. * @param twirlClockwise defines the twirl
  25751. * @param tiltRight defines the tilt
  25752. * @returns the current mesh
  25753. */
  25754. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25755. /**
  25756. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25757. * Supports definition of mesh facing forward or backward.
  25758. * @param flipBack defines the flip
  25759. * @param twirlClockwise defines the twirl
  25760. * @param tiltRight defines the tilt
  25761. * @returns the new rotation vector
  25762. */
  25763. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25764. /**
  25765. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25766. * This means the mesh underlying bounding box and sphere are recomputed.
  25767. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25768. * @returns the current mesh
  25769. */
  25770. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25771. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25772. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25773. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25774. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25775. /** @hidden */
  25776. protected _afterComputeWorldMatrix(): void;
  25777. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25778. /**
  25779. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25780. * A mesh is in the frustum if its bounding box intersects the frustum
  25781. * @param frustumPlanes defines the frustum to test
  25782. * @returns true if the mesh is in the frustum planes
  25783. */
  25784. isInFrustum(frustumPlanes: Plane[]): boolean;
  25785. /**
  25786. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25787. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25788. * @param frustumPlanes defines the frustum to test
  25789. * @returns true if the mesh is completely in the frustum planes
  25790. */
  25791. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25792. /**
  25793. * True if the mesh intersects another mesh or a SolidParticle object
  25794. * @param mesh defines a target mesh or SolidParticle to test
  25795. * @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)
  25796. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25797. * @returns true if there is an intersection
  25798. */
  25799. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25800. /**
  25801. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25802. * @param point defines the point to test
  25803. * @returns true if there is an intersection
  25804. */
  25805. intersectsPoint(point: Vector3): boolean;
  25806. /**
  25807. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25808. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25809. */
  25810. checkCollisions: boolean;
  25811. /**
  25812. * Gets Collider object used to compute collisions (not physics)
  25813. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25814. */
  25815. readonly collider: Nullable<Collider>;
  25816. /**
  25817. * Move the mesh using collision engine
  25818. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25819. * @param displacement defines the requested displacement vector
  25820. * @returns the current mesh
  25821. */
  25822. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25823. private _onCollisionPositionChange;
  25824. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25825. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25826. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  25827. /** @hidden */ private _generatePointsArray(): boolean;
  25828. /**
  25829. * Checks if the passed Ray intersects with the mesh
  25830. * @param ray defines the ray to use
  25831. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25832. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25833. * @returns the picking info
  25834. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25835. */
  25836. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25837. /**
  25838. * Clones the current mesh
  25839. * @param name defines the mesh name
  25840. * @param newParent defines the new mesh parent
  25841. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25842. * @returns the new mesh
  25843. */
  25844. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25845. /**
  25846. * Disposes all the submeshes of the current meshnp
  25847. * @returns the current mesh
  25848. */
  25849. releaseSubMeshes(): AbstractMesh;
  25850. /**
  25851. * Releases resources associated with this abstract mesh.
  25852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25854. */
  25855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25856. /**
  25857. * Adds the passed mesh as a child to the current mesh
  25858. * @param mesh defines the child mesh
  25859. * @returns the current mesh
  25860. */
  25861. addChild(mesh: AbstractMesh): AbstractMesh;
  25862. /**
  25863. * Removes the passed mesh from the current mesh children list
  25864. * @param mesh defines the child mesh
  25865. * @returns the current mesh
  25866. */
  25867. removeChild(mesh: AbstractMesh): AbstractMesh;
  25868. /** @hidden */
  25869. private _initFacetData;
  25870. /**
  25871. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25872. * This method can be called within the render loop.
  25873. * 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
  25874. * @returns the current mesh
  25875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25876. */
  25877. updateFacetData(): AbstractMesh;
  25878. /**
  25879. * Returns the facetLocalNormals array.
  25880. * The normals are expressed in the mesh local spac
  25881. * @returns an array of Vector3
  25882. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25883. */
  25884. getFacetLocalNormals(): Vector3[];
  25885. /**
  25886. * Returns the facetLocalPositions array.
  25887. * The facet positions are expressed in the mesh local space
  25888. * @returns an array of Vector3
  25889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25890. */
  25891. getFacetLocalPositions(): Vector3[];
  25892. /**
  25893. * Returns the facetLocalPartioning array
  25894. * @returns an array of array of numbers
  25895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25896. */
  25897. getFacetLocalPartitioning(): number[][];
  25898. /**
  25899. * Returns the i-th facet position in the world system.
  25900. * This method allocates a new Vector3 per call
  25901. * @param i defines the facet index
  25902. * @returns a new Vector3
  25903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25904. */
  25905. getFacetPosition(i: number): Vector3;
  25906. /**
  25907. * Sets the reference Vector3 with the i-th facet position in the world system
  25908. * @param i defines the facet index
  25909. * @param ref defines the target vector
  25910. * @returns the current mesh
  25911. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25912. */
  25913. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25914. /**
  25915. * Returns the i-th facet normal in the world system.
  25916. * This method allocates a new Vector3 per call
  25917. * @param i defines the facet index
  25918. * @returns a new Vector3
  25919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25920. */
  25921. getFacetNormal(i: number): Vector3;
  25922. /**
  25923. * Sets the reference Vector3 with the i-th facet normal in the world system
  25924. * @param i defines the facet index
  25925. * @param ref defines the target vector
  25926. * @returns the current mesh
  25927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25928. */
  25929. getFacetNormalToRef(i: number, ref: Vector3): this;
  25930. /**
  25931. * 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)
  25932. * @param x defines x coordinate
  25933. * @param y defines y coordinate
  25934. * @param z defines z coordinate
  25935. * @returns the array of facet indexes
  25936. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25937. */
  25938. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25939. /**
  25940. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25941. * @param projected sets as the (x,y,z) world projection on the facet
  25942. * @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
  25943. * @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
  25944. * @param x defines x coordinate
  25945. * @param y defines y coordinate
  25946. * @param z defines z coordinate
  25947. * @returns the face index if found (or null instead)
  25948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25949. */
  25950. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25951. /**
  25952. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25953. * @param projected sets as the (x,y,z) local projection on the facet
  25954. * @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
  25955. * @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
  25956. * @param x defines x coordinate
  25957. * @param y defines y coordinate
  25958. * @param z defines z coordinate
  25959. * @returns the face index if found (or null instead)
  25960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25961. */
  25962. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25963. /**
  25964. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25965. * @returns the parameters
  25966. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25967. */
  25968. getFacetDataParameters(): any;
  25969. /**
  25970. * Disables the feature FacetData and frees the related memory
  25971. * @returns the current mesh
  25972. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25973. */
  25974. disableFacetData(): AbstractMesh;
  25975. /**
  25976. * Updates the AbstractMesh indices array
  25977. * @param indices defines the data source
  25978. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25979. * @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)
  25980. * @returns the current mesh
  25981. */
  25982. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25983. /**
  25984. * Creates new normals data for the mesh
  25985. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25986. * @returns the current mesh
  25987. */
  25988. createNormals(updatable: boolean): AbstractMesh;
  25989. /**
  25990. * Align the mesh with a normal
  25991. * @param normal defines the normal to use
  25992. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25993. * @returns the current mesh
  25994. */
  25995. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25996. /** @hidden */ private _checkOcclusionQuery(): boolean;
  25997. /**
  25998. * Disables the mesh edge rendering mode
  25999. * @returns the currentAbstractMesh
  26000. */
  26001. disableEdgesRendering(): AbstractMesh;
  26002. /**
  26003. * Enables the edge rendering mode on the mesh.
  26004. * This mode makes the mesh edges visible
  26005. * @param epsilon defines the maximal distance between two angles to detect a face
  26006. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26007. * @returns the currentAbstractMesh
  26008. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26009. */
  26010. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26011. }
  26012. }
  26013. declare module BABYLON {
  26014. /**
  26015. * Interface used to define ActionEvent
  26016. */
  26017. export interface IActionEvent {
  26018. /** The mesh or sprite that triggered the action */
  26019. source: any;
  26020. /** The X mouse cursor position at the time of the event */
  26021. pointerX: number;
  26022. /** The Y mouse cursor position at the time of the event */
  26023. pointerY: number;
  26024. /** The mesh that is currently pointed at (can be null) */
  26025. meshUnderPointer: Nullable<AbstractMesh>;
  26026. /** the original (browser) event that triggered the ActionEvent */
  26027. sourceEvent?: any;
  26028. /** additional data for the event */
  26029. additionalData?: any;
  26030. }
  26031. /**
  26032. * ActionEvent is the event being sent when an action is triggered.
  26033. */
  26034. export class ActionEvent implements IActionEvent {
  26035. /** The mesh or sprite that triggered the action */
  26036. source: any;
  26037. /** The X mouse cursor position at the time of the event */
  26038. pointerX: number;
  26039. /** The Y mouse cursor position at the time of the event */
  26040. pointerY: number;
  26041. /** The mesh that is currently pointed at (can be null) */
  26042. meshUnderPointer: Nullable<AbstractMesh>;
  26043. /** the original (browser) event that triggered the ActionEvent */
  26044. sourceEvent?: any;
  26045. /** additional data for the event */
  26046. additionalData?: any;
  26047. /**
  26048. * Creates a new ActionEvent
  26049. * @param source The mesh or sprite that triggered the action
  26050. * @param pointerX The X mouse cursor position at the time of the event
  26051. * @param pointerY The Y mouse cursor position at the time of the event
  26052. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26053. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26054. * @param additionalData additional data for the event
  26055. */
  26056. constructor(
  26057. /** The mesh or sprite that triggered the action */
  26058. source: any,
  26059. /** The X mouse cursor position at the time of the event */
  26060. pointerX: number,
  26061. /** The Y mouse cursor position at the time of the event */
  26062. pointerY: number,
  26063. /** The mesh that is currently pointed at (can be null) */
  26064. meshUnderPointer: Nullable<AbstractMesh>,
  26065. /** the original (browser) event that triggered the ActionEvent */
  26066. sourceEvent?: any,
  26067. /** additional data for the event */
  26068. additionalData?: any);
  26069. /**
  26070. * Helper function to auto-create an ActionEvent from a source mesh.
  26071. * @param source The source mesh that triggered the event
  26072. * @param evt The original (browser) event
  26073. * @param additionalData additional data for the event
  26074. * @returns the new ActionEvent
  26075. */
  26076. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26077. /**
  26078. * Helper function to auto-create an ActionEvent from a source sprite
  26079. * @param source The source sprite that triggered the event
  26080. * @param scene Scene associated with the sprite
  26081. * @param evt The original (browser) event
  26082. * @param additionalData additional data for the event
  26083. * @returns the new ActionEvent
  26084. */
  26085. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26086. /**
  26087. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26088. * @param scene the scene where the event occurred
  26089. * @param evt The original (browser) event
  26090. * @returns the new ActionEvent
  26091. */
  26092. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26093. /**
  26094. * Helper function to auto-create an ActionEvent from a primitive
  26095. * @param prim defines the target primitive
  26096. * @param pointerPos defines the pointer position
  26097. * @param evt The original (browser) event
  26098. * @param additionalData additional data for the event
  26099. * @returns the new ActionEvent
  26100. */
  26101. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26102. }
  26103. }
  26104. declare module BABYLON {
  26105. /**
  26106. * Abstract class used to decouple action Manager from scene and meshes.
  26107. * Do not instantiate.
  26108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26109. */
  26110. export abstract class AbstractActionManager implements IDisposable {
  26111. /** Gets the list of active triggers */
  26112. static Triggers: {
  26113. [key: string]: number;
  26114. };
  26115. /** Gets the cursor to use when hovering items */
  26116. hoverCursor: string;
  26117. /** Gets the list of actions */
  26118. actions: IAction[];
  26119. /**
  26120. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26121. */
  26122. isRecursive: boolean;
  26123. /**
  26124. * Releases all associated resources
  26125. */
  26126. abstract dispose(): void;
  26127. /**
  26128. * Does this action manager has pointer triggers
  26129. */
  26130. abstract readonly hasPointerTriggers: boolean;
  26131. /**
  26132. * Does this action manager has pick triggers
  26133. */
  26134. abstract readonly hasPickTriggers: boolean;
  26135. /**
  26136. * Process a specific trigger
  26137. * @param trigger defines the trigger to process
  26138. * @param evt defines the event details to be processed
  26139. */
  26140. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26141. /**
  26142. * Does this action manager handles actions of any of the given triggers
  26143. * @param triggers defines the triggers to be tested
  26144. * @return a boolean indicating whether one (or more) of the triggers is handled
  26145. */
  26146. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26147. /**
  26148. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26149. * speed.
  26150. * @param triggerA defines the trigger to be tested
  26151. * @param triggerB defines the trigger to be tested
  26152. * @return a boolean indicating whether one (or more) of the triggers is handled
  26153. */
  26154. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26155. /**
  26156. * Does this action manager handles actions of a given trigger
  26157. * @param trigger defines the trigger to be tested
  26158. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26159. * @return whether the trigger is handled
  26160. */
  26161. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26162. /**
  26163. * Serialize this manager to a JSON object
  26164. * @param name defines the property name to store this manager
  26165. * @returns a JSON representation of this manager
  26166. */
  26167. abstract serialize(name: string): any;
  26168. /**
  26169. * Registers an action to this action manager
  26170. * @param action defines the action to be registered
  26171. * @return the action amended (prepared) after registration
  26172. */
  26173. abstract registerAction(action: IAction): Nullable<IAction>;
  26174. /**
  26175. * Unregisters an action to this action manager
  26176. * @param action defines the action to be unregistered
  26177. * @return a boolean indicating whether the action has been unregistered
  26178. */
  26179. abstract unregisterAction(action: IAction): Boolean;
  26180. /**
  26181. * Does exist one action manager with at least one trigger
  26182. **/
  26183. static readonly HasTriggers: boolean;
  26184. /**
  26185. * Does exist one action manager with at least one pick trigger
  26186. **/
  26187. static readonly HasPickTriggers: boolean;
  26188. /**
  26189. * Does exist one action manager that handles actions of a given trigger
  26190. * @param trigger defines the trigger to be tested
  26191. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26192. **/
  26193. static HasSpecificTrigger(trigger: number): boolean;
  26194. }
  26195. }
  26196. declare module BABYLON {
  26197. /**
  26198. * Defines how a node can be built from a string name.
  26199. */
  26200. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26201. /**
  26202. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26203. */
  26204. export class Node implements IBehaviorAware<Node> {
  26205. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26206. private static _NodeConstructors;
  26207. /**
  26208. * Add a new node constructor
  26209. * @param type defines the type name of the node to construct
  26210. * @param constructorFunc defines the constructor function
  26211. */
  26212. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26213. /**
  26214. * Returns a node constructor based on type name
  26215. * @param type defines the type name
  26216. * @param name defines the new node name
  26217. * @param scene defines the hosting scene
  26218. * @param options defines optional options to transmit to constructors
  26219. * @returns the new constructor or null
  26220. */
  26221. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26222. /**
  26223. * Gets or sets the name of the node
  26224. */
  26225. name: string;
  26226. /**
  26227. * Gets or sets the id of the node
  26228. */
  26229. id: string;
  26230. /**
  26231. * Gets or sets the unique id of the node
  26232. */
  26233. uniqueId: number;
  26234. /**
  26235. * Gets or sets a string used to store user defined state for the node
  26236. */
  26237. state: string;
  26238. /**
  26239. * Gets or sets an object used to store user defined information for the node
  26240. */
  26241. metadata: any;
  26242. /**
  26243. * For internal use only. Please do not use.
  26244. */
  26245. reservedDataStore: any;
  26246. /**
  26247. * List of inspectable custom properties (used by the Inspector)
  26248. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26249. */
  26250. inspectableCustomProperties: IInspectable[];
  26251. /**
  26252. * Gets or sets a boolean used to define if the node must be serialized
  26253. */
  26254. doNotSerialize: boolean;
  26255. /** @hidden */ private _isDisposed: boolean;
  26256. /**
  26257. * Gets a list of Animations associated with the node
  26258. */
  26259. animations: Animation[];
  26260. protected _ranges: {
  26261. [name: string]: Nullable<AnimationRange>;
  26262. };
  26263. /**
  26264. * Callback raised when the node is ready to be used
  26265. */
  26266. onReady: Nullable<(node: Node) => void>;
  26267. private _isEnabled;
  26268. private _isParentEnabled;
  26269. private _isReady;
  26270. /** @hidden */ private _currentRenderId: number;
  26271. private _parentUpdateId;
  26272. /** @hidden */ private _childUpdateId: number;
  26273. /** @hidden */ private _waitingParentId: Nullable<string>;
  26274. /** @hidden */ private _scene: Scene;
  26275. /** @hidden */ private _cache: any;
  26276. private _parentNode;
  26277. private _children;
  26278. /** @hidden */ private _worldMatrix: Matrix;
  26279. /** @hidden */ private _worldMatrixDeterminant: number;
  26280. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26281. /** @hidden */
  26282. private _sceneRootNodesIndex;
  26283. /**
  26284. * Gets a boolean indicating if the node has been disposed
  26285. * @returns true if the node was disposed
  26286. */
  26287. isDisposed(): boolean;
  26288. /**
  26289. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26290. * @see https://doc.babylonjs.com/how_to/parenting
  26291. */
  26292. parent: Nullable<Node>;
  26293. private addToSceneRootNodes;
  26294. private removeFromSceneRootNodes;
  26295. private _animationPropertiesOverride;
  26296. /**
  26297. * Gets or sets the animation properties override
  26298. */
  26299. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26300. /**
  26301. * Gets a string idenfifying the name of the class
  26302. * @returns "Node" string
  26303. */
  26304. getClassName(): string;
  26305. /** @hidden */ protected readonly _isNode: boolean;
  26306. /**
  26307. * An event triggered when the mesh is disposed
  26308. */
  26309. onDisposeObservable: Observable<Node>;
  26310. private _onDisposeObserver;
  26311. /**
  26312. * Sets a callback that will be raised when the node will be disposed
  26313. */
  26314. onDispose: () => void;
  26315. /**
  26316. * Creates a new Node
  26317. * @param name the name and id to be given to this node
  26318. * @param scene the scene this node will be added to
  26319. * @param addToRootNodes the node will be added to scene.rootNodes
  26320. */
  26321. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26322. /**
  26323. * Gets the scene of the node
  26324. * @returns a scene
  26325. */
  26326. getScene(): Scene;
  26327. /**
  26328. * Gets the engine of the node
  26329. * @returns a Engine
  26330. */
  26331. getEngine(): Engine;
  26332. private _behaviors;
  26333. /**
  26334. * Attach a behavior to the node
  26335. * @see http://doc.babylonjs.com/features/behaviour
  26336. * @param behavior defines the behavior to attach
  26337. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26338. * @returns the current Node
  26339. */
  26340. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26341. /**
  26342. * Remove an attached behavior
  26343. * @see http://doc.babylonjs.com/features/behaviour
  26344. * @param behavior defines the behavior to attach
  26345. * @returns the current Node
  26346. */
  26347. removeBehavior(behavior: Behavior<Node>): Node;
  26348. /**
  26349. * Gets the list of attached behaviors
  26350. * @see http://doc.babylonjs.com/features/behaviour
  26351. */
  26352. readonly behaviors: Behavior<Node>[];
  26353. /**
  26354. * Gets an attached behavior by name
  26355. * @param name defines the name of the behavior to look for
  26356. * @see http://doc.babylonjs.com/features/behaviour
  26357. * @returns null if behavior was not found else the requested behavior
  26358. */
  26359. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26360. /**
  26361. * Returns the latest update of the World matrix
  26362. * @returns a Matrix
  26363. */
  26364. getWorldMatrix(): Matrix;
  26365. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26366. /**
  26367. * Returns directly the latest state of the mesh World matrix.
  26368. * A Matrix is returned.
  26369. */
  26370. readonly worldMatrixFromCache: Matrix;
  26371. /** @hidden */ private _initCache(): void;
  26372. /** @hidden */
  26373. updateCache(force?: boolean): void;
  26374. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26375. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26376. /** @hidden */ private _isSynchronized(): boolean;
  26377. /** @hidden */ private _markSyncedWithParent(): void;
  26378. /** @hidden */
  26379. isSynchronizedWithParent(): boolean;
  26380. /** @hidden */
  26381. isSynchronized(): boolean;
  26382. /**
  26383. * Is this node ready to be used/rendered
  26384. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26385. * @return true if the node is ready
  26386. */
  26387. isReady(completeCheck?: boolean): boolean;
  26388. /**
  26389. * Is this node enabled?
  26390. * 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
  26391. * @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
  26392. * @return whether this node (and its parent) is enabled
  26393. */
  26394. isEnabled(checkAncestors?: boolean): boolean;
  26395. /** @hidden */
  26396. protected _syncParentEnabledState(): void;
  26397. /**
  26398. * Set the enabled state of this node
  26399. * @param value defines the new enabled state
  26400. */
  26401. setEnabled(value: boolean): void;
  26402. /**
  26403. * Is this node a descendant of the given node?
  26404. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26405. * @param ancestor defines the parent node to inspect
  26406. * @returns a boolean indicating if this node is a descendant of the given node
  26407. */
  26408. isDescendantOf(ancestor: Node): boolean;
  26409. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26410. /**
  26411. * Will return all nodes that have this node as ascendant
  26412. * @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
  26413. * @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
  26414. * @return all children nodes of all types
  26415. */
  26416. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26417. /**
  26418. * Get all child-meshes of this node
  26419. * @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)
  26420. * @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
  26421. * @returns an array of AbstractMesh
  26422. */
  26423. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26424. /**
  26425. * Get all direct children of this node
  26426. * @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
  26427. * @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)
  26428. * @returns an array of Node
  26429. */
  26430. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26431. /** @hidden */ private _setReady(state: boolean): void;
  26432. /**
  26433. * Get an animation by name
  26434. * @param name defines the name of the animation to look for
  26435. * @returns null if not found else the requested animation
  26436. */
  26437. getAnimationByName(name: string): Nullable<Animation>;
  26438. /**
  26439. * Creates an animation range for this node
  26440. * @param name defines the name of the range
  26441. * @param from defines the starting key
  26442. * @param to defines the end key
  26443. */
  26444. createAnimationRange(name: string, from: number, to: number): void;
  26445. /**
  26446. * Delete a specific animation range
  26447. * @param name defines the name of the range to delete
  26448. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26449. */
  26450. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26451. /**
  26452. * Get an animation range by name
  26453. * @param name defines the name of the animation range to look for
  26454. * @returns null if not found else the requested animation range
  26455. */
  26456. getAnimationRange(name: string): Nullable<AnimationRange>;
  26457. /**
  26458. * Gets the list of all animation ranges defined on this node
  26459. * @returns an array
  26460. */
  26461. getAnimationRanges(): Nullable<AnimationRange>[];
  26462. /**
  26463. * Will start the animation sequence
  26464. * @param name defines the range frames for animation sequence
  26465. * @param loop defines if the animation should loop (false by default)
  26466. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26467. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26468. * @returns the object created for this animation. If range does not exist, it will return null
  26469. */
  26470. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26471. /**
  26472. * Serialize animation ranges into a JSON compatible object
  26473. * @returns serialization object
  26474. */
  26475. serializeAnimationRanges(): any;
  26476. /**
  26477. * Computes the world matrix of the node
  26478. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26479. * @returns the world matrix
  26480. */
  26481. computeWorldMatrix(force?: boolean): Matrix;
  26482. /**
  26483. * Releases resources associated with this node.
  26484. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26485. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26486. */
  26487. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26488. /**
  26489. * Parse animation range data from a serialization object and store them into a given node
  26490. * @param node defines where to store the animation ranges
  26491. * @param parsedNode defines the serialization object to read data from
  26492. * @param scene defines the hosting scene
  26493. */
  26494. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26495. /**
  26496. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26497. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26498. * @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
  26499. * @returns the new bounding vectors
  26500. */
  26501. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26502. min: Vector3;
  26503. max: Vector3;
  26504. };
  26505. }
  26506. }
  26507. declare module BABYLON {
  26508. /**
  26509. * @hidden
  26510. */
  26511. export class _IAnimationState {
  26512. key: number;
  26513. repeatCount: number;
  26514. workValue?: any;
  26515. loopMode?: number;
  26516. offsetValue?: any;
  26517. highLimitValue?: any;
  26518. }
  26519. /**
  26520. * Class used to store any kind of animation
  26521. */
  26522. export class Animation {
  26523. /**Name of the animation */
  26524. name: string;
  26525. /**Property to animate */
  26526. targetProperty: string;
  26527. /**The frames per second of the animation */
  26528. framePerSecond: number;
  26529. /**The data type of the animation */
  26530. dataType: number;
  26531. /**The loop mode of the animation */
  26532. loopMode?: number | undefined;
  26533. /**Specifies if blending should be enabled */
  26534. enableBlending?: boolean | undefined;
  26535. /**
  26536. * Use matrix interpolation instead of using direct key value when animating matrices
  26537. */
  26538. static AllowMatricesInterpolation: boolean;
  26539. /**
  26540. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26541. */
  26542. static AllowMatrixDecomposeForInterpolation: boolean;
  26543. /**
  26544. * Stores the key frames of the animation
  26545. */
  26546. private _keys;
  26547. /**
  26548. * Stores the easing function of the animation
  26549. */
  26550. private _easingFunction;
  26551. /**
  26552. * @hidden Internal use only
  26553. */ private _runtimeAnimations: RuntimeAnimation[];
  26554. /**
  26555. * The set of event that will be linked to this animation
  26556. */
  26557. private _events;
  26558. /**
  26559. * Stores an array of target property paths
  26560. */
  26561. targetPropertyPath: string[];
  26562. /**
  26563. * Stores the blending speed of the animation
  26564. */
  26565. blendingSpeed: number;
  26566. /**
  26567. * Stores the animation ranges for the animation
  26568. */
  26569. private _ranges;
  26570. /**
  26571. * @hidden Internal use
  26572. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26573. /**
  26574. * Sets up an animation
  26575. * @param property The property to animate
  26576. * @param animationType The animation type to apply
  26577. * @param framePerSecond The frames per second of the animation
  26578. * @param easingFunction The easing function used in the animation
  26579. * @returns The created animation
  26580. */
  26581. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26582. /**
  26583. * Create and start an animation on a node
  26584. * @param name defines the name of the global animation that will be run on all nodes
  26585. * @param node defines the root node where the animation will take place
  26586. * @param targetProperty defines property to animate
  26587. * @param framePerSecond defines the number of frame per second yo use
  26588. * @param totalFrame defines the number of frames in total
  26589. * @param from defines the initial value
  26590. * @param to defines the final value
  26591. * @param loopMode defines which loop mode you want to use (off by default)
  26592. * @param easingFunction defines the easing function to use (linear by default)
  26593. * @param onAnimationEnd defines the callback to call when animation end
  26594. * @returns the animatable created for this animation
  26595. */
  26596. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26597. /**
  26598. * Create and start an animation on a node and its descendants
  26599. * @param name defines the name of the global animation that will be run on all nodes
  26600. * @param node defines the root node where the animation will take place
  26601. * @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
  26602. * @param targetProperty defines property to animate
  26603. * @param framePerSecond defines the number of frame per second to use
  26604. * @param totalFrame defines the number of frames in total
  26605. * @param from defines the initial value
  26606. * @param to defines the final value
  26607. * @param loopMode defines which loop mode you want to use (off by default)
  26608. * @param easingFunction defines the easing function to use (linear by default)
  26609. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26610. * @returns the list of animatables created for all nodes
  26611. * @example https://www.babylonjs-playground.com/#MH0VLI
  26612. */
  26613. 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[]>;
  26614. /**
  26615. * Creates a new animation, merges it with the existing animations and starts it
  26616. * @param name Name of the animation
  26617. * @param node Node which contains the scene that begins the animations
  26618. * @param targetProperty Specifies which property to animate
  26619. * @param framePerSecond The frames per second of the animation
  26620. * @param totalFrame The total number of frames
  26621. * @param from The frame at the beginning of the animation
  26622. * @param to The frame at the end of the animation
  26623. * @param loopMode Specifies the loop mode of the animation
  26624. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26625. * @param onAnimationEnd Callback to run once the animation is complete
  26626. * @returns Nullable animation
  26627. */
  26628. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26629. /**
  26630. * Transition property of an host to the target Value
  26631. * @param property The property to transition
  26632. * @param targetValue The target Value of the property
  26633. * @param host The object where the property to animate belongs
  26634. * @param scene Scene used to run the animation
  26635. * @param frameRate Framerate (in frame/s) to use
  26636. * @param transition The transition type we want to use
  26637. * @param duration The duration of the animation, in milliseconds
  26638. * @param onAnimationEnd Callback trigger at the end of the animation
  26639. * @returns Nullable animation
  26640. */
  26641. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26642. /**
  26643. * Return the array of runtime animations currently using this animation
  26644. */
  26645. readonly runtimeAnimations: RuntimeAnimation[];
  26646. /**
  26647. * Specifies if any of the runtime animations are currently running
  26648. */
  26649. readonly hasRunningRuntimeAnimations: boolean;
  26650. /**
  26651. * Initializes the animation
  26652. * @param name Name of the animation
  26653. * @param targetProperty Property to animate
  26654. * @param framePerSecond The frames per second of the animation
  26655. * @param dataType The data type of the animation
  26656. * @param loopMode The loop mode of the animation
  26657. * @param enableBlending Specifies if blending should be enabled
  26658. */
  26659. constructor(
  26660. /**Name of the animation */
  26661. name: string,
  26662. /**Property to animate */
  26663. targetProperty: string,
  26664. /**The frames per second of the animation */
  26665. framePerSecond: number,
  26666. /**The data type of the animation */
  26667. dataType: number,
  26668. /**The loop mode of the animation */
  26669. loopMode?: number | undefined,
  26670. /**Specifies if blending should be enabled */
  26671. enableBlending?: boolean | undefined);
  26672. /**
  26673. * Converts the animation to a string
  26674. * @param fullDetails support for multiple levels of logging within scene loading
  26675. * @returns String form of the animation
  26676. */
  26677. toString(fullDetails?: boolean): string;
  26678. /**
  26679. * Add an event to this animation
  26680. * @param event Event to add
  26681. */
  26682. addEvent(event: AnimationEvent): void;
  26683. /**
  26684. * Remove all events found at the given frame
  26685. * @param frame The frame to remove events from
  26686. */
  26687. removeEvents(frame: number): void;
  26688. /**
  26689. * Retrieves all the events from the animation
  26690. * @returns Events from the animation
  26691. */
  26692. getEvents(): AnimationEvent[];
  26693. /**
  26694. * Creates an animation range
  26695. * @param name Name of the animation range
  26696. * @param from Starting frame of the animation range
  26697. * @param to Ending frame of the animation
  26698. */
  26699. createRange(name: string, from: number, to: number): void;
  26700. /**
  26701. * Deletes an animation range by name
  26702. * @param name Name of the animation range to delete
  26703. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26704. */
  26705. deleteRange(name: string, deleteFrames?: boolean): void;
  26706. /**
  26707. * Gets the animation range by name, or null if not defined
  26708. * @param name Name of the animation range
  26709. * @returns Nullable animation range
  26710. */
  26711. getRange(name: string): Nullable<AnimationRange>;
  26712. /**
  26713. * Gets the key frames from the animation
  26714. * @returns The key frames of the animation
  26715. */
  26716. getKeys(): Array<IAnimationKey>;
  26717. /**
  26718. * Gets the highest frame rate of the animation
  26719. * @returns Highest frame rate of the animation
  26720. */
  26721. getHighestFrame(): number;
  26722. /**
  26723. * Gets the easing function of the animation
  26724. * @returns Easing function of the animation
  26725. */
  26726. getEasingFunction(): IEasingFunction;
  26727. /**
  26728. * Sets the easing function of the animation
  26729. * @param easingFunction A custom mathematical formula for animation
  26730. */
  26731. setEasingFunction(easingFunction: EasingFunction): void;
  26732. /**
  26733. * Interpolates a scalar linearly
  26734. * @param startValue Start value of the animation curve
  26735. * @param endValue End value of the animation curve
  26736. * @param gradient Scalar amount to interpolate
  26737. * @returns Interpolated scalar value
  26738. */
  26739. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26740. /**
  26741. * Interpolates a scalar cubically
  26742. * @param startValue Start value of the animation curve
  26743. * @param outTangent End tangent of the animation
  26744. * @param endValue End value of the animation curve
  26745. * @param inTangent Start tangent of the animation curve
  26746. * @param gradient Scalar amount to interpolate
  26747. * @returns Interpolated scalar value
  26748. */
  26749. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26750. /**
  26751. * Interpolates a quaternion using a spherical linear interpolation
  26752. * @param startValue Start value of the animation curve
  26753. * @param endValue End value of the animation curve
  26754. * @param gradient Scalar amount to interpolate
  26755. * @returns Interpolated quaternion value
  26756. */
  26757. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26758. /**
  26759. * Interpolates a quaternion cubically
  26760. * @param startValue Start value of the animation curve
  26761. * @param outTangent End tangent of the animation curve
  26762. * @param endValue End value of the animation curve
  26763. * @param inTangent Start tangent of the animation curve
  26764. * @param gradient Scalar amount to interpolate
  26765. * @returns Interpolated quaternion value
  26766. */
  26767. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26768. /**
  26769. * Interpolates a Vector3 linearl
  26770. * @param startValue Start value of the animation curve
  26771. * @param endValue End value of the animation curve
  26772. * @param gradient Scalar amount to interpolate
  26773. * @returns Interpolated scalar value
  26774. */
  26775. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26776. /**
  26777. * Interpolates a Vector3 cubically
  26778. * @param startValue Start value of the animation curve
  26779. * @param outTangent End tangent of the animation
  26780. * @param endValue End value of the animation curve
  26781. * @param inTangent Start tangent of the animation curve
  26782. * @param gradient Scalar amount to interpolate
  26783. * @returns InterpolatedVector3 value
  26784. */
  26785. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26786. /**
  26787. * Interpolates a Vector2 linearly
  26788. * @param startValue Start value of the animation curve
  26789. * @param endValue End value of the animation curve
  26790. * @param gradient Scalar amount to interpolate
  26791. * @returns Interpolated Vector2 value
  26792. */
  26793. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26794. /**
  26795. * Interpolates a Vector2 cubically
  26796. * @param startValue Start value of the animation curve
  26797. * @param outTangent End tangent of the animation
  26798. * @param endValue End value of the animation curve
  26799. * @param inTangent Start tangent of the animation curve
  26800. * @param gradient Scalar amount to interpolate
  26801. * @returns Interpolated Vector2 value
  26802. */
  26803. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26804. /**
  26805. * Interpolates a size linearly
  26806. * @param startValue Start value of the animation curve
  26807. * @param endValue End value of the animation curve
  26808. * @param gradient Scalar amount to interpolate
  26809. * @returns Interpolated Size value
  26810. */
  26811. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26812. /**
  26813. * Interpolates a Color3 linearly
  26814. * @param startValue Start value of the animation curve
  26815. * @param endValue End value of the animation curve
  26816. * @param gradient Scalar amount to interpolate
  26817. * @returns Interpolated Color3 value
  26818. */
  26819. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26820. /**
  26821. * @hidden Internal use only
  26822. */ private _getKeyValue(value: any): any;
  26823. /**
  26824. * @hidden Internal use only
  26825. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  26826. /**
  26827. * Defines the function to use to interpolate matrices
  26828. * @param startValue defines the start matrix
  26829. * @param endValue defines the end matrix
  26830. * @param gradient defines the gradient between both matrices
  26831. * @param result defines an optional target matrix where to store the interpolation
  26832. * @returns the interpolated matrix
  26833. */
  26834. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26835. /**
  26836. * Makes a copy of the animation
  26837. * @returns Cloned animation
  26838. */
  26839. clone(): Animation;
  26840. /**
  26841. * Sets the key frames of the animation
  26842. * @param values The animation key frames to set
  26843. */
  26844. setKeys(values: Array<IAnimationKey>): void;
  26845. /**
  26846. * Serializes the animation to an object
  26847. * @returns Serialized object
  26848. */
  26849. serialize(): any;
  26850. /**
  26851. * Float animation type
  26852. */
  26853. private static _ANIMATIONTYPE_FLOAT;
  26854. /**
  26855. * Vector3 animation type
  26856. */
  26857. private static _ANIMATIONTYPE_VECTOR3;
  26858. /**
  26859. * Quaternion animation type
  26860. */
  26861. private static _ANIMATIONTYPE_QUATERNION;
  26862. /**
  26863. * Matrix animation type
  26864. */
  26865. private static _ANIMATIONTYPE_MATRIX;
  26866. /**
  26867. * Color3 animation type
  26868. */
  26869. private static _ANIMATIONTYPE_COLOR3;
  26870. /**
  26871. * Vector2 animation type
  26872. */
  26873. private static _ANIMATIONTYPE_VECTOR2;
  26874. /**
  26875. * Size animation type
  26876. */
  26877. private static _ANIMATIONTYPE_SIZE;
  26878. /**
  26879. * Relative Loop Mode
  26880. */
  26881. private static _ANIMATIONLOOPMODE_RELATIVE;
  26882. /**
  26883. * Cycle Loop Mode
  26884. */
  26885. private static _ANIMATIONLOOPMODE_CYCLE;
  26886. /**
  26887. * Constant Loop Mode
  26888. */
  26889. private static _ANIMATIONLOOPMODE_CONSTANT;
  26890. /**
  26891. * Get the float animation type
  26892. */
  26893. static readonly ANIMATIONTYPE_FLOAT: number;
  26894. /**
  26895. * Get the Vector3 animation type
  26896. */
  26897. static readonly ANIMATIONTYPE_VECTOR3: number;
  26898. /**
  26899. * Get the Vector2 animation type
  26900. */
  26901. static readonly ANIMATIONTYPE_VECTOR2: number;
  26902. /**
  26903. * Get the Size animation type
  26904. */
  26905. static readonly ANIMATIONTYPE_SIZE: number;
  26906. /**
  26907. * Get the Quaternion animation type
  26908. */
  26909. static readonly ANIMATIONTYPE_QUATERNION: number;
  26910. /**
  26911. * Get the Matrix animation type
  26912. */
  26913. static readonly ANIMATIONTYPE_MATRIX: number;
  26914. /**
  26915. * Get the Color3 animation type
  26916. */
  26917. static readonly ANIMATIONTYPE_COLOR3: number;
  26918. /**
  26919. * Get the Relative Loop Mode
  26920. */
  26921. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26922. /**
  26923. * Get the Cycle Loop Mode
  26924. */
  26925. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26926. /**
  26927. * Get the Constant Loop Mode
  26928. */
  26929. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26930. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  26931. /**
  26932. * Parses an animation object and creates an animation
  26933. * @param parsedAnimation Parsed animation object
  26934. * @returns Animation object
  26935. */
  26936. static Parse(parsedAnimation: any): Animation;
  26937. /**
  26938. * Appends the serialized animations from the source animations
  26939. * @param source Source containing the animations
  26940. * @param destination Target to store the animations
  26941. */
  26942. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26943. }
  26944. }
  26945. declare module BABYLON {
  26946. /**
  26947. * Interface containing an array of animations
  26948. */
  26949. export interface IAnimatable {
  26950. /**
  26951. * Array of animations
  26952. */
  26953. animations: Nullable<Array<Animation>>;
  26954. }
  26955. }
  26956. declare module BABYLON {
  26957. /**
  26958. * This represents all the required information to add a fresnel effect on a material:
  26959. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26960. */
  26961. export class FresnelParameters {
  26962. private _isEnabled;
  26963. /**
  26964. * Define if the fresnel effect is enable or not.
  26965. */
  26966. isEnabled: boolean;
  26967. /**
  26968. * Define the color used on edges (grazing angle)
  26969. */
  26970. leftColor: Color3;
  26971. /**
  26972. * Define the color used on center
  26973. */
  26974. rightColor: Color3;
  26975. /**
  26976. * Define bias applied to computed fresnel term
  26977. */
  26978. bias: number;
  26979. /**
  26980. * Defined the power exponent applied to fresnel term
  26981. */
  26982. power: number;
  26983. /**
  26984. * Clones the current fresnel and its valuues
  26985. * @returns a clone fresnel configuration
  26986. */
  26987. clone(): FresnelParameters;
  26988. /**
  26989. * Serializes the current fresnel parameters to a JSON representation.
  26990. * @return the JSON serialization
  26991. */
  26992. serialize(): any;
  26993. /**
  26994. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26995. * @param parsedFresnelParameters Define the JSON representation
  26996. * @returns the parsed parameters
  26997. */
  26998. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26999. }
  27000. }
  27001. declare module BABYLON {
  27002. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27003. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27004. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27005. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27006. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27007. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27008. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27009. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27010. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27011. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27012. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27013. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27014. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27015. /**
  27016. * Decorator used to define property that can be serialized as reference to a camera
  27017. * @param sourceName defines the name of the property to decorate
  27018. */
  27019. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27020. /**
  27021. * Class used to help serialization objects
  27022. */
  27023. export class SerializationHelper {
  27024. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27025. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27026. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27027. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27028. /**
  27029. * Appends the serialized animations from the source animations
  27030. * @param source Source containing the animations
  27031. * @param destination Target to store the animations
  27032. */
  27033. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27034. /**
  27035. * Static function used to serialized a specific entity
  27036. * @param entity defines the entity to serialize
  27037. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27038. * @returns a JSON compatible object representing the serialization of the entity
  27039. */
  27040. static Serialize<T>(entity: T, serializationObject?: any): any;
  27041. /**
  27042. * Creates a new entity from a serialization data object
  27043. * @param creationFunction defines a function used to instanciated the new entity
  27044. * @param source defines the source serialization data
  27045. * @param scene defines the hosting scene
  27046. * @param rootUrl defines the root url for resources
  27047. * @returns a new entity
  27048. */
  27049. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27050. /**
  27051. * Clones an object
  27052. * @param creationFunction defines the function used to instanciate the new object
  27053. * @param source defines the source object
  27054. * @returns the cloned object
  27055. */
  27056. static Clone<T>(creationFunction: () => T, source: T): T;
  27057. /**
  27058. * Instanciates a new object based on a source one (some data will be shared between both object)
  27059. * @param creationFunction defines the function used to instanciate the new object
  27060. * @param source defines the source object
  27061. * @returns the new object
  27062. */
  27063. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27064. }
  27065. }
  27066. declare module BABYLON {
  27067. /**
  27068. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27069. */
  27070. export interface CubeMapInfo {
  27071. /**
  27072. * The pixel array for the front face.
  27073. * This is stored in format, left to right, up to down format.
  27074. */
  27075. front: Nullable<ArrayBufferView>;
  27076. /**
  27077. * The pixel array for the back face.
  27078. * This is stored in format, left to right, up to down format.
  27079. */
  27080. back: Nullable<ArrayBufferView>;
  27081. /**
  27082. * The pixel array for the left face.
  27083. * This is stored in format, left to right, up to down format.
  27084. */
  27085. left: Nullable<ArrayBufferView>;
  27086. /**
  27087. * The pixel array for the right face.
  27088. * This is stored in format, left to right, up to down format.
  27089. */
  27090. right: Nullable<ArrayBufferView>;
  27091. /**
  27092. * The pixel array for the up face.
  27093. * This is stored in format, left to right, up to down format.
  27094. */
  27095. up: Nullable<ArrayBufferView>;
  27096. /**
  27097. * The pixel array for the down face.
  27098. * This is stored in format, left to right, up to down format.
  27099. */
  27100. down: Nullable<ArrayBufferView>;
  27101. /**
  27102. * The size of the cubemap stored.
  27103. *
  27104. * Each faces will be size * size pixels.
  27105. */
  27106. size: number;
  27107. /**
  27108. * The format of the texture.
  27109. *
  27110. * RGBA, RGB.
  27111. */
  27112. format: number;
  27113. /**
  27114. * The type of the texture data.
  27115. *
  27116. * UNSIGNED_INT, FLOAT.
  27117. */
  27118. type: number;
  27119. /**
  27120. * Specifies whether the texture is in gamma space.
  27121. */
  27122. gammaSpace: boolean;
  27123. }
  27124. /**
  27125. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27126. */
  27127. export class PanoramaToCubeMapTools {
  27128. private static FACE_FRONT;
  27129. private static FACE_BACK;
  27130. private static FACE_RIGHT;
  27131. private static FACE_LEFT;
  27132. private static FACE_DOWN;
  27133. private static FACE_UP;
  27134. /**
  27135. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27136. *
  27137. * @param float32Array The source data.
  27138. * @param inputWidth The width of the input panorama.
  27139. * @param inputHeight The height of the input panorama.
  27140. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27141. * @return The cubemap data
  27142. */
  27143. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27144. private static CreateCubemapTexture;
  27145. private static CalcProjectionSpherical;
  27146. }
  27147. }
  27148. declare module BABYLON {
  27149. /**
  27150. * Helper class dealing with the extraction of spherical polynomial dataArray
  27151. * from a cube map.
  27152. */
  27153. export class CubeMapToSphericalPolynomialTools {
  27154. private static FileFaces;
  27155. /**
  27156. * Converts a texture to the according Spherical Polynomial data.
  27157. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27158. *
  27159. * @param texture The texture to extract the information from.
  27160. * @return The Spherical Polynomial data.
  27161. */
  27162. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27163. /**
  27164. * Converts a cubemap to the according Spherical Polynomial data.
  27165. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27166. *
  27167. * @param cubeInfo The Cube map to extract the information from.
  27168. * @return The Spherical Polynomial data.
  27169. */
  27170. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27171. }
  27172. }
  27173. declare module BABYLON {
  27174. /**
  27175. * Class used to manipulate GUIDs
  27176. */
  27177. export class GUID {
  27178. /**
  27179. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27180. * Be aware Math.random() could cause collisions, but:
  27181. * "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"
  27182. * @returns a pseudo random id
  27183. */
  27184. static RandomId(): string;
  27185. }
  27186. }
  27187. declare module BABYLON {
  27188. /**
  27189. * Base class of all the textures in babylon.
  27190. * It groups all the common properties the materials, post process, lights... might need
  27191. * in order to make a correct use of the texture.
  27192. */
  27193. export class BaseTexture implements IAnimatable {
  27194. /**
  27195. * Default anisotropic filtering level for the application.
  27196. * It is set to 4 as a good tradeoff between perf and quality.
  27197. */
  27198. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27199. /**
  27200. * Gets or sets the unique id of the texture
  27201. */
  27202. uniqueId: number;
  27203. /**
  27204. * Define the name of the texture.
  27205. */
  27206. name: string;
  27207. /**
  27208. * Gets or sets an object used to store user defined information.
  27209. */
  27210. metadata: any;
  27211. /**
  27212. * For internal use only. Please do not use.
  27213. */
  27214. reservedDataStore: any;
  27215. private _hasAlpha;
  27216. /**
  27217. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27218. */
  27219. hasAlpha: boolean;
  27220. /**
  27221. * Defines if the alpha value should be determined via the rgb values.
  27222. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27223. */
  27224. getAlphaFromRGB: boolean;
  27225. /**
  27226. * Intensity or strength of the texture.
  27227. * It is commonly used by materials to fine tune the intensity of the texture
  27228. */
  27229. level: number;
  27230. /**
  27231. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27232. * This is part of the texture as textures usually maps to one uv set.
  27233. */
  27234. coordinatesIndex: number;
  27235. private _coordinatesMode;
  27236. /**
  27237. * How a texture is mapped.
  27238. *
  27239. * | Value | Type | Description |
  27240. * | ----- | ----------------------------------- | ----------- |
  27241. * | 0 | EXPLICIT_MODE | |
  27242. * | 1 | SPHERICAL_MODE | |
  27243. * | 2 | PLANAR_MODE | |
  27244. * | 3 | CUBIC_MODE | |
  27245. * | 4 | PROJECTION_MODE | |
  27246. * | 5 | SKYBOX_MODE | |
  27247. * | 6 | INVCUBIC_MODE | |
  27248. * | 7 | EQUIRECTANGULAR_MODE | |
  27249. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27250. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27251. */
  27252. coordinatesMode: number;
  27253. /**
  27254. * | Value | Type | Description |
  27255. * | ----- | ------------------ | ----------- |
  27256. * | 0 | CLAMP_ADDRESSMODE | |
  27257. * | 1 | WRAP_ADDRESSMODE | |
  27258. * | 2 | MIRROR_ADDRESSMODE | |
  27259. */
  27260. wrapU: number;
  27261. /**
  27262. * | Value | Type | Description |
  27263. * | ----- | ------------------ | ----------- |
  27264. * | 0 | CLAMP_ADDRESSMODE | |
  27265. * | 1 | WRAP_ADDRESSMODE | |
  27266. * | 2 | MIRROR_ADDRESSMODE | |
  27267. */
  27268. wrapV: number;
  27269. /**
  27270. * | Value | Type | Description |
  27271. * | ----- | ------------------ | ----------- |
  27272. * | 0 | CLAMP_ADDRESSMODE | |
  27273. * | 1 | WRAP_ADDRESSMODE | |
  27274. * | 2 | MIRROR_ADDRESSMODE | |
  27275. */
  27276. wrapR: number;
  27277. /**
  27278. * With compliant hardware and browser (supporting anisotropic filtering)
  27279. * this defines the level of anisotropic filtering in the texture.
  27280. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27281. */
  27282. anisotropicFilteringLevel: number;
  27283. /**
  27284. * Define if the texture is a cube texture or if false a 2d texture.
  27285. */
  27286. isCube: boolean;
  27287. /**
  27288. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27289. */
  27290. is3D: boolean;
  27291. /**
  27292. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27293. * HDR texture are usually stored in linear space.
  27294. * This only impacts the PBR and Background materials
  27295. */
  27296. gammaSpace: boolean;
  27297. /**
  27298. * Gets or sets whether or not the texture contains RGBD data.
  27299. */
  27300. isRGBD: boolean;
  27301. /**
  27302. * Is Z inverted in the texture (useful in a cube texture).
  27303. */
  27304. invertZ: boolean;
  27305. /**
  27306. * Are mip maps generated for this texture or not.
  27307. */
  27308. readonly noMipmap: boolean;
  27309. /**
  27310. * @hidden
  27311. */
  27312. lodLevelInAlpha: boolean;
  27313. /**
  27314. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27315. */
  27316. lodGenerationOffset: number;
  27317. /**
  27318. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27319. */
  27320. lodGenerationScale: number;
  27321. /**
  27322. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27323. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27324. * average roughness values.
  27325. */
  27326. linearSpecularLOD: boolean;
  27327. /**
  27328. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27329. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27330. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27331. */
  27332. irradianceTexture: Nullable<BaseTexture>;
  27333. /**
  27334. * Define if the texture is a render target.
  27335. */
  27336. isRenderTarget: boolean;
  27337. /**
  27338. * Define the unique id of the texture in the scene.
  27339. */
  27340. readonly uid: string;
  27341. /**
  27342. * Return a string representation of the texture.
  27343. * @returns the texture as a string
  27344. */
  27345. toString(): string;
  27346. /**
  27347. * Get the class name of the texture.
  27348. * @returns "BaseTexture"
  27349. */
  27350. getClassName(): string;
  27351. /**
  27352. * Define the list of animation attached to the texture.
  27353. */
  27354. animations: Animation[];
  27355. /**
  27356. * An event triggered when the texture is disposed.
  27357. */
  27358. onDisposeObservable: Observable<BaseTexture>;
  27359. private _onDisposeObserver;
  27360. /**
  27361. * Callback triggered when the texture has been disposed.
  27362. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27363. */
  27364. onDispose: () => void;
  27365. /**
  27366. * Define the current state of the loading sequence when in delayed load mode.
  27367. */
  27368. delayLoadState: number;
  27369. private _scene;
  27370. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27371. private _uid;
  27372. /**
  27373. * Define if the texture is preventinga material to render or not.
  27374. * If not and the texture is not ready, the engine will use a default black texture instead.
  27375. */
  27376. readonly isBlocking: boolean;
  27377. /**
  27378. * Instantiates a new BaseTexture.
  27379. * Base class of all the textures in babylon.
  27380. * It groups all the common properties the materials, post process, lights... might need
  27381. * in order to make a correct use of the texture.
  27382. * @param scene Define the scene the texture blongs to
  27383. */
  27384. constructor(scene: Nullable<Scene>);
  27385. /**
  27386. * Get the scene the texture belongs to.
  27387. * @returns the scene or null if undefined
  27388. */
  27389. getScene(): Nullable<Scene>;
  27390. /**
  27391. * Get the texture transform matrix used to offset tile the texture for istance.
  27392. * @returns the transformation matrix
  27393. */
  27394. getTextureMatrix(): Matrix;
  27395. /**
  27396. * Get the texture reflection matrix used to rotate/transform the reflection.
  27397. * @returns the reflection matrix
  27398. */
  27399. getReflectionTextureMatrix(): Matrix;
  27400. /**
  27401. * Get the underlying lower level texture from Babylon.
  27402. * @returns the insternal texture
  27403. */
  27404. getInternalTexture(): Nullable<InternalTexture>;
  27405. /**
  27406. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27407. * @returns true if ready or not blocking
  27408. */
  27409. isReadyOrNotBlocking(): boolean;
  27410. /**
  27411. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27412. * @returns true if fully ready
  27413. */
  27414. isReady(): boolean;
  27415. private _cachedSize;
  27416. /**
  27417. * Get the size of the texture.
  27418. * @returns the texture size.
  27419. */
  27420. getSize(): ISize;
  27421. /**
  27422. * Get the base size of the texture.
  27423. * It can be different from the size if the texture has been resized for POT for instance
  27424. * @returns the base size
  27425. */
  27426. getBaseSize(): ISize;
  27427. /**
  27428. * Update the sampling mode of the texture.
  27429. * Default is Trilinear mode.
  27430. *
  27431. * | Value | Type | Description |
  27432. * | ----- | ------------------ | ----------- |
  27433. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27434. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27435. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27436. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27437. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27438. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27439. * | 7 | NEAREST_LINEAR | |
  27440. * | 8 | NEAREST_NEAREST | |
  27441. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27442. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27443. * | 11 | LINEAR_LINEAR | |
  27444. * | 12 | LINEAR_NEAREST | |
  27445. *
  27446. * > _mag_: magnification filter (close to the viewer)
  27447. * > _min_: minification filter (far from the viewer)
  27448. * > _mip_: filter used between mip map levels
  27449. *@param samplingMode Define the new sampling mode of the texture
  27450. */
  27451. updateSamplingMode(samplingMode: number): void;
  27452. /**
  27453. * Scales the texture if is `canRescale()`
  27454. * @param ratio the resize factor we want to use to rescale
  27455. */
  27456. scale(ratio: number): void;
  27457. /**
  27458. * Get if the texture can rescale.
  27459. */
  27460. readonly canRescale: boolean;
  27461. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27462. /** @hidden */ private _rebuild(): void;
  27463. /**
  27464. * Triggers the load sequence in delayed load mode.
  27465. */
  27466. delayLoad(): void;
  27467. /**
  27468. * Clones the texture.
  27469. * @returns the cloned texture
  27470. */
  27471. clone(): Nullable<BaseTexture>;
  27472. /**
  27473. * Get the texture underlying type (INT, FLOAT...)
  27474. */
  27475. readonly textureType: number;
  27476. /**
  27477. * Get the texture underlying format (RGB, RGBA...)
  27478. */
  27479. readonly textureFormat: number;
  27480. /**
  27481. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27482. * This will returns an RGBA array buffer containing either in values (0-255) or
  27483. * float values (0-1) depending of the underlying buffer type.
  27484. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27485. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27486. * @param buffer defines a user defined buffer to fill with data (can be null)
  27487. * @returns The Array buffer containing the pixels data.
  27488. */
  27489. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27490. /**
  27491. * Release and destroy the underlying lower level texture aka internalTexture.
  27492. */
  27493. releaseInternalTexture(): void;
  27494. /**
  27495. * Get the polynomial representation of the texture data.
  27496. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27497. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27498. */
  27499. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27500. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27501. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27502. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27503. /**
  27504. * Dispose the texture and release its associated resources.
  27505. */
  27506. dispose(): void;
  27507. /**
  27508. * Serialize the texture into a JSON representation that can be parsed later on.
  27509. * @returns the JSON representation of the texture
  27510. */
  27511. serialize(): any;
  27512. /**
  27513. * Helper function to be called back once a list of texture contains only ready textures.
  27514. * @param textures Define the list of textures to wait for
  27515. * @param callback Define the callback triggered once the entire list will be ready
  27516. */
  27517. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27518. }
  27519. }
  27520. declare module BABYLON {
  27521. /**
  27522. * Class used to store data associated with WebGL texture data for the engine
  27523. * This class should not be used directly
  27524. */
  27525. export class InternalTexture {
  27526. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27527. /**
  27528. * The source of the texture data is unknown
  27529. */
  27530. static DATASOURCE_UNKNOWN: number;
  27531. /**
  27532. * Texture data comes from an URL
  27533. */
  27534. static DATASOURCE_URL: number;
  27535. /**
  27536. * Texture data is only used for temporary storage
  27537. */
  27538. static DATASOURCE_TEMP: number;
  27539. /**
  27540. * Texture data comes from raw data (ArrayBuffer)
  27541. */
  27542. static DATASOURCE_RAW: number;
  27543. /**
  27544. * Texture content is dynamic (video or dynamic texture)
  27545. */
  27546. static DATASOURCE_DYNAMIC: number;
  27547. /**
  27548. * Texture content is generated by rendering to it
  27549. */
  27550. static DATASOURCE_RENDERTARGET: number;
  27551. /**
  27552. * Texture content is part of a multi render target process
  27553. */
  27554. static DATASOURCE_MULTIRENDERTARGET: number;
  27555. /**
  27556. * Texture data comes from a cube data file
  27557. */
  27558. static DATASOURCE_CUBE: number;
  27559. /**
  27560. * Texture data comes from a raw cube data
  27561. */
  27562. static DATASOURCE_CUBERAW: number;
  27563. /**
  27564. * Texture data come from a prefiltered cube data file
  27565. */
  27566. static DATASOURCE_CUBEPREFILTERED: number;
  27567. /**
  27568. * Texture content is raw 3D data
  27569. */
  27570. static DATASOURCE_RAW3D: number;
  27571. /**
  27572. * Texture content is a depth texture
  27573. */
  27574. static DATASOURCE_DEPTHTEXTURE: number;
  27575. /**
  27576. * Texture data comes from a raw cube data encoded with RGBD
  27577. */
  27578. static DATASOURCE_CUBERAW_RGBD: number;
  27579. /**
  27580. * Defines if the texture is ready
  27581. */
  27582. isReady: boolean;
  27583. /**
  27584. * Defines if the texture is a cube texture
  27585. */
  27586. isCube: boolean;
  27587. /**
  27588. * Defines if the texture contains 3D data
  27589. */
  27590. is3D: boolean;
  27591. /**
  27592. * Defines if the texture contains multiview data
  27593. */
  27594. isMultiview: boolean;
  27595. /**
  27596. * Gets the URL used to load this texture
  27597. */
  27598. url: string;
  27599. /**
  27600. * Gets the sampling mode of the texture
  27601. */
  27602. samplingMode: number;
  27603. /**
  27604. * Gets a boolean indicating if the texture needs mipmaps generation
  27605. */
  27606. generateMipMaps: boolean;
  27607. /**
  27608. * Gets the number of samples used by the texture (WebGL2+ only)
  27609. */
  27610. samples: number;
  27611. /**
  27612. * Gets the type of the texture (int, float...)
  27613. */
  27614. type: number;
  27615. /**
  27616. * Gets the format of the texture (RGB, RGBA...)
  27617. */
  27618. format: number;
  27619. /**
  27620. * Observable called when the texture is loaded
  27621. */
  27622. onLoadedObservable: Observable<InternalTexture>;
  27623. /**
  27624. * Gets the width of the texture
  27625. */
  27626. width: number;
  27627. /**
  27628. * Gets the height of the texture
  27629. */
  27630. height: number;
  27631. /**
  27632. * Gets the depth of the texture
  27633. */
  27634. depth: number;
  27635. /**
  27636. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27637. */
  27638. baseWidth: number;
  27639. /**
  27640. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27641. */
  27642. baseHeight: number;
  27643. /**
  27644. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27645. */
  27646. baseDepth: number;
  27647. /**
  27648. * Gets a boolean indicating if the texture is inverted on Y axis
  27649. */
  27650. invertY: boolean;
  27651. /** @hidden */ private _invertVScale: boolean;
  27652. /** @hidden */ private _associatedChannel: number;
  27653. /** @hidden */ private _dataSource: number;
  27654. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  27655. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  27656. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  27657. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27658. /** @hidden */ private _size: number;
  27659. /** @hidden */ private _extension: string;
  27660. /** @hidden */ private _files: Nullable<string[]>;
  27661. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27662. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27663. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  27664. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27665. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27666. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27667. /** @hidden */ private _attachments: Nullable<number[]>;
  27668. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  27669. /** @hidden */ private _cachedWrapU: Nullable<number>;
  27670. /** @hidden */ private _cachedWrapV: Nullable<number>;
  27671. /** @hidden */ private _cachedWrapR: Nullable<number>;
  27672. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  27673. /** @hidden */ private _isDisabled: boolean;
  27674. /** @hidden */ private _compression: Nullable<string>;
  27675. /** @hidden */ private _generateStencilBuffer: boolean;
  27676. /** @hidden */ private _generateDepthBuffer: boolean;
  27677. /** @hidden */ private _comparisonFunction: number;
  27678. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  27679. /** @hidden */ private _lodGenerationScale: number;
  27680. /** @hidden */ private _lodGenerationOffset: number;
  27681. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  27682. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  27683. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  27684. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  27685. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  27686. /** @hidden */ private _isRGBD: boolean;
  27687. /** @hidden */ private _linearSpecularLOD: boolean;
  27688. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  27689. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  27690. /** @hidden */ private _references: number;
  27691. private _engine;
  27692. /**
  27693. * Gets the Engine the texture belongs to.
  27694. * @returns The babylon engine
  27695. */
  27696. getEngine(): Engine;
  27697. /**
  27698. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  27699. */
  27700. readonly dataSource: number;
  27701. /**
  27702. * Creates a new InternalTexture
  27703. * @param engine defines the engine to use
  27704. * @param dataSource defines the type of data that will be used
  27705. * @param delayAllocation if the texture allocation should be delayed (default: false)
  27706. */
  27707. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  27708. /**
  27709. * Increments the number of references (ie. the number of Texture that point to it)
  27710. */
  27711. incrementReferences(): void;
  27712. /**
  27713. * Change the size of the texture (not the size of the content)
  27714. * @param width defines the new width
  27715. * @param height defines the new height
  27716. * @param depth defines the new depth (1 by default)
  27717. */
  27718. updateSize(width: int, height: int, depth?: int): void;
  27719. /** @hidden */ private _rebuild(): void;
  27720. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  27721. /**
  27722. * Dispose the current allocated resources
  27723. */
  27724. dispose(): void;
  27725. }
  27726. }
  27727. declare module BABYLON {
  27728. /**
  27729. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  27730. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  27731. */
  27732. export class EffectFallbacks {
  27733. private _defines;
  27734. private _currentRank;
  27735. private _maxRank;
  27736. private _mesh;
  27737. /**
  27738. * Removes the fallback from the bound mesh.
  27739. */
  27740. unBindMesh(): void;
  27741. /**
  27742. * Adds a fallback on the specified property.
  27743. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27744. * @param define The name of the define in the shader
  27745. */
  27746. addFallback(rank: number, define: string): void;
  27747. /**
  27748. * Sets the mesh to use CPU skinning when needing to fallback.
  27749. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27750. * @param mesh The mesh to use the fallbacks.
  27751. */
  27752. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  27753. /**
  27754. * Checks to see if more fallbacks are still availible.
  27755. */
  27756. readonly hasMoreFallbacks: boolean;
  27757. /**
  27758. * Removes the defines that should be removed when falling back.
  27759. * @param currentDefines defines the current define statements for the shader.
  27760. * @param effect defines the current effect we try to compile
  27761. * @returns The resulting defines with defines of the current rank removed.
  27762. */
  27763. reduce(currentDefines: string, effect: Effect): string;
  27764. }
  27765. /**
  27766. * Options to be used when creating an effect.
  27767. */
  27768. export class EffectCreationOptions {
  27769. /**
  27770. * Atrributes that will be used in the shader.
  27771. */
  27772. attributes: string[];
  27773. /**
  27774. * Uniform varible names that will be set in the shader.
  27775. */
  27776. uniformsNames: string[];
  27777. /**
  27778. * Uniform buffer varible names that will be set in the shader.
  27779. */
  27780. uniformBuffersNames: string[];
  27781. /**
  27782. * Sampler texture variable names that will be set in the shader.
  27783. */
  27784. samplers: string[];
  27785. /**
  27786. * Define statements that will be set in the shader.
  27787. */
  27788. defines: any;
  27789. /**
  27790. * Possible fallbacks for this effect to improve performance when needed.
  27791. */
  27792. fallbacks: Nullable<EffectFallbacks>;
  27793. /**
  27794. * Callback that will be called when the shader is compiled.
  27795. */
  27796. onCompiled: Nullable<(effect: Effect) => void>;
  27797. /**
  27798. * Callback that will be called if an error occurs during shader compilation.
  27799. */
  27800. onError: Nullable<(effect: Effect, errors: string) => void>;
  27801. /**
  27802. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27803. */
  27804. indexParameters: any;
  27805. /**
  27806. * Max number of lights that can be used in the shader.
  27807. */
  27808. maxSimultaneousLights: number;
  27809. /**
  27810. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27811. */
  27812. transformFeedbackVaryings: Nullable<string[]>;
  27813. }
  27814. /**
  27815. * Effect containing vertex and fragment shader that can be executed on an object.
  27816. */
  27817. export class Effect implements IDisposable {
  27818. /**
  27819. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27820. */
  27821. static ShadersRepository: string;
  27822. /**
  27823. * Name of the effect.
  27824. */
  27825. name: any;
  27826. /**
  27827. * String container all the define statements that should be set on the shader.
  27828. */
  27829. defines: string;
  27830. /**
  27831. * Callback that will be called when the shader is compiled.
  27832. */
  27833. onCompiled: Nullable<(effect: Effect) => void>;
  27834. /**
  27835. * Callback that will be called if an error occurs during shader compilation.
  27836. */
  27837. onError: Nullable<(effect: Effect, errors: string) => void>;
  27838. /**
  27839. * Callback that will be called when effect is bound.
  27840. */
  27841. onBind: Nullable<(effect: Effect) => void>;
  27842. /**
  27843. * Unique ID of the effect.
  27844. */
  27845. uniqueId: number;
  27846. /**
  27847. * Observable that will be called when the shader is compiled.
  27848. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27849. */
  27850. onCompileObservable: Observable<Effect>;
  27851. /**
  27852. * Observable that will be called if an error occurs during shader compilation.
  27853. */
  27854. onErrorObservable: Observable<Effect>;
  27855. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27856. /**
  27857. * Observable that will be called when effect is bound.
  27858. */
  27859. readonly onBindObservable: Observable<Effect>;
  27860. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27861. private static _uniqueIdSeed;
  27862. private _engine;
  27863. private _uniformBuffersNames;
  27864. private _uniformsNames;
  27865. private _samplerList;
  27866. private _samplers;
  27867. private _isReady;
  27868. private _compilationError;
  27869. private _attributesNames;
  27870. private _attributes;
  27871. private _uniforms;
  27872. /**
  27873. * Key for the effect.
  27874. * @hidden
  27875. */ private _key: string;
  27876. private _indexParameters;
  27877. private _fallbacks;
  27878. private _vertexSourceCode;
  27879. private _fragmentSourceCode;
  27880. private _vertexSourceCodeOverride;
  27881. private _fragmentSourceCodeOverride;
  27882. private _transformFeedbackVaryings;
  27883. /**
  27884. * Compiled shader to webGL program.
  27885. * @hidden
  27886. */ private _pipelineContext: Nullable<IPipelineContext>;
  27887. private _valueCache;
  27888. private static _baseCache;
  27889. /**
  27890. * Instantiates an effect.
  27891. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27892. * @param baseName Name of the effect.
  27893. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27894. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27895. * @param samplers List of sampler variables that will be passed to the shader.
  27896. * @param engine Engine to be used to render the effect
  27897. * @param defines Define statements to be added to the shader.
  27898. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27899. * @param onCompiled Callback that will be called when the shader is compiled.
  27900. * @param onError Callback that will be called if an error occurs during shader compilation.
  27901. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27902. */
  27903. 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);
  27904. private _useFinalCode;
  27905. /**
  27906. * Unique key for this effect
  27907. */
  27908. readonly key: string;
  27909. /**
  27910. * If the effect has been compiled and prepared.
  27911. * @returns if the effect is compiled and prepared.
  27912. */
  27913. isReady(): boolean;
  27914. private _isReadyInternal;
  27915. /**
  27916. * The engine the effect was initialized with.
  27917. * @returns the engine.
  27918. */
  27919. getEngine(): Engine;
  27920. /**
  27921. * The pipeline context for this effect
  27922. * @returns the associated pipeline context
  27923. */
  27924. getPipelineContext(): Nullable<IPipelineContext>;
  27925. /**
  27926. * The set of names of attribute variables for the shader.
  27927. * @returns An array of attribute names.
  27928. */
  27929. getAttributesNames(): string[];
  27930. /**
  27931. * Returns the attribute at the given index.
  27932. * @param index The index of the attribute.
  27933. * @returns The location of the attribute.
  27934. */
  27935. getAttributeLocation(index: number): number;
  27936. /**
  27937. * Returns the attribute based on the name of the variable.
  27938. * @param name of the attribute to look up.
  27939. * @returns the attribute location.
  27940. */
  27941. getAttributeLocationByName(name: string): number;
  27942. /**
  27943. * The number of attributes.
  27944. * @returns the numnber of attributes.
  27945. */
  27946. getAttributesCount(): number;
  27947. /**
  27948. * Gets the index of a uniform variable.
  27949. * @param uniformName of the uniform to look up.
  27950. * @returns the index.
  27951. */
  27952. getUniformIndex(uniformName: string): number;
  27953. /**
  27954. * Returns the attribute based on the name of the variable.
  27955. * @param uniformName of the uniform to look up.
  27956. * @returns the location of the uniform.
  27957. */
  27958. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27959. /**
  27960. * Returns an array of sampler variable names
  27961. * @returns The array of sampler variable neames.
  27962. */
  27963. getSamplers(): string[];
  27964. /**
  27965. * The error from the last compilation.
  27966. * @returns the error string.
  27967. */
  27968. getCompilationError(): string;
  27969. /**
  27970. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27971. * @param func The callback to be used.
  27972. */
  27973. executeWhenCompiled(func: (effect: Effect) => void): void;
  27974. private _checkIsReady;
  27975. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27976. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27977. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27978. /**
  27979. * Recompiles the webGL program
  27980. * @param vertexSourceCode The source code for the vertex shader.
  27981. * @param fragmentSourceCode The source code for the fragment shader.
  27982. * @param onCompiled Callback called when completed.
  27983. * @param onError Callback called on error.
  27984. * @hidden
  27985. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27986. /**
  27987. * Prepares the effect
  27988. * @hidden
  27989. */ private _prepareEffect(): void;
  27990. private _processCompilationErrors;
  27991. /**
  27992. * Checks if the effect is supported. (Must be called after compilation)
  27993. */
  27994. readonly isSupported: boolean;
  27995. /**
  27996. * Binds a texture to the engine to be used as output of the shader.
  27997. * @param channel Name of the output variable.
  27998. * @param texture Texture to bind.
  27999. * @hidden
  28000. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  28001. /**
  28002. * Sets a texture on the engine to be used in the shader.
  28003. * @param channel Name of the sampler variable.
  28004. * @param texture Texture to set.
  28005. */
  28006. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28007. /**
  28008. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28009. * @param channel Name of the sampler variable.
  28010. * @param texture Texture to set.
  28011. */
  28012. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28013. /**
  28014. * Sets an array of textures on the engine to be used in the shader.
  28015. * @param channel Name of the variable.
  28016. * @param textures Textures to set.
  28017. */
  28018. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28019. /**
  28020. * 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)
  28021. * @param channel Name of the sampler variable.
  28022. * @param postProcess Post process to get the input texture from.
  28023. */
  28024. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28025. /**
  28026. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28027. * 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)
  28028. * @param channel Name of the sampler variable.
  28029. * @param postProcess Post process to get the output texture from.
  28030. */
  28031. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28032. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28033. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28034. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28035. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28036. /**
  28037. * Binds a buffer to a uniform.
  28038. * @param buffer Buffer to bind.
  28039. * @param name Name of the uniform variable to bind to.
  28040. */
  28041. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28042. /**
  28043. * Binds block to a uniform.
  28044. * @param blockName Name of the block to bind.
  28045. * @param index Index to bind.
  28046. */
  28047. bindUniformBlock(blockName: string, index: number): void;
  28048. /**
  28049. * Sets an interger value on a uniform variable.
  28050. * @param uniformName Name of the variable.
  28051. * @param value Value to be set.
  28052. * @returns this effect.
  28053. */
  28054. setInt(uniformName: string, value: number): Effect;
  28055. /**
  28056. * Sets an int array on a uniform variable.
  28057. * @param uniformName Name of the variable.
  28058. * @param array array to be set.
  28059. * @returns this effect.
  28060. */
  28061. setIntArray(uniformName: string, array: Int32Array): Effect;
  28062. /**
  28063. * 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)
  28064. * @param uniformName Name of the variable.
  28065. * @param array array to be set.
  28066. * @returns this effect.
  28067. */
  28068. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28069. /**
  28070. * 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)
  28071. * @param uniformName Name of the variable.
  28072. * @param array array to be set.
  28073. * @returns this effect.
  28074. */
  28075. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28076. /**
  28077. * 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)
  28078. * @param uniformName Name of the variable.
  28079. * @param array array to be set.
  28080. * @returns this effect.
  28081. */
  28082. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28083. /**
  28084. * Sets an float array on a uniform variable.
  28085. * @param uniformName Name of the variable.
  28086. * @param array array to be set.
  28087. * @returns this effect.
  28088. */
  28089. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28090. /**
  28091. * 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)
  28092. * @param uniformName Name of the variable.
  28093. * @param array array to be set.
  28094. * @returns this effect.
  28095. */
  28096. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28097. /**
  28098. * 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)
  28099. * @param uniformName Name of the variable.
  28100. * @param array array to be set.
  28101. * @returns this effect.
  28102. */
  28103. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28104. /**
  28105. * 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)
  28106. * @param uniformName Name of the variable.
  28107. * @param array array to be set.
  28108. * @returns this effect.
  28109. */
  28110. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28111. /**
  28112. * Sets an array on a uniform variable.
  28113. * @param uniformName Name of the variable.
  28114. * @param array array to be set.
  28115. * @returns this effect.
  28116. */
  28117. setArray(uniformName: string, array: number[]): Effect;
  28118. /**
  28119. * 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)
  28120. * @param uniformName Name of the variable.
  28121. * @param array array to be set.
  28122. * @returns this effect.
  28123. */
  28124. setArray2(uniformName: string, array: number[]): Effect;
  28125. /**
  28126. * 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)
  28127. * @param uniformName Name of the variable.
  28128. * @param array array to be set.
  28129. * @returns this effect.
  28130. */
  28131. setArray3(uniformName: string, array: number[]): Effect;
  28132. /**
  28133. * 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)
  28134. * @param uniformName Name of the variable.
  28135. * @param array array to be set.
  28136. * @returns this effect.
  28137. */
  28138. setArray4(uniformName: string, array: number[]): Effect;
  28139. /**
  28140. * Sets matrices on a uniform variable.
  28141. * @param uniformName Name of the variable.
  28142. * @param matrices matrices to be set.
  28143. * @returns this effect.
  28144. */
  28145. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28146. /**
  28147. * Sets matrix on a uniform variable.
  28148. * @param uniformName Name of the variable.
  28149. * @param matrix matrix to be set.
  28150. * @returns this effect.
  28151. */
  28152. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28153. /**
  28154. * 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)
  28155. * @param uniformName Name of the variable.
  28156. * @param matrix matrix to be set.
  28157. * @returns this effect.
  28158. */
  28159. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28160. /**
  28161. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28162. * @param uniformName Name of the variable.
  28163. * @param matrix matrix to be set.
  28164. * @returns this effect.
  28165. */
  28166. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28167. /**
  28168. * Sets a float on a uniform variable.
  28169. * @param uniformName Name of the variable.
  28170. * @param value value to be set.
  28171. * @returns this effect.
  28172. */
  28173. setFloat(uniformName: string, value: number): Effect;
  28174. /**
  28175. * Sets a boolean on a uniform variable.
  28176. * @param uniformName Name of the variable.
  28177. * @param bool value to be set.
  28178. * @returns this effect.
  28179. */
  28180. setBool(uniformName: string, bool: boolean): Effect;
  28181. /**
  28182. * Sets a Vector2 on a uniform variable.
  28183. * @param uniformName Name of the variable.
  28184. * @param vector2 vector2 to be set.
  28185. * @returns this effect.
  28186. */
  28187. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28188. /**
  28189. * Sets a float2 on a uniform variable.
  28190. * @param uniformName Name of the variable.
  28191. * @param x First float in float2.
  28192. * @param y Second float in float2.
  28193. * @returns this effect.
  28194. */
  28195. setFloat2(uniformName: string, x: number, y: number): Effect;
  28196. /**
  28197. * Sets a Vector3 on a uniform variable.
  28198. * @param uniformName Name of the variable.
  28199. * @param vector3 Value to be set.
  28200. * @returns this effect.
  28201. */
  28202. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28203. /**
  28204. * Sets a float3 on a uniform variable.
  28205. * @param uniformName Name of the variable.
  28206. * @param x First float in float3.
  28207. * @param y Second float in float3.
  28208. * @param z Third float in float3.
  28209. * @returns this effect.
  28210. */
  28211. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28212. /**
  28213. * Sets a Vector4 on a uniform variable.
  28214. * @param uniformName Name of the variable.
  28215. * @param vector4 Value to be set.
  28216. * @returns this effect.
  28217. */
  28218. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28219. /**
  28220. * Sets a float4 on a uniform variable.
  28221. * @param uniformName Name of the variable.
  28222. * @param x First float in float4.
  28223. * @param y Second float in float4.
  28224. * @param z Third float in float4.
  28225. * @param w Fourth float in float4.
  28226. * @returns this effect.
  28227. */
  28228. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28229. /**
  28230. * Sets a Color3 on a uniform variable.
  28231. * @param uniformName Name of the variable.
  28232. * @param color3 Value to be set.
  28233. * @returns this effect.
  28234. */
  28235. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28236. /**
  28237. * Sets a Color4 on a uniform variable.
  28238. * @param uniformName Name of the variable.
  28239. * @param color3 Value to be set.
  28240. * @param alpha Alpha value to be set.
  28241. * @returns this effect.
  28242. */
  28243. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28244. /**
  28245. * Sets a Color4 on a uniform variable
  28246. * @param uniformName defines the name of the variable
  28247. * @param color4 defines the value to be set
  28248. * @returns this effect.
  28249. */
  28250. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28251. /** Release all associated resources */
  28252. dispose(): void;
  28253. /**
  28254. * This function will add a new shader to the shader store
  28255. * @param name the name of the shader
  28256. * @param pixelShader optional pixel shader content
  28257. * @param vertexShader optional vertex shader content
  28258. */
  28259. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28260. /**
  28261. * Store of each shader (The can be looked up using effect.key)
  28262. */
  28263. static ShadersStore: {
  28264. [key: string]: string;
  28265. };
  28266. /**
  28267. * Store of each included file for a shader (The can be looked up using effect.key)
  28268. */
  28269. static IncludesShadersStore: {
  28270. [key: string]: string;
  28271. };
  28272. /**
  28273. * Resets the cache of effects.
  28274. */
  28275. static ResetCache(): void;
  28276. }
  28277. }
  28278. declare module BABYLON {
  28279. /**
  28280. * Uniform buffer objects.
  28281. *
  28282. * Handles blocks of uniform on the GPU.
  28283. *
  28284. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28285. *
  28286. * For more information, please refer to :
  28287. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28288. */
  28289. export class UniformBuffer {
  28290. private _engine;
  28291. private _buffer;
  28292. private _data;
  28293. private _bufferData;
  28294. private _dynamic?;
  28295. private _uniformLocations;
  28296. private _uniformSizes;
  28297. private _uniformLocationPointer;
  28298. private _needSync;
  28299. private _noUBO;
  28300. private _currentEffect;
  28301. private static _MAX_UNIFORM_SIZE;
  28302. private static _tempBuffer;
  28303. /**
  28304. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28305. * This is dynamic to allow compat with webgl 1 and 2.
  28306. * You will need to pass the name of the uniform as well as the value.
  28307. */
  28308. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28309. /**
  28310. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28311. * This is dynamic to allow compat with webgl 1 and 2.
  28312. * You will need to pass the name of the uniform as well as the value.
  28313. */
  28314. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28315. /**
  28316. * Lambda to Update a single float in a uniform buffer.
  28317. * This is dynamic to allow compat with webgl 1 and 2.
  28318. * You will need to pass the name of the uniform as well as the value.
  28319. */
  28320. updateFloat: (name: string, x: number) => void;
  28321. /**
  28322. * Lambda to Update a vec2 of float in a uniform buffer.
  28323. * This is dynamic to allow compat with webgl 1 and 2.
  28324. * You will need to pass the name of the uniform as well as the value.
  28325. */
  28326. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28327. /**
  28328. * Lambda to Update a vec3 of float in a uniform buffer.
  28329. * This is dynamic to allow compat with webgl 1 and 2.
  28330. * You will need to pass the name of the uniform as well as the value.
  28331. */
  28332. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28333. /**
  28334. * Lambda to Update a vec4 of float in a uniform buffer.
  28335. * This is dynamic to allow compat with webgl 1 and 2.
  28336. * You will need to pass the name of the uniform as well as the value.
  28337. */
  28338. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28339. /**
  28340. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28341. * This is dynamic to allow compat with webgl 1 and 2.
  28342. * You will need to pass the name of the uniform as well as the value.
  28343. */
  28344. updateMatrix: (name: string, mat: Matrix) => void;
  28345. /**
  28346. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28347. * This is dynamic to allow compat with webgl 1 and 2.
  28348. * You will need to pass the name of the uniform as well as the value.
  28349. */
  28350. updateVector3: (name: string, vector: Vector3) => void;
  28351. /**
  28352. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28353. * This is dynamic to allow compat with webgl 1 and 2.
  28354. * You will need to pass the name of the uniform as well as the value.
  28355. */
  28356. updateVector4: (name: string, vector: Vector4) => void;
  28357. /**
  28358. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28359. * This is dynamic to allow compat with webgl 1 and 2.
  28360. * You will need to pass the name of the uniform as well as the value.
  28361. */
  28362. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28363. /**
  28364. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28365. * This is dynamic to allow compat with webgl 1 and 2.
  28366. * You will need to pass the name of the uniform as well as the value.
  28367. */
  28368. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28369. /**
  28370. * Instantiates a new Uniform buffer objects.
  28371. *
  28372. * Handles blocks of uniform on the GPU.
  28373. *
  28374. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28375. *
  28376. * For more information, please refer to :
  28377. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28378. * @param engine Define the engine the buffer is associated with
  28379. * @param data Define the data contained in the buffer
  28380. * @param dynamic Define if the buffer is updatable
  28381. */
  28382. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28383. /**
  28384. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28385. * or just falling back on setUniformXXX calls.
  28386. */
  28387. readonly useUbo: boolean;
  28388. /**
  28389. * Indicates if the WebGL underlying uniform buffer is in sync
  28390. * with the javascript cache data.
  28391. */
  28392. readonly isSync: boolean;
  28393. /**
  28394. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28395. * Also, a dynamic UniformBuffer will disable cache verification and always
  28396. * update the underlying WebGL uniform buffer to the GPU.
  28397. * @returns if Dynamic, otherwise false
  28398. */
  28399. isDynamic(): boolean;
  28400. /**
  28401. * The data cache on JS side.
  28402. * @returns the underlying data as a float array
  28403. */
  28404. getData(): Float32Array;
  28405. /**
  28406. * The underlying WebGL Uniform buffer.
  28407. * @returns the webgl buffer
  28408. */
  28409. getBuffer(): Nullable<DataBuffer>;
  28410. /**
  28411. * std140 layout specifies how to align data within an UBO structure.
  28412. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28413. * for specs.
  28414. */
  28415. private _fillAlignment;
  28416. /**
  28417. * Adds an uniform in the buffer.
  28418. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28419. * for the layout to be correct !
  28420. * @param name Name of the uniform, as used in the uniform block in the shader.
  28421. * @param size Data size, or data directly.
  28422. */
  28423. addUniform(name: string, size: number | number[]): void;
  28424. /**
  28425. * Adds a Matrix 4x4 to the uniform buffer.
  28426. * @param name Name of the uniform, as used in the uniform block in the shader.
  28427. * @param mat A 4x4 matrix.
  28428. */
  28429. addMatrix(name: string, mat: Matrix): void;
  28430. /**
  28431. * Adds a vec2 to the uniform buffer.
  28432. * @param name Name of the uniform, as used in the uniform block in the shader.
  28433. * @param x Define the x component value of the vec2
  28434. * @param y Define the y component value of the vec2
  28435. */
  28436. addFloat2(name: string, x: number, y: number): void;
  28437. /**
  28438. * Adds a vec3 to the uniform buffer.
  28439. * @param name Name of the uniform, as used in the uniform block in the shader.
  28440. * @param x Define the x component value of the vec3
  28441. * @param y Define the y component value of the vec3
  28442. * @param z Define the z component value of the vec3
  28443. */
  28444. addFloat3(name: string, x: number, y: number, z: number): void;
  28445. /**
  28446. * Adds a vec3 to the uniform buffer.
  28447. * @param name Name of the uniform, as used in the uniform block in the shader.
  28448. * @param color Define the vec3 from a Color
  28449. */
  28450. addColor3(name: string, color: Color3): void;
  28451. /**
  28452. * Adds a vec4 to the uniform buffer.
  28453. * @param name Name of the uniform, as used in the uniform block in the shader.
  28454. * @param color Define the rgb components from a Color
  28455. * @param alpha Define the a component of the vec4
  28456. */
  28457. addColor4(name: string, color: Color3, alpha: number): void;
  28458. /**
  28459. * Adds a vec3 to the uniform buffer.
  28460. * @param name Name of the uniform, as used in the uniform block in the shader.
  28461. * @param vector Define the vec3 components from a Vector
  28462. */
  28463. addVector3(name: string, vector: Vector3): void;
  28464. /**
  28465. * Adds a Matrix 3x3 to the uniform buffer.
  28466. * @param name Name of the uniform, as used in the uniform block in the shader.
  28467. */
  28468. addMatrix3x3(name: string): void;
  28469. /**
  28470. * Adds a Matrix 2x2 to the uniform buffer.
  28471. * @param name Name of the uniform, as used in the uniform block in the shader.
  28472. */
  28473. addMatrix2x2(name: string): void;
  28474. /**
  28475. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28476. */
  28477. create(): void;
  28478. /** @hidden */ private _rebuild(): void;
  28479. /**
  28480. * Updates the WebGL Uniform Buffer on the GPU.
  28481. * If the `dynamic` flag is set to true, no cache comparison is done.
  28482. * Otherwise, the buffer will be updated only if the cache differs.
  28483. */
  28484. update(): void;
  28485. /**
  28486. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28487. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28488. * @param data Define the flattened data
  28489. * @param size Define the size of the data.
  28490. */
  28491. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28492. private _valueCache;
  28493. private _cacheMatrix;
  28494. private _updateMatrix3x3ForUniform;
  28495. private _updateMatrix3x3ForEffect;
  28496. private _updateMatrix2x2ForEffect;
  28497. private _updateMatrix2x2ForUniform;
  28498. private _updateFloatForEffect;
  28499. private _updateFloatForUniform;
  28500. private _updateFloat2ForEffect;
  28501. private _updateFloat2ForUniform;
  28502. private _updateFloat3ForEffect;
  28503. private _updateFloat3ForUniform;
  28504. private _updateFloat4ForEffect;
  28505. private _updateFloat4ForUniform;
  28506. private _updateMatrixForEffect;
  28507. private _updateMatrixForUniform;
  28508. private _updateVector3ForEffect;
  28509. private _updateVector3ForUniform;
  28510. private _updateVector4ForEffect;
  28511. private _updateVector4ForUniform;
  28512. private _updateColor3ForEffect;
  28513. private _updateColor3ForUniform;
  28514. private _updateColor4ForEffect;
  28515. private _updateColor4ForUniform;
  28516. /**
  28517. * Sets a sampler uniform on the effect.
  28518. * @param name Define the name of the sampler.
  28519. * @param texture Define the texture to set in the sampler
  28520. */
  28521. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28522. /**
  28523. * Directly updates the value of the uniform in the cache AND on the GPU.
  28524. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28525. * @param data Define the flattened data
  28526. */
  28527. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28528. /**
  28529. * Binds this uniform buffer to an effect.
  28530. * @param effect Define the effect to bind the buffer to
  28531. * @param name Name of the uniform block in the shader.
  28532. */
  28533. bindToEffect(effect: Effect, name: string): void;
  28534. /**
  28535. * Disposes the uniform buffer.
  28536. */
  28537. dispose(): void;
  28538. }
  28539. }
  28540. declare module BABYLON {
  28541. /**
  28542. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28544. */
  28545. export class Analyser {
  28546. /**
  28547. * Gets or sets the smoothing
  28548. * @ignorenaming
  28549. */
  28550. SMOOTHING: number;
  28551. /**
  28552. * Gets or sets the FFT table size
  28553. * @ignorenaming
  28554. */
  28555. FFT_SIZE: number;
  28556. /**
  28557. * Gets or sets the bar graph amplitude
  28558. * @ignorenaming
  28559. */
  28560. BARGRAPHAMPLITUDE: number;
  28561. /**
  28562. * Gets or sets the position of the debug canvas
  28563. * @ignorenaming
  28564. */
  28565. DEBUGCANVASPOS: {
  28566. x: number;
  28567. y: number;
  28568. };
  28569. /**
  28570. * Gets or sets the debug canvas size
  28571. * @ignorenaming
  28572. */
  28573. DEBUGCANVASSIZE: {
  28574. width: number;
  28575. height: number;
  28576. };
  28577. private _byteFreqs;
  28578. private _byteTime;
  28579. private _floatFreqs;
  28580. private _webAudioAnalyser;
  28581. private _debugCanvas;
  28582. private _debugCanvasContext;
  28583. private _scene;
  28584. private _registerFunc;
  28585. private _audioEngine;
  28586. /**
  28587. * Creates a new analyser
  28588. * @param scene defines hosting scene
  28589. */
  28590. constructor(scene: Scene);
  28591. /**
  28592. * Get the number of data values you will have to play with for the visualization
  28593. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28594. * @returns a number
  28595. */
  28596. getFrequencyBinCount(): number;
  28597. /**
  28598. * Gets the current frequency data as a byte array
  28599. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28600. * @returns a Uint8Array
  28601. */
  28602. getByteFrequencyData(): Uint8Array;
  28603. /**
  28604. * Gets the current waveform as a byte array
  28605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28606. * @returns a Uint8Array
  28607. */
  28608. getByteTimeDomainData(): Uint8Array;
  28609. /**
  28610. * Gets the current frequency data as a float array
  28611. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28612. * @returns a Float32Array
  28613. */
  28614. getFloatFrequencyData(): Float32Array;
  28615. /**
  28616. * Renders the debug canvas
  28617. */
  28618. drawDebugCanvas(): void;
  28619. /**
  28620. * Stops rendering the debug canvas and removes it
  28621. */
  28622. stopDebugCanvas(): void;
  28623. /**
  28624. * Connects two audio nodes
  28625. * @param inputAudioNode defines first node to connect
  28626. * @param outputAudioNode defines second node to connect
  28627. */
  28628. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  28629. /**
  28630. * Releases all associated resources
  28631. */
  28632. dispose(): void;
  28633. }
  28634. }
  28635. declare module BABYLON {
  28636. /**
  28637. * This represents an audio engine and it is responsible
  28638. * to play, synchronize and analyse sounds throughout the application.
  28639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28640. */
  28641. export interface IAudioEngine extends IDisposable {
  28642. /**
  28643. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28644. */
  28645. readonly canUseWebAudio: boolean;
  28646. /**
  28647. * Gets the current AudioContext if available.
  28648. */
  28649. readonly audioContext: Nullable<AudioContext>;
  28650. /**
  28651. * The master gain node defines the global audio volume of your audio engine.
  28652. */
  28653. readonly masterGain: GainNode;
  28654. /**
  28655. * Gets whether or not mp3 are supported by your browser.
  28656. */
  28657. readonly isMP3supported: boolean;
  28658. /**
  28659. * Gets whether or not ogg are supported by your browser.
  28660. */
  28661. readonly isOGGsupported: boolean;
  28662. /**
  28663. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28664. * @ignoreNaming
  28665. */
  28666. WarnedWebAudioUnsupported: boolean;
  28667. /**
  28668. * Defines if the audio engine relies on a custom unlocked button.
  28669. * In this case, the embedded button will not be displayed.
  28670. */
  28671. useCustomUnlockedButton: boolean;
  28672. /**
  28673. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  28674. */
  28675. readonly unlocked: boolean;
  28676. /**
  28677. * Event raised when audio has been unlocked on the browser.
  28678. */
  28679. onAudioUnlockedObservable: Observable<AudioEngine>;
  28680. /**
  28681. * Event raised when audio has been locked on the browser.
  28682. */
  28683. onAudioLockedObservable: Observable<AudioEngine>;
  28684. /**
  28685. * Flags the audio engine in Locked state.
  28686. * This happens due to new browser policies preventing audio to autoplay.
  28687. */
  28688. lock(): void;
  28689. /**
  28690. * Unlocks the audio engine once a user action has been done on the dom.
  28691. * This is helpful to resume play once browser policies have been satisfied.
  28692. */
  28693. unlock(): void;
  28694. }
  28695. /**
  28696. * This represents the default audio engine used in babylon.
  28697. * It is responsible to play, synchronize and analyse sounds throughout the application.
  28698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28699. */
  28700. export class AudioEngine implements IAudioEngine {
  28701. private _audioContext;
  28702. private _audioContextInitialized;
  28703. private _muteButton;
  28704. private _hostElement;
  28705. /**
  28706. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28707. */
  28708. canUseWebAudio: boolean;
  28709. /**
  28710. * The master gain node defines the global audio volume of your audio engine.
  28711. */
  28712. masterGain: GainNode;
  28713. /**
  28714. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28715. * @ignoreNaming
  28716. */
  28717. WarnedWebAudioUnsupported: boolean;
  28718. /**
  28719. * Gets whether or not mp3 are supported by your browser.
  28720. */
  28721. isMP3supported: boolean;
  28722. /**
  28723. * Gets whether or not ogg are supported by your browser.
  28724. */
  28725. isOGGsupported: boolean;
  28726. /**
  28727. * Gets whether audio has been unlocked on the device.
  28728. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  28729. * a user interaction has happened.
  28730. */
  28731. unlocked: boolean;
  28732. /**
  28733. * Defines if the audio engine relies on a custom unlocked button.
  28734. * In this case, the embedded button will not be displayed.
  28735. */
  28736. useCustomUnlockedButton: boolean;
  28737. /**
  28738. * Event raised when audio has been unlocked on the browser.
  28739. */
  28740. onAudioUnlockedObservable: Observable<AudioEngine>;
  28741. /**
  28742. * Event raised when audio has been locked on the browser.
  28743. */
  28744. onAudioLockedObservable: Observable<AudioEngine>;
  28745. /**
  28746. * Gets the current AudioContext if available.
  28747. */
  28748. readonly audioContext: Nullable<AudioContext>;
  28749. private _connectedAnalyser;
  28750. /**
  28751. * Instantiates a new audio engine.
  28752. *
  28753. * There should be only one per page as some browsers restrict the number
  28754. * of audio contexts you can create.
  28755. * @param hostElement defines the host element where to display the mute icon if necessary
  28756. */
  28757. constructor(hostElement?: Nullable<HTMLElement>);
  28758. /**
  28759. * Flags the audio engine in Locked state.
  28760. * This happens due to new browser policies preventing audio to autoplay.
  28761. */
  28762. lock(): void;
  28763. /**
  28764. * Unlocks the audio engine once a user action has been done on the dom.
  28765. * This is helpful to resume play once browser policies have been satisfied.
  28766. */
  28767. unlock(): void;
  28768. private _resumeAudioContext;
  28769. private _initializeAudioContext;
  28770. private _tryToRun;
  28771. private _triggerRunningState;
  28772. private _triggerSuspendedState;
  28773. private _displayMuteButton;
  28774. private _moveButtonToTopLeft;
  28775. private _onResize;
  28776. private _hideMuteButton;
  28777. /**
  28778. * Destroy and release the resources associated with the audio ccontext.
  28779. */
  28780. dispose(): void;
  28781. /**
  28782. * Gets the global volume sets on the master gain.
  28783. * @returns the global volume if set or -1 otherwise
  28784. */
  28785. getGlobalVolume(): number;
  28786. /**
  28787. * Sets the global volume of your experience (sets on the master gain).
  28788. * @param newVolume Defines the new global volume of the application
  28789. */
  28790. setGlobalVolume(newVolume: number): void;
  28791. /**
  28792. * Connect the audio engine to an audio analyser allowing some amazing
  28793. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  28794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  28795. * @param analyser The analyser to connect to the engine
  28796. */
  28797. connectToAnalyser(analyser: Analyser): void;
  28798. }
  28799. }
  28800. declare module BABYLON {
  28801. /**
  28802. * Interface used to present a loading screen while loading a scene
  28803. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28804. */
  28805. export interface ILoadingScreen {
  28806. /**
  28807. * Function called to display the loading screen
  28808. */
  28809. displayLoadingUI: () => void;
  28810. /**
  28811. * Function called to hide the loading screen
  28812. */
  28813. hideLoadingUI: () => void;
  28814. /**
  28815. * Gets or sets the color to use for the background
  28816. */
  28817. loadingUIBackgroundColor: string;
  28818. /**
  28819. * Gets or sets the text to display while loading
  28820. */
  28821. loadingUIText: string;
  28822. }
  28823. /**
  28824. * Class used for the default loading screen
  28825. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28826. */
  28827. export class DefaultLoadingScreen implements ILoadingScreen {
  28828. private _renderingCanvas;
  28829. private _loadingText;
  28830. private _loadingDivBackgroundColor;
  28831. private _loadingDiv;
  28832. private _loadingTextDiv;
  28833. /** Gets or sets the logo url to use for the default loading screen */
  28834. static DefaultLogoUrl: string;
  28835. /** Gets or sets the spinner url to use for the default loading screen */
  28836. static DefaultSpinnerUrl: string;
  28837. /**
  28838. * Creates a new default loading screen
  28839. * @param _renderingCanvas defines the canvas used to render the scene
  28840. * @param _loadingText defines the default text to display
  28841. * @param _loadingDivBackgroundColor defines the default background color
  28842. */
  28843. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  28844. /**
  28845. * Function called to display the loading screen
  28846. */
  28847. displayLoadingUI(): void;
  28848. /**
  28849. * Function called to hide the loading screen
  28850. */
  28851. hideLoadingUI(): void;
  28852. /**
  28853. * Gets or sets the text to display while loading
  28854. */
  28855. loadingUIText: string;
  28856. /**
  28857. * Gets or sets the color to use for the background
  28858. */
  28859. loadingUIBackgroundColor: string;
  28860. private _resizeLoadingUI;
  28861. }
  28862. }
  28863. declare module BABYLON {
  28864. /** @hidden */
  28865. export class WebGLPipelineContext implements IPipelineContext {
  28866. engine: Engine;
  28867. program: Nullable<WebGLProgram>;
  28868. context?: WebGLRenderingContext;
  28869. vertexShader?: WebGLShader;
  28870. fragmentShader?: WebGLShader;
  28871. isParallelCompiled: boolean;
  28872. onCompiled?: () => void;
  28873. transformFeedback?: WebGLTransformFeedback | null;
  28874. readonly isAsync: boolean;
  28875. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  28876. }
  28877. }
  28878. declare module BABYLON {
  28879. /** @hidden */
  28880. export class WebGLDataBuffer extends DataBuffer {
  28881. private _buffer;
  28882. constructor(resource: WebGLBuffer);
  28883. readonly underlyingResource: any;
  28884. }
  28885. }
  28886. declare module BABYLON {
  28887. /** @hidden */
  28888. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28889. attributeProcessor(attribute: string): string;
  28890. varyingProcessor(varying: string, isFragment: boolean): string;
  28891. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28892. }
  28893. }
  28894. declare module BABYLON {
  28895. /**
  28896. * This class is used to track a performance counter which is number based.
  28897. * The user has access to many properties which give statistics of different nature.
  28898. *
  28899. * The implementer can track two kinds of Performance Counter: time and count.
  28900. * 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.
  28901. * 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.
  28902. */
  28903. export class PerfCounter {
  28904. /**
  28905. * Gets or sets a global boolean to turn on and off all the counters
  28906. */
  28907. static Enabled: boolean;
  28908. /**
  28909. * Returns the smallest value ever
  28910. */
  28911. readonly min: number;
  28912. /**
  28913. * Returns the biggest value ever
  28914. */
  28915. readonly max: number;
  28916. /**
  28917. * Returns the average value since the performance counter is running
  28918. */
  28919. readonly average: number;
  28920. /**
  28921. * Returns the average value of the last second the counter was monitored
  28922. */
  28923. readonly lastSecAverage: number;
  28924. /**
  28925. * Returns the current value
  28926. */
  28927. readonly current: number;
  28928. /**
  28929. * Gets the accumulated total
  28930. */
  28931. readonly total: number;
  28932. /**
  28933. * Gets the total value count
  28934. */
  28935. readonly count: number;
  28936. /**
  28937. * Creates a new counter
  28938. */
  28939. constructor();
  28940. /**
  28941. * Call this method to start monitoring a new frame.
  28942. * 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.
  28943. */
  28944. fetchNewFrame(): void;
  28945. /**
  28946. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28947. * @param newCount the count value to add to the monitored count
  28948. * @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.
  28949. */
  28950. addCount(newCount: number, fetchResult: boolean): void;
  28951. /**
  28952. * Start monitoring this performance counter
  28953. */
  28954. beginMonitoring(): void;
  28955. /**
  28956. * Compute the time lapsed since the previous beginMonitoring() call.
  28957. * @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
  28958. */
  28959. endMonitoring(newFrame?: boolean): void;
  28960. private _fetchResult;
  28961. private _startMonitoringTime;
  28962. private _min;
  28963. private _max;
  28964. private _average;
  28965. private _current;
  28966. private _totalValueCount;
  28967. private _totalAccumulated;
  28968. private _lastSecAverage;
  28969. private _lastSecAccumulated;
  28970. private _lastSecTime;
  28971. private _lastSecValueCount;
  28972. }
  28973. }
  28974. declare module BABYLON {
  28975. /**
  28976. * Interface for any object that can request an animation frame
  28977. */
  28978. export interface ICustomAnimationFrameRequester {
  28979. /**
  28980. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  28981. */
  28982. renderFunction?: Function;
  28983. /**
  28984. * Called to request the next frame to render to
  28985. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  28986. */
  28987. requestAnimationFrame: Function;
  28988. /**
  28989. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  28990. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  28991. */
  28992. requestID?: number;
  28993. }
  28994. }
  28995. declare module BABYLON {
  28996. /**
  28997. * Settings for finer control over video usage
  28998. */
  28999. export interface VideoTextureSettings {
  29000. /**
  29001. * Applies `autoplay` to video, if specified
  29002. */
  29003. autoPlay?: boolean;
  29004. /**
  29005. * Applies `loop` to video, if specified
  29006. */
  29007. loop?: boolean;
  29008. /**
  29009. * Automatically updates internal texture from video at every frame in the render loop
  29010. */
  29011. autoUpdateTexture: boolean;
  29012. /**
  29013. * Image src displayed during the video loading or until the user interacts with the video.
  29014. */
  29015. poster?: string;
  29016. }
  29017. /**
  29018. * If you want to display a video in your scene, this is the special texture for that.
  29019. * This special texture works similar to other textures, with the exception of a few parameters.
  29020. * @see https://doc.babylonjs.com/how_to/video_texture
  29021. */
  29022. export class VideoTexture extends Texture {
  29023. /**
  29024. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29025. */
  29026. readonly autoUpdateTexture: boolean;
  29027. /**
  29028. * The video instance used by the texture internally
  29029. */
  29030. readonly video: HTMLVideoElement;
  29031. private _onUserActionRequestedObservable;
  29032. /**
  29033. * Event triggerd when a dom action is required by the user to play the video.
  29034. * This happens due to recent changes in browser policies preventing video to auto start.
  29035. */
  29036. readonly onUserActionRequestedObservable: Observable<Texture>;
  29037. private _generateMipMaps;
  29038. private _engine;
  29039. private _stillImageCaptured;
  29040. private _displayingPosterTexture;
  29041. private _settings;
  29042. private _createInternalTextureOnEvent;
  29043. private _frameId;
  29044. /**
  29045. * Creates a video texture.
  29046. * If you want to display a video in your scene, this is the special texture for that.
  29047. * This special texture works similar to other textures, with the exception of a few parameters.
  29048. * @see https://doc.babylonjs.com/how_to/video_texture
  29049. * @param name optional name, will detect from video source, if not defined
  29050. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29051. * @param scene is obviously the current scene.
  29052. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29053. * @param invertY is false by default but can be used to invert video on Y axis
  29054. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29055. * @param settings allows finer control over video usage
  29056. */
  29057. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29058. private _getName;
  29059. private _getVideo;
  29060. private _createInternalTexture;
  29061. private reset;
  29062. /**
  29063. * @hidden Internal method to initiate `update`.
  29064. */ private _rebuild(): void;
  29065. /**
  29066. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29067. */
  29068. update(): void;
  29069. /**
  29070. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29071. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29072. */
  29073. updateTexture(isVisible: boolean): void;
  29074. protected _updateInternalTexture: () => void;
  29075. /**
  29076. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29077. * @param url New url.
  29078. */
  29079. updateURL(url: string): void;
  29080. /**
  29081. * Dispose the texture and release its associated resources.
  29082. */
  29083. dispose(): void;
  29084. /**
  29085. * Creates a video texture straight from a stream.
  29086. * @param scene Define the scene the texture should be created in
  29087. * @param stream Define the stream the texture should be created from
  29088. * @returns The created video texture as a promise
  29089. */
  29090. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29091. /**
  29092. * Creates a video texture straight from your WebCam video feed.
  29093. * @param scene Define the scene the texture should be created in
  29094. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29095. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29096. * @returns The created video texture as a promise
  29097. */
  29098. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29099. minWidth: number;
  29100. maxWidth: number;
  29101. minHeight: number;
  29102. maxHeight: number;
  29103. deviceId: string;
  29104. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29105. /**
  29106. * Creates a video texture straight from your WebCam video feed.
  29107. * @param scene Define the scene the texture should be created in
  29108. * @param onReady Define a callback to triggered once the texture will be ready
  29109. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29110. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29111. */
  29112. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29113. minWidth: number;
  29114. maxWidth: number;
  29115. minHeight: number;
  29116. maxHeight: number;
  29117. deviceId: string;
  29118. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29119. }
  29120. }
  29121. declare module BABYLON {
  29122. /**
  29123. * Defines the interface used by objects containing a viewport (like a camera)
  29124. */
  29125. interface IViewportOwnerLike {
  29126. /**
  29127. * Gets or sets the viewport
  29128. */
  29129. viewport: IViewportLike;
  29130. }
  29131. /**
  29132. * Interface for attribute information associated with buffer instanciation
  29133. */
  29134. export class InstancingAttributeInfo {
  29135. /**
  29136. * Index/offset of the attribute in the vertex shader
  29137. */
  29138. index: number;
  29139. /**
  29140. * size of the attribute, 1, 2, 3 or 4
  29141. */
  29142. attributeSize: number;
  29143. /**
  29144. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29145. * default is FLOAT
  29146. */
  29147. attribyteType: number;
  29148. /**
  29149. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29150. */
  29151. normalized: boolean;
  29152. /**
  29153. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29154. */
  29155. offset: number;
  29156. /**
  29157. * Name of the GLSL attribute, for debugging purpose only
  29158. */
  29159. attributeName: string;
  29160. }
  29161. /**
  29162. * Define options used to create a depth texture
  29163. */
  29164. export class DepthTextureCreationOptions {
  29165. /** Specifies whether or not a stencil should be allocated in the texture */
  29166. generateStencil?: boolean;
  29167. /** Specifies whether or not bilinear filtering is enable on the texture */
  29168. bilinearFiltering?: boolean;
  29169. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29170. comparisonFunction?: number;
  29171. /** Specifies if the created texture is a cube texture */
  29172. isCube?: boolean;
  29173. }
  29174. /**
  29175. * Class used to describe the capabilities of the engine relatively to the current browser
  29176. */
  29177. export class EngineCapabilities {
  29178. /** Maximum textures units per fragment shader */
  29179. maxTexturesImageUnits: number;
  29180. /** Maximum texture units per vertex shader */
  29181. maxVertexTextureImageUnits: number;
  29182. /** Maximum textures units in the entire pipeline */
  29183. maxCombinedTexturesImageUnits: number;
  29184. /** Maximum texture size */
  29185. maxTextureSize: number;
  29186. /** Maximum cube texture size */
  29187. maxCubemapTextureSize: number;
  29188. /** Maximum render texture size */
  29189. maxRenderTextureSize: number;
  29190. /** Maximum number of vertex attributes */
  29191. maxVertexAttribs: number;
  29192. /** Maximum number of varyings */
  29193. maxVaryingVectors: number;
  29194. /** Maximum number of uniforms per vertex shader */
  29195. maxVertexUniformVectors: number;
  29196. /** Maximum number of uniforms per fragment shader */
  29197. maxFragmentUniformVectors: number;
  29198. /** Defines if standard derivates (dx/dy) are supported */
  29199. standardDerivatives: boolean;
  29200. /** Defines if s3tc texture compression is supported */
  29201. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29202. /** Defines if pvrtc texture compression is supported */
  29203. pvrtc: any;
  29204. /** Defines if etc1 texture compression is supported */
  29205. etc1: any;
  29206. /** Defines if etc2 texture compression is supported */
  29207. etc2: any;
  29208. /** Defines if astc texture compression is supported */
  29209. astc: any;
  29210. /** Defines if float textures are supported */
  29211. textureFloat: boolean;
  29212. /** Defines if vertex array objects are supported */
  29213. vertexArrayObject: boolean;
  29214. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29215. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29216. /** Gets the maximum level of anisotropy supported */
  29217. maxAnisotropy: number;
  29218. /** Defines if instancing is supported */
  29219. instancedArrays: boolean;
  29220. /** Defines if 32 bits indices are supported */
  29221. uintIndices: boolean;
  29222. /** Defines if high precision shaders are supported */
  29223. highPrecisionShaderSupported: boolean;
  29224. /** Defines if depth reading in the fragment shader is supported */
  29225. fragmentDepthSupported: boolean;
  29226. /** Defines if float texture linear filtering is supported*/
  29227. textureFloatLinearFiltering: boolean;
  29228. /** Defines if rendering to float textures is supported */
  29229. textureFloatRender: boolean;
  29230. /** Defines if half float textures are supported*/
  29231. textureHalfFloat: boolean;
  29232. /** Defines if half float texture linear filtering is supported*/
  29233. textureHalfFloatLinearFiltering: boolean;
  29234. /** Defines if rendering to half float textures is supported */
  29235. textureHalfFloatRender: boolean;
  29236. /** Defines if textureLOD shader command is supported */
  29237. textureLOD: boolean;
  29238. /** Defines if draw buffers extension is supported */
  29239. drawBuffersExtension: boolean;
  29240. /** Defines if depth textures are supported */
  29241. depthTextureExtension: boolean;
  29242. /** Defines if float color buffer are supported */
  29243. colorBufferFloat: boolean;
  29244. /** Gets disjoint timer query extension (null if not supported) */
  29245. timerQuery: EXT_disjoint_timer_query;
  29246. /** Defines if timestamp can be used with timer query */
  29247. canUseTimestampForTimerQuery: boolean;
  29248. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29249. multiview: any;
  29250. /** Function used to let the system compiles shaders in background */
  29251. parallelShaderCompile: {
  29252. COMPLETION_STATUS_KHR: number;
  29253. };
  29254. /** Max number of texture samples for MSAA */
  29255. maxMSAASamples: number;
  29256. }
  29257. /** Interface defining initialization parameters for Engine class */
  29258. export interface EngineOptions extends WebGLContextAttributes {
  29259. /**
  29260. * Defines if the engine should no exceed a specified device ratio
  29261. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29262. */
  29263. limitDeviceRatio?: number;
  29264. /**
  29265. * Defines if webvr should be enabled automatically
  29266. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29267. */
  29268. autoEnableWebVR?: boolean;
  29269. /**
  29270. * Defines if webgl2 should be turned off even if supported
  29271. * @see http://doc.babylonjs.com/features/webgl2
  29272. */
  29273. disableWebGL2Support?: boolean;
  29274. /**
  29275. * Defines if webaudio should be initialized as well
  29276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29277. */
  29278. audioEngine?: boolean;
  29279. /**
  29280. * Defines if animations should run using a deterministic lock step
  29281. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29282. */
  29283. deterministicLockstep?: boolean;
  29284. /** Defines the maximum steps to use with deterministic lock step mode */
  29285. lockstepMaxSteps?: number;
  29286. /**
  29287. * Defines that engine should ignore context lost events
  29288. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29289. */
  29290. doNotHandleContextLost?: boolean;
  29291. /**
  29292. * Defines that engine should ignore modifying touch action attribute and style
  29293. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29294. */
  29295. doNotHandleTouchAction?: boolean;
  29296. /**
  29297. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29298. */
  29299. useHighPrecisionFloats?: boolean;
  29300. }
  29301. /**
  29302. * Defines the interface used by display changed events
  29303. */
  29304. export interface IDisplayChangedEventArgs {
  29305. /** Gets the vrDisplay object (if any) */
  29306. vrDisplay: Nullable<any>;
  29307. /** Gets a boolean indicating if webVR is supported */
  29308. vrSupported: boolean;
  29309. }
  29310. /**
  29311. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29312. */
  29313. export class Engine {
  29314. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29315. static ExceptionList: ({
  29316. key: string;
  29317. capture: string;
  29318. captureConstraint: number;
  29319. targets: string[];
  29320. } | {
  29321. key: string;
  29322. capture: null;
  29323. captureConstraint: null;
  29324. targets: string[];
  29325. })[];
  29326. /** Gets the list of created engines */
  29327. static readonly Instances: Engine[];
  29328. /**
  29329. * Gets the latest created engine
  29330. */
  29331. static readonly LastCreatedEngine: Nullable<Engine>;
  29332. /**
  29333. * Gets the latest created scene
  29334. */
  29335. static readonly LastCreatedScene: Nullable<Scene>;
  29336. /**
  29337. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29338. * @param flag defines which part of the materials must be marked as dirty
  29339. * @param predicate defines a predicate used to filter which materials should be affected
  29340. */
  29341. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29342. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  29343. /** Defines that alpha blending is disabled */
  29344. static readonly ALPHA_DISABLE: number;
  29345. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29346. static readonly ALPHA_ADD: number;
  29347. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29348. static readonly ALPHA_COMBINE: number;
  29349. /** Defines that alpha blending to DEST - SRC * DEST */
  29350. static readonly ALPHA_SUBTRACT: number;
  29351. /** Defines that alpha blending to SRC * DEST */
  29352. static readonly ALPHA_MULTIPLY: number;
  29353. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29354. static readonly ALPHA_MAXIMIZED: number;
  29355. /** Defines that alpha blending to SRC + DEST */
  29356. static readonly ALPHA_ONEONE: number;
  29357. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29358. static readonly ALPHA_PREMULTIPLIED: number;
  29359. /**
  29360. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29361. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29362. */
  29363. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29364. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29365. static readonly ALPHA_INTERPOLATE: number;
  29366. /**
  29367. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29368. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29369. */
  29370. static readonly ALPHA_SCREENMODE: number;
  29371. /** Defines that the ressource is not delayed*/
  29372. static readonly DELAYLOADSTATE_NONE: number;
  29373. /** Defines that the ressource was successfully delay loaded */
  29374. static readonly DELAYLOADSTATE_LOADED: number;
  29375. /** Defines that the ressource is currently delay loading */
  29376. static readonly DELAYLOADSTATE_LOADING: number;
  29377. /** Defines that the ressource is delayed and has not started loading */
  29378. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29379. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29380. static readonly NEVER: number;
  29381. /** 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 */
  29382. static readonly ALWAYS: number;
  29383. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29384. static readonly LESS: number;
  29385. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29386. static readonly EQUAL: number;
  29387. /** 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 */
  29388. static readonly LEQUAL: number;
  29389. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29390. static readonly GREATER: number;
  29391. /** 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 */
  29392. static readonly GEQUAL: number;
  29393. /** 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 */
  29394. static readonly NOTEQUAL: number;
  29395. /** Passed to stencilOperation to specify that stencil value must be kept */
  29396. static readonly KEEP: number;
  29397. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29398. static readonly REPLACE: number;
  29399. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29400. static readonly INCR: number;
  29401. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29402. static readonly DECR: number;
  29403. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29404. static readonly INVERT: number;
  29405. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29406. static readonly INCR_WRAP: number;
  29407. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29408. static readonly DECR_WRAP: number;
  29409. /** Texture is not repeating outside of 0..1 UVs */
  29410. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29411. /** Texture is repeating outside of 0..1 UVs */
  29412. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29413. /** Texture is repeating and mirrored */
  29414. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29415. /** ALPHA */
  29416. static readonly TEXTUREFORMAT_ALPHA: number;
  29417. /** LUMINANCE */
  29418. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29419. /** LUMINANCE_ALPHA */
  29420. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29421. /** RGB */
  29422. static readonly TEXTUREFORMAT_RGB: number;
  29423. /** RGBA */
  29424. static readonly TEXTUREFORMAT_RGBA: number;
  29425. /** RED */
  29426. static readonly TEXTUREFORMAT_RED: number;
  29427. /** RED (2nd reference) */
  29428. static readonly TEXTUREFORMAT_R: number;
  29429. /** RG */
  29430. static readonly TEXTUREFORMAT_RG: number;
  29431. /** RED_INTEGER */
  29432. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29433. /** RED_INTEGER (2nd reference) */
  29434. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29435. /** RG_INTEGER */
  29436. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29437. /** RGB_INTEGER */
  29438. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29439. /** RGBA_INTEGER */
  29440. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29441. /** UNSIGNED_BYTE */
  29442. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29443. /** UNSIGNED_BYTE (2nd reference) */
  29444. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29445. /** FLOAT */
  29446. static readonly TEXTURETYPE_FLOAT: number;
  29447. /** HALF_FLOAT */
  29448. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29449. /** BYTE */
  29450. static readonly TEXTURETYPE_BYTE: number;
  29451. /** SHORT */
  29452. static readonly TEXTURETYPE_SHORT: number;
  29453. /** UNSIGNED_SHORT */
  29454. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29455. /** INT */
  29456. static readonly TEXTURETYPE_INT: number;
  29457. /** UNSIGNED_INT */
  29458. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29459. /** UNSIGNED_SHORT_4_4_4_4 */
  29460. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29461. /** UNSIGNED_SHORT_5_5_5_1 */
  29462. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29463. /** UNSIGNED_SHORT_5_6_5 */
  29464. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29465. /** UNSIGNED_INT_2_10_10_10_REV */
  29466. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29467. /** UNSIGNED_INT_24_8 */
  29468. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29469. /** UNSIGNED_INT_10F_11F_11F_REV */
  29470. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29471. /** UNSIGNED_INT_5_9_9_9_REV */
  29472. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29473. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29474. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29475. /** nearest is mag = nearest and min = nearest and mip = linear */
  29476. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29477. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29478. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29479. /** Trilinear is mag = linear and min = linear and mip = linear */
  29480. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29481. /** nearest is mag = nearest and min = nearest and mip = linear */
  29482. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29483. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29484. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29485. /** Trilinear is mag = linear and min = linear and mip = linear */
  29486. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29487. /** mag = nearest and min = nearest and mip = nearest */
  29488. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29489. /** mag = nearest and min = linear and mip = nearest */
  29490. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29491. /** mag = nearest and min = linear and mip = linear */
  29492. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29493. /** mag = nearest and min = linear and mip = none */
  29494. static readonly TEXTURE_NEAREST_LINEAR: number;
  29495. /** mag = nearest and min = nearest and mip = none */
  29496. static readonly TEXTURE_NEAREST_NEAREST: number;
  29497. /** mag = linear and min = nearest and mip = nearest */
  29498. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29499. /** mag = linear and min = nearest and mip = linear */
  29500. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29501. /** mag = linear and min = linear and mip = none */
  29502. static readonly TEXTURE_LINEAR_LINEAR: number;
  29503. /** mag = linear and min = nearest and mip = none */
  29504. static readonly TEXTURE_LINEAR_NEAREST: number;
  29505. /** Explicit coordinates mode */
  29506. static readonly TEXTURE_EXPLICIT_MODE: number;
  29507. /** Spherical coordinates mode */
  29508. static readonly TEXTURE_SPHERICAL_MODE: number;
  29509. /** Planar coordinates mode */
  29510. static readonly TEXTURE_PLANAR_MODE: number;
  29511. /** Cubic coordinates mode */
  29512. static readonly TEXTURE_CUBIC_MODE: number;
  29513. /** Projection coordinates mode */
  29514. static readonly TEXTURE_PROJECTION_MODE: number;
  29515. /** Skybox coordinates mode */
  29516. static readonly TEXTURE_SKYBOX_MODE: number;
  29517. /** Inverse Cubic coordinates mode */
  29518. static readonly TEXTURE_INVCUBIC_MODE: number;
  29519. /** Equirectangular coordinates mode */
  29520. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29521. /** Equirectangular Fixed coordinates mode */
  29522. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29523. /** Equirectangular Fixed Mirrored coordinates mode */
  29524. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29525. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29526. static readonly SCALEMODE_FLOOR: number;
  29527. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29528. static readonly SCALEMODE_NEAREST: number;
  29529. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29530. static readonly SCALEMODE_CEILING: number;
  29531. /**
  29532. * Returns the current npm package of the sdk
  29533. */
  29534. static readonly NpmPackage: string;
  29535. /**
  29536. * Returns the current version of the framework
  29537. */
  29538. static readonly Version: string;
  29539. /**
  29540. * Returns a string describing the current engine
  29541. */
  29542. readonly description: string;
  29543. /**
  29544. * Gets or sets the epsilon value used by collision engine
  29545. */
  29546. static CollisionsEpsilon: number;
  29547. /**
  29548. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29549. */
  29550. static ShadersRepository: string;
  29551. /**
  29552. * Method called to create the default loading screen.
  29553. * This can be overriden in your own app.
  29554. * @param canvas The rendering canvas element
  29555. * @returns The loading screen
  29556. */
  29557. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29558. /**
  29559. * Method called to create the default rescale post process on each engine.
  29560. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29561. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  29562. /**
  29563. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29564. */
  29565. forcePOTTextures: boolean;
  29566. /**
  29567. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29568. */
  29569. isFullscreen: boolean;
  29570. /**
  29571. * Gets a boolean indicating if the pointer is currently locked
  29572. */
  29573. isPointerLock: boolean;
  29574. /**
  29575. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29576. */
  29577. cullBackFaces: boolean;
  29578. /**
  29579. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29580. */
  29581. renderEvenInBackground: boolean;
  29582. /**
  29583. * Gets or sets a boolean indicating that cache can be kept between frames
  29584. */
  29585. preventCacheWipeBetweenFrames: boolean;
  29586. /**
  29587. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29588. **/
  29589. enableOfflineSupport: boolean;
  29590. /**
  29591. * 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)
  29592. **/
  29593. disableManifestCheck: boolean;
  29594. /**
  29595. * Gets the list of created scenes
  29596. */
  29597. scenes: Scene[];
  29598. /**
  29599. * Event raised when a new scene is created
  29600. */
  29601. onNewSceneAddedObservable: Observable<Scene>;
  29602. /**
  29603. * Gets the list of created postprocesses
  29604. */
  29605. postProcesses: PostProcess[];
  29606. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29607. validateShaderPrograms: boolean;
  29608. /**
  29609. * Observable event triggered each time the rendering canvas is resized
  29610. */
  29611. onResizeObservable: Observable<Engine>;
  29612. /**
  29613. * Observable event triggered each time the canvas loses focus
  29614. */
  29615. onCanvasBlurObservable: Observable<Engine>;
  29616. /**
  29617. * Observable event triggered each time the canvas gains focus
  29618. */
  29619. onCanvasFocusObservable: Observable<Engine>;
  29620. /**
  29621. * Observable event triggered each time the canvas receives pointerout event
  29622. */
  29623. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29624. /**
  29625. * Observable event triggered before each texture is initialized
  29626. */
  29627. onBeforeTextureInitObservable: Observable<Texture>;
  29628. /**
  29629. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29630. */
  29631. disableUniformBuffers: boolean;
  29632. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  29633. /**
  29634. * Gets a boolean indicating that the engine supports uniform buffers
  29635. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29636. */
  29637. readonly supportsUniformBuffers: boolean;
  29638. /**
  29639. * Observable raised when the engine begins a new frame
  29640. */
  29641. onBeginFrameObservable: Observable<Engine>;
  29642. /**
  29643. * If set, will be used to request the next animation frame for the render loop
  29644. */
  29645. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  29646. /**
  29647. * Observable raised when the engine ends the current frame
  29648. */
  29649. onEndFrameObservable: Observable<Engine>;
  29650. /**
  29651. * Observable raised when the engine is about to compile a shader
  29652. */
  29653. onBeforeShaderCompilationObservable: Observable<Engine>;
  29654. /**
  29655. * Observable raised when the engine has jsut compiled a shader
  29656. */
  29657. onAfterShaderCompilationObservable: Observable<Engine>;
  29658. /** @hidden */ private _gl: WebGLRenderingContext;
  29659. private _renderingCanvas;
  29660. private _windowIsBackground;
  29661. protected _webGLVersion: number;
  29662. protected _highPrecisionShadersAllowed: boolean;
  29663. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  29664. /**
  29665. * Gets a boolean indicating that only power of 2 textures are supported
  29666. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29667. */
  29668. readonly needPOTTextures: boolean;
  29669. /** @hidden */ private _badOS: boolean;
  29670. /** @hidden */ private _badDesktopOS: boolean;
  29671. /**
  29672. * Gets the audio engine
  29673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29674. * @ignorenaming
  29675. */
  29676. static audioEngine: IAudioEngine;
  29677. /**
  29678. * Default AudioEngine factory responsible of creating the Audio Engine.
  29679. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  29680. */
  29681. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  29682. /**
  29683. * Default offline support factory responsible of creating a tool used to store data locally.
  29684. * By default, this will create a Database object if the workload has been embedded.
  29685. */
  29686. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  29687. private _onFocus;
  29688. private _onBlur;
  29689. private _onCanvasPointerOut;
  29690. private _onCanvasBlur;
  29691. private _onCanvasFocus;
  29692. private _onFullscreenChange;
  29693. private _onPointerLockChange;
  29694. private _hardwareScalingLevel;
  29695. /** @hidden */ private _caps: EngineCapabilities;
  29696. private _pointerLockRequested;
  29697. private _isStencilEnable;
  29698. protected _colorWrite: boolean;
  29699. private _loadingScreen;
  29700. /** @hidden */ private _drawCalls: PerfCounter;
  29701. private _glVersion;
  29702. private _glRenderer;
  29703. private _glVendor;
  29704. private _videoTextureSupported;
  29705. private _renderingQueueLaunched;
  29706. private _activeRenderLoops;
  29707. private _deterministicLockstep;
  29708. private _lockstepMaxSteps;
  29709. /**
  29710. * Observable signaled when a context lost event is raised
  29711. */
  29712. onContextLostObservable: Observable<Engine>;
  29713. /**
  29714. * Observable signaled when a context restored event is raised
  29715. */
  29716. onContextRestoredObservable: Observable<Engine>;
  29717. private _onContextLost;
  29718. private _onContextRestored;
  29719. private _contextWasLost;
  29720. /** @hidden */ private _doNotHandleContextLost: boolean;
  29721. /**
  29722. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29724. */
  29725. doNotHandleContextLost: boolean;
  29726. private _performanceMonitor;
  29727. private _fps;
  29728. private _deltaTime;
  29729. /**
  29730. * Turn this value on if you want to pause FPS computation when in background
  29731. */
  29732. disablePerformanceMonitorInBackground: boolean;
  29733. /**
  29734. * Gets the performance monitor attached to this engine
  29735. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  29736. */
  29737. readonly performanceMonitor: PerformanceMonitor;
  29738. /**
  29739. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29740. */
  29741. disableVertexArrayObjects: boolean;
  29742. /** @hidden */
  29743. protected _depthCullingState: _DepthCullingState;
  29744. /** @hidden */
  29745. protected _stencilState: _StencilState;
  29746. /** @hidden */
  29747. protected _alphaState: _AlphaState;
  29748. /** @hidden */
  29749. protected _alphaMode: number;
  29750. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  29751. /** @hidden */
  29752. protected _activeChannel: number;
  29753. private _currentTextureChannel;
  29754. /** @hidden */
  29755. protected _boundTexturesCache: {
  29756. [key: string]: Nullable<InternalTexture>;
  29757. };
  29758. /** @hidden */
  29759. protected _currentEffect: Nullable<Effect>;
  29760. /** @hidden */
  29761. protected _currentProgram: Nullable<WebGLProgram>;
  29762. private _compiledEffects;
  29763. private _vertexAttribArraysEnabled;
  29764. /** @hidden */
  29765. protected _cachedViewport: Nullable<IViewportLike>;
  29766. private _cachedVertexArrayObject;
  29767. /** @hidden */
  29768. protected _cachedVertexBuffers: any;
  29769. /** @hidden */
  29770. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29771. /** @hidden */
  29772. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29773. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  29774. private _uintIndicesCurrentlySet;
  29775. private _currentBoundBuffer;
  29776. /** @hidden */
  29777. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29778. private _currentBufferPointers;
  29779. private _currentInstanceLocations;
  29780. private _currentInstanceBuffers;
  29781. private _textureUnits;
  29782. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  29783. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  29784. private _rescalePostProcess;
  29785. private _dummyFramebuffer;
  29786. private _externalData;
  29787. /** @hidden */ private _bindedRenderFunction: any;
  29788. private _vaoRecordInProgress;
  29789. private _mustWipeVertexAttributes;
  29790. private _emptyTexture;
  29791. private _emptyCubeTexture;
  29792. private _emptyTexture3D;
  29793. /** @hidden */ private _frameHandler: number;
  29794. private _nextFreeTextureSlots;
  29795. private _maxSimultaneousTextures;
  29796. private _activeRequests;
  29797. private _texturesSupported;
  29798. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  29799. /**
  29800. * Gets the list of texture formats supported
  29801. */
  29802. readonly texturesSupported: Array<string>;
  29803. /**
  29804. * Gets the list of texture formats in use
  29805. */
  29806. readonly textureFormatInUse: Nullable<string>;
  29807. /**
  29808. * Gets the current viewport
  29809. */
  29810. readonly currentViewport: Nullable<IViewportLike>;
  29811. /**
  29812. * Gets the default empty texture
  29813. */
  29814. readonly emptyTexture: InternalTexture;
  29815. /**
  29816. * Gets the default empty 3D texture
  29817. */
  29818. readonly emptyTexture3D: InternalTexture;
  29819. /**
  29820. * Gets the default empty cube texture
  29821. */
  29822. readonly emptyCubeTexture: InternalTexture;
  29823. /**
  29824. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29825. */
  29826. readonly premultipliedAlpha: boolean;
  29827. /**
  29828. * Creates a new engine
  29829. * @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
  29830. * @param antialias defines enable antialiasing (default: false)
  29831. * @param options defines further options to be sent to the getContext() function
  29832. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29833. */
  29834. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29835. /**
  29836. * Initializes a webVR display and starts listening to display change events
  29837. * The onVRDisplayChangedObservable will be notified upon these changes
  29838. * @returns The onVRDisplayChangedObservable
  29839. */
  29840. initWebVR(): Observable<IDisplayChangedEventArgs>;
  29841. /** @hidden */ private _prepareVRComponent(): void;
  29842. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  29843. /** @hidden */ private _submitVRFrame(): void;
  29844. /**
  29845. * Call this function to leave webVR mode
  29846. * Will do nothing if webVR is not supported or if there is no webVR device
  29847. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29848. */
  29849. disableVR(): void;
  29850. /**
  29851. * Gets a boolean indicating that the system is in VR mode and is presenting
  29852. * @returns true if VR mode is engaged
  29853. */
  29854. isVRPresenting(): boolean;
  29855. /** @hidden */ private _requestVRFrame(): void;
  29856. private _disableTouchAction;
  29857. private _rebuildInternalTextures;
  29858. private _rebuildEffects;
  29859. /**
  29860. * Gets a boolean indicating if all created effects are ready
  29861. * @returns true if all effects are ready
  29862. */
  29863. areAllEffectsReady(): boolean;
  29864. private _rebuildBuffers;
  29865. private _initGLContext;
  29866. /**
  29867. * Gets version of the current webGL context
  29868. */
  29869. readonly webGLVersion: number;
  29870. /**
  29871. * Gets a string idenfifying the name of the class
  29872. * @returns "Engine" string
  29873. */
  29874. getClassName(): string;
  29875. /**
  29876. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29877. */
  29878. readonly isStencilEnable: boolean;
  29879. /** @hidden */ private _prepareWorkingCanvas(): void;
  29880. /**
  29881. * Reset the texture cache to empty state
  29882. */
  29883. resetTextureCache(): void;
  29884. /**
  29885. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29886. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29887. * @returns true if engine is in deterministic lock step mode
  29888. */
  29889. isDeterministicLockStep(): boolean;
  29890. /**
  29891. * Gets the max steps when engine is running in deterministic lock step
  29892. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29893. * @returns the max steps
  29894. */
  29895. getLockstepMaxSteps(): number;
  29896. /**
  29897. * Gets an object containing information about the current webGL context
  29898. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29899. */
  29900. getGlInfo(): {
  29901. vendor: string;
  29902. renderer: string;
  29903. version: string;
  29904. };
  29905. /**
  29906. * Gets current aspect ratio
  29907. * @param viewportOwner defines the camera to use to get the aspect ratio
  29908. * @param useScreen defines if screen size must be used (or the current render target if any)
  29909. * @returns a number defining the aspect ratio
  29910. */
  29911. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  29912. /**
  29913. * Gets current screen aspect ratio
  29914. * @returns a number defining the aspect ratio
  29915. */
  29916. getScreenAspectRatio(): number;
  29917. /**
  29918. * Gets the current render width
  29919. * @param useScreen defines if screen size must be used (or the current render target if any)
  29920. * @returns a number defining the current render width
  29921. */
  29922. getRenderWidth(useScreen?: boolean): number;
  29923. /**
  29924. * Gets the current render height
  29925. * @param useScreen defines if screen size must be used (or the current render target if any)
  29926. * @returns a number defining the current render height
  29927. */
  29928. getRenderHeight(useScreen?: boolean): number;
  29929. /**
  29930. * Gets the HTML canvas attached with the current webGL context
  29931. * @returns a HTML canvas
  29932. */
  29933. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29934. /**
  29935. * Gets host window
  29936. * @returns the host window object
  29937. */
  29938. getHostWindow(): Window;
  29939. /**
  29940. * Gets host document
  29941. * @returns the host document object
  29942. */
  29943. getHostDocument(): Document;
  29944. /**
  29945. * Gets the client rect of the HTML canvas attached with the current webGL context
  29946. * @returns a client rectanglee
  29947. */
  29948. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  29949. /**
  29950. * Defines the hardware scaling level.
  29951. * By default the hardware scaling level is computed from the window device ratio.
  29952. * 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.
  29953. * @param level defines the level to use
  29954. */
  29955. setHardwareScalingLevel(level: number): void;
  29956. /**
  29957. * Gets the current hardware scaling level.
  29958. * By default the hardware scaling level is computed from the window device ratio.
  29959. * 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.
  29960. * @returns a number indicating the current hardware scaling level
  29961. */
  29962. getHardwareScalingLevel(): number;
  29963. /**
  29964. * Gets the list of loaded textures
  29965. * @returns an array containing all loaded textures
  29966. */
  29967. getLoadedTexturesCache(): InternalTexture[];
  29968. /**
  29969. * Gets the object containing all engine capabilities
  29970. * @returns the EngineCapabilities object
  29971. */
  29972. getCaps(): EngineCapabilities;
  29973. /**
  29974. * Gets the current depth function
  29975. * @returns a number defining the depth function
  29976. */
  29977. getDepthFunction(): Nullable<number>;
  29978. /**
  29979. * Sets the current depth function
  29980. * @param depthFunc defines the function to use
  29981. */
  29982. setDepthFunction(depthFunc: number): void;
  29983. /**
  29984. * Sets the current depth function to GREATER
  29985. */
  29986. setDepthFunctionToGreater(): void;
  29987. /**
  29988. * Sets the current depth function to GEQUAL
  29989. */
  29990. setDepthFunctionToGreaterOrEqual(): void;
  29991. /**
  29992. * Sets the current depth function to LESS
  29993. */
  29994. setDepthFunctionToLess(): void;
  29995. private _cachedStencilBuffer;
  29996. private _cachedStencilFunction;
  29997. private _cachedStencilMask;
  29998. private _cachedStencilOperationPass;
  29999. private _cachedStencilOperationFail;
  30000. private _cachedStencilOperationDepthFail;
  30001. private _cachedStencilReference;
  30002. /**
  30003. * Caches the the state of the stencil buffer
  30004. */
  30005. cacheStencilState(): void;
  30006. /**
  30007. * Restores the state of the stencil buffer
  30008. */
  30009. restoreStencilState(): void;
  30010. /**
  30011. * Sets the current depth function to LEQUAL
  30012. */
  30013. setDepthFunctionToLessOrEqual(): void;
  30014. /**
  30015. * Gets a boolean indicating if stencil buffer is enabled
  30016. * @returns the current stencil buffer state
  30017. */
  30018. getStencilBuffer(): boolean;
  30019. /**
  30020. * Enable or disable the stencil buffer
  30021. * @param enable defines if the stencil buffer must be enabled or disabled
  30022. */
  30023. setStencilBuffer(enable: boolean): void;
  30024. /**
  30025. * Gets the current stencil mask
  30026. * @returns a number defining the new stencil mask to use
  30027. */
  30028. getStencilMask(): number;
  30029. /**
  30030. * Sets the current stencil mask
  30031. * @param mask defines the new stencil mask to use
  30032. */
  30033. setStencilMask(mask: number): void;
  30034. /**
  30035. * Gets the current stencil function
  30036. * @returns a number defining the stencil function to use
  30037. */
  30038. getStencilFunction(): number;
  30039. /**
  30040. * Gets the current stencil reference value
  30041. * @returns a number defining the stencil reference value to use
  30042. */
  30043. getStencilFunctionReference(): number;
  30044. /**
  30045. * Gets the current stencil mask
  30046. * @returns a number defining the stencil mask to use
  30047. */
  30048. getStencilFunctionMask(): number;
  30049. /**
  30050. * Sets the current stencil function
  30051. * @param stencilFunc defines the new stencil function to use
  30052. */
  30053. setStencilFunction(stencilFunc: number): void;
  30054. /**
  30055. * Sets the current stencil reference
  30056. * @param reference defines the new stencil reference to use
  30057. */
  30058. setStencilFunctionReference(reference: number): void;
  30059. /**
  30060. * Sets the current stencil mask
  30061. * @param mask defines the new stencil mask to use
  30062. */
  30063. setStencilFunctionMask(mask: number): void;
  30064. /**
  30065. * Gets the current stencil operation when stencil fails
  30066. * @returns a number defining stencil operation to use when stencil fails
  30067. */
  30068. getStencilOperationFail(): number;
  30069. /**
  30070. * Gets the current stencil operation when depth fails
  30071. * @returns a number defining stencil operation to use when depth fails
  30072. */
  30073. getStencilOperationDepthFail(): number;
  30074. /**
  30075. * Gets the current stencil operation when stencil passes
  30076. * @returns a number defining stencil operation to use when stencil passes
  30077. */
  30078. getStencilOperationPass(): number;
  30079. /**
  30080. * Sets the stencil operation to use when stencil fails
  30081. * @param operation defines the stencil operation to use when stencil fails
  30082. */
  30083. setStencilOperationFail(operation: number): void;
  30084. /**
  30085. * Sets the stencil operation to use when depth fails
  30086. * @param operation defines the stencil operation to use when depth fails
  30087. */
  30088. setStencilOperationDepthFail(operation: number): void;
  30089. /**
  30090. * Sets the stencil operation to use when stencil passes
  30091. * @param operation defines the stencil operation to use when stencil passes
  30092. */
  30093. setStencilOperationPass(operation: number): void;
  30094. /**
  30095. * Sets a boolean indicating if the dithering state is enabled or disabled
  30096. * @param value defines the dithering state
  30097. */
  30098. setDitheringState(value: boolean): void;
  30099. /**
  30100. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30101. * @param value defines the rasterizer state
  30102. */
  30103. setRasterizerState(value: boolean): void;
  30104. /**
  30105. * stop executing a render loop function and remove it from the execution array
  30106. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30107. */
  30108. stopRenderLoop(renderFunction?: () => void): void;
  30109. /** @hidden */ private _renderLoop(): void;
  30110. /**
  30111. * Can be used to override the current requestAnimationFrame requester.
  30112. * @hidden
  30113. */
  30114. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30115. /**
  30116. * Register and execute a render loop. The engine can have more than one render function
  30117. * @param renderFunction defines the function to continuously execute
  30118. */
  30119. runRenderLoop(renderFunction: () => void): void;
  30120. /**
  30121. * Toggle full screen mode
  30122. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30123. */
  30124. switchFullscreen(requestPointerLock: boolean): void;
  30125. /**
  30126. * Enters full screen mode
  30127. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30128. */
  30129. enterFullscreen(requestPointerLock: boolean): void;
  30130. /**
  30131. * Exits full screen mode
  30132. */
  30133. exitFullscreen(): void;
  30134. /**
  30135. * Enters Pointerlock mode
  30136. */
  30137. enterPointerlock(): void;
  30138. /**
  30139. * Exits Pointerlock mode
  30140. */
  30141. exitPointerlock(): void;
  30142. /**
  30143. * Clear the current render buffer or the current render target (if any is set up)
  30144. * @param color defines the color to use
  30145. * @param backBuffer defines if the back buffer must be cleared
  30146. * @param depth defines if the depth buffer must be cleared
  30147. * @param stencil defines if the stencil buffer must be cleared
  30148. */
  30149. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30150. /**
  30151. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30152. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30153. * @param y defines the y-coordinate of the corner of the clear rectangle
  30154. * @param width defines the width of the clear rectangle
  30155. * @param height defines the height of the clear rectangle
  30156. * @param clearColor defines the clear color
  30157. */
  30158. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30159. /**
  30160. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30161. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30162. * @param y defines the y-coordinate of the corner of the clear rectangle
  30163. * @param width defines the width of the clear rectangle
  30164. * @param height defines the height of the clear rectangle
  30165. */
  30166. enableScissor(x: number, y: number, width: number, height: number): void;
  30167. /**
  30168. * Disable previously set scissor test rectangle
  30169. */
  30170. disableScissor(): void;
  30171. private _viewportCached;
  30172. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  30173. /**
  30174. * Set the WebGL's viewport
  30175. * @param viewport defines the viewport element to be used
  30176. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30177. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30178. */
  30179. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30180. /**
  30181. * Directly set the WebGL Viewport
  30182. * @param x defines the x coordinate of the viewport (in screen space)
  30183. * @param y defines the y coordinate of the viewport (in screen space)
  30184. * @param width defines the width of the viewport (in screen space)
  30185. * @param height defines the height of the viewport (in screen space)
  30186. * @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
  30187. */
  30188. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30189. /**
  30190. * Begin a new frame
  30191. */
  30192. beginFrame(): void;
  30193. /**
  30194. * Enf the current frame
  30195. */
  30196. endFrame(): void;
  30197. /**
  30198. * Resize the view according to the canvas' size
  30199. */
  30200. resize(): void;
  30201. /**
  30202. * Force a specific size of the canvas
  30203. * @param width defines the new canvas' width
  30204. * @param height defines the new canvas' height
  30205. */
  30206. setSize(width: number, height: number): void;
  30207. /**
  30208. * Binds the frame buffer to the specified texture.
  30209. * @param texture The texture to render to or null for the default canvas
  30210. * @param faceIndex The face of the texture to render to in case of cube texture
  30211. * @param requiredWidth The width of the target to render to
  30212. * @param requiredHeight The height of the target to render to
  30213. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30214. * @param depthStencilTexture The depth stencil texture to use to render
  30215. * @param lodLevel defines le lod level to bind to the frame buffer
  30216. */
  30217. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30218. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30219. /**
  30220. * Unbind the current render target texture from the webGL context
  30221. * @param texture defines the render target texture to unbind
  30222. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30223. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30224. */
  30225. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30226. /**
  30227. * Force the mipmap generation for the given render target texture
  30228. * @param texture defines the render target texture to use
  30229. */
  30230. generateMipMapsForCubemap(texture: InternalTexture): void;
  30231. /**
  30232. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30233. */
  30234. flushFramebuffer(): void;
  30235. /**
  30236. * Unbind the current render target and bind the default framebuffer
  30237. */
  30238. restoreDefaultFramebuffer(): void;
  30239. /**
  30240. * Create an uniform buffer
  30241. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30242. * @param elements defines the content of the uniform buffer
  30243. * @returns the webGL uniform buffer
  30244. */
  30245. createUniformBuffer(elements: FloatArray): DataBuffer;
  30246. /**
  30247. * Create a dynamic uniform buffer
  30248. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30249. * @param elements defines the content of the uniform buffer
  30250. * @returns the webGL uniform buffer
  30251. */
  30252. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30253. /**
  30254. * Update an existing uniform buffer
  30255. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30256. * @param uniformBuffer defines the target uniform buffer
  30257. * @param elements defines the content to update
  30258. * @param offset defines the offset in the uniform buffer where update should start
  30259. * @param count defines the size of the data to update
  30260. */
  30261. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30262. private _resetVertexBufferBinding;
  30263. /**
  30264. * Creates a vertex buffer
  30265. * @param data the data for the vertex buffer
  30266. * @returns the new WebGL static buffer
  30267. */
  30268. createVertexBuffer(data: DataArray): DataBuffer;
  30269. /**
  30270. * Creates a dynamic vertex buffer
  30271. * @param data the data for the dynamic vertex buffer
  30272. * @returns the new WebGL dynamic buffer
  30273. */
  30274. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30275. /**
  30276. * Update a dynamic index buffer
  30277. * @param indexBuffer defines the target index buffer
  30278. * @param indices defines the data to update
  30279. * @param offset defines the offset in the target index buffer where update should start
  30280. */
  30281. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30282. /**
  30283. * Updates a dynamic vertex buffer.
  30284. * @param vertexBuffer the vertex buffer to update
  30285. * @param data the data used to update the vertex buffer
  30286. * @param byteOffset the byte offset of the data
  30287. * @param byteLength the byte length of the data
  30288. */
  30289. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30290. private _resetIndexBufferBinding;
  30291. /**
  30292. * Creates a new index buffer
  30293. * @param indices defines the content of the index buffer
  30294. * @param updatable defines if the index buffer must be updatable
  30295. * @returns a new webGL buffer
  30296. */
  30297. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30298. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30299. /**
  30300. * Bind a webGL buffer to the webGL context
  30301. * @param buffer defines the buffer to bind
  30302. */
  30303. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30304. /**
  30305. * Bind an uniform buffer to the current webGL context
  30306. * @param buffer defines the buffer to bind
  30307. */
  30308. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30309. /**
  30310. * Bind a buffer to the current webGL context at a given location
  30311. * @param buffer defines the buffer to bind
  30312. * @param location defines the index where to bind the buffer
  30313. */
  30314. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30315. /**
  30316. * Bind a specific block at a given index in a specific shader program
  30317. * @param pipelineContext defines the pipeline context to use
  30318. * @param blockName defines the block name
  30319. * @param index defines the index where to bind the block
  30320. */
  30321. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30322. private bindIndexBuffer;
  30323. private bindBuffer;
  30324. /**
  30325. * update the bound buffer with the given data
  30326. * @param data defines the data to update
  30327. */
  30328. updateArrayBuffer(data: Float32Array): void;
  30329. private _vertexAttribPointer;
  30330. private _bindIndexBufferWithCache;
  30331. private _bindVertexBuffersAttributes;
  30332. /**
  30333. * Records a vertex array object
  30334. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30335. * @param vertexBuffers defines the list of vertex buffers to store
  30336. * @param indexBuffer defines the index buffer to store
  30337. * @param effect defines the effect to store
  30338. * @returns the new vertex array object
  30339. */
  30340. recordVertexArrayObject(vertexBuffers: {
  30341. [key: string]: VertexBuffer;
  30342. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30343. /**
  30344. * Bind a specific vertex array object
  30345. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30346. * @param vertexArrayObject defines the vertex array object to bind
  30347. * @param indexBuffer defines the index buffer to bind
  30348. */
  30349. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30350. /**
  30351. * Bind webGl buffers directly to the webGL context
  30352. * @param vertexBuffer defines the vertex buffer to bind
  30353. * @param indexBuffer defines the index buffer to bind
  30354. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30355. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30356. * @param effect defines the effect associated with the vertex buffer
  30357. */
  30358. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30359. private _unbindVertexArrayObject;
  30360. /**
  30361. * Bind a list of vertex buffers to the webGL context
  30362. * @param vertexBuffers defines the list of vertex buffers to bind
  30363. * @param indexBuffer defines the index buffer to bind
  30364. * @param effect defines the effect associated with the vertex buffers
  30365. */
  30366. bindBuffers(vertexBuffers: {
  30367. [key: string]: Nullable<VertexBuffer>;
  30368. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30369. /**
  30370. * Unbind all instance attributes
  30371. */
  30372. unbindInstanceAttributes(): void;
  30373. /**
  30374. * Release and free the memory of a vertex array object
  30375. * @param vao defines the vertex array object to delete
  30376. */
  30377. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30378. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  30379. protected _deleteBuffer(buffer: DataBuffer): void;
  30380. /**
  30381. * Creates a webGL buffer to use with instanciation
  30382. * @param capacity defines the size of the buffer
  30383. * @returns the webGL buffer
  30384. */
  30385. createInstancesBuffer(capacity: number): DataBuffer;
  30386. /**
  30387. * Delete a webGL buffer used with instanciation
  30388. * @param buffer defines the webGL buffer to delete
  30389. */
  30390. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30391. /**
  30392. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30393. * @param instancesBuffer defines the webGL buffer to update and bind
  30394. * @param data defines the data to store in the buffer
  30395. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30396. */
  30397. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30398. /**
  30399. * Apply all cached states (depth, culling, stencil and alpha)
  30400. */
  30401. applyStates(): void;
  30402. /**
  30403. * Send a draw order
  30404. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30405. * @param indexStart defines the starting index
  30406. * @param indexCount defines the number of index to draw
  30407. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30408. */
  30409. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30410. /**
  30411. * Draw a list of points
  30412. * @param verticesStart defines the index of first vertex to draw
  30413. * @param verticesCount defines the count of vertices to draw
  30414. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30415. */
  30416. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30417. /**
  30418. * Draw a list of unindexed primitives
  30419. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30420. * @param verticesStart defines the index of first vertex to draw
  30421. * @param verticesCount defines the count of vertices to draw
  30422. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30423. */
  30424. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30425. /**
  30426. * Draw a list of indexed primitives
  30427. * @param fillMode defines the primitive to use
  30428. * @param indexStart defines the starting index
  30429. * @param indexCount defines the number of index to draw
  30430. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30431. */
  30432. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30433. /**
  30434. * Draw a list of unindexed primitives
  30435. * @param fillMode defines the primitive to use
  30436. * @param verticesStart defines the index of first vertex to draw
  30437. * @param verticesCount defines the count of vertices to draw
  30438. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30439. */
  30440. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30441. private _drawMode;
  30442. /** @hidden */ private _releaseEffect(effect: Effect): void;
  30443. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30444. /**
  30445. * Create a new effect (used to store vertex/fragment shaders)
  30446. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30447. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30448. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30449. * @param samplers defines an array of string used to represent textures
  30450. * @param defines defines the string containing the defines to use to compile the shaders
  30451. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30452. * @param onCompiled defines a function to call when the effect creation is successful
  30453. * @param onError defines a function to call when the effect creation has failed
  30454. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30455. * @returns the new Effect
  30456. */
  30457. 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;
  30458. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30459. private _compileShader;
  30460. private _compileRawShader;
  30461. /**
  30462. * Directly creates a webGL program
  30463. * @param pipelineContext defines the pipeline context to attach to
  30464. * @param vertexCode defines the vertex shader code to use
  30465. * @param fragmentCode defines the fragment shader code to use
  30466. * @param context defines the webGL context to use (if not set, the current one will be used)
  30467. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30468. * @returns the new webGL program
  30469. */
  30470. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30471. /**
  30472. * Creates a webGL program
  30473. * @param pipelineContext defines the pipeline context to attach to
  30474. * @param vertexCode defines the vertex shader code to use
  30475. * @param fragmentCode defines the fragment shader code to use
  30476. * @param defines defines the string containing the defines to use to compile the shaders
  30477. * @param context defines the webGL context to use (if not set, the current one will be used)
  30478. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30479. * @returns the new webGL program
  30480. */
  30481. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30482. /**
  30483. * Creates a new pipeline context
  30484. * @returns the new pipeline
  30485. */
  30486. createPipelineContext(): IPipelineContext;
  30487. private _createShaderProgram;
  30488. private _finalizePipelineContext;
  30489. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30490. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30491. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30492. /**
  30493. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30494. * @param pipelineContext defines the pipeline context to use
  30495. * @param uniformsNames defines the list of uniform names
  30496. * @returns an array of webGL uniform locations
  30497. */
  30498. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30499. /**
  30500. * Gets the lsit of active attributes for a given webGL program
  30501. * @param pipelineContext defines the pipeline context to use
  30502. * @param attributesNames defines the list of attribute names to get
  30503. * @returns an array of indices indicating the offset of each attribute
  30504. */
  30505. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30506. /**
  30507. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30508. * @param effect defines the effect to activate
  30509. */
  30510. enableEffect(effect: Nullable<Effect>): void;
  30511. /**
  30512. * Set the value of an uniform to an array of int32
  30513. * @param uniform defines the webGL uniform location where to store the value
  30514. * @param array defines the array of int32 to store
  30515. */
  30516. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30517. /**
  30518. * Set the value of an uniform to an array of int32 (stored as vec2)
  30519. * @param uniform defines the webGL uniform location where to store the value
  30520. * @param array defines the array of int32 to store
  30521. */
  30522. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30523. /**
  30524. * Set the value of an uniform to an array of int32 (stored as vec3)
  30525. * @param uniform defines the webGL uniform location where to store the value
  30526. * @param array defines the array of int32 to store
  30527. */
  30528. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30529. /**
  30530. * Set the value of an uniform to an array of int32 (stored as vec4)
  30531. * @param uniform defines the webGL uniform location where to store the value
  30532. * @param array defines the array of int32 to store
  30533. */
  30534. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30535. /**
  30536. * Set the value of an uniform to an array of float32
  30537. * @param uniform defines the webGL uniform location where to store the value
  30538. * @param array defines the array of float32 to store
  30539. */
  30540. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30541. /**
  30542. * Set the value of an uniform to an array of float32 (stored as vec2)
  30543. * @param uniform defines the webGL uniform location where to store the value
  30544. * @param array defines the array of float32 to store
  30545. */
  30546. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30547. /**
  30548. * Set the value of an uniform to an array of float32 (stored as vec3)
  30549. * @param uniform defines the webGL uniform location where to store the value
  30550. * @param array defines the array of float32 to store
  30551. */
  30552. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30553. /**
  30554. * Set the value of an uniform to an array of float32 (stored as vec4)
  30555. * @param uniform defines the webGL uniform location where to store the value
  30556. * @param array defines the array of float32 to store
  30557. */
  30558. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30559. /**
  30560. * Set the value of an uniform to an array of number
  30561. * @param uniform defines the webGL uniform location where to store the value
  30562. * @param array defines the array of number to store
  30563. */
  30564. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30565. /**
  30566. * Set the value of an uniform to an array of number (stored as vec2)
  30567. * @param uniform defines the webGL uniform location where to store the value
  30568. * @param array defines the array of number to store
  30569. */
  30570. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30571. /**
  30572. * Set the value of an uniform to an array of number (stored as vec3)
  30573. * @param uniform defines the webGL uniform location where to store the value
  30574. * @param array defines the array of number to store
  30575. */
  30576. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30577. /**
  30578. * Set the value of an uniform to an array of number (stored as vec4)
  30579. * @param uniform defines the webGL uniform location where to store the value
  30580. * @param array defines the array of number to store
  30581. */
  30582. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30583. /**
  30584. * Set the value of an uniform to an array of float32 (stored as matrices)
  30585. * @param uniform defines the webGL uniform location where to store the value
  30586. * @param matrices defines the array of float32 to store
  30587. */
  30588. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30589. /**
  30590. * Set the value of an uniform to a matrix (3x3)
  30591. * @param uniform defines the webGL uniform location where to store the value
  30592. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30593. */
  30594. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30595. /**
  30596. * Set the value of an uniform to a matrix (2x2)
  30597. * @param uniform defines the webGL uniform location where to store the value
  30598. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30599. */
  30600. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30601. /**
  30602. * Set the value of an uniform to a number (int)
  30603. * @param uniform defines the webGL uniform location where to store the value
  30604. * @param value defines the int number to store
  30605. */
  30606. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30607. /**
  30608. * Set the value of an uniform to a number (float)
  30609. * @param uniform defines the webGL uniform location where to store the value
  30610. * @param value defines the float number to store
  30611. */
  30612. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30613. /**
  30614. * Set the value of an uniform to a vec2
  30615. * @param uniform defines the webGL uniform location where to store the value
  30616. * @param x defines the 1st component of the value
  30617. * @param y defines the 2nd component of the value
  30618. */
  30619. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30620. /**
  30621. * Set the value of an uniform to a vec3
  30622. * @param uniform defines the webGL uniform location where to store the value
  30623. * @param x defines the 1st component of the value
  30624. * @param y defines the 2nd component of the value
  30625. * @param z defines the 3rd component of the value
  30626. */
  30627. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30628. /**
  30629. * Set the value of an uniform to a boolean
  30630. * @param uniform defines the webGL uniform location where to store the value
  30631. * @param bool defines the boolean to store
  30632. */
  30633. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30634. /**
  30635. * Set the value of an uniform to a vec4
  30636. * @param uniform defines the webGL uniform location where to store the value
  30637. * @param x defines the 1st component of the value
  30638. * @param y defines the 2nd component of the value
  30639. * @param z defines the 3rd component of the value
  30640. * @param w defines the 4th component of the value
  30641. */
  30642. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30643. /**
  30644. * Sets a Color4 on a uniform variable
  30645. * @param uniform defines the uniform location
  30646. * @param color4 defines the value to be set
  30647. */
  30648. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30649. /**
  30650. * Set various states to the webGL context
  30651. * @param culling defines backface culling state
  30652. * @param zOffset defines the value to apply to zOffset (0 by default)
  30653. * @param force defines if states must be applied even if cache is up to date
  30654. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30655. */
  30656. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30657. /**
  30658. * Set the z offset to apply to current rendering
  30659. * @param value defines the offset to apply
  30660. */
  30661. setZOffset(value: number): void;
  30662. /**
  30663. * Gets the current value of the zOffset
  30664. * @returns the current zOffset state
  30665. */
  30666. getZOffset(): number;
  30667. /**
  30668. * Enable or disable depth buffering
  30669. * @param enable defines the state to set
  30670. */
  30671. setDepthBuffer(enable: boolean): void;
  30672. /**
  30673. * Gets a boolean indicating if depth writing is enabled
  30674. * @returns the current depth writing state
  30675. */
  30676. getDepthWrite(): boolean;
  30677. /**
  30678. * Enable or disable depth writing
  30679. * @param enable defines the state to set
  30680. */
  30681. setDepthWrite(enable: boolean): void;
  30682. /**
  30683. * Enable or disable color writing
  30684. * @param enable defines the state to set
  30685. */
  30686. setColorWrite(enable: boolean): void;
  30687. /**
  30688. * Gets a boolean indicating if color writing is enabled
  30689. * @returns the current color writing state
  30690. */
  30691. getColorWrite(): boolean;
  30692. /**
  30693. * Sets alpha constants used by some alpha blending modes
  30694. * @param r defines the red component
  30695. * @param g defines the green component
  30696. * @param b defines the blue component
  30697. * @param a defines the alpha component
  30698. */
  30699. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30700. /**
  30701. * Sets the current alpha mode
  30702. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30703. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30704. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30705. */
  30706. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30707. /**
  30708. * Gets the current alpha mode
  30709. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30710. * @returns the current alpha mode
  30711. */
  30712. getAlphaMode(): number;
  30713. /**
  30714. * Clears the list of texture accessible through engine.
  30715. * This can help preventing texture load conflict due to name collision.
  30716. */
  30717. clearInternalTexturesCache(): void;
  30718. /**
  30719. * Force the entire cache to be cleared
  30720. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30721. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30722. */
  30723. wipeCaches(bruteForce?: boolean): void;
  30724. /**
  30725. * Set the compressed texture format to use, based on the formats you have, and the formats
  30726. * supported by the hardware / browser.
  30727. *
  30728. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30729. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30730. * to API arguments needed to compressed textures. This puts the burden on the container
  30731. * generator to house the arcane code for determining these for current & future formats.
  30732. *
  30733. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30734. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30735. *
  30736. * Note: The result of this call is not taken into account when a texture is base64.
  30737. *
  30738. * @param formatsAvailable defines the list of those format families you have created
  30739. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30740. *
  30741. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30742. * @returns The extension selected.
  30743. */
  30744. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  30745. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30746. min: number;
  30747. mag: number;
  30748. };
  30749. /** @hidden */ private _createTexture(): WebGLTexture;
  30750. /**
  30751. * Usually called from Texture.ts.
  30752. * Passed information to create a WebGLTexture
  30753. * @param urlArg defines a value which contains one of the following:
  30754. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30755. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30756. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30758. * @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)
  30759. * @param scene needed for loading to the correct scene
  30760. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30761. * @param onLoad optional callback to be called upon successful completion
  30762. * @param onError optional callback to be called upon failure
  30763. * @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
  30764. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30765. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30766. * @param forcedExtension defines the extension to use to pick the right loader
  30767. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30768. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30769. */
  30770. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30771. /**
  30772. * @hidden
  30773. * Rescales a texture
  30774. * @param source input texutre
  30775. * @param destination destination texture
  30776. * @param scene scene to use to render the resize
  30777. * @param internalFormat format to use when resizing
  30778. * @param onComplete callback to be called when resize has completed
  30779. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  30780. private _unpackFlipYCached;
  30781. /**
  30782. * In case you are sharing the context with other applications, it might
  30783. * be interested to not cache the unpack flip y state to ensure a consistent
  30784. * value would be set.
  30785. */
  30786. enableUnpackFlipYCached: boolean;
  30787. /** @hidden */ private _unpackFlipY(value: boolean): void;
  30788. /** @hidden */ private _getUnpackAlignement(): number;
  30789. /**
  30790. * Creates a dynamic texture
  30791. * @param width defines the width of the texture
  30792. * @param height defines the height of the texture
  30793. * @param generateMipMaps defines if the engine should generate the mip levels
  30794. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30795. * @returns the dynamic texture inside an InternalTexture
  30796. */
  30797. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  30798. /**
  30799. * Update the sampling mode of a given texture
  30800. * @param samplingMode defines the required sampling mode
  30801. * @param texture defines the texture to update
  30802. */
  30803. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30804. /**
  30805. * Update the content of a dynamic texture
  30806. * @param texture defines the texture to update
  30807. * @param canvas defines the canvas containing the source
  30808. * @param invertY defines if data must be stored with Y axis inverted
  30809. * @param premulAlpha defines if alpha is stored as premultiplied
  30810. * @param format defines the format of the data
  30811. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  30812. */
  30813. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  30814. /**
  30815. * Update a video texture
  30816. * @param texture defines the texture to update
  30817. * @param video defines the video element to use
  30818. * @param invertY defines if data must be stored with Y axis inverted
  30819. */
  30820. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30821. /**
  30822. * Updates a depth texture Comparison Mode and Function.
  30823. * If the comparison Function is equal to 0, the mode will be set to none.
  30824. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30825. * @param texture The texture to set the comparison function for
  30826. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30827. */
  30828. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30829. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30830. width: number;
  30831. height: number;
  30832. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30833. /**
  30834. * Creates a depth stencil texture.
  30835. * This is only available in WebGL 2 or with the depth texture extension available.
  30836. * @param size The size of face edge in the texture.
  30837. * @param options The options defining the texture.
  30838. * @returns The texture
  30839. */
  30840. createDepthStencilTexture(size: number | {
  30841. width: number;
  30842. height: number;
  30843. }, options: DepthTextureCreationOptions): InternalTexture;
  30844. /**
  30845. * Creates a depth stencil texture.
  30846. * This is only available in WebGL 2 or with the depth texture extension available.
  30847. * @param size The size of face edge in the texture.
  30848. * @param options The options defining the texture.
  30849. * @returns The texture
  30850. */
  30851. private _createDepthStencilTexture;
  30852. /**
  30853. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30854. * @param renderTarget The render target to set the frame buffer for
  30855. */
  30856. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30857. /**
  30858. * Creates a new render target texture
  30859. * @param size defines the size of the texture
  30860. * @param options defines the options used to create the texture
  30861. * @returns a new render target texture stored in an InternalTexture
  30862. */
  30863. createRenderTargetTexture(size: number | {
  30864. width: number;
  30865. height: number;
  30866. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  30867. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30868. /**
  30869. * Updates the sample count of a render target texture
  30870. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  30871. * @param texture defines the texture to update
  30872. * @param samples defines the sample count to set
  30873. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  30874. */
  30875. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  30876. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30877. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30878. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30879. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30880. /**
  30881. * @hidden
  30882. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  30883. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30884. private _prepareWebGLTexture;
  30885. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  30886. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  30887. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  30888. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30889. protected _setProgram(program: WebGLProgram): void;
  30890. protected _boundUniforms: {
  30891. [key: number]: WebGLUniformLocation;
  30892. };
  30893. /**
  30894. * Binds an effect to the webGL context
  30895. * @param effect defines the effect to bind
  30896. */
  30897. bindSamplers(effect: Effect): void;
  30898. private _activateCurrentTexture;
  30899. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30900. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30901. /**
  30902. * Sets a texture to the webGL context from a postprocess
  30903. * @param channel defines the channel to use
  30904. * @param postProcess defines the source postprocess
  30905. */
  30906. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  30907. /**
  30908. * Binds the output of the passed in post process to the texture channel specified
  30909. * @param channel The channel the texture should be bound to
  30910. * @param postProcess The post process which's output should be bound
  30911. */
  30912. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  30913. /**
  30914. * Unbind all textures from the webGL context
  30915. */
  30916. unbindAllTextures(): void;
  30917. /**
  30918. * Sets a texture to the according uniform.
  30919. * @param channel The texture channel
  30920. * @param uniform The uniform to set
  30921. * @param texture The texture to apply
  30922. */
  30923. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30924. /**
  30925. * Sets a depth stencil texture from a render target to the according uniform.
  30926. * @param channel The texture channel
  30927. * @param uniform The uniform to set
  30928. * @param texture The render target texture containing the depth stencil texture to apply
  30929. */
  30930. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  30931. private _bindSamplerUniformToChannel;
  30932. private _getTextureWrapMode;
  30933. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30934. /**
  30935. * Sets an array of texture to the webGL context
  30936. * @param channel defines the channel where the texture array must be set
  30937. * @param uniform defines the associated uniform location
  30938. * @param textures defines the array of textures to bind
  30939. */
  30940. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30941. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30942. private _setTextureParameterFloat;
  30943. private _setTextureParameterInteger;
  30944. /**
  30945. * Reads pixels from the current frame buffer. Please note that this function can be slow
  30946. * @param x defines the x coordinate of the rectangle where pixels must be read
  30947. * @param y defines the y coordinate of the rectangle where pixels must be read
  30948. * @param width defines the width of the rectangle where pixels must be read
  30949. * @param height defines the height of the rectangle where pixels must be read
  30950. * @returns a Uint8Array containing RGBA colors
  30951. */
  30952. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  30953. /**
  30954. * Add an externaly attached data from its key.
  30955. * This method call will fail and return false, if such key already exists.
  30956. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  30957. * @param key the unique key that identifies the data
  30958. * @param data the data object to associate to the key for this Engine instance
  30959. * @return true if no such key were already present and the data was added successfully, false otherwise
  30960. */
  30961. addExternalData<T>(key: string, data: T): boolean;
  30962. /**
  30963. * Get an externaly attached data from its key
  30964. * @param key the unique key that identifies the data
  30965. * @return the associated data, if present (can be null), or undefined if not present
  30966. */
  30967. getExternalData<T>(key: string): T;
  30968. /**
  30969. * Get an externaly attached data from its key, create it using a factory if it's not already present
  30970. * @param key the unique key that identifies the data
  30971. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  30972. * @return the associated data, can be null if the factory returned null.
  30973. */
  30974. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  30975. /**
  30976. * Remove an externaly attached data from the Engine instance
  30977. * @param key the unique key that identifies the data
  30978. * @return true if the data was successfully removed, false if it doesn't exist
  30979. */
  30980. removeExternalData(key: string): boolean;
  30981. /**
  30982. * Unbind all vertex attributes from the webGL context
  30983. */
  30984. unbindAllAttributes(): void;
  30985. /**
  30986. * 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
  30987. */
  30988. releaseEffects(): void;
  30989. /**
  30990. * Dispose and release all associated resources
  30991. */
  30992. dispose(): void;
  30993. /**
  30994. * Display the loading screen
  30995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30996. */
  30997. displayLoadingUI(): void;
  30998. /**
  30999. * Hide the loading screen
  31000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31001. */
  31002. hideLoadingUI(): void;
  31003. /**
  31004. * Gets the current loading screen object
  31005. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31006. */
  31007. /**
  31008. * Sets the current loading screen object
  31009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31010. */
  31011. loadingScreen: ILoadingScreen;
  31012. /**
  31013. * Sets the current loading screen text
  31014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31015. */
  31016. loadingUIText: string;
  31017. /**
  31018. * Sets the current loading screen background color
  31019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31020. */
  31021. loadingUIBackgroundColor: string;
  31022. /**
  31023. * Attach a new callback raised when context lost event is fired
  31024. * @param callback defines the callback to call
  31025. */
  31026. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31027. /**
  31028. * Attach a new callback raised when context restored event is fired
  31029. * @param callback defines the callback to call
  31030. */
  31031. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31032. /**
  31033. * Gets the source code of the vertex shader associated with a specific webGL program
  31034. * @param program defines the program to use
  31035. * @returns a string containing the source code of the vertex shader associated with the program
  31036. */
  31037. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31038. /**
  31039. * Gets the source code of the fragment shader associated with a specific webGL program
  31040. * @param program defines the program to use
  31041. * @returns a string containing the source code of the fragment shader associated with the program
  31042. */
  31043. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31044. /**
  31045. * Get the current error code of the webGL context
  31046. * @returns the error code
  31047. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31048. */
  31049. getError(): number;
  31050. /**
  31051. * Gets the current framerate
  31052. * @returns a number representing the framerate
  31053. */
  31054. getFps(): number;
  31055. /**
  31056. * Gets the time spent between current and previous frame
  31057. * @returns a number representing the delta time in ms
  31058. */
  31059. getDeltaTime(): number;
  31060. private _measureFps;
  31061. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31062. private _canRenderToFloatFramebuffer;
  31063. private _canRenderToHalfFloatFramebuffer;
  31064. private _canRenderToFramebuffer;
  31065. /** @hidden */ private _getWebGLTextureType(type: number): number;
  31066. /** @hidden */ private _getInternalFormat(format: number): number;
  31067. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31068. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  31069. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31070. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31071. /**
  31072. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31073. * @returns true if the engine can be created
  31074. * @ignorenaming
  31075. */
  31076. static isSupported(): boolean;
  31077. /**
  31078. * Find the next highest power of two.
  31079. * @param x Number to start search from.
  31080. * @return Next highest power of two.
  31081. */
  31082. static CeilingPOT(x: number): number;
  31083. /**
  31084. * Find the next lowest power of two.
  31085. * @param x Number to start search from.
  31086. * @return Next lowest power of two.
  31087. */
  31088. static FloorPOT(x: number): number;
  31089. /**
  31090. * Find the nearest power of two.
  31091. * @param x Number to start search from.
  31092. * @return Next nearest power of two.
  31093. */
  31094. static NearestPOT(x: number): number;
  31095. /**
  31096. * Get the closest exponent of two
  31097. * @param value defines the value to approximate
  31098. * @param max defines the maximum value to return
  31099. * @param mode defines how to define the closest value
  31100. * @returns closest exponent of two of the given value
  31101. */
  31102. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31103. /**
  31104. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31105. * @param func - the function to be called
  31106. * @param requester - the object that will request the next frame. Falls back to window.
  31107. * @returns frame number
  31108. */
  31109. static QueueNewFrame(func: () => void, requester?: any): number;
  31110. /**
  31111. * Ask the browser to promote the current element to pointerlock mode
  31112. * @param element defines the DOM element to promote
  31113. */ private static _RequestPointerlock(element: HTMLElement): void;
  31114. /**
  31115. * Asks the browser to exit pointerlock mode
  31116. */ private static _ExitPointerlock(): void;
  31117. /**
  31118. * Ask the browser to promote the current element to fullscreen rendering mode
  31119. * @param element defines the DOM element to promote
  31120. */ private static _RequestFullscreen(element: HTMLElement): void;
  31121. /**
  31122. * Asks the browser to exit fullscreen mode
  31123. */ private static _ExitFullscreen(): void;
  31124. }
  31125. }
  31126. declare module BABYLON {
  31127. /**
  31128. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31129. * during the life time of the application.
  31130. */
  31131. export class EngineStore {
  31132. /** Gets the list of created engines */
  31133. static Instances: Engine[];
  31134. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  31135. /**
  31136. * Gets the latest created engine
  31137. */
  31138. static readonly LastCreatedEngine: Nullable<Engine>;
  31139. /**
  31140. * Gets the latest created scene
  31141. */
  31142. static readonly LastCreatedScene: Nullable<Scene>;
  31143. /**
  31144. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31145. * @ignorenaming
  31146. */
  31147. static UseFallbackTexture: boolean;
  31148. /**
  31149. * Texture content used if a texture cannot loaded
  31150. * @ignorenaming
  31151. */
  31152. static FallbackTexture: string;
  31153. }
  31154. }
  31155. declare module BABYLON {
  31156. /**
  31157. * Helper class that provides a small promise polyfill
  31158. */
  31159. export class PromisePolyfill {
  31160. /**
  31161. * Static function used to check if the polyfill is required
  31162. * If this is the case then the function will inject the polyfill to window.Promise
  31163. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31164. */
  31165. static Apply(force?: boolean): void;
  31166. }
  31167. }
  31168. declare module BABYLON {
  31169. /**
  31170. * Interface for screenshot methods with describe argument called `size` as object with options
  31171. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31172. */
  31173. export interface IScreenshotSize {
  31174. /**
  31175. * number in pixels for canvas height
  31176. */
  31177. height?: number;
  31178. /**
  31179. * multiplier allowing render at a higher or lower resolution
  31180. * If value is defined then height and width will be ignored and taken from camera
  31181. */
  31182. precision?: number;
  31183. /**
  31184. * number in pixels for canvas width
  31185. */
  31186. width?: number;
  31187. }
  31188. }
  31189. declare module BABYLON {
  31190. interface IColor4Like {
  31191. r: float;
  31192. g: float;
  31193. b: float;
  31194. a: float;
  31195. }
  31196. /**
  31197. * Class containing a set of static utilities functions
  31198. */
  31199. export class Tools {
  31200. /**
  31201. * Gets or sets the base URL to use to load assets
  31202. */
  31203. static BaseUrl: string;
  31204. /**
  31205. * Enable/Disable Custom HTTP Request Headers globally.
  31206. * default = false
  31207. * @see CustomRequestHeaders
  31208. */
  31209. static UseCustomRequestHeaders: boolean;
  31210. /**
  31211. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31212. * i.e. when loading files, where the server/service expects an Authorization header
  31213. */
  31214. static CustomRequestHeaders: {
  31215. [key: string]: string;
  31216. };
  31217. /**
  31218. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31219. */
  31220. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31221. /**
  31222. * Default behaviour for cors in the application.
  31223. * It can be a string if the expected behavior is identical in the entire app.
  31224. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31225. */
  31226. static CorsBehavior: string | ((url: string | string[]) => string);
  31227. /**
  31228. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31229. * @ignorenaming
  31230. */
  31231. static UseFallbackTexture: boolean;
  31232. /**
  31233. * Use this object to register external classes like custom textures or material
  31234. * to allow the laoders to instantiate them
  31235. */
  31236. static RegisteredExternalClasses: {
  31237. [key: string]: Object;
  31238. };
  31239. /**
  31240. * Texture content used if a texture cannot loaded
  31241. * @ignorenaming
  31242. */
  31243. static fallbackTexture: string;
  31244. /**
  31245. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31246. * @param u defines the coordinate on X axis
  31247. * @param v defines the coordinate on Y axis
  31248. * @param width defines the width of the source data
  31249. * @param height defines the height of the source data
  31250. * @param pixels defines the source byte array
  31251. * @param color defines the output color
  31252. */
  31253. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31254. /**
  31255. * Interpolates between a and b via alpha
  31256. * @param a The lower value (returned when alpha = 0)
  31257. * @param b The upper value (returned when alpha = 1)
  31258. * @param alpha The interpolation-factor
  31259. * @return The mixed value
  31260. */
  31261. static Mix(a: number, b: number, alpha: number): number;
  31262. /**
  31263. * Tries to instantiate a new object from a given class name
  31264. * @param className defines the class name to instantiate
  31265. * @returns the new object or null if the system was not able to do the instantiation
  31266. */
  31267. static Instantiate(className: string): any;
  31268. /**
  31269. * Provides a slice function that will work even on IE
  31270. * @param data defines the array to slice
  31271. * @param start defines the start of the data (optional)
  31272. * @param end defines the end of the data (optional)
  31273. * @returns the new sliced array
  31274. */
  31275. static Slice<T>(data: T, start?: number, end?: number): T;
  31276. /**
  31277. * Polyfill for setImmediate
  31278. * @param action defines the action to execute after the current execution block
  31279. */
  31280. static SetImmediate(action: () => void): void;
  31281. /**
  31282. * Function indicating if a number is an exponent of 2
  31283. * @param value defines the value to test
  31284. * @returns true if the value is an exponent of 2
  31285. */
  31286. static IsExponentOfTwo(value: number): boolean;
  31287. private static _tmpFloatArray;
  31288. /**
  31289. * Returns the nearest 32-bit single precision float representation of a Number
  31290. * @param value A Number. If the parameter is of a different type, it will get converted
  31291. * to a number or to NaN if it cannot be converted
  31292. * @returns number
  31293. */
  31294. static FloatRound(value: number): number;
  31295. /**
  31296. * Extracts the filename from a path
  31297. * @param path defines the path to use
  31298. * @returns the filename
  31299. */
  31300. static GetFilename(path: string): string;
  31301. /**
  31302. * Extracts the "folder" part of a path (everything before the filename).
  31303. * @param uri The URI to extract the info from
  31304. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31305. * @returns The "folder" part of the path
  31306. */
  31307. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31308. /**
  31309. * Extracts text content from a DOM element hierarchy
  31310. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31311. */
  31312. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31313. /**
  31314. * Convert an angle in radians to degrees
  31315. * @param angle defines the angle to convert
  31316. * @returns the angle in degrees
  31317. */
  31318. static ToDegrees(angle: number): number;
  31319. /**
  31320. * Convert an angle in degrees to radians
  31321. * @param angle defines the angle to convert
  31322. * @returns the angle in radians
  31323. */
  31324. static ToRadians(angle: number): number;
  31325. /**
  31326. * Encode a buffer to a base64 string
  31327. * @param buffer defines the buffer to encode
  31328. * @returns the encoded string
  31329. */
  31330. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31331. /**
  31332. * Returns an array if obj is not an array
  31333. * @param obj defines the object to evaluate as an array
  31334. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31335. * @returns either obj directly if obj is an array or a new array containing obj
  31336. */
  31337. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31338. /**
  31339. * Gets the pointer prefix to use
  31340. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31341. */
  31342. static GetPointerPrefix(): string;
  31343. /**
  31344. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31345. * @param url define the url we are trying
  31346. * @param element define the dom element where to configure the cors policy
  31347. */
  31348. static SetCorsBehavior(url: string | string[], element: {
  31349. crossOrigin: string | null;
  31350. }): void;
  31351. /**
  31352. * Removes unwanted characters from an url
  31353. * @param url defines the url to clean
  31354. * @returns the cleaned url
  31355. */
  31356. static CleanUrl(url: string): string;
  31357. /**
  31358. * Gets or sets a function used to pre-process url before using them to load assets
  31359. */
  31360. static PreprocessUrl: (url: string) => string;
  31361. /**
  31362. * Loads an image as an HTMLImageElement.
  31363. * @param input url string, ArrayBuffer, or Blob to load
  31364. * @param onLoad callback called when the image successfully loads
  31365. * @param onError callback called when the image fails to load
  31366. * @param offlineProvider offline provider for caching
  31367. * @returns the HTMLImageElement of the loaded image
  31368. */
  31369. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31370. /**
  31371. * Loads a file
  31372. * @param url url string, ArrayBuffer, or Blob to load
  31373. * @param onSuccess callback called when the file successfully loads
  31374. * @param onProgress callback called while file is loading (if the server supports this mode)
  31375. * @param offlineProvider defines the offline provider for caching
  31376. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31377. * @param onError callback called when the file fails to load
  31378. * @returns a file request object
  31379. */
  31380. 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;
  31381. /**
  31382. * Loads a file from a url
  31383. * @param url the file url to load
  31384. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31385. */
  31386. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31387. /**
  31388. * Load a script (identified by an url). When the url returns, the
  31389. * content of this file is added into a new script element, attached to the DOM (body element)
  31390. * @param scriptUrl defines the url of the script to laod
  31391. * @param onSuccess defines the callback called when the script is loaded
  31392. * @param onError defines the callback to call if an error occurs
  31393. * @param scriptId defines the id of the script element
  31394. */
  31395. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31396. /**
  31397. * Load an asynchronous script (identified by an url). When the url returns, the
  31398. * content of this file is added into a new script element, attached to the DOM (body element)
  31399. * @param scriptUrl defines the url of the script to laod
  31400. * @param scriptId defines the id of the script element
  31401. * @returns a promise request object
  31402. */
  31403. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31404. /**
  31405. * Loads a file from a blob
  31406. * @param fileToLoad defines the blob to use
  31407. * @param callback defines the callback to call when data is loaded
  31408. * @param progressCallback defines the callback to call during loading process
  31409. * @returns a file request object
  31410. */
  31411. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31412. /**
  31413. * Loads a file
  31414. * @param fileToLoad defines the file to load
  31415. * @param callback defines the callback to call when data is loaded
  31416. * @param progressCallBack defines the callback to call during loading process
  31417. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31418. * @returns a file request object
  31419. */
  31420. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31421. /**
  31422. * Creates a data url from a given string content
  31423. * @param content defines the content to convert
  31424. * @returns the new data url link
  31425. */
  31426. static FileAsURL(content: string): string;
  31427. /**
  31428. * Format the given number to a specific decimal format
  31429. * @param value defines the number to format
  31430. * @param decimals defines the number of decimals to use
  31431. * @returns the formatted string
  31432. */
  31433. static Format(value: number, decimals?: number): string;
  31434. /**
  31435. * Tries to copy an object by duplicating every property
  31436. * @param source defines the source object
  31437. * @param destination defines the target object
  31438. * @param doNotCopyList defines a list of properties to avoid
  31439. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31440. */
  31441. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31442. /**
  31443. * Gets a boolean indicating if the given object has no own property
  31444. * @param obj defines the object to test
  31445. * @returns true if object has no own property
  31446. */
  31447. static IsEmpty(obj: any): boolean;
  31448. /**
  31449. * Function used to register events at window level
  31450. * @param windowElement defines the Window object to use
  31451. * @param events defines the events to register
  31452. */
  31453. static RegisterTopRootEvents(windowElement: Window, events: {
  31454. name: string;
  31455. handler: Nullable<(e: FocusEvent) => any>;
  31456. }[]): void;
  31457. /**
  31458. * Function used to unregister events from window level
  31459. * @param windowElement defines the Window object to use
  31460. * @param events defines the events to unregister
  31461. */
  31462. static UnregisterTopRootEvents(windowElement: Window, events: {
  31463. name: string;
  31464. handler: Nullable<(e: FocusEvent) => any>;
  31465. }[]): void;
  31466. /**
  31467. * @ignore
  31468. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31469. /**
  31470. * Dumps the current bound framebuffer
  31471. * @param width defines the rendering width
  31472. * @param height defines the rendering height
  31473. * @param engine defines the hosting engine
  31474. * @param successCallback defines the callback triggered once the data are available
  31475. * @param mimeType defines the mime type of the result
  31476. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31477. */
  31478. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31479. /**
  31480. * Converts the canvas data to blob.
  31481. * This acts as a polyfill for browsers not supporting the to blob function.
  31482. * @param canvas Defines the canvas to extract the data from
  31483. * @param successCallback Defines the callback triggered once the data are available
  31484. * @param mimeType Defines the mime type of the result
  31485. */
  31486. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31487. /**
  31488. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31489. * @param successCallback defines the callback triggered once the data are available
  31490. * @param mimeType defines the mime type of the result
  31491. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31492. */
  31493. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31494. /**
  31495. * Downloads a blob in the browser
  31496. * @param blob defines the blob to download
  31497. * @param fileName defines the name of the downloaded file
  31498. */
  31499. static Download(blob: Blob, fileName: string): void;
  31500. /**
  31501. * Captures a screenshot of the current rendering
  31502. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31503. * @param engine defines the rendering engine
  31504. * @param camera defines the source camera
  31505. * @param size This parameter can be set to a single number or to an object with the
  31506. * following (optional) properties: precision, width, height. If a single number is passed,
  31507. * it will be used for both width and height. If an object is passed, the screenshot size
  31508. * will be derived from the parameters. The precision property is a multiplier allowing
  31509. * rendering at a higher or lower resolution
  31510. * @param successCallback defines the callback receives a single parameter which contains the
  31511. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31512. * src parameter of an <img> to display it
  31513. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31514. * Check your browser for supported MIME types
  31515. */
  31516. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31517. /**
  31518. * Captures a screenshot of the current rendering
  31519. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31520. * @param engine defines the rendering engine
  31521. * @param camera defines the source camera
  31522. * @param size This parameter can be set to a single number or to an object with the
  31523. * following (optional) properties: precision, width, height. If a single number is passed,
  31524. * it will be used for both width and height. If an object is passed, the screenshot size
  31525. * will be derived from the parameters. The precision property is a multiplier allowing
  31526. * rendering at a higher or lower resolution
  31527. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31528. * Check your browser for supported MIME types
  31529. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31530. * to the src parameter of an <img> to display it
  31531. */
  31532. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31533. /**
  31534. * Generates an image screenshot from the specified camera.
  31535. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31536. * @param engine The engine to use for rendering
  31537. * @param camera The camera to use for rendering
  31538. * @param size This parameter can be set to a single number or to an object with the
  31539. * following (optional) properties: precision, width, height. If a single number is passed,
  31540. * it will be used for both width and height. If an object is passed, the screenshot size
  31541. * will be derived from the parameters. The precision property is a multiplier allowing
  31542. * rendering at a higher or lower resolution
  31543. * @param successCallback The callback receives a single parameter which contains the
  31544. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31545. * src parameter of an <img> to display it
  31546. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31547. * Check your browser for supported MIME types
  31548. * @param samples Texture samples (default: 1)
  31549. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31550. * @param fileName A name for for the downloaded file.
  31551. */
  31552. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31553. /**
  31554. * Generates an image screenshot from the specified camera.
  31555. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31556. * @param engine The engine to use for rendering
  31557. * @param camera The camera to use for rendering
  31558. * @param size This parameter can be set to a single number or to an object with the
  31559. * following (optional) properties: precision, width, height. If a single number is passed,
  31560. * it will be used for both width and height. If an object is passed, the screenshot size
  31561. * will be derived from the parameters. The precision property is a multiplier allowing
  31562. * rendering at a higher or lower resolution
  31563. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31564. * Check your browser for supported MIME types
  31565. * @param samples Texture samples (default: 1)
  31566. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31567. * @param fileName A name for for the downloaded file.
  31568. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31569. * to the src parameter of an <img> to display it
  31570. */
  31571. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31572. /**
  31573. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31574. * Be aware Math.random() could cause collisions, but:
  31575. * "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"
  31576. * @returns a pseudo random id
  31577. */
  31578. static RandomId(): string;
  31579. /**
  31580. * Test if the given uri is a base64 string
  31581. * @param uri The uri to test
  31582. * @return True if the uri is a base64 string or false otherwise
  31583. */
  31584. static IsBase64(uri: string): boolean;
  31585. /**
  31586. * Decode the given base64 uri.
  31587. * @param uri The uri to decode
  31588. * @return The decoded base64 data.
  31589. */
  31590. static DecodeBase64(uri: string): ArrayBuffer;
  31591. /**
  31592. * Gets the absolute url.
  31593. * @param url the input url
  31594. * @return the absolute url
  31595. */
  31596. static GetAbsoluteUrl(url: string): string;
  31597. /**
  31598. * No log
  31599. */
  31600. static readonly NoneLogLevel: number;
  31601. /**
  31602. * Only message logs
  31603. */
  31604. static readonly MessageLogLevel: number;
  31605. /**
  31606. * Only warning logs
  31607. */
  31608. static readonly WarningLogLevel: number;
  31609. /**
  31610. * Only error logs
  31611. */
  31612. static readonly ErrorLogLevel: number;
  31613. /**
  31614. * All logs
  31615. */
  31616. static readonly AllLogLevel: number;
  31617. /**
  31618. * Gets a value indicating the number of loading errors
  31619. * @ignorenaming
  31620. */
  31621. static readonly errorsCount: number;
  31622. /**
  31623. * Callback called when a new log is added
  31624. */
  31625. static OnNewCacheEntry: (entry: string) => void;
  31626. /**
  31627. * Log a message to the console
  31628. * @param message defines the message to log
  31629. */
  31630. static Log(message: string): void;
  31631. /**
  31632. * Write a warning message to the console
  31633. * @param message defines the message to log
  31634. */
  31635. static Warn(message: string): void;
  31636. /**
  31637. * Write an error message to the console
  31638. * @param message defines the message to log
  31639. */
  31640. static Error(message: string): void;
  31641. /**
  31642. * Gets current log cache (list of logs)
  31643. */
  31644. static readonly LogCache: string;
  31645. /**
  31646. * Clears the log cache
  31647. */
  31648. static ClearLogCache(): void;
  31649. /**
  31650. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31651. */
  31652. static LogLevels: number;
  31653. /**
  31654. * Checks if the window object exists
  31655. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31656. */
  31657. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31658. /**
  31659. * No performance log
  31660. */
  31661. static readonly PerformanceNoneLogLevel: number;
  31662. /**
  31663. * Use user marks to log performance
  31664. */
  31665. static readonly PerformanceUserMarkLogLevel: number;
  31666. /**
  31667. * Log performance to the console
  31668. */
  31669. static readonly PerformanceConsoleLogLevel: number;
  31670. private static _performance;
  31671. /**
  31672. * Sets the current performance log level
  31673. */
  31674. static PerformanceLogLevel: number;
  31675. private static _StartPerformanceCounterDisabled;
  31676. private static _EndPerformanceCounterDisabled;
  31677. private static _StartUserMark;
  31678. private static _EndUserMark;
  31679. private static _StartPerformanceConsole;
  31680. private static _EndPerformanceConsole;
  31681. /**
  31682. * Starts a performance counter
  31683. */
  31684. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31685. /**
  31686. * Ends a specific performance coutner
  31687. */
  31688. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31689. /**
  31690. * Gets either window.performance.now() if supported or Date.now() else
  31691. */
  31692. static readonly Now: number;
  31693. /**
  31694. * This method will return the name of the class used to create the instance of the given object.
  31695. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31696. * @param object the object to get the class name from
  31697. * @param isType defines if the object is actually a type
  31698. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31699. */
  31700. static GetClassName(object: any, isType?: boolean): string;
  31701. /**
  31702. * Gets the first element of an array satisfying a given predicate
  31703. * @param array defines the array to browse
  31704. * @param predicate defines the predicate to use
  31705. * @returns null if not found or the element
  31706. */
  31707. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31708. /**
  31709. * This method will return the name of the full name of the class, including its owning module (if any).
  31710. * 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).
  31711. * @param object the object to get the class name from
  31712. * @param isType defines if the object is actually a type
  31713. * @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.
  31714. * @ignorenaming
  31715. */
  31716. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31717. /**
  31718. * Returns a promise that resolves after the given amount of time.
  31719. * @param delay Number of milliseconds to delay
  31720. * @returns Promise that resolves after the given amount of time
  31721. */
  31722. static DelayAsync(delay: number): Promise<void>;
  31723. }
  31724. /**
  31725. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31726. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31727. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31728. * @param name The name of the class, case should be preserved
  31729. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31730. */
  31731. export function className(name: string, module?: string): (target: Object) => void;
  31732. /**
  31733. * An implementation of a loop for asynchronous functions.
  31734. */
  31735. export class AsyncLoop {
  31736. /**
  31737. * Defines the number of iterations for the loop
  31738. */
  31739. iterations: number;
  31740. /**
  31741. * Defines the current index of the loop.
  31742. */
  31743. index: number;
  31744. private _done;
  31745. private _fn;
  31746. private _successCallback;
  31747. /**
  31748. * Constructor.
  31749. * @param iterations the number of iterations.
  31750. * @param func the function to run each iteration
  31751. * @param successCallback the callback that will be called upon succesful execution
  31752. * @param offset starting offset.
  31753. */
  31754. constructor(
  31755. /**
  31756. * Defines the number of iterations for the loop
  31757. */
  31758. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31759. /**
  31760. * Execute the next iteration. Must be called after the last iteration was finished.
  31761. */
  31762. executeNext(): void;
  31763. /**
  31764. * Break the loop and run the success callback.
  31765. */
  31766. breakLoop(): void;
  31767. /**
  31768. * Create and run an async loop.
  31769. * @param iterations the number of iterations.
  31770. * @param fn the function to run each iteration
  31771. * @param successCallback the callback that will be called upon succesful execution
  31772. * @param offset starting offset.
  31773. * @returns the created async loop object
  31774. */
  31775. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31776. /**
  31777. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31778. * @param iterations total number of iterations
  31779. * @param syncedIterations number of synchronous iterations in each async iteration.
  31780. * @param fn the function to call each iteration.
  31781. * @param callback a success call back that will be called when iterating stops.
  31782. * @param breakFunction a break condition (optional)
  31783. * @param timeout timeout settings for the setTimeout function. default - 0.
  31784. * @returns the created async loop object
  31785. */
  31786. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31787. }
  31788. }
  31789. declare module BABYLON {
  31790. /** @hidden */
  31791. export interface ICollisionCoordinator {
  31792. createCollider(): Collider;
  31793. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31794. init(scene: Scene): void;
  31795. }
  31796. /** @hidden */
  31797. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31798. private _scene;
  31799. private _scaledPosition;
  31800. private _scaledVelocity;
  31801. private _finalPosition;
  31802. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31803. createCollider(): Collider;
  31804. init(scene: Scene): void;
  31805. private _collideWithWorld;
  31806. }
  31807. }
  31808. declare module BABYLON {
  31809. /**
  31810. * Class used to manage all inputs for the scene.
  31811. */
  31812. export class InputManager {
  31813. /** The distance in pixel that you have to move to prevent some events */
  31814. static DragMovementThreshold: number;
  31815. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31816. static LongPressDelay: number;
  31817. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31818. static DoubleClickDelay: number;
  31819. /** If you need to check double click without raising a single click at first click, enable this flag */
  31820. static ExclusiveDoubleClickMode: boolean;
  31821. private _wheelEventName;
  31822. private _onPointerMove;
  31823. private _onPointerDown;
  31824. private _onPointerUp;
  31825. private _initClickEvent;
  31826. private _initActionManager;
  31827. private _delayedSimpleClick;
  31828. private _delayedSimpleClickTimeout;
  31829. private _previousDelayedSimpleClickTimeout;
  31830. private _meshPickProceed;
  31831. private _previousButtonPressed;
  31832. private _currentPickResult;
  31833. private _previousPickResult;
  31834. private _totalPointersPressed;
  31835. private _doubleClickOccured;
  31836. private _pointerOverMesh;
  31837. private _pickedDownMesh;
  31838. private _pickedUpMesh;
  31839. private _pointerX;
  31840. private _pointerY;
  31841. private _unTranslatedPointerX;
  31842. private _unTranslatedPointerY;
  31843. private _startingPointerPosition;
  31844. private _previousStartingPointerPosition;
  31845. private _startingPointerTime;
  31846. private _previousStartingPointerTime;
  31847. private _pointerCaptures;
  31848. private _onKeyDown;
  31849. private _onKeyUp;
  31850. private _onCanvasFocusObserver;
  31851. private _onCanvasBlurObserver;
  31852. private _scene;
  31853. /**
  31854. * Creates a new InputManager
  31855. * @param scene defines the hosting scene
  31856. */
  31857. constructor(scene: Scene);
  31858. /**
  31859. * Gets the mesh that is currently under the pointer
  31860. */
  31861. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31862. /**
  31863. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31864. */
  31865. readonly unTranslatedPointer: Vector2;
  31866. /**
  31867. * Gets or sets the current on-screen X position of the pointer
  31868. */
  31869. pointerX: number;
  31870. /**
  31871. * Gets or sets the current on-screen Y position of the pointer
  31872. */
  31873. pointerY: number;
  31874. private _updatePointerPosition;
  31875. private _processPointerMove;
  31876. private _setRayOnPointerInfo;
  31877. private _checkPrePointerObservable;
  31878. /**
  31879. * Use this method to simulate a pointer move on a mesh
  31880. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31881. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31882. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31883. */
  31884. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31885. /**
  31886. * Use this method to simulate a pointer down on a mesh
  31887. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31888. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31889. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31890. */
  31891. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31892. private _processPointerDown;
  31893. /** @hidden */ private _isPointerSwiping(): boolean;
  31894. /**
  31895. * Use this method to simulate a pointer up on a mesh
  31896. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31897. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31898. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31899. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31900. */
  31901. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31902. private _processPointerUp;
  31903. /**
  31904. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31905. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31906. * @returns true if the pointer was captured
  31907. */
  31908. isPointerCaptured(pointerId?: number): boolean;
  31909. /**
  31910. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31911. * @param attachUp defines if you want to attach events to pointerup
  31912. * @param attachDown defines if you want to attach events to pointerdown
  31913. * @param attachMove defines if you want to attach events to pointermove
  31914. */
  31915. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31916. /**
  31917. * Detaches all event handlers
  31918. */
  31919. detachControl(): void;
  31920. /**
  31921. * Force the value of meshUnderPointer
  31922. * @param mesh defines the mesh to use
  31923. */
  31924. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31925. /**
  31926. * Gets the mesh under the pointer
  31927. * @returns a Mesh or null if no mesh is under the pointer
  31928. */
  31929. getPointerOverMesh(): Nullable<AbstractMesh>;
  31930. }
  31931. }
  31932. declare module BABYLON {
  31933. /**
  31934. * Helper class used to generate session unique ID
  31935. */
  31936. export class UniqueIdGenerator {
  31937. private static _UniqueIdCounter;
  31938. /**
  31939. * Gets an unique (relatively to the current scene) Id
  31940. */
  31941. static readonly UniqueId: number;
  31942. }
  31943. }
  31944. declare module BABYLON {
  31945. /**
  31946. * This class defines the direct association between an animation and a target
  31947. */
  31948. export class TargetedAnimation {
  31949. /**
  31950. * Animation to perform
  31951. */
  31952. animation: Animation;
  31953. /**
  31954. * Target to animate
  31955. */
  31956. target: any;
  31957. /**
  31958. * Serialize the object
  31959. * @returns the JSON object representing the current entity
  31960. */
  31961. serialize(): any;
  31962. }
  31963. /**
  31964. * Use this class to create coordinated animations on multiple targets
  31965. */
  31966. export class AnimationGroup implements IDisposable {
  31967. /** The name of the animation group */
  31968. name: string;
  31969. private _scene;
  31970. private _targetedAnimations;
  31971. private _animatables;
  31972. private _from;
  31973. private _to;
  31974. private _isStarted;
  31975. private _isPaused;
  31976. private _speedRatio;
  31977. private _loopAnimation;
  31978. /**
  31979. * Gets or sets the unique id of the node
  31980. */
  31981. uniqueId: number;
  31982. /**
  31983. * This observable will notify when one animation have ended
  31984. */
  31985. onAnimationEndObservable: Observable<TargetedAnimation>;
  31986. /**
  31987. * Observer raised when one animation loops
  31988. */
  31989. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31990. /**
  31991. * This observable will notify when all animations have ended.
  31992. */
  31993. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31994. /**
  31995. * This observable will notify when all animations have paused.
  31996. */
  31997. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31998. /**
  31999. * This observable will notify when all animations are playing.
  32000. */
  32001. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32002. /**
  32003. * Gets the first frame
  32004. */
  32005. readonly from: number;
  32006. /**
  32007. * Gets the last frame
  32008. */
  32009. readonly to: number;
  32010. /**
  32011. * Define if the animations are started
  32012. */
  32013. readonly isStarted: boolean;
  32014. /**
  32015. * Gets a value indicating that the current group is playing
  32016. */
  32017. readonly isPlaying: boolean;
  32018. /**
  32019. * Gets or sets the speed ratio to use for all animations
  32020. */
  32021. /**
  32022. * Gets or sets the speed ratio to use for all animations
  32023. */
  32024. speedRatio: number;
  32025. /**
  32026. * Gets or sets if all animations should loop or not
  32027. */
  32028. loopAnimation: boolean;
  32029. /**
  32030. * Gets the targeted animations for this animation group
  32031. */
  32032. readonly targetedAnimations: Array<TargetedAnimation>;
  32033. /**
  32034. * returning the list of animatables controlled by this animation group.
  32035. */
  32036. readonly animatables: Array<Animatable>;
  32037. /**
  32038. * Instantiates a new Animation Group.
  32039. * This helps managing several animations at once.
  32040. * @see http://doc.babylonjs.com/how_to/group
  32041. * @param name Defines the name of the group
  32042. * @param scene Defines the scene the group belongs to
  32043. */
  32044. constructor(
  32045. /** The name of the animation group */
  32046. name: string, scene?: Nullable<Scene>);
  32047. /**
  32048. * Add an animation (with its target) in the group
  32049. * @param animation defines the animation we want to add
  32050. * @param target defines the target of the animation
  32051. * @returns the TargetedAnimation object
  32052. */
  32053. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32054. /**
  32055. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32056. * It can add constant keys at begin or end
  32057. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32058. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32059. * @returns the animation group
  32060. */
  32061. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32062. /**
  32063. * Start all animations on given targets
  32064. * @param loop defines if animations must loop
  32065. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32066. * @param from defines the from key (optional)
  32067. * @param to defines the to key (optional)
  32068. * @returns the current animation group
  32069. */
  32070. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32071. /**
  32072. * Pause all animations
  32073. * @returns the animation group
  32074. */
  32075. pause(): AnimationGroup;
  32076. /**
  32077. * Play all animations to initial state
  32078. * This function will start() the animations if they were not started or will restart() them if they were paused
  32079. * @param loop defines if animations must loop
  32080. * @returns the animation group
  32081. */
  32082. play(loop?: boolean): AnimationGroup;
  32083. /**
  32084. * Reset all animations to initial state
  32085. * @returns the animation group
  32086. */
  32087. reset(): AnimationGroup;
  32088. /**
  32089. * Restart animations from key 0
  32090. * @returns the animation group
  32091. */
  32092. restart(): AnimationGroup;
  32093. /**
  32094. * Stop all animations
  32095. * @returns the animation group
  32096. */
  32097. stop(): AnimationGroup;
  32098. /**
  32099. * Set animation weight for all animatables
  32100. * @param weight defines the weight to use
  32101. * @return the animationGroup
  32102. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32103. */
  32104. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32105. /**
  32106. * Synchronize and normalize all animatables with a source animatable
  32107. * @param root defines the root animatable to synchronize with
  32108. * @return the animationGroup
  32109. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32110. */
  32111. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32112. /**
  32113. * Goes to a specific frame in this animation group
  32114. * @param frame the frame number to go to
  32115. * @return the animationGroup
  32116. */
  32117. goToFrame(frame: number): AnimationGroup;
  32118. /**
  32119. * Dispose all associated resources
  32120. */
  32121. dispose(): void;
  32122. private _checkAnimationGroupEnded;
  32123. /**
  32124. * Clone the current animation group and returns a copy
  32125. * @param newName defines the name of the new group
  32126. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32127. * @returns the new aniamtion group
  32128. */
  32129. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32130. /**
  32131. * Serializes the animationGroup to an object
  32132. * @returns Serialized object
  32133. */
  32134. serialize(): any;
  32135. /**
  32136. * Returns a new AnimationGroup object parsed from the source provided.
  32137. * @param parsedAnimationGroup defines the source
  32138. * @param scene defines the scene that will receive the animationGroup
  32139. * @returns a new AnimationGroup
  32140. */
  32141. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32142. /**
  32143. * Returns the string "AnimationGroup"
  32144. * @returns "AnimationGroup"
  32145. */
  32146. getClassName(): string;
  32147. /**
  32148. * Creates a detailled string about the object
  32149. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32150. * @returns a string representing the object
  32151. */
  32152. toString(fullDetails?: boolean): string;
  32153. }
  32154. }
  32155. declare module BABYLON {
  32156. /**
  32157. * Define an interface for all classes that will hold resources
  32158. */
  32159. export interface IDisposable {
  32160. /**
  32161. * Releases all held resources
  32162. */
  32163. dispose(): void;
  32164. }
  32165. /** Interface defining initialization parameters for Scene class */
  32166. export interface SceneOptions {
  32167. /**
  32168. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32169. * It will improve performance when the number of geometries becomes important.
  32170. */
  32171. useGeometryUniqueIdsMap?: boolean;
  32172. /**
  32173. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32174. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32175. */
  32176. useMaterialMeshMap?: boolean;
  32177. /**
  32178. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32179. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32180. */
  32181. useClonedMeshhMap?: boolean;
  32182. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32183. virtual?: boolean;
  32184. }
  32185. /**
  32186. * Represents a scene to be rendered by the engine.
  32187. * @see http://doc.babylonjs.com/features/scene
  32188. */
  32189. export class Scene extends AbstractScene implements IAnimatable {
  32190. /** The fog is deactivated */
  32191. static readonly FOGMODE_NONE: number;
  32192. /** The fog density is following an exponential function */
  32193. static readonly FOGMODE_EXP: number;
  32194. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32195. static readonly FOGMODE_EXP2: number;
  32196. /** The fog density is following a linear function. */
  32197. static readonly FOGMODE_LINEAR: number;
  32198. /**
  32199. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32200. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32201. */
  32202. static MinDeltaTime: number;
  32203. /**
  32204. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32205. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32206. */
  32207. static MaxDeltaTime: number;
  32208. /**
  32209. * Factory used to create the default material.
  32210. * @param name The name of the material to create
  32211. * @param scene The scene to create the material for
  32212. * @returns The default material
  32213. */
  32214. static DefaultMaterialFactory(scene: Scene): Material;
  32215. /**
  32216. * Factory used to create the a collision coordinator.
  32217. * @returns The collision coordinator
  32218. */
  32219. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32220. /** @hidden */ private _inputManager: InputManager;
  32221. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32222. cameraToUseForPointers: Nullable<Camera>;
  32223. /** @hidden */ protected readonly _isScene: boolean;
  32224. /**
  32225. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32226. */
  32227. autoClear: boolean;
  32228. /**
  32229. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32230. */
  32231. autoClearDepthAndStencil: boolean;
  32232. /**
  32233. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32234. */
  32235. clearColor: Color4;
  32236. /**
  32237. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32238. */
  32239. ambientColor: Color3;
  32240. /**
  32241. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32242. * It should only be one of the following (if not the default embedded one):
  32243. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32244. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32245. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32246. * The material properties need to be setup according to the type of texture in use.
  32247. */
  32248. environmentBRDFTexture: BaseTexture;
  32249. /** @hidden */
  32250. protected _environmentTexture: Nullable<BaseTexture>;
  32251. /**
  32252. * Texture used in all pbr material as the reflection texture.
  32253. * As in the majority of the scene they are the same (exception for multi room and so on),
  32254. * this is easier to reference from here than from all the materials.
  32255. */
  32256. /**
  32257. * Texture used in all pbr material as the reflection texture.
  32258. * As in the majority of the scene they are the same (exception for multi room and so on),
  32259. * this is easier to set here than in all the materials.
  32260. */
  32261. environmentTexture: Nullable<BaseTexture>;
  32262. /** @hidden */
  32263. protected _environmentIntensity: number;
  32264. /**
  32265. * Intensity of the environment in all pbr material.
  32266. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32267. * As in the majority of the scene they are the same (exception for multi room and so on),
  32268. * this is easier to reference from here than from all the materials.
  32269. */
  32270. /**
  32271. * Intensity of the environment in all pbr material.
  32272. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32273. * As in the majority of the scene they are the same (exception for multi room and so on),
  32274. * this is easier to set here than in all the materials.
  32275. */
  32276. environmentIntensity: number;
  32277. /** @hidden */
  32278. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32279. /**
  32280. * Default image processing configuration used either in the rendering
  32281. * Forward main pass or through the imageProcessingPostProcess if present.
  32282. * As in the majority of the scene they are the same (exception for multi camera),
  32283. * this is easier to reference from here than from all the materials and post process.
  32284. *
  32285. * No setter as we it is a shared configuration, you can set the values instead.
  32286. */
  32287. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32288. private _forceWireframe;
  32289. /**
  32290. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32291. */
  32292. forceWireframe: boolean;
  32293. private _forcePointsCloud;
  32294. /**
  32295. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32296. */
  32297. forcePointsCloud: boolean;
  32298. /**
  32299. * Gets or sets the active clipplane 1
  32300. */
  32301. clipPlane: Nullable<Plane>;
  32302. /**
  32303. * Gets or sets the active clipplane 2
  32304. */
  32305. clipPlane2: Nullable<Plane>;
  32306. /**
  32307. * Gets or sets the active clipplane 3
  32308. */
  32309. clipPlane3: Nullable<Plane>;
  32310. /**
  32311. * Gets or sets the active clipplane 4
  32312. */
  32313. clipPlane4: Nullable<Plane>;
  32314. /**
  32315. * Gets or sets a boolean indicating if animations are enabled
  32316. */
  32317. animationsEnabled: boolean;
  32318. private _animationPropertiesOverride;
  32319. /**
  32320. * Gets or sets the animation properties override
  32321. */
  32322. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32323. /**
  32324. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32325. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32326. */
  32327. useConstantAnimationDeltaTime: boolean;
  32328. /**
  32329. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32330. * Please note that it requires to run a ray cast through the scene on every frame
  32331. */
  32332. constantlyUpdateMeshUnderPointer: boolean;
  32333. /**
  32334. * Defines the HTML cursor to use when hovering over interactive elements
  32335. */
  32336. hoverCursor: string;
  32337. /**
  32338. * Defines the HTML default cursor to use (empty by default)
  32339. */
  32340. defaultCursor: string;
  32341. /**
  32342. * This is used to call preventDefault() on pointer down
  32343. * in order to block unwanted artifacts like system double clicks
  32344. */
  32345. preventDefaultOnPointerDown: boolean;
  32346. /**
  32347. * This is used to call preventDefault() on pointer up
  32348. * in order to block unwanted artifacts like system double clicks
  32349. */
  32350. preventDefaultOnPointerUp: boolean;
  32351. /**
  32352. * Gets or sets user defined metadata
  32353. */
  32354. metadata: any;
  32355. /**
  32356. * For internal use only. Please do not use.
  32357. */
  32358. reservedDataStore: any;
  32359. /**
  32360. * Gets the name of the plugin used to load this scene (null by default)
  32361. */
  32362. loadingPluginName: string;
  32363. /**
  32364. * Use this array to add regular expressions used to disable offline support for specific urls
  32365. */
  32366. disableOfflineSupportExceptionRules: RegExp[];
  32367. /**
  32368. * An event triggered when the scene is disposed.
  32369. */
  32370. onDisposeObservable: Observable<Scene>;
  32371. private _onDisposeObserver;
  32372. /** Sets a function to be executed when this scene is disposed. */
  32373. onDispose: () => void;
  32374. /**
  32375. * An event triggered before rendering the scene (right after animations and physics)
  32376. */
  32377. onBeforeRenderObservable: Observable<Scene>;
  32378. private _onBeforeRenderObserver;
  32379. /** Sets a function to be executed before rendering this scene */
  32380. beforeRender: Nullable<() => void>;
  32381. /**
  32382. * An event triggered after rendering the scene
  32383. */
  32384. onAfterRenderObservable: Observable<Scene>;
  32385. /**
  32386. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32387. */
  32388. onAfterRenderCameraObservable: Observable<Camera>;
  32389. private _onAfterRenderObserver;
  32390. /** Sets a function to be executed after rendering this scene */
  32391. afterRender: Nullable<() => void>;
  32392. /**
  32393. * An event triggered before animating the scene
  32394. */
  32395. onBeforeAnimationsObservable: Observable<Scene>;
  32396. /**
  32397. * An event triggered after animations processing
  32398. */
  32399. onAfterAnimationsObservable: Observable<Scene>;
  32400. /**
  32401. * An event triggered before draw calls are ready to be sent
  32402. */
  32403. onBeforeDrawPhaseObservable: Observable<Scene>;
  32404. /**
  32405. * An event triggered after draw calls have been sent
  32406. */
  32407. onAfterDrawPhaseObservable: Observable<Scene>;
  32408. /**
  32409. * An event triggered when the scene is ready
  32410. */
  32411. onReadyObservable: Observable<Scene>;
  32412. /**
  32413. * An event triggered before rendering a camera
  32414. */
  32415. onBeforeCameraRenderObservable: Observable<Camera>;
  32416. private _onBeforeCameraRenderObserver;
  32417. /** Sets a function to be executed before rendering a camera*/
  32418. beforeCameraRender: () => void;
  32419. /**
  32420. * An event triggered after rendering a camera
  32421. */
  32422. onAfterCameraRenderObservable: Observable<Camera>;
  32423. private _onAfterCameraRenderObserver;
  32424. /** Sets a function to be executed after rendering a camera*/
  32425. afterCameraRender: () => void;
  32426. /**
  32427. * An event triggered when active meshes evaluation is about to start
  32428. */
  32429. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32430. /**
  32431. * An event triggered when active meshes evaluation is done
  32432. */
  32433. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32434. /**
  32435. * An event triggered when particles rendering is about to start
  32436. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32437. */
  32438. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32439. /**
  32440. * An event triggered when particles rendering is done
  32441. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32442. */
  32443. onAfterParticlesRenderingObservable: Observable<Scene>;
  32444. /**
  32445. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32446. */
  32447. onDataLoadedObservable: Observable<Scene>;
  32448. /**
  32449. * An event triggered when a camera is created
  32450. */
  32451. onNewCameraAddedObservable: Observable<Camera>;
  32452. /**
  32453. * An event triggered when a camera is removed
  32454. */
  32455. onCameraRemovedObservable: Observable<Camera>;
  32456. /**
  32457. * An event triggered when a light is created
  32458. */
  32459. onNewLightAddedObservable: Observable<Light>;
  32460. /**
  32461. * An event triggered when a light is removed
  32462. */
  32463. onLightRemovedObservable: Observable<Light>;
  32464. /**
  32465. * An event triggered when a geometry is created
  32466. */
  32467. onNewGeometryAddedObservable: Observable<Geometry>;
  32468. /**
  32469. * An event triggered when a geometry is removed
  32470. */
  32471. onGeometryRemovedObservable: Observable<Geometry>;
  32472. /**
  32473. * An event triggered when a transform node is created
  32474. */
  32475. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32476. /**
  32477. * An event triggered when a transform node is removed
  32478. */
  32479. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32480. /**
  32481. * An event triggered when a mesh is created
  32482. */
  32483. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32484. /**
  32485. * An event triggered when a mesh is removed
  32486. */
  32487. onMeshRemovedObservable: Observable<AbstractMesh>;
  32488. /**
  32489. * An event triggered when a skeleton is created
  32490. */
  32491. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32492. /**
  32493. * An event triggered when a skeleton is removed
  32494. */
  32495. onSkeletonRemovedObservable: Observable<Skeleton>;
  32496. /**
  32497. * An event triggered when a material is created
  32498. */
  32499. onNewMaterialAddedObservable: Observable<Material>;
  32500. /**
  32501. * An event triggered when a material is removed
  32502. */
  32503. onMaterialRemovedObservable: Observable<Material>;
  32504. /**
  32505. * An event triggered when a texture is created
  32506. */
  32507. onNewTextureAddedObservable: Observable<BaseTexture>;
  32508. /**
  32509. * An event triggered when a texture is removed
  32510. */
  32511. onTextureRemovedObservable: Observable<BaseTexture>;
  32512. /**
  32513. * An event triggered when render targets are about to be rendered
  32514. * Can happen multiple times per frame.
  32515. */
  32516. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32517. /**
  32518. * An event triggered when render targets were rendered.
  32519. * Can happen multiple times per frame.
  32520. */
  32521. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32522. /**
  32523. * An event triggered before calculating deterministic simulation step
  32524. */
  32525. onBeforeStepObservable: Observable<Scene>;
  32526. /**
  32527. * An event triggered after calculating deterministic simulation step
  32528. */
  32529. onAfterStepObservable: Observable<Scene>;
  32530. /**
  32531. * An event triggered when the activeCamera property is updated
  32532. */
  32533. onActiveCameraChanged: Observable<Scene>;
  32534. /**
  32535. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32536. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32537. * 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)
  32538. */
  32539. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32540. /**
  32541. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32542. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32543. * 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)
  32544. */
  32545. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32546. /**
  32547. * This Observable will when a mesh has been imported into the scene.
  32548. */
  32549. onMeshImportedObservable: Observable<AbstractMesh>;
  32550. /**
  32551. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32552. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32553. */
  32554. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32555. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32556. /**
  32557. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32558. */
  32559. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32560. /**
  32561. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32562. */
  32563. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32564. /**
  32565. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32566. */
  32567. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32568. /** Callback called when a pointer move is detected */
  32569. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32570. /** Callback called when a pointer down is detected */
  32571. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32572. /** Callback called when a pointer up is detected */
  32573. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32574. /** Callback called when a pointer pick is detected */
  32575. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32576. /**
  32577. * 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).
  32578. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32579. */
  32580. onPrePointerObservable: Observable<PointerInfoPre>;
  32581. /**
  32582. * Observable event triggered each time an input event is received from the rendering canvas
  32583. */
  32584. onPointerObservable: Observable<PointerInfo>;
  32585. /**
  32586. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32587. */
  32588. readonly unTranslatedPointer: Vector2;
  32589. /**
  32590. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32591. */
  32592. static DragMovementThreshold: number;
  32593. /**
  32594. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32595. */
  32596. static LongPressDelay: number;
  32597. /**
  32598. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32599. */
  32600. static DoubleClickDelay: number;
  32601. /** If you need to check double click without raising a single click at first click, enable this flag */
  32602. static ExclusiveDoubleClickMode: boolean;
  32603. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32604. /**
  32605. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32606. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32607. */
  32608. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32609. /**
  32610. * Observable event triggered each time an keyboard event is received from the hosting window
  32611. */
  32612. onKeyboardObservable: Observable<KeyboardInfo>;
  32613. private _useRightHandedSystem;
  32614. /**
  32615. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32616. */
  32617. useRightHandedSystem: boolean;
  32618. private _timeAccumulator;
  32619. private _currentStepId;
  32620. private _currentInternalStep;
  32621. /**
  32622. * Sets the step Id used by deterministic lock step
  32623. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32624. * @param newStepId defines the step Id
  32625. */
  32626. setStepId(newStepId: number): void;
  32627. /**
  32628. * Gets the step Id used by deterministic lock step
  32629. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32630. * @returns the step Id
  32631. */
  32632. getStepId(): number;
  32633. /**
  32634. * Gets the internal step used by deterministic lock step
  32635. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32636. * @returns the internal step
  32637. */
  32638. getInternalStep(): number;
  32639. private _fogEnabled;
  32640. /**
  32641. * Gets or sets a boolean indicating if fog is enabled on this scene
  32642. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32643. * (Default is true)
  32644. */
  32645. fogEnabled: boolean;
  32646. private _fogMode;
  32647. /**
  32648. * Gets or sets the fog mode to use
  32649. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32650. * | mode | value |
  32651. * | --- | --- |
  32652. * | FOGMODE_NONE | 0 |
  32653. * | FOGMODE_EXP | 1 |
  32654. * | FOGMODE_EXP2 | 2 |
  32655. * | FOGMODE_LINEAR | 3 |
  32656. */
  32657. fogMode: number;
  32658. /**
  32659. * Gets or sets the fog color to use
  32660. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32661. * (Default is Color3(0.2, 0.2, 0.3))
  32662. */
  32663. fogColor: Color3;
  32664. /**
  32665. * Gets or sets the fog density to use
  32666. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32667. * (Default is 0.1)
  32668. */
  32669. fogDensity: number;
  32670. /**
  32671. * Gets or sets the fog start distance to use
  32672. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32673. * (Default is 0)
  32674. */
  32675. fogStart: number;
  32676. /**
  32677. * Gets or sets the fog end distance to use
  32678. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32679. * (Default is 1000)
  32680. */
  32681. fogEnd: number;
  32682. private _shadowsEnabled;
  32683. /**
  32684. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32685. */
  32686. shadowsEnabled: boolean;
  32687. private _lightsEnabled;
  32688. /**
  32689. * Gets or sets a boolean indicating if lights are enabled on this scene
  32690. */
  32691. lightsEnabled: boolean;
  32692. /** All of the active cameras added to this scene. */
  32693. activeCameras: Camera[];
  32694. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32695. /** Gets or sets the current active camera */
  32696. activeCamera: Nullable<Camera>;
  32697. private _defaultMaterial;
  32698. /** The default material used on meshes when no material is affected */
  32699. /** The default material used on meshes when no material is affected */
  32700. defaultMaterial: Material;
  32701. private _texturesEnabled;
  32702. /**
  32703. * Gets or sets a boolean indicating if textures are enabled on this scene
  32704. */
  32705. texturesEnabled: boolean;
  32706. /**
  32707. * Gets or sets a boolean indicating if particles are enabled on this scene
  32708. */
  32709. particlesEnabled: boolean;
  32710. /**
  32711. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32712. */
  32713. spritesEnabled: boolean;
  32714. private _skeletonsEnabled;
  32715. /**
  32716. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32717. */
  32718. skeletonsEnabled: boolean;
  32719. /**
  32720. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32721. */
  32722. lensFlaresEnabled: boolean;
  32723. /**
  32724. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32725. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32726. */
  32727. collisionsEnabled: boolean;
  32728. private _collisionCoordinator;
  32729. /** @hidden */
  32730. readonly collisionCoordinator: ICollisionCoordinator;
  32731. /**
  32732. * Defines the gravity applied to this scene (used only for collisions)
  32733. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32734. */
  32735. gravity: Vector3;
  32736. /**
  32737. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32738. */
  32739. postProcessesEnabled: boolean;
  32740. /**
  32741. * The list of postprocesses added to the scene
  32742. */
  32743. postProcesses: PostProcess[];
  32744. /**
  32745. * Gets the current postprocess manager
  32746. */
  32747. postProcessManager: PostProcessManager;
  32748. /**
  32749. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32750. */
  32751. renderTargetsEnabled: boolean;
  32752. /**
  32753. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32754. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32755. */
  32756. dumpNextRenderTargets: boolean;
  32757. /**
  32758. * The list of user defined render targets added to the scene
  32759. */
  32760. customRenderTargets: RenderTargetTexture[];
  32761. /**
  32762. * Defines if texture loading must be delayed
  32763. * If true, textures will only be loaded when they need to be rendered
  32764. */
  32765. useDelayedTextureLoading: boolean;
  32766. /**
  32767. * Gets the list of meshes imported to the scene through SceneLoader
  32768. */
  32769. importedMeshesFiles: String[];
  32770. /**
  32771. * Gets or sets a boolean indicating if probes are enabled on this scene
  32772. */
  32773. probesEnabled: boolean;
  32774. /**
  32775. * Gets or sets the current offline provider to use to store scene data
  32776. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32777. */
  32778. offlineProvider: IOfflineProvider;
  32779. /**
  32780. * Gets or sets the action manager associated with the scene
  32781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32782. */
  32783. actionManager: AbstractActionManager;
  32784. private _meshesForIntersections;
  32785. /**
  32786. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32787. */
  32788. proceduralTexturesEnabled: boolean;
  32789. private _engine;
  32790. private _totalVertices;
  32791. /** @hidden */ private _activeIndices: PerfCounter;
  32792. /** @hidden */ private _activeParticles: PerfCounter;
  32793. /** @hidden */ private _activeBones: PerfCounter;
  32794. private _animationRatio;
  32795. /** @hidden */ private _animationTimeLast: number;
  32796. /** @hidden */ private _animationTime: number;
  32797. /**
  32798. * Gets or sets a general scale for animation speed
  32799. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32800. */
  32801. animationTimeScale: number;
  32802. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32803. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32804. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32805. private _renderId;
  32806. private _frameId;
  32807. private _executeWhenReadyTimeoutId;
  32808. private _intermediateRendering;
  32809. private _viewUpdateFlag;
  32810. private _projectionUpdateFlag;
  32811. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32812. private _activeRequests;
  32813. /** @hidden */ private _pendingData: any[];
  32814. private _isDisposed;
  32815. /**
  32816. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32817. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32818. */
  32819. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32820. private _activeMeshes;
  32821. private _processedMaterials;
  32822. private _renderTargets;
  32823. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  32824. private _activeSkeletons;
  32825. private _softwareSkinnedMeshes;
  32826. private _renderingManager;
  32827. /** @hidden */ private _activeAnimatables: Animatable[];
  32828. private _transformMatrix;
  32829. private _sceneUbo;
  32830. /** @hidden */ private _viewMatrix: Matrix;
  32831. private _projectionMatrix;
  32832. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  32833. /** @hidden */ private _frustumPlanes: Plane[];
  32834. /**
  32835. * Gets the list of frustum planes (built from the active camera)
  32836. */
  32837. readonly frustumPlanes: Plane[];
  32838. /**
  32839. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32840. * This is useful if there are more lights that the maximum simulteanous authorized
  32841. */
  32842. requireLightSorting: boolean;
  32843. /** @hidden */
  32844. readonly useMaterialMeshMap: boolean;
  32845. /** @hidden */
  32846. readonly useClonedMeshhMap: boolean;
  32847. private _externalData;
  32848. private _uid;
  32849. /**
  32850. * @hidden
  32851. * Backing store of defined scene components.
  32852. */ private _components: ISceneComponent[];
  32853. /**
  32854. * @hidden
  32855. * Backing store of defined scene components.
  32856. */ private _serializableComponents: ISceneSerializableComponent[];
  32857. /**
  32858. * List of components to register on the next registration step.
  32859. */
  32860. private _transientComponents;
  32861. /**
  32862. * Registers the transient components if needed.
  32863. */
  32864. private _registerTransientComponents;
  32865. /**
  32866. * @hidden
  32867. * Add a component to the scene.
  32868. * Note that the ccomponent could be registered on th next frame if this is called after
  32869. * the register component stage.
  32870. * @param component Defines the component to add to the scene
  32871. */ private _addComponent(component: ISceneComponent): void;
  32872. /**
  32873. * @hidden
  32874. * Gets a component from the scene.
  32875. * @param name defines the name of the component to retrieve
  32876. * @returns the component or null if not present
  32877. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32878. /**
  32879. * @hidden
  32880. * Defines the actions happening before camera updates.
  32881. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32882. /**
  32883. * @hidden
  32884. * Defines the actions happening before clear the canvas.
  32885. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32886. /**
  32887. * @hidden
  32888. * Defines the actions when collecting render targets for the frame.
  32889. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32890. /**
  32891. * @hidden
  32892. * Defines the actions happening for one camera in the frame.
  32893. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32894. /**
  32895. * @hidden
  32896. * Defines the actions happening during the per mesh ready checks.
  32897. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32898. /**
  32899. * @hidden
  32900. * Defines the actions happening before evaluate active mesh checks.
  32901. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32902. /**
  32903. * @hidden
  32904. * Defines the actions happening during the evaluate sub mesh checks.
  32905. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32906. /**
  32907. * @hidden
  32908. * Defines the actions happening during the active mesh stage.
  32909. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32910. /**
  32911. * @hidden
  32912. * Defines the actions happening during the per camera render target step.
  32913. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32914. /**
  32915. * @hidden
  32916. * Defines the actions happening just before the active camera is drawing.
  32917. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32918. /**
  32919. * @hidden
  32920. * Defines the actions happening just before a render target is drawing.
  32921. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32922. /**
  32923. * @hidden
  32924. * Defines the actions happening just before a rendering group is drawing.
  32925. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32926. /**
  32927. * @hidden
  32928. * Defines the actions happening just before a mesh is drawing.
  32929. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32930. /**
  32931. * @hidden
  32932. * Defines the actions happening just after a mesh has been drawn.
  32933. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32934. /**
  32935. * @hidden
  32936. * Defines the actions happening just after a rendering group has been drawn.
  32937. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32938. /**
  32939. * @hidden
  32940. * Defines the actions happening just after the active camera has been drawn.
  32941. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32942. /**
  32943. * @hidden
  32944. * Defines the actions happening just after a render target has been drawn.
  32945. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32946. /**
  32947. * @hidden
  32948. * Defines the actions happening just after rendering all cameras and computing intersections.
  32949. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32950. /**
  32951. * @hidden
  32952. * Defines the actions happening when a pointer move event happens.
  32953. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32954. /**
  32955. * @hidden
  32956. * Defines the actions happening when a pointer down event happens.
  32957. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32958. /**
  32959. * @hidden
  32960. * Defines the actions happening when a pointer up event happens.
  32961. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32962. /**
  32963. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32964. */
  32965. private geometriesByUniqueId;
  32966. /**
  32967. * Creates a new Scene
  32968. * @param engine defines the engine to use to render this scene
  32969. * @param options defines the scene options
  32970. */
  32971. constructor(engine: Engine, options?: SceneOptions);
  32972. /**
  32973. * Gets a string idenfifying the name of the class
  32974. * @returns "Scene" string
  32975. */
  32976. getClassName(): string;
  32977. private _defaultMeshCandidates;
  32978. /**
  32979. * @hidden
  32980. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32981. private _defaultSubMeshCandidates;
  32982. /**
  32983. * @hidden
  32984. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32985. /**
  32986. * Sets the default candidate providers for the scene.
  32987. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32988. * and getCollidingSubMeshCandidates to their default function
  32989. */
  32990. setDefaultCandidateProviders(): void;
  32991. /**
  32992. * Gets the mesh that is currently under the pointer
  32993. */
  32994. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32995. /**
  32996. * Gets or sets the current on-screen X position of the pointer
  32997. */
  32998. pointerX: number;
  32999. /**
  33000. * Gets or sets the current on-screen Y position of the pointer
  33001. */
  33002. pointerY: number;
  33003. /**
  33004. * Gets the cached material (ie. the latest rendered one)
  33005. * @returns the cached material
  33006. */
  33007. getCachedMaterial(): Nullable<Material>;
  33008. /**
  33009. * Gets the cached effect (ie. the latest rendered one)
  33010. * @returns the cached effect
  33011. */
  33012. getCachedEffect(): Nullable<Effect>;
  33013. /**
  33014. * Gets the cached visibility state (ie. the latest rendered one)
  33015. * @returns the cached visibility state
  33016. */
  33017. getCachedVisibility(): Nullable<number>;
  33018. /**
  33019. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33020. * @param material defines the current material
  33021. * @param effect defines the current effect
  33022. * @param visibility defines the current visibility state
  33023. * @returns true if one parameter is not cached
  33024. */
  33025. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33026. /**
  33027. * Gets the engine associated with the scene
  33028. * @returns an Engine
  33029. */
  33030. getEngine(): Engine;
  33031. /**
  33032. * Gets the total number of vertices rendered per frame
  33033. * @returns the total number of vertices rendered per frame
  33034. */
  33035. getTotalVertices(): number;
  33036. /**
  33037. * Gets the performance counter for total vertices
  33038. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33039. */
  33040. readonly totalVerticesPerfCounter: PerfCounter;
  33041. /**
  33042. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33043. * @returns the total number of active indices rendered per frame
  33044. */
  33045. getActiveIndices(): number;
  33046. /**
  33047. * Gets the performance counter for active indices
  33048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33049. */
  33050. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33051. /**
  33052. * Gets the total number of active particles rendered per frame
  33053. * @returns the total number of active particles rendered per frame
  33054. */
  33055. getActiveParticles(): number;
  33056. /**
  33057. * Gets the performance counter for active particles
  33058. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33059. */
  33060. readonly activeParticlesPerfCounter: PerfCounter;
  33061. /**
  33062. * Gets the total number of active bones rendered per frame
  33063. * @returns the total number of active bones rendered per frame
  33064. */
  33065. getActiveBones(): number;
  33066. /**
  33067. * Gets the performance counter for active bones
  33068. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33069. */
  33070. readonly activeBonesPerfCounter: PerfCounter;
  33071. /**
  33072. * Gets the array of active meshes
  33073. * @returns an array of AbstractMesh
  33074. */
  33075. getActiveMeshes(): SmartArray<AbstractMesh>;
  33076. /**
  33077. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33078. * @returns a number
  33079. */
  33080. getAnimationRatio(): number;
  33081. /**
  33082. * Gets an unique Id for the current render phase
  33083. * @returns a number
  33084. */
  33085. getRenderId(): number;
  33086. /**
  33087. * Gets an unique Id for the current frame
  33088. * @returns a number
  33089. */
  33090. getFrameId(): number;
  33091. /** Call this function if you want to manually increment the render Id*/
  33092. incrementRenderId(): void;
  33093. private _createUbo;
  33094. /**
  33095. * Use this method to simulate a pointer move on a mesh
  33096. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33097. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33098. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33099. * @returns the current scene
  33100. */
  33101. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33102. /**
  33103. * Use this method to simulate a pointer down on a mesh
  33104. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33105. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33106. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33107. * @returns the current scene
  33108. */
  33109. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33110. /**
  33111. * Use this method to simulate a pointer up on a mesh
  33112. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33113. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33114. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33115. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33116. * @returns the current scene
  33117. */
  33118. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33119. /**
  33120. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33121. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33122. * @returns true if the pointer was captured
  33123. */
  33124. isPointerCaptured(pointerId?: number): boolean;
  33125. /**
  33126. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33127. * @param attachUp defines if you want to attach events to pointerup
  33128. * @param attachDown defines if you want to attach events to pointerdown
  33129. * @param attachMove defines if you want to attach events to pointermove
  33130. */
  33131. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33132. /** Detaches all event handlers*/
  33133. detachControl(): void;
  33134. /**
  33135. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33136. * Delay loaded resources are not taking in account
  33137. * @return true if all required resources are ready
  33138. */
  33139. isReady(): boolean;
  33140. /** Resets all cached information relative to material (including effect and visibility) */
  33141. resetCachedMaterial(): void;
  33142. /**
  33143. * Registers a function to be called before every frame render
  33144. * @param func defines the function to register
  33145. */
  33146. registerBeforeRender(func: () => void): void;
  33147. /**
  33148. * Unregisters a function called before every frame render
  33149. * @param func defines the function to unregister
  33150. */
  33151. unregisterBeforeRender(func: () => void): void;
  33152. /**
  33153. * Registers a function to be called after every frame render
  33154. * @param func defines the function to register
  33155. */
  33156. registerAfterRender(func: () => void): void;
  33157. /**
  33158. * Unregisters a function called after every frame render
  33159. * @param func defines the function to unregister
  33160. */
  33161. unregisterAfterRender(func: () => void): void;
  33162. private _executeOnceBeforeRender;
  33163. /**
  33164. * The provided function will run before render once and will be disposed afterwards.
  33165. * A timeout delay can be provided so that the function will be executed in N ms.
  33166. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33167. * @param func The function to be executed.
  33168. * @param timeout optional delay in ms
  33169. */
  33170. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33171. /** @hidden */ private _addPendingData(data: any): void;
  33172. /** @hidden */ private _removePendingData(data: any): void;
  33173. /**
  33174. * Returns the number of items waiting to be loaded
  33175. * @returns the number of items waiting to be loaded
  33176. */
  33177. getWaitingItemsCount(): number;
  33178. /**
  33179. * Returns a boolean indicating if the scene is still loading data
  33180. */
  33181. readonly isLoading: boolean;
  33182. /**
  33183. * Registers a function to be executed when the scene is ready
  33184. * @param {Function} func - the function to be executed
  33185. */
  33186. executeWhenReady(func: () => void): void;
  33187. /**
  33188. * Returns a promise that resolves when the scene is ready
  33189. * @returns A promise that resolves when the scene is ready
  33190. */
  33191. whenReadyAsync(): Promise<void>;
  33192. /** @hidden */ private _checkIsReady(): void;
  33193. /**
  33194. * Gets all animatable attached to the scene
  33195. */
  33196. readonly animatables: Animatable[];
  33197. /**
  33198. * Resets the last animation time frame.
  33199. * Useful to override when animations start running when loading a scene for the first time.
  33200. */
  33201. resetLastAnimationTimeFrame(): void;
  33202. /**
  33203. * Gets the current view matrix
  33204. * @returns a Matrix
  33205. */
  33206. getViewMatrix(): Matrix;
  33207. /**
  33208. * Gets the current projection matrix
  33209. * @returns a Matrix
  33210. */
  33211. getProjectionMatrix(): Matrix;
  33212. /**
  33213. * Gets the current transform matrix
  33214. * @returns a Matrix made of View * Projection
  33215. */
  33216. getTransformMatrix(): Matrix;
  33217. /**
  33218. * Sets the current transform matrix
  33219. * @param viewL defines the View matrix to use
  33220. * @param projectionL defines the Projection matrix to use
  33221. * @param viewR defines the right View matrix to use (if provided)
  33222. * @param projectionR defines the right Projection matrix to use (if provided)
  33223. */
  33224. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33225. /**
  33226. * Gets the uniform buffer used to store scene data
  33227. * @returns a UniformBuffer
  33228. */
  33229. getSceneUniformBuffer(): UniformBuffer;
  33230. /**
  33231. * Gets an unique (relatively to the current scene) Id
  33232. * @returns an unique number for the scene
  33233. */
  33234. getUniqueId(): number;
  33235. /**
  33236. * Add a mesh to the list of scene's meshes
  33237. * @param newMesh defines the mesh to add
  33238. * @param recursive if all child meshes should also be added to the scene
  33239. */
  33240. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33241. /**
  33242. * Remove a mesh for the list of scene's meshes
  33243. * @param toRemove defines the mesh to remove
  33244. * @param recursive if all child meshes should also be removed from the scene
  33245. * @returns the index where the mesh was in the mesh list
  33246. */
  33247. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33248. /**
  33249. * Add a transform node to the list of scene's transform nodes
  33250. * @param newTransformNode defines the transform node to add
  33251. */
  33252. addTransformNode(newTransformNode: TransformNode): void;
  33253. /**
  33254. * Remove a transform node for the list of scene's transform nodes
  33255. * @param toRemove defines the transform node to remove
  33256. * @returns the index where the transform node was in the transform node list
  33257. */
  33258. removeTransformNode(toRemove: TransformNode): number;
  33259. /**
  33260. * Remove a skeleton for the list of scene's skeletons
  33261. * @param toRemove defines the skeleton to remove
  33262. * @returns the index where the skeleton was in the skeleton list
  33263. */
  33264. removeSkeleton(toRemove: Skeleton): number;
  33265. /**
  33266. * Remove a morph target for the list of scene's morph targets
  33267. * @param toRemove defines the morph target to remove
  33268. * @returns the index where the morph target was in the morph target list
  33269. */
  33270. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33271. /**
  33272. * Remove a light for the list of scene's lights
  33273. * @param toRemove defines the light to remove
  33274. * @returns the index where the light was in the light list
  33275. */
  33276. removeLight(toRemove: Light): number;
  33277. /**
  33278. * Remove a camera for the list of scene's cameras
  33279. * @param toRemove defines the camera to remove
  33280. * @returns the index where the camera was in the camera list
  33281. */
  33282. removeCamera(toRemove: Camera): number;
  33283. /**
  33284. * Remove a particle system for the list of scene's particle systems
  33285. * @param toRemove defines the particle system to remove
  33286. * @returns the index where the particle system was in the particle system list
  33287. */
  33288. removeParticleSystem(toRemove: IParticleSystem): number;
  33289. /**
  33290. * Remove a animation for the list of scene's animations
  33291. * @param toRemove defines the animation to remove
  33292. * @returns the index where the animation was in the animation list
  33293. */
  33294. removeAnimation(toRemove: Animation): number;
  33295. /**
  33296. * Will stop the animation of the given target
  33297. * @param target - the target
  33298. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33299. * @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)
  33300. */
  33301. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33302. /**
  33303. * Removes the given animation group from this scene.
  33304. * @param toRemove The animation group to remove
  33305. * @returns The index of the removed animation group
  33306. */
  33307. removeAnimationGroup(toRemove: AnimationGroup): number;
  33308. /**
  33309. * Removes the given multi-material from this scene.
  33310. * @param toRemove The multi-material to remove
  33311. * @returns The index of the removed multi-material
  33312. */
  33313. removeMultiMaterial(toRemove: MultiMaterial): number;
  33314. /**
  33315. * Removes the given material from this scene.
  33316. * @param toRemove The material to remove
  33317. * @returns The index of the removed material
  33318. */
  33319. removeMaterial(toRemove: Material): number;
  33320. /**
  33321. * Removes the given action manager from this scene.
  33322. * @param toRemove The action manager to remove
  33323. * @returns The index of the removed action manager
  33324. */
  33325. removeActionManager(toRemove: AbstractActionManager): number;
  33326. /**
  33327. * Removes the given texture from this scene.
  33328. * @param toRemove The texture to remove
  33329. * @returns The index of the removed texture
  33330. */
  33331. removeTexture(toRemove: BaseTexture): number;
  33332. /**
  33333. * Adds the given light to this scene
  33334. * @param newLight The light to add
  33335. */
  33336. addLight(newLight: Light): void;
  33337. /**
  33338. * Sorts the list list based on light priorities
  33339. */
  33340. sortLightsByPriority(): void;
  33341. /**
  33342. * Adds the given camera to this scene
  33343. * @param newCamera The camera to add
  33344. */
  33345. addCamera(newCamera: Camera): void;
  33346. /**
  33347. * Adds the given skeleton to this scene
  33348. * @param newSkeleton The skeleton to add
  33349. */
  33350. addSkeleton(newSkeleton: Skeleton): void;
  33351. /**
  33352. * Adds the given particle system to this scene
  33353. * @param newParticleSystem The particle system to add
  33354. */
  33355. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33356. /**
  33357. * Adds the given animation to this scene
  33358. * @param newAnimation The animation to add
  33359. */
  33360. addAnimation(newAnimation: Animation): void;
  33361. /**
  33362. * Adds the given animation group to this scene.
  33363. * @param newAnimationGroup The animation group to add
  33364. */
  33365. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33366. /**
  33367. * Adds the given multi-material to this scene
  33368. * @param newMultiMaterial The multi-material to add
  33369. */
  33370. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33371. /**
  33372. * Adds the given material to this scene
  33373. * @param newMaterial The material to add
  33374. */
  33375. addMaterial(newMaterial: Material): void;
  33376. /**
  33377. * Adds the given morph target to this scene
  33378. * @param newMorphTargetManager The morph target to add
  33379. */
  33380. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33381. /**
  33382. * Adds the given geometry to this scene
  33383. * @param newGeometry The geometry to add
  33384. */
  33385. addGeometry(newGeometry: Geometry): void;
  33386. /**
  33387. * Adds the given action manager to this scene
  33388. * @param newActionManager The action manager to add
  33389. */
  33390. addActionManager(newActionManager: AbstractActionManager): void;
  33391. /**
  33392. * Adds the given texture to this scene.
  33393. * @param newTexture The texture to add
  33394. */
  33395. addTexture(newTexture: BaseTexture): void;
  33396. /**
  33397. * Switch active camera
  33398. * @param newCamera defines the new active camera
  33399. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33400. */
  33401. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33402. /**
  33403. * sets the active camera of the scene using its ID
  33404. * @param id defines the camera's ID
  33405. * @return the new active camera or null if none found.
  33406. */
  33407. setActiveCameraByID(id: string): Nullable<Camera>;
  33408. /**
  33409. * sets the active camera of the scene using its name
  33410. * @param name defines the camera's name
  33411. * @returns the new active camera or null if none found.
  33412. */
  33413. setActiveCameraByName(name: string): Nullable<Camera>;
  33414. /**
  33415. * get an animation group using its name
  33416. * @param name defines the material's name
  33417. * @return the animation group or null if none found.
  33418. */
  33419. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33420. /**
  33421. * Get a material using its unique id
  33422. * @param uniqueId defines the material's unique id
  33423. * @return the material or null if none found.
  33424. */
  33425. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33426. /**
  33427. * get a material using its id
  33428. * @param id defines the material's ID
  33429. * @return the material or null if none found.
  33430. */
  33431. getMaterialByID(id: string): Nullable<Material>;
  33432. /**
  33433. * Gets a the last added material using a given id
  33434. * @param id defines the material's ID
  33435. * @return the last material with the given id or null if none found.
  33436. */
  33437. getLastMaterialByID(id: string): Nullable<Material>;
  33438. /**
  33439. * Gets a material using its name
  33440. * @param name defines the material's name
  33441. * @return the material or null if none found.
  33442. */
  33443. getMaterialByName(name: string): Nullable<Material>;
  33444. /**
  33445. * Get a texture using its unique id
  33446. * @param uniqueId defines the texture's unique id
  33447. * @return the texture or null if none found.
  33448. */
  33449. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33450. /**
  33451. * Gets a camera using its id
  33452. * @param id defines the id to look for
  33453. * @returns the camera or null if not found
  33454. */
  33455. getCameraByID(id: string): Nullable<Camera>;
  33456. /**
  33457. * Gets a camera using its unique id
  33458. * @param uniqueId defines the unique id to look for
  33459. * @returns the camera or null if not found
  33460. */
  33461. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33462. /**
  33463. * Gets a camera using its name
  33464. * @param name defines the camera's name
  33465. * @return the camera or null if none found.
  33466. */
  33467. getCameraByName(name: string): Nullable<Camera>;
  33468. /**
  33469. * Gets a bone using its id
  33470. * @param id defines the bone's id
  33471. * @return the bone or null if not found
  33472. */
  33473. getBoneByID(id: string): Nullable<Bone>;
  33474. /**
  33475. * Gets a bone using its id
  33476. * @param name defines the bone's name
  33477. * @return the bone or null if not found
  33478. */
  33479. getBoneByName(name: string): Nullable<Bone>;
  33480. /**
  33481. * Gets a light node using its name
  33482. * @param name defines the the light's name
  33483. * @return the light or null if none found.
  33484. */
  33485. getLightByName(name: string): Nullable<Light>;
  33486. /**
  33487. * Gets a light node using its id
  33488. * @param id defines the light's id
  33489. * @return the light or null if none found.
  33490. */
  33491. getLightByID(id: string): Nullable<Light>;
  33492. /**
  33493. * Gets a light node using its scene-generated unique ID
  33494. * @param uniqueId defines the light's unique id
  33495. * @return the light or null if none found.
  33496. */
  33497. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33498. /**
  33499. * Gets a particle system by id
  33500. * @param id defines the particle system id
  33501. * @return the corresponding system or null if none found
  33502. */
  33503. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33504. /**
  33505. * Gets a geometry using its ID
  33506. * @param id defines the geometry's id
  33507. * @return the geometry or null if none found.
  33508. */
  33509. getGeometryByID(id: string): Nullable<Geometry>;
  33510. private _getGeometryByUniqueID;
  33511. /**
  33512. * Add a new geometry to this scene
  33513. * @param geometry defines the geometry to be added to the scene.
  33514. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33515. * @return a boolean defining if the geometry was added or not
  33516. */
  33517. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33518. /**
  33519. * Removes an existing geometry
  33520. * @param geometry defines the geometry to be removed from the scene
  33521. * @return a boolean defining if the geometry was removed or not
  33522. */
  33523. removeGeometry(geometry: Geometry): boolean;
  33524. /**
  33525. * Gets the list of geometries attached to the scene
  33526. * @returns an array of Geometry
  33527. */
  33528. getGeometries(): Geometry[];
  33529. /**
  33530. * Gets the first added mesh found of a given ID
  33531. * @param id defines the id to search for
  33532. * @return the mesh found or null if not found at all
  33533. */
  33534. getMeshByID(id: string): Nullable<AbstractMesh>;
  33535. /**
  33536. * Gets a list of meshes using their id
  33537. * @param id defines the id to search for
  33538. * @returns a list of meshes
  33539. */
  33540. getMeshesByID(id: string): Array<AbstractMesh>;
  33541. /**
  33542. * Gets the first added transform node found of a given ID
  33543. * @param id defines the id to search for
  33544. * @return the found transform node or null if not found at all.
  33545. */
  33546. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33547. /**
  33548. * Gets a transform node with its auto-generated unique id
  33549. * @param uniqueId efines the unique id to search for
  33550. * @return the found transform node or null if not found at all.
  33551. */
  33552. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33553. /**
  33554. * Gets a list of transform nodes using their id
  33555. * @param id defines the id to search for
  33556. * @returns a list of transform nodes
  33557. */
  33558. getTransformNodesByID(id: string): Array<TransformNode>;
  33559. /**
  33560. * Gets a mesh with its auto-generated unique id
  33561. * @param uniqueId defines the unique id to search for
  33562. * @return the found mesh or null if not found at all.
  33563. */
  33564. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33565. /**
  33566. * Gets a the last added mesh using a given id
  33567. * @param id defines the id to search for
  33568. * @return the found mesh or null if not found at all.
  33569. */
  33570. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33571. /**
  33572. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33573. * @param id defines the id to search for
  33574. * @return the found node or null if not found at all
  33575. */
  33576. getLastEntryByID(id: string): Nullable<Node>;
  33577. /**
  33578. * Gets a node (Mesh, Camera, Light) using a given id
  33579. * @param id defines the id to search for
  33580. * @return the found node or null if not found at all
  33581. */
  33582. getNodeByID(id: string): Nullable<Node>;
  33583. /**
  33584. * Gets a node (Mesh, Camera, Light) using a given name
  33585. * @param name defines the name to search for
  33586. * @return the found node or null if not found at all.
  33587. */
  33588. getNodeByName(name: string): Nullable<Node>;
  33589. /**
  33590. * Gets a mesh using a given name
  33591. * @param name defines the name to search for
  33592. * @return the found mesh or null if not found at all.
  33593. */
  33594. getMeshByName(name: string): Nullable<AbstractMesh>;
  33595. /**
  33596. * Gets a transform node using a given name
  33597. * @param name defines the name to search for
  33598. * @return the found transform node or null if not found at all.
  33599. */
  33600. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33601. /**
  33602. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33603. * @param id defines the id to search for
  33604. * @return the found skeleton or null if not found at all.
  33605. */
  33606. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33607. /**
  33608. * Gets a skeleton using a given auto generated unique id
  33609. * @param uniqueId defines the unique id to search for
  33610. * @return the found skeleton or null if not found at all.
  33611. */
  33612. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33613. /**
  33614. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33615. * @param id defines the id to search for
  33616. * @return the found skeleton or null if not found at all.
  33617. */
  33618. getSkeletonById(id: string): Nullable<Skeleton>;
  33619. /**
  33620. * Gets a skeleton using a given name
  33621. * @param name defines the name to search for
  33622. * @return the found skeleton or null if not found at all.
  33623. */
  33624. getSkeletonByName(name: string): Nullable<Skeleton>;
  33625. /**
  33626. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33627. * @param id defines the id to search for
  33628. * @return the found morph target manager or null if not found at all.
  33629. */
  33630. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33631. /**
  33632. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33633. * @param id defines the id to search for
  33634. * @return the found morph target or null if not found at all.
  33635. */
  33636. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33637. /**
  33638. * Gets a boolean indicating if the given mesh is active
  33639. * @param mesh defines the mesh to look for
  33640. * @returns true if the mesh is in the active list
  33641. */
  33642. isActiveMesh(mesh: AbstractMesh): boolean;
  33643. /**
  33644. * Return a unique id as a string which can serve as an identifier for the scene
  33645. */
  33646. readonly uid: string;
  33647. /**
  33648. * Add an externaly attached data from its key.
  33649. * This method call will fail and return false, if such key already exists.
  33650. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33651. * @param key the unique key that identifies the data
  33652. * @param data the data object to associate to the key for this Engine instance
  33653. * @return true if no such key were already present and the data was added successfully, false otherwise
  33654. */
  33655. addExternalData<T>(key: string, data: T): boolean;
  33656. /**
  33657. * Get an externaly attached data from its key
  33658. * @param key the unique key that identifies the data
  33659. * @return the associated data, if present (can be null), or undefined if not present
  33660. */
  33661. getExternalData<T>(key: string): Nullable<T>;
  33662. /**
  33663. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33664. * @param key the unique key that identifies the data
  33665. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33666. * @return the associated data, can be null if the factory returned null.
  33667. */
  33668. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33669. /**
  33670. * Remove an externaly attached data from the Engine instance
  33671. * @param key the unique key that identifies the data
  33672. * @return true if the data was successfully removed, false if it doesn't exist
  33673. */
  33674. removeExternalData(key: string): boolean;
  33675. private _evaluateSubMesh;
  33676. /**
  33677. * Clear the processed materials smart array preventing retention point in material dispose.
  33678. */
  33679. freeProcessedMaterials(): void;
  33680. private _preventFreeActiveMeshesAndRenderingGroups;
  33681. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33682. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33683. * when disposing several meshes in a row or a hierarchy of meshes.
  33684. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33685. */
  33686. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33687. /**
  33688. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33689. */
  33690. freeActiveMeshes(): void;
  33691. /**
  33692. * Clear the info related to rendering groups preventing retention points during dispose.
  33693. */
  33694. freeRenderingGroups(): void;
  33695. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33696. /**
  33697. * Lambda returning the list of potentially active meshes.
  33698. */
  33699. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33700. /**
  33701. * Lambda returning the list of potentially active sub meshes.
  33702. */
  33703. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33704. /**
  33705. * Lambda returning the list of potentially intersecting sub meshes.
  33706. */
  33707. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33708. /**
  33709. * Lambda returning the list of potentially colliding sub meshes.
  33710. */
  33711. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33712. private _activeMeshesFrozen;
  33713. /**
  33714. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33715. * @returns the current scene
  33716. */
  33717. freezeActiveMeshes(): Scene;
  33718. /**
  33719. * Use this function to restart evaluating active meshes on every frame
  33720. * @returns the current scene
  33721. */
  33722. unfreezeActiveMeshes(): Scene;
  33723. private _evaluateActiveMeshes;
  33724. private _activeMesh;
  33725. /**
  33726. * Update the transform matrix to update from the current active camera
  33727. * @param force defines a boolean used to force the update even if cache is up to date
  33728. */
  33729. updateTransformMatrix(force?: boolean): void;
  33730. private _bindFrameBuffer;
  33731. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33732. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33733. private _processSubCameras;
  33734. private _checkIntersections;
  33735. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33736. /**
  33737. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33738. */
  33739. getDeterministicFrameTime: () => number;
  33740. /** @hidden */ private _animate(): void;
  33741. /** Execute all animations (for a frame) */
  33742. animate(): void;
  33743. /**
  33744. * Render the scene
  33745. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33746. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33747. */
  33748. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33749. /**
  33750. * Freeze all materials
  33751. * A frozen material will not be updatable but should be faster to render
  33752. */
  33753. freezeMaterials(): void;
  33754. /**
  33755. * Unfreeze all materials
  33756. * A frozen material will not be updatable but should be faster to render
  33757. */
  33758. unfreezeMaterials(): void;
  33759. /**
  33760. * Releases all held ressources
  33761. */
  33762. dispose(): void;
  33763. /**
  33764. * Gets if the scene is already disposed
  33765. */
  33766. readonly isDisposed: boolean;
  33767. /**
  33768. * Call this function to reduce memory footprint of the scene.
  33769. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33770. */
  33771. clearCachedVertexData(): void;
  33772. /**
  33773. * This function will remove the local cached buffer data from texture.
  33774. * It will save memory but will prevent the texture from being rebuilt
  33775. */
  33776. cleanCachedTextureBuffer(): void;
  33777. /**
  33778. * Get the world extend vectors with an optional filter
  33779. *
  33780. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33781. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33782. */
  33783. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33784. min: Vector3;
  33785. max: Vector3;
  33786. };
  33787. /**
  33788. * Creates a ray that can be used to pick in the scene
  33789. * @param x defines the x coordinate of the origin (on-screen)
  33790. * @param y defines the y coordinate of the origin (on-screen)
  33791. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33792. * @param camera defines the camera to use for the picking
  33793. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33794. * @returns a Ray
  33795. */
  33796. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33797. /**
  33798. * Creates a ray that can be used to pick in the scene
  33799. * @param x defines the x coordinate of the origin (on-screen)
  33800. * @param y defines the y coordinate of the origin (on-screen)
  33801. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33802. * @param result defines the ray where to store the picking ray
  33803. * @param camera defines the camera to use for the picking
  33804. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33805. * @returns the current scene
  33806. */
  33807. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33808. /**
  33809. * Creates a ray that can be used to pick in the scene
  33810. * @param x defines the x coordinate of the origin (on-screen)
  33811. * @param y defines the y coordinate of the origin (on-screen)
  33812. * @param camera defines the camera to use for the picking
  33813. * @returns a Ray
  33814. */
  33815. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33816. /**
  33817. * Creates a ray that can be used to pick in the scene
  33818. * @param x defines the x coordinate of the origin (on-screen)
  33819. * @param y defines the y coordinate of the origin (on-screen)
  33820. * @param result defines the ray where to store the picking ray
  33821. * @param camera defines the camera to use for the picking
  33822. * @returns the current scene
  33823. */
  33824. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33825. /** Launch a ray to try to pick a mesh in the scene
  33826. * @param x position on screen
  33827. * @param y position on screen
  33828. * @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
  33829. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33830. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33831. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33832. * @returns a PickingInfo
  33833. */
  33834. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33835. /** Use the given ray to pick a mesh in the scene
  33836. * @param ray The ray to use to pick meshes
  33837. * @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
  33838. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33839. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33840. * @returns a PickingInfo
  33841. */
  33842. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33843. /**
  33844. * Launch a ray to try to pick a mesh in the scene
  33845. * @param x X position on screen
  33846. * @param y Y position on screen
  33847. * @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
  33848. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33849. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33850. * @returns an array of PickingInfo
  33851. */
  33852. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33853. /**
  33854. * Launch a ray to try to pick a mesh in the scene
  33855. * @param ray Ray to use
  33856. * @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
  33857. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33858. * @returns an array of PickingInfo
  33859. */
  33860. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33861. /**
  33862. * Force the value of meshUnderPointer
  33863. * @param mesh defines the mesh to use
  33864. */
  33865. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33866. /**
  33867. * Gets the mesh under the pointer
  33868. * @returns a Mesh or null if no mesh is under the pointer
  33869. */
  33870. getPointerOverMesh(): Nullable<AbstractMesh>;
  33871. /** @hidden */ private _rebuildGeometries(): void;
  33872. /** @hidden */ private _rebuildTextures(): void;
  33873. private _getByTags;
  33874. /**
  33875. * Get a list of meshes by tags
  33876. * @param tagsQuery defines the tags query to use
  33877. * @param forEach defines a predicate used to filter results
  33878. * @returns an array of Mesh
  33879. */
  33880. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33881. /**
  33882. * Get a list of cameras by tags
  33883. * @param tagsQuery defines the tags query to use
  33884. * @param forEach defines a predicate used to filter results
  33885. * @returns an array of Camera
  33886. */
  33887. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33888. /**
  33889. * Get a list of lights by tags
  33890. * @param tagsQuery defines the tags query to use
  33891. * @param forEach defines a predicate used to filter results
  33892. * @returns an array of Light
  33893. */
  33894. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33895. /**
  33896. * Get a list of materials by tags
  33897. * @param tagsQuery defines the tags query to use
  33898. * @param forEach defines a predicate used to filter results
  33899. * @returns an array of Material
  33900. */
  33901. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33902. /**
  33903. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33904. * This allowed control for front to back rendering or reversly depending of the special needs.
  33905. *
  33906. * @param renderingGroupId The rendering group id corresponding to its index
  33907. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33908. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33909. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33910. */
  33911. 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;
  33912. /**
  33913. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33914. *
  33915. * @param renderingGroupId The rendering group id corresponding to its index
  33916. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33917. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33918. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33919. */
  33920. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33921. /**
  33922. * Gets the current auto clear configuration for one rendering group of the rendering
  33923. * manager.
  33924. * @param index the rendering group index to get the information for
  33925. * @returns The auto clear setup for the requested rendering group
  33926. */
  33927. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33928. private _blockMaterialDirtyMechanism;
  33929. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33930. blockMaterialDirtyMechanism: boolean;
  33931. /**
  33932. * Will flag all materials as dirty to trigger new shader compilation
  33933. * @param flag defines the flag used to specify which material part must be marked as dirty
  33934. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33935. */
  33936. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33937. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33938. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33939. }
  33940. }
  33941. declare module BABYLON {
  33942. /**
  33943. * Set of assets to keep when moving a scene into an asset container.
  33944. */
  33945. export class KeepAssets extends AbstractScene {
  33946. }
  33947. /**
  33948. * Container with a set of assets that can be added or removed from a scene.
  33949. */
  33950. export class AssetContainer extends AbstractScene {
  33951. /**
  33952. * The scene the AssetContainer belongs to.
  33953. */
  33954. scene: Scene;
  33955. /**
  33956. * Instantiates an AssetContainer.
  33957. * @param scene The scene the AssetContainer belongs to.
  33958. */
  33959. constructor(scene: Scene);
  33960. /**
  33961. * Adds all the assets from the container to the scene.
  33962. */
  33963. addAllToScene(): void;
  33964. /**
  33965. * Removes all the assets in the container from the scene
  33966. */
  33967. removeAllFromScene(): void;
  33968. /**
  33969. * Disposes all the assets in the container
  33970. */
  33971. dispose(): void;
  33972. private _moveAssets;
  33973. /**
  33974. * Removes all the assets contained in the scene and adds them to the container.
  33975. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33976. */
  33977. moveAllFromScene(keepAssets?: KeepAssets): void;
  33978. /**
  33979. * 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.
  33980. * @returns the root mesh
  33981. */
  33982. createRootMesh(): Mesh;
  33983. }
  33984. }
  33985. declare module BABYLON {
  33986. /**
  33987. * Defines how the parser contract is defined.
  33988. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33989. */
  33990. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33991. /**
  33992. * Defines how the individual parser contract is defined.
  33993. * These parser can parse an individual asset
  33994. */
  33995. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33996. /**
  33997. * Base class of the scene acting as a container for the different elements composing a scene.
  33998. * This class is dynamically extended by the different components of the scene increasing
  33999. * flexibility and reducing coupling
  34000. */
  34001. export abstract class AbstractScene {
  34002. /**
  34003. * Stores the list of available parsers in the application.
  34004. */
  34005. private static _BabylonFileParsers;
  34006. /**
  34007. * Stores the list of available individual parsers in the application.
  34008. */
  34009. private static _IndividualBabylonFileParsers;
  34010. /**
  34011. * Adds a parser in the list of available ones
  34012. * @param name Defines the name of the parser
  34013. * @param parser Defines the parser to add
  34014. */
  34015. static AddParser(name: string, parser: BabylonFileParser): void;
  34016. /**
  34017. * Gets a general parser from the list of avaialble ones
  34018. * @param name Defines the name of the parser
  34019. * @returns the requested parser or null
  34020. */
  34021. static GetParser(name: string): Nullable<BabylonFileParser>;
  34022. /**
  34023. * Adds n individual parser in the list of available ones
  34024. * @param name Defines the name of the parser
  34025. * @param parser Defines the parser to add
  34026. */
  34027. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34028. /**
  34029. * Gets an individual parser from the list of avaialble ones
  34030. * @param name Defines the name of the parser
  34031. * @returns the requested parser or null
  34032. */
  34033. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34034. /**
  34035. * Parser json data and populate both a scene and its associated container object
  34036. * @param jsonData Defines the data to parse
  34037. * @param scene Defines the scene to parse the data for
  34038. * @param container Defines the container attached to the parsing sequence
  34039. * @param rootUrl Defines the root url of the data
  34040. */
  34041. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34042. /**
  34043. * Gets the list of root nodes (ie. nodes with no parent)
  34044. */
  34045. rootNodes: Node[];
  34046. /** All of the cameras added to this scene
  34047. * @see http://doc.babylonjs.com/babylon101/cameras
  34048. */
  34049. cameras: Camera[];
  34050. /**
  34051. * All of the lights added to this scene
  34052. * @see http://doc.babylonjs.com/babylon101/lights
  34053. */
  34054. lights: Light[];
  34055. /**
  34056. * All of the (abstract) meshes added to this scene
  34057. */
  34058. meshes: AbstractMesh[];
  34059. /**
  34060. * The list of skeletons added to the scene
  34061. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34062. */
  34063. skeletons: Skeleton[];
  34064. /**
  34065. * All of the particle systems added to this scene
  34066. * @see http://doc.babylonjs.com/babylon101/particles
  34067. */
  34068. particleSystems: IParticleSystem[];
  34069. /**
  34070. * Gets a list of Animations associated with the scene
  34071. */
  34072. animations: Animation[];
  34073. /**
  34074. * All of the animation groups added to this scene
  34075. * @see http://doc.babylonjs.com/how_to/group
  34076. */
  34077. animationGroups: AnimationGroup[];
  34078. /**
  34079. * All of the multi-materials added to this scene
  34080. * @see http://doc.babylonjs.com/how_to/multi_materials
  34081. */
  34082. multiMaterials: MultiMaterial[];
  34083. /**
  34084. * All of the materials added to this scene
  34085. * In the context of a Scene, it is not supposed to be modified manually.
  34086. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34087. * Note also that the order of the Material wihin the array is not significant and might change.
  34088. * @see http://doc.babylonjs.com/babylon101/materials
  34089. */
  34090. materials: Material[];
  34091. /**
  34092. * The list of morph target managers added to the scene
  34093. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34094. */
  34095. morphTargetManagers: MorphTargetManager[];
  34096. /**
  34097. * The list of geometries used in the scene.
  34098. */
  34099. geometries: Geometry[];
  34100. /**
  34101. * All of the tranform nodes added to this scene
  34102. * In the context of a Scene, it is not supposed to be modified manually.
  34103. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34104. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34105. * @see http://doc.babylonjs.com/how_to/transformnode
  34106. */
  34107. transformNodes: TransformNode[];
  34108. /**
  34109. * ActionManagers available on the scene.
  34110. */
  34111. actionManagers: AbstractActionManager[];
  34112. /**
  34113. * Textures to keep.
  34114. */
  34115. textures: BaseTexture[];
  34116. /**
  34117. * Environment texture for the scene
  34118. */
  34119. environmentTexture: Nullable<BaseTexture>;
  34120. }
  34121. }
  34122. declare module BABYLON {
  34123. /**
  34124. * Interface used to define options for Sound class
  34125. */
  34126. export interface ISoundOptions {
  34127. /**
  34128. * Does the sound autoplay once loaded.
  34129. */
  34130. autoplay?: boolean;
  34131. /**
  34132. * Does the sound loop after it finishes playing once.
  34133. */
  34134. loop?: boolean;
  34135. /**
  34136. * Sound's volume
  34137. */
  34138. volume?: number;
  34139. /**
  34140. * Is it a spatial sound?
  34141. */
  34142. spatialSound?: boolean;
  34143. /**
  34144. * Maximum distance to hear that sound
  34145. */
  34146. maxDistance?: number;
  34147. /**
  34148. * Uses user defined attenuation function
  34149. */
  34150. useCustomAttenuation?: boolean;
  34151. /**
  34152. * Define the roll off factor of spatial sounds.
  34153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34154. */
  34155. rolloffFactor?: number;
  34156. /**
  34157. * Define the reference distance the sound should be heard perfectly.
  34158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34159. */
  34160. refDistance?: number;
  34161. /**
  34162. * Define the distance attenuation model the sound will follow.
  34163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34164. */
  34165. distanceModel?: string;
  34166. /**
  34167. * Defines the playback speed (1 by default)
  34168. */
  34169. playbackRate?: number;
  34170. /**
  34171. * Defines if the sound is from a streaming source
  34172. */
  34173. streaming?: boolean;
  34174. /**
  34175. * Defines an optional length (in seconds) inside the sound file
  34176. */
  34177. length?: number;
  34178. /**
  34179. * Defines an optional offset (in seconds) inside the sound file
  34180. */
  34181. offset?: number;
  34182. /**
  34183. * If true, URLs will not be required to state the audio file codec to use.
  34184. */
  34185. skipCodecCheck?: boolean;
  34186. }
  34187. /**
  34188. * Defines a sound that can be played in the application.
  34189. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34191. */
  34192. export class Sound {
  34193. /**
  34194. * The name of the sound in the scene.
  34195. */
  34196. name: string;
  34197. /**
  34198. * Does the sound autoplay once loaded.
  34199. */
  34200. autoplay: boolean;
  34201. /**
  34202. * Does the sound loop after it finishes playing once.
  34203. */
  34204. loop: boolean;
  34205. /**
  34206. * Does the sound use a custom attenuation curve to simulate the falloff
  34207. * happening when the source gets further away from the camera.
  34208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34209. */
  34210. useCustomAttenuation: boolean;
  34211. /**
  34212. * The sound track id this sound belongs to.
  34213. */
  34214. soundTrackId: number;
  34215. /**
  34216. * Is this sound currently played.
  34217. */
  34218. isPlaying: boolean;
  34219. /**
  34220. * Is this sound currently paused.
  34221. */
  34222. isPaused: boolean;
  34223. /**
  34224. * Does this sound enables spatial sound.
  34225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34226. */
  34227. spatialSound: boolean;
  34228. /**
  34229. * Define the reference distance the sound should be heard perfectly.
  34230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34231. */
  34232. refDistance: number;
  34233. /**
  34234. * Define the roll off factor of spatial sounds.
  34235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34236. */
  34237. rolloffFactor: number;
  34238. /**
  34239. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34241. */
  34242. maxDistance: number;
  34243. /**
  34244. * Define the distance attenuation model the sound will follow.
  34245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34246. */
  34247. distanceModel: string;
  34248. /**
  34249. * @hidden
  34250. * Back Compat
  34251. **/
  34252. onended: () => any;
  34253. /**
  34254. * Observable event when the current playing sound finishes.
  34255. */
  34256. onEndedObservable: Observable<Sound>;
  34257. private _panningModel;
  34258. private _playbackRate;
  34259. private _streaming;
  34260. private _startTime;
  34261. private _startOffset;
  34262. private _position;
  34263. /** @hidden */ private _positionInEmitterSpace: boolean;
  34264. private _localDirection;
  34265. private _volume;
  34266. private _isReadyToPlay;
  34267. private _isDirectional;
  34268. private _readyToPlayCallback;
  34269. private _audioBuffer;
  34270. private _soundSource;
  34271. private _streamingSource;
  34272. private _soundPanner;
  34273. private _soundGain;
  34274. private _inputAudioNode;
  34275. private _outputAudioNode;
  34276. private _coneInnerAngle;
  34277. private _coneOuterAngle;
  34278. private _coneOuterGain;
  34279. private _scene;
  34280. private _connectedTransformNode;
  34281. private _customAttenuationFunction;
  34282. private _registerFunc;
  34283. private _isOutputConnected;
  34284. private _htmlAudioElement;
  34285. private _urlType;
  34286. private _length?;
  34287. private _offset?;
  34288. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34289. /**
  34290. * Create a sound and attach it to a scene
  34291. * @param name Name of your sound
  34292. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34293. * @param scene defines the scene the sound belongs to
  34294. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34295. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34296. */
  34297. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34298. /**
  34299. * Release the sound and its associated resources
  34300. */
  34301. dispose(): void;
  34302. /**
  34303. * Gets if the sounds is ready to be played or not.
  34304. * @returns true if ready, otherwise false
  34305. */
  34306. isReady(): boolean;
  34307. private _soundLoaded;
  34308. /**
  34309. * Sets the data of the sound from an audiobuffer
  34310. * @param audioBuffer The audioBuffer containing the data
  34311. */
  34312. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34313. /**
  34314. * Updates the current sounds options such as maxdistance, loop...
  34315. * @param options A JSON object containing values named as the object properties
  34316. */
  34317. updateOptions(options: ISoundOptions): void;
  34318. private _createSpatialParameters;
  34319. private _updateSpatialParameters;
  34320. /**
  34321. * Switch the panning model to HRTF:
  34322. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34324. */
  34325. switchPanningModelToHRTF(): void;
  34326. /**
  34327. * Switch the panning model to Equal Power:
  34328. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34330. */
  34331. switchPanningModelToEqualPower(): void;
  34332. private _switchPanningModel;
  34333. /**
  34334. * Connect this sound to a sound track audio node like gain...
  34335. * @param soundTrackAudioNode the sound track audio node to connect to
  34336. */
  34337. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34338. /**
  34339. * Transform this sound into a directional source
  34340. * @param coneInnerAngle Size of the inner cone in degree
  34341. * @param coneOuterAngle Size of the outer cone in degree
  34342. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34343. */
  34344. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34345. /**
  34346. * Gets or sets the inner angle for the directional cone.
  34347. */
  34348. /**
  34349. * Gets or sets the inner angle for the directional cone.
  34350. */
  34351. directionalConeInnerAngle: number;
  34352. /**
  34353. * Gets or sets the outer angle for the directional cone.
  34354. */
  34355. /**
  34356. * Gets or sets the outer angle for the directional cone.
  34357. */
  34358. directionalConeOuterAngle: number;
  34359. /**
  34360. * Sets the position of the emitter if spatial sound is enabled
  34361. * @param newPosition Defines the new posisiton
  34362. */
  34363. setPosition(newPosition: Vector3): void;
  34364. /**
  34365. * Sets the local direction of the emitter if spatial sound is enabled
  34366. * @param newLocalDirection Defines the new local direction
  34367. */
  34368. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34369. private _updateDirection;
  34370. /** @hidden */
  34371. updateDistanceFromListener(): void;
  34372. /**
  34373. * Sets a new custom attenuation function for the sound.
  34374. * @param callback Defines the function used for the attenuation
  34375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34376. */
  34377. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34378. /**
  34379. * Play the sound
  34380. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34381. * @param offset (optional) Start the sound at a specific time in seconds
  34382. * @param length (optional) Sound duration (in seconds)
  34383. */
  34384. play(time?: number, offset?: number, length?: number): void;
  34385. private _onended;
  34386. /**
  34387. * Stop the sound
  34388. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34389. */
  34390. stop(time?: number): void;
  34391. /**
  34392. * Put the sound in pause
  34393. */
  34394. pause(): void;
  34395. /**
  34396. * Sets a dedicated volume for this sounds
  34397. * @param newVolume Define the new volume of the sound
  34398. * @param time Define time for gradual change to new volume
  34399. */
  34400. setVolume(newVolume: number, time?: number): void;
  34401. /**
  34402. * Set the sound play back rate
  34403. * @param newPlaybackRate Define the playback rate the sound should be played at
  34404. */
  34405. setPlaybackRate(newPlaybackRate: number): void;
  34406. /**
  34407. * Gets the volume of the sound.
  34408. * @returns the volume of the sound
  34409. */
  34410. getVolume(): number;
  34411. /**
  34412. * Attach the sound to a dedicated mesh
  34413. * @param transformNode The transform node to connect the sound with
  34414. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34415. */
  34416. attachToMesh(transformNode: TransformNode): void;
  34417. /**
  34418. * Detach the sound from the previously attached mesh
  34419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34420. */
  34421. detachFromMesh(): void;
  34422. private _onRegisterAfterWorldMatrixUpdate;
  34423. /**
  34424. * Clone the current sound in the scene.
  34425. * @returns the new sound clone
  34426. */
  34427. clone(): Nullable<Sound>;
  34428. /**
  34429. * Gets the current underlying audio buffer containing the data
  34430. * @returns the audio buffer
  34431. */
  34432. getAudioBuffer(): Nullable<AudioBuffer>;
  34433. /**
  34434. * Serializes the Sound in a JSON representation
  34435. * @returns the JSON representation of the sound
  34436. */
  34437. serialize(): any;
  34438. /**
  34439. * Parse a JSON representation of a sound to innstantiate in a given scene
  34440. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34441. * @param scene Define the scene the new parsed sound should be created in
  34442. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34443. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34444. * @returns the newly parsed sound
  34445. */
  34446. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34447. }
  34448. }
  34449. declare module BABYLON {
  34450. /**
  34451. * This defines an action helpful to play a defined sound on a triggered action.
  34452. */
  34453. export class PlaySoundAction extends Action {
  34454. private _sound;
  34455. /**
  34456. * Instantiate the action
  34457. * @param triggerOptions defines the trigger options
  34458. * @param sound defines the sound to play
  34459. * @param condition defines the trigger related conditions
  34460. */
  34461. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34462. /** @hidden */ private _prepare(): void;
  34463. /**
  34464. * Execute the action and play the sound.
  34465. */
  34466. execute(): void;
  34467. /**
  34468. * Serializes the actions and its related information.
  34469. * @param parent defines the object to serialize in
  34470. * @returns the serialized object
  34471. */
  34472. serialize(parent: any): any;
  34473. }
  34474. /**
  34475. * This defines an action helpful to stop a defined sound on a triggered action.
  34476. */
  34477. export class StopSoundAction extends Action {
  34478. private _sound;
  34479. /**
  34480. * Instantiate the action
  34481. * @param triggerOptions defines the trigger options
  34482. * @param sound defines the sound to stop
  34483. * @param condition defines the trigger related conditions
  34484. */
  34485. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34486. /** @hidden */ private _prepare(): void;
  34487. /**
  34488. * Execute the action and stop the sound.
  34489. */
  34490. execute(): void;
  34491. /**
  34492. * Serializes the actions and its related information.
  34493. * @param parent defines the object to serialize in
  34494. * @returns the serialized object
  34495. */
  34496. serialize(parent: any): any;
  34497. }
  34498. }
  34499. declare module BABYLON {
  34500. /**
  34501. * This defines an action responsible to change the value of a property
  34502. * by interpolating between its current value and the newly set one once triggered.
  34503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34504. */
  34505. export class InterpolateValueAction extends Action {
  34506. /**
  34507. * Defines the path of the property where the value should be interpolated
  34508. */
  34509. propertyPath: string;
  34510. /**
  34511. * Defines the target value at the end of the interpolation.
  34512. */
  34513. value: any;
  34514. /**
  34515. * Defines the time it will take for the property to interpolate to the value.
  34516. */
  34517. duration: number;
  34518. /**
  34519. * Defines if the other scene animations should be stopped when the action has been triggered
  34520. */
  34521. stopOtherAnimations?: boolean;
  34522. /**
  34523. * Defines a callback raised once the interpolation animation has been done.
  34524. */
  34525. onInterpolationDone?: () => void;
  34526. /**
  34527. * Observable triggered once the interpolation animation has been done.
  34528. */
  34529. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34530. private _target;
  34531. private _effectiveTarget;
  34532. private _property;
  34533. /**
  34534. * Instantiate the action
  34535. * @param triggerOptions defines the trigger options
  34536. * @param target defines the object containing the value to interpolate
  34537. * @param propertyPath defines the path to the property in the target object
  34538. * @param value defines the target value at the end of the interpolation
  34539. * @param duration deines the time it will take for the property to interpolate to the value.
  34540. * @param condition defines the trigger related conditions
  34541. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34542. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34543. */
  34544. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34545. /** @hidden */ private _prepare(): void;
  34546. /**
  34547. * Execute the action starts the value interpolation.
  34548. */
  34549. execute(): void;
  34550. /**
  34551. * Serializes the actions and its related information.
  34552. * @param parent defines the object to serialize in
  34553. * @returns the serialized object
  34554. */
  34555. serialize(parent: any): any;
  34556. }
  34557. }
  34558. declare module BABYLON {
  34559. /**
  34560. * Options allowed during the creation of a sound track.
  34561. */
  34562. export interface ISoundTrackOptions {
  34563. /**
  34564. * The volume the sound track should take during creation
  34565. */
  34566. volume?: number;
  34567. /**
  34568. * Define if the sound track is the main sound track of the scene
  34569. */
  34570. mainTrack?: boolean;
  34571. }
  34572. /**
  34573. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34574. * It will be also used in a future release to apply effects on a specific track.
  34575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34576. */
  34577. export class SoundTrack {
  34578. /**
  34579. * The unique identifier of the sound track in the scene.
  34580. */
  34581. id: number;
  34582. /**
  34583. * The list of sounds included in the sound track.
  34584. */
  34585. soundCollection: Array<Sound>;
  34586. private _outputAudioNode;
  34587. private _scene;
  34588. private _isMainTrack;
  34589. private _connectedAnalyser;
  34590. private _options;
  34591. private _isInitialized;
  34592. /**
  34593. * Creates a new sound track.
  34594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34595. * @param scene Define the scene the sound track belongs to
  34596. * @param options
  34597. */
  34598. constructor(scene: Scene, options?: ISoundTrackOptions);
  34599. private _initializeSoundTrackAudioGraph;
  34600. /**
  34601. * Release the sound track and its associated resources
  34602. */
  34603. dispose(): void;
  34604. /**
  34605. * Adds a sound to this sound track
  34606. * @param sound define the cound to add
  34607. * @ignoreNaming
  34608. */
  34609. AddSound(sound: Sound): void;
  34610. /**
  34611. * Removes a sound to this sound track
  34612. * @param sound define the cound to remove
  34613. * @ignoreNaming
  34614. */
  34615. RemoveSound(sound: Sound): void;
  34616. /**
  34617. * Set a global volume for the full sound track.
  34618. * @param newVolume Define the new volume of the sound track
  34619. */
  34620. setVolume(newVolume: number): void;
  34621. /**
  34622. * Switch the panning model to HRTF:
  34623. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34625. */
  34626. switchPanningModelToHRTF(): void;
  34627. /**
  34628. * Switch the panning model to Equal Power:
  34629. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34631. */
  34632. switchPanningModelToEqualPower(): void;
  34633. /**
  34634. * Connect the sound track to an audio analyser allowing some amazing
  34635. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34637. * @param analyser The analyser to connect to the engine
  34638. */
  34639. connectToAnalyser(analyser: Analyser): void;
  34640. }
  34641. }
  34642. declare module BABYLON {
  34643. interface AbstractScene {
  34644. /**
  34645. * The list of sounds used in the scene.
  34646. */
  34647. sounds: Nullable<Array<Sound>>;
  34648. }
  34649. interface Scene {
  34650. /**
  34651. * @hidden
  34652. * Backing field
  34653. */ private _mainSoundTrack: SoundTrack;
  34654. /**
  34655. * The main sound track played by the scene.
  34656. * It cotains your primary collection of sounds.
  34657. */
  34658. mainSoundTrack: SoundTrack;
  34659. /**
  34660. * The list of sound tracks added to the scene
  34661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34662. */
  34663. soundTracks: Nullable<Array<SoundTrack>>;
  34664. /**
  34665. * Gets a sound using a given name
  34666. * @param name defines the name to search for
  34667. * @return the found sound or null if not found at all.
  34668. */
  34669. getSoundByName(name: string): Nullable<Sound>;
  34670. /**
  34671. * Gets or sets if audio support is enabled
  34672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34673. */
  34674. audioEnabled: boolean;
  34675. /**
  34676. * Gets or sets if audio will be output to headphones
  34677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34678. */
  34679. headphone: boolean;
  34680. /**
  34681. * Gets or sets custom audio listener position provider
  34682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34683. */
  34684. audioListenerPositionProvider: Nullable<() => Vector3>;
  34685. }
  34686. /**
  34687. * Defines the sound scene component responsible to manage any sounds
  34688. * in a given scene.
  34689. */
  34690. export class AudioSceneComponent implements ISceneSerializableComponent {
  34691. /**
  34692. * The component name helpfull to identify the component in the list of scene components.
  34693. */
  34694. readonly name: string;
  34695. /**
  34696. * The scene the component belongs to.
  34697. */
  34698. scene: Scene;
  34699. private _audioEnabled;
  34700. /**
  34701. * Gets whether audio is enabled or not.
  34702. * Please use related enable/disable method to switch state.
  34703. */
  34704. readonly audioEnabled: boolean;
  34705. private _headphone;
  34706. /**
  34707. * Gets whether audio is outputing to headphone or not.
  34708. * Please use the according Switch methods to change output.
  34709. */
  34710. readonly headphone: boolean;
  34711. private _audioListenerPositionProvider;
  34712. /**
  34713. * Gets the current audio listener position provider
  34714. */
  34715. /**
  34716. * Sets a custom listener position for all sounds in the scene
  34717. * By default, this is the position of the first active camera
  34718. */
  34719. audioListenerPositionProvider: Nullable<() => Vector3>;
  34720. /**
  34721. * Creates a new instance of the component for the given scene
  34722. * @param scene Defines the scene to register the component in
  34723. */
  34724. constructor(scene: Scene);
  34725. /**
  34726. * Registers the component in a given scene
  34727. */
  34728. register(): void;
  34729. /**
  34730. * Rebuilds the elements related to this component in case of
  34731. * context lost for instance.
  34732. */
  34733. rebuild(): void;
  34734. /**
  34735. * Serializes the component data to the specified json object
  34736. * @param serializationObject The object to serialize to
  34737. */
  34738. serialize(serializationObject: any): void;
  34739. /**
  34740. * Adds all the elements from the container to the scene
  34741. * @param container the container holding the elements
  34742. */
  34743. addFromContainer(container: AbstractScene): void;
  34744. /**
  34745. * Removes all the elements in the container from the scene
  34746. * @param container contains the elements to remove
  34747. * @param dispose if the removed element should be disposed (default: false)
  34748. */
  34749. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34750. /**
  34751. * Disposes the component and the associated ressources.
  34752. */
  34753. dispose(): void;
  34754. /**
  34755. * Disables audio in the associated scene.
  34756. */
  34757. disableAudio(): void;
  34758. /**
  34759. * Enables audio in the associated scene.
  34760. */
  34761. enableAudio(): void;
  34762. /**
  34763. * Switch audio to headphone output.
  34764. */
  34765. switchAudioModeForHeadphones(): void;
  34766. /**
  34767. * Switch audio to normal speakers.
  34768. */
  34769. switchAudioModeForNormalSpeakers(): void;
  34770. private _afterRender;
  34771. }
  34772. }
  34773. declare module BABYLON {
  34774. /**
  34775. * Wraps one or more Sound objects and selects one with random weight for playback.
  34776. */
  34777. export class WeightedSound {
  34778. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34779. loop: boolean;
  34780. private _coneInnerAngle;
  34781. private _coneOuterAngle;
  34782. private _volume;
  34783. /** A Sound is currently playing. */
  34784. isPlaying: boolean;
  34785. /** A Sound is currently paused. */
  34786. isPaused: boolean;
  34787. private _sounds;
  34788. private _weights;
  34789. private _currentIndex?;
  34790. /**
  34791. * Creates a new WeightedSound from the list of sounds given.
  34792. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34793. * @param sounds Array of Sounds that will be selected from.
  34794. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34795. */
  34796. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34797. /**
  34798. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34799. */
  34800. /**
  34801. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34802. */
  34803. directionalConeInnerAngle: number;
  34804. /**
  34805. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34806. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34807. */
  34808. /**
  34809. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34810. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34811. */
  34812. directionalConeOuterAngle: number;
  34813. /**
  34814. * Playback volume.
  34815. */
  34816. /**
  34817. * Playback volume.
  34818. */
  34819. volume: number;
  34820. private _onended;
  34821. /**
  34822. * Suspend playback
  34823. */
  34824. pause(): void;
  34825. /**
  34826. * Stop playback
  34827. */
  34828. stop(): void;
  34829. /**
  34830. * Start playback.
  34831. * @param startOffset Position the clip head at a specific time in seconds.
  34832. */
  34833. play(startOffset?: number): void;
  34834. }
  34835. }
  34836. declare module BABYLON {
  34837. /**
  34838. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34839. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34840. */
  34841. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34842. /**
  34843. * Gets the name of the behavior.
  34844. */
  34845. readonly name: string;
  34846. /**
  34847. * The easing function used by animations
  34848. */
  34849. static EasingFunction: BackEase;
  34850. /**
  34851. * The easing mode used by animations
  34852. */
  34853. static EasingMode: number;
  34854. /**
  34855. * The duration of the animation, in milliseconds
  34856. */
  34857. transitionDuration: number;
  34858. /**
  34859. * Length of the distance animated by the transition when lower radius is reached
  34860. */
  34861. lowerRadiusTransitionRange: number;
  34862. /**
  34863. * Length of the distance animated by the transition when upper radius is reached
  34864. */
  34865. upperRadiusTransitionRange: number;
  34866. private _autoTransitionRange;
  34867. /**
  34868. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34869. */
  34870. /**
  34871. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34872. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34873. */
  34874. autoTransitionRange: boolean;
  34875. private _attachedCamera;
  34876. private _onAfterCheckInputsObserver;
  34877. private _onMeshTargetChangedObserver;
  34878. /**
  34879. * Initializes the behavior.
  34880. */
  34881. init(): void;
  34882. /**
  34883. * Attaches the behavior to its arc rotate camera.
  34884. * @param camera Defines the camera to attach the behavior to
  34885. */
  34886. attach(camera: ArcRotateCamera): void;
  34887. /**
  34888. * Detaches the behavior from its current arc rotate camera.
  34889. */
  34890. detach(): void;
  34891. private _radiusIsAnimating;
  34892. private _radiusBounceTransition;
  34893. private _animatables;
  34894. private _cachedWheelPrecision;
  34895. /**
  34896. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34897. * @param radiusLimit The limit to check against.
  34898. * @return Bool to indicate if at limit.
  34899. */
  34900. private _isRadiusAtLimit;
  34901. /**
  34902. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34903. * @param radiusDelta The delta by which to animate to. Can be negative.
  34904. */
  34905. private _applyBoundRadiusAnimation;
  34906. /**
  34907. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34908. */
  34909. protected _clearAnimationLocks(): void;
  34910. /**
  34911. * Stops and removes all animations that have been applied to the camera
  34912. */
  34913. stopAllAnimations(): void;
  34914. }
  34915. }
  34916. declare module BABYLON {
  34917. /**
  34918. * 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.
  34919. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34920. */
  34921. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34922. /**
  34923. * Gets the name of the behavior.
  34924. */
  34925. readonly name: string;
  34926. private _mode;
  34927. private _radiusScale;
  34928. private _positionScale;
  34929. private _defaultElevation;
  34930. private _elevationReturnTime;
  34931. private _elevationReturnWaitTime;
  34932. private _zoomStopsAnimation;
  34933. private _framingTime;
  34934. /**
  34935. * The easing function used by animations
  34936. */
  34937. static EasingFunction: ExponentialEase;
  34938. /**
  34939. * The easing mode used by animations
  34940. */
  34941. static EasingMode: number;
  34942. /**
  34943. * Sets the current mode used by the behavior
  34944. */
  34945. /**
  34946. * Gets current mode used by the behavior.
  34947. */
  34948. mode: number;
  34949. /**
  34950. * Sets the scale applied to the radius (1 by default)
  34951. */
  34952. /**
  34953. * Gets the scale applied to the radius
  34954. */
  34955. radiusScale: number;
  34956. /**
  34957. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34958. */
  34959. /**
  34960. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34961. */
  34962. positionScale: number;
  34963. /**
  34964. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34965. * behaviour is triggered, in radians.
  34966. */
  34967. /**
  34968. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34969. * behaviour is triggered, in radians.
  34970. */
  34971. defaultElevation: number;
  34972. /**
  34973. * Sets the time (in milliseconds) taken to return to the default beta position.
  34974. * Negative value indicates camera should not return to default.
  34975. */
  34976. /**
  34977. * Gets the time (in milliseconds) taken to return to the default beta position.
  34978. * Negative value indicates camera should not return to default.
  34979. */
  34980. elevationReturnTime: number;
  34981. /**
  34982. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34983. */
  34984. /**
  34985. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34986. */
  34987. elevationReturnWaitTime: number;
  34988. /**
  34989. * Sets the flag that indicates if user zooming should stop animation.
  34990. */
  34991. /**
  34992. * Gets the flag that indicates if user zooming should stop animation.
  34993. */
  34994. zoomStopsAnimation: boolean;
  34995. /**
  34996. * Sets the transition time when framing the mesh, in milliseconds
  34997. */
  34998. /**
  34999. * Gets the transition time when framing the mesh, in milliseconds
  35000. */
  35001. framingTime: number;
  35002. /**
  35003. * Define if the behavior should automatically change the configured
  35004. * camera limits and sensibilities.
  35005. */
  35006. autoCorrectCameraLimitsAndSensibility: boolean;
  35007. private _onPrePointerObservableObserver;
  35008. private _onAfterCheckInputsObserver;
  35009. private _onMeshTargetChangedObserver;
  35010. private _attachedCamera;
  35011. private _isPointerDown;
  35012. private _lastInteractionTime;
  35013. /**
  35014. * Initializes the behavior.
  35015. */
  35016. init(): void;
  35017. /**
  35018. * Attaches the behavior to its arc rotate camera.
  35019. * @param camera Defines the camera to attach the behavior to
  35020. */
  35021. attach(camera: ArcRotateCamera): void;
  35022. /**
  35023. * Detaches the behavior from its current arc rotate camera.
  35024. */
  35025. detach(): void;
  35026. private _animatables;
  35027. private _betaIsAnimating;
  35028. private _betaTransition;
  35029. private _radiusTransition;
  35030. private _vectorTransition;
  35031. /**
  35032. * Targets the given mesh and updates zoom level accordingly.
  35033. * @param mesh The mesh to target.
  35034. * @param radius Optional. If a cached radius position already exists, overrides default.
  35035. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35036. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35037. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35038. */
  35039. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35040. /**
  35041. * Targets the given mesh with its children and updates zoom level accordingly.
  35042. * @param mesh The mesh to target.
  35043. * @param radius Optional. If a cached radius position already exists, overrides default.
  35044. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35045. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35046. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35047. */
  35048. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35049. /**
  35050. * Targets the given meshes with their children and updates zoom level accordingly.
  35051. * @param meshes The mesh to target.
  35052. * @param radius Optional. If a cached radius position already exists, overrides default.
  35053. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35054. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35055. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35056. */
  35057. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35058. /**
  35059. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35060. * @param minimumWorld Determines the smaller position of the bounding box extend
  35061. * @param maximumWorld Determines the bigger position of the bounding box extend
  35062. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35063. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35064. */
  35065. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35066. /**
  35067. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35068. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35069. * frustum width.
  35070. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35071. * to fully enclose the mesh in the viewing frustum.
  35072. */
  35073. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35074. /**
  35075. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35076. * is automatically returned to its default position (expected to be above ground plane).
  35077. */
  35078. private _maintainCameraAboveGround;
  35079. /**
  35080. * Returns the frustum slope based on the canvas ratio and camera FOV
  35081. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35082. */
  35083. private _getFrustumSlope;
  35084. /**
  35085. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35086. */
  35087. private _clearAnimationLocks;
  35088. /**
  35089. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35090. */
  35091. private _applyUserInteraction;
  35092. /**
  35093. * Stops and removes all animations that have been applied to the camera
  35094. */
  35095. stopAllAnimations(): void;
  35096. /**
  35097. * Gets a value indicating if the user is moving the camera
  35098. */
  35099. readonly isUserIsMoving: boolean;
  35100. /**
  35101. * The camera can move all the way towards the mesh.
  35102. */
  35103. static IgnoreBoundsSizeMode: number;
  35104. /**
  35105. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35106. */
  35107. static FitFrustumSidesMode: number;
  35108. }
  35109. }
  35110. declare module BABYLON {
  35111. /**
  35112. * Base class for Camera Pointer Inputs.
  35113. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35114. * for example usage.
  35115. */
  35116. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35117. /**
  35118. * Defines the camera the input is attached to.
  35119. */
  35120. abstract camera: Camera;
  35121. /**
  35122. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35123. */
  35124. protected _altKey: boolean;
  35125. protected _ctrlKey: boolean;
  35126. protected _metaKey: boolean;
  35127. protected _shiftKey: boolean;
  35128. /**
  35129. * Which mouse buttons were pressed at time of last mouse event.
  35130. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35131. */
  35132. protected _buttonsPressed: number;
  35133. /**
  35134. * Defines the buttons associated with the input to handle camera move.
  35135. */
  35136. buttons: number[];
  35137. /**
  35138. * Attach the input controls to a specific dom element to get the input from.
  35139. * @param element Defines the element the controls should be listened from
  35140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35141. */
  35142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35143. /**
  35144. * Detach the current controls from the specified dom element.
  35145. * @param element Defines the element to stop listening the inputs from
  35146. */
  35147. detachControl(element: Nullable<HTMLElement>): void;
  35148. /**
  35149. * Gets the class name of the current input.
  35150. * @returns the class name
  35151. */
  35152. getClassName(): string;
  35153. /**
  35154. * Get the friendly name associated with the input class.
  35155. * @returns the input friendly name
  35156. */
  35157. getSimpleName(): string;
  35158. /**
  35159. * Called on pointer POINTERDOUBLETAP event.
  35160. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35161. */
  35162. protected onDoubleTap(type: string): void;
  35163. /**
  35164. * Called on pointer POINTERMOVE event if only a single touch is active.
  35165. * Override this method to provide functionality.
  35166. */
  35167. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35168. /**
  35169. * Called on pointer POINTERMOVE event if multiple touches are active.
  35170. * Override this method to provide functionality.
  35171. */
  35172. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35173. /**
  35174. * Called on JS contextmenu event.
  35175. * Override this method to provide functionality.
  35176. */
  35177. protected onContextMenu(evt: PointerEvent): void;
  35178. /**
  35179. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35180. * press.
  35181. * Override this method to provide functionality.
  35182. */
  35183. protected onButtonDown(evt: PointerEvent): void;
  35184. /**
  35185. * Called each time a new POINTERUP event occurs. Ie, for each button
  35186. * release.
  35187. * Override this method to provide functionality.
  35188. */
  35189. protected onButtonUp(evt: PointerEvent): void;
  35190. /**
  35191. * Called when window becomes inactive.
  35192. * Override this method to provide functionality.
  35193. */
  35194. protected onLostFocus(): void;
  35195. private _pointerInput;
  35196. private _observer;
  35197. private _onLostFocus;
  35198. private pointA;
  35199. private pointB;
  35200. }
  35201. }
  35202. declare module BABYLON {
  35203. /**
  35204. * Manage the pointers inputs to control an arc rotate camera.
  35205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35206. */
  35207. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35208. /**
  35209. * Defines the camera the input is attached to.
  35210. */
  35211. camera: ArcRotateCamera;
  35212. /**
  35213. * Gets the class name of the current input.
  35214. * @returns the class name
  35215. */
  35216. getClassName(): string;
  35217. /**
  35218. * Defines the buttons associated with the input to handle camera move.
  35219. */
  35220. buttons: number[];
  35221. /**
  35222. * Defines the pointer angular sensibility along the X axis or how fast is
  35223. * the camera rotating.
  35224. */
  35225. angularSensibilityX: number;
  35226. /**
  35227. * Defines the pointer angular sensibility along the Y axis or how fast is
  35228. * the camera rotating.
  35229. */
  35230. angularSensibilityY: number;
  35231. /**
  35232. * Defines the pointer pinch precision or how fast is the camera zooming.
  35233. */
  35234. pinchPrecision: number;
  35235. /**
  35236. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35237. * from 0.
  35238. * It defines the percentage of current camera.radius to use as delta when
  35239. * pinch zoom is used.
  35240. */
  35241. pinchDeltaPercentage: number;
  35242. /**
  35243. * Defines the pointer panning sensibility or how fast is the camera moving.
  35244. */
  35245. panningSensibility: number;
  35246. /**
  35247. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35248. */
  35249. multiTouchPanning: boolean;
  35250. /**
  35251. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35252. * zoom (pinch) through multitouch.
  35253. */
  35254. multiTouchPanAndZoom: boolean;
  35255. /**
  35256. * Revers pinch action direction.
  35257. */
  35258. pinchInwards: boolean;
  35259. private _isPanClick;
  35260. private _twoFingerActivityCount;
  35261. private _isPinching;
  35262. /**
  35263. * Called on pointer POINTERMOVE event if only a single touch is active.
  35264. */
  35265. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35266. /**
  35267. * Called on pointer POINTERDOUBLETAP event.
  35268. */
  35269. protected onDoubleTap(type: string): void;
  35270. /**
  35271. * Called on pointer POINTERMOVE event if multiple touches are active.
  35272. */
  35273. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35274. /**
  35275. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35276. * press.
  35277. */
  35278. protected onButtonDown(evt: PointerEvent): void;
  35279. /**
  35280. * Called each time a new POINTERUP event occurs. Ie, for each button
  35281. * release.
  35282. */
  35283. protected onButtonUp(evt: PointerEvent): void;
  35284. /**
  35285. * Called when window becomes inactive.
  35286. */
  35287. protected onLostFocus(): void;
  35288. }
  35289. }
  35290. declare module BABYLON {
  35291. /**
  35292. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35294. */
  35295. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35296. /**
  35297. * Defines the camera the input is attached to.
  35298. */
  35299. camera: ArcRotateCamera;
  35300. /**
  35301. * Defines the list of key codes associated with the up action (increase alpha)
  35302. */
  35303. keysUp: number[];
  35304. /**
  35305. * Defines the list of key codes associated with the down action (decrease alpha)
  35306. */
  35307. keysDown: number[];
  35308. /**
  35309. * Defines the list of key codes associated with the left action (increase beta)
  35310. */
  35311. keysLeft: number[];
  35312. /**
  35313. * Defines the list of key codes associated with the right action (decrease beta)
  35314. */
  35315. keysRight: number[];
  35316. /**
  35317. * Defines the list of key codes associated with the reset action.
  35318. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35319. */
  35320. keysReset: number[];
  35321. /**
  35322. * Defines the panning sensibility of the inputs.
  35323. * (How fast is the camera paning)
  35324. */
  35325. panningSensibility: number;
  35326. /**
  35327. * Defines the zooming sensibility of the inputs.
  35328. * (How fast is the camera zooming)
  35329. */
  35330. zoomingSensibility: number;
  35331. /**
  35332. * Defines wether maintaining the alt key down switch the movement mode from
  35333. * orientation to zoom.
  35334. */
  35335. useAltToZoom: boolean;
  35336. /**
  35337. * Rotation speed of the camera
  35338. */
  35339. angularSpeed: number;
  35340. private _keys;
  35341. private _ctrlPressed;
  35342. private _altPressed;
  35343. private _onCanvasBlurObserver;
  35344. private _onKeyboardObserver;
  35345. private _engine;
  35346. private _scene;
  35347. /**
  35348. * Attach the input controls to a specific dom element to get the input from.
  35349. * @param element Defines the element the controls should be listened from
  35350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35351. */
  35352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35353. /**
  35354. * Detach the current controls from the specified dom element.
  35355. * @param element Defines the element to stop listening the inputs from
  35356. */
  35357. detachControl(element: Nullable<HTMLElement>): void;
  35358. /**
  35359. * Update the current camera state depending on the inputs that have been used this frame.
  35360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35361. */
  35362. checkInputs(): void;
  35363. /**
  35364. * Gets the class name of the current intput.
  35365. * @returns the class name
  35366. */
  35367. getClassName(): string;
  35368. /**
  35369. * Get the friendly name associated with the input class.
  35370. * @returns the input friendly name
  35371. */
  35372. getSimpleName(): string;
  35373. }
  35374. }
  35375. declare module BABYLON {
  35376. /**
  35377. * Manage the mouse wheel inputs to control an arc rotate camera.
  35378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35379. */
  35380. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35381. /**
  35382. * Defines the camera the input is attached to.
  35383. */
  35384. camera: ArcRotateCamera;
  35385. /**
  35386. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35387. */
  35388. wheelPrecision: number;
  35389. /**
  35390. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35391. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35392. */
  35393. wheelDeltaPercentage: number;
  35394. private _wheel;
  35395. private _observer;
  35396. private computeDeltaFromMouseWheelLegacyEvent;
  35397. /**
  35398. * Attach the input controls to a specific dom element to get the input from.
  35399. * @param element Defines the element the controls should be listened from
  35400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35401. */
  35402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35403. /**
  35404. * Detach the current controls from the specified dom element.
  35405. * @param element Defines the element to stop listening the inputs from
  35406. */
  35407. detachControl(element: Nullable<HTMLElement>): void;
  35408. /**
  35409. * Gets the class name of the current intput.
  35410. * @returns the class name
  35411. */
  35412. getClassName(): string;
  35413. /**
  35414. * Get the friendly name associated with the input class.
  35415. * @returns the input friendly name
  35416. */
  35417. getSimpleName(): string;
  35418. }
  35419. }
  35420. declare module BABYLON {
  35421. /**
  35422. * Default Inputs manager for the ArcRotateCamera.
  35423. * It groups all the default supported inputs for ease of use.
  35424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35425. */
  35426. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35427. /**
  35428. * Instantiates a new ArcRotateCameraInputsManager.
  35429. * @param camera Defines the camera the inputs belong to
  35430. */
  35431. constructor(camera: ArcRotateCamera);
  35432. /**
  35433. * Add mouse wheel input support to the input manager.
  35434. * @returns the current input manager
  35435. */
  35436. addMouseWheel(): ArcRotateCameraInputsManager;
  35437. /**
  35438. * Add pointers input support to the input manager.
  35439. * @returns the current input manager
  35440. */
  35441. addPointers(): ArcRotateCameraInputsManager;
  35442. /**
  35443. * Add keyboard input support to the input manager.
  35444. * @returns the current input manager
  35445. */
  35446. addKeyboard(): ArcRotateCameraInputsManager;
  35447. }
  35448. }
  35449. declare module BABYLON {
  35450. /**
  35451. * This represents an orbital type of camera.
  35452. *
  35453. * 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.
  35454. * 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.
  35455. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35456. */
  35457. export class ArcRotateCamera extends TargetCamera {
  35458. /**
  35459. * Defines the rotation angle of the camera along the longitudinal axis.
  35460. */
  35461. alpha: number;
  35462. /**
  35463. * Defines the rotation angle of the camera along the latitudinal axis.
  35464. */
  35465. beta: number;
  35466. /**
  35467. * Defines the radius of the camera from it s target point.
  35468. */
  35469. radius: number;
  35470. protected _target: Vector3;
  35471. protected _targetHost: Nullable<AbstractMesh>;
  35472. /**
  35473. * Defines the target point of the camera.
  35474. * The camera looks towards it form the radius distance.
  35475. */
  35476. target: Vector3;
  35477. /**
  35478. * Define the current local position of the camera in the scene
  35479. */
  35480. position: Vector3;
  35481. protected _upVector: Vector3;
  35482. protected _upToYMatrix: Matrix;
  35483. protected _YToUpMatrix: Matrix;
  35484. /**
  35485. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35486. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35487. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35488. */
  35489. upVector: Vector3;
  35490. /**
  35491. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35492. */
  35493. setMatUp(): void;
  35494. /**
  35495. * Current inertia value on the longitudinal axis.
  35496. * The bigger this number the longer it will take for the camera to stop.
  35497. */
  35498. inertialAlphaOffset: number;
  35499. /**
  35500. * Current inertia value on the latitudinal axis.
  35501. * The bigger this number the longer it will take for the camera to stop.
  35502. */
  35503. inertialBetaOffset: number;
  35504. /**
  35505. * Current inertia value on the radius axis.
  35506. * The bigger this number the longer it will take for the camera to stop.
  35507. */
  35508. inertialRadiusOffset: number;
  35509. /**
  35510. * Minimum allowed angle on the longitudinal axis.
  35511. * This can help limiting how the Camera is able to move in the scene.
  35512. */
  35513. lowerAlphaLimit: Nullable<number>;
  35514. /**
  35515. * Maximum allowed angle on the longitudinal axis.
  35516. * This can help limiting how the Camera is able to move in the scene.
  35517. */
  35518. upperAlphaLimit: Nullable<number>;
  35519. /**
  35520. * Minimum allowed angle on the latitudinal axis.
  35521. * This can help limiting how the Camera is able to move in the scene.
  35522. */
  35523. lowerBetaLimit: number;
  35524. /**
  35525. * Maximum allowed angle on the latitudinal axis.
  35526. * This can help limiting how the Camera is able to move in the scene.
  35527. */
  35528. upperBetaLimit: number;
  35529. /**
  35530. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35531. * This can help limiting how the Camera is able to move in the scene.
  35532. */
  35533. lowerRadiusLimit: Nullable<number>;
  35534. /**
  35535. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35536. * This can help limiting how the Camera is able to move in the scene.
  35537. */
  35538. upperRadiusLimit: Nullable<number>;
  35539. /**
  35540. * Defines the current inertia value used during panning of the camera along the X axis.
  35541. */
  35542. inertialPanningX: number;
  35543. /**
  35544. * Defines the current inertia value used during panning of the camera along the Y axis.
  35545. */
  35546. inertialPanningY: number;
  35547. /**
  35548. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35549. * Basically if your fingers moves away from more than this distance you will be considered
  35550. * in pinch mode.
  35551. */
  35552. pinchToPanMaxDistance: number;
  35553. /**
  35554. * Defines the maximum distance the camera can pan.
  35555. * This could help keeping the cammera always in your scene.
  35556. */
  35557. panningDistanceLimit: Nullable<number>;
  35558. /**
  35559. * Defines the target of the camera before paning.
  35560. */
  35561. panningOriginTarget: Vector3;
  35562. /**
  35563. * Defines the value of the inertia used during panning.
  35564. * 0 would mean stop inertia and one would mean no decelleration at all.
  35565. */
  35566. panningInertia: number;
  35567. /**
  35568. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35569. */
  35570. angularSensibilityX: number;
  35571. /**
  35572. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35573. */
  35574. angularSensibilityY: number;
  35575. /**
  35576. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35577. */
  35578. pinchPrecision: number;
  35579. /**
  35580. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35581. * It will be used instead of pinchDeltaPrecision if different from 0.
  35582. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35583. */
  35584. pinchDeltaPercentage: number;
  35585. /**
  35586. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35587. */
  35588. panningSensibility: number;
  35589. /**
  35590. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35591. */
  35592. keysUp: number[];
  35593. /**
  35594. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35595. */
  35596. keysDown: number[];
  35597. /**
  35598. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35599. */
  35600. keysLeft: number[];
  35601. /**
  35602. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35603. */
  35604. keysRight: number[];
  35605. /**
  35606. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35607. */
  35608. wheelPrecision: number;
  35609. /**
  35610. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35611. * It will be used instead of pinchDeltaPrecision if different from 0.
  35612. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35613. */
  35614. wheelDeltaPercentage: number;
  35615. /**
  35616. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35617. */
  35618. zoomOnFactor: number;
  35619. /**
  35620. * Defines a screen offset for the camera position.
  35621. */
  35622. targetScreenOffset: Vector2;
  35623. /**
  35624. * Allows the camera to be completely reversed.
  35625. * If false the camera can not arrive upside down.
  35626. */
  35627. allowUpsideDown: boolean;
  35628. /**
  35629. * Define if double tap/click is used to restore the previously saved state of the camera.
  35630. */
  35631. useInputToRestoreState: boolean;
  35632. /** @hidden */ private _viewMatrix: Matrix;
  35633. /** @hidden */ private _useCtrlForPanning: boolean;
  35634. /** @hidden */ private _panningMouseButton: number;
  35635. /**
  35636. * Defines the input associated to the camera.
  35637. */
  35638. inputs: ArcRotateCameraInputsManager;
  35639. /** @hidden */ private _reset: () => void;
  35640. /**
  35641. * Defines the allowed panning axis.
  35642. */
  35643. panningAxis: Vector3;
  35644. protected _localDirection: Vector3;
  35645. protected _transformedDirection: Vector3;
  35646. private _bouncingBehavior;
  35647. /**
  35648. * Gets the bouncing behavior of the camera if it has been enabled.
  35649. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35650. */
  35651. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35652. /**
  35653. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35654. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35655. */
  35656. useBouncingBehavior: boolean;
  35657. private _framingBehavior;
  35658. /**
  35659. * Gets the framing behavior of the camera if it has been enabled.
  35660. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35661. */
  35662. readonly framingBehavior: Nullable<FramingBehavior>;
  35663. /**
  35664. * Defines if the framing behavior of the camera is enabled on the camera.
  35665. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35666. */
  35667. useFramingBehavior: boolean;
  35668. private _autoRotationBehavior;
  35669. /**
  35670. * Gets the auto rotation behavior of the camera if it has been enabled.
  35671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35672. */
  35673. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35674. /**
  35675. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35676. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35677. */
  35678. useAutoRotationBehavior: boolean;
  35679. /**
  35680. * Observable triggered when the mesh target has been changed on the camera.
  35681. */
  35682. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35683. /**
  35684. * Event raised when the camera is colliding with a mesh.
  35685. */
  35686. onCollide: (collidedMesh: AbstractMesh) => void;
  35687. /**
  35688. * Defines whether the camera should check collision with the objects oh the scene.
  35689. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35690. */
  35691. checkCollisions: boolean;
  35692. /**
  35693. * Defines the collision radius of the camera.
  35694. * This simulates a sphere around the camera.
  35695. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35696. */
  35697. collisionRadius: Vector3;
  35698. protected _collider: Collider;
  35699. protected _previousPosition: Vector3;
  35700. protected _collisionVelocity: Vector3;
  35701. protected _newPosition: Vector3;
  35702. protected _previousAlpha: number;
  35703. protected _previousBeta: number;
  35704. protected _previousRadius: number;
  35705. protected _collisionTriggered: boolean;
  35706. protected _targetBoundingCenter: Nullable<Vector3>;
  35707. private _computationVector;
  35708. /**
  35709. * Instantiates a new ArcRotateCamera in a given scene
  35710. * @param name Defines the name of the camera
  35711. * @param alpha Defines the camera rotation along the logitudinal axis
  35712. * @param beta Defines the camera rotation along the latitudinal axis
  35713. * @param radius Defines the camera distance from its target
  35714. * @param target Defines the camera target
  35715. * @param scene Defines the scene the camera belongs to
  35716. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35717. */
  35718. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35719. /** @hidden */ private _initCache(): void;
  35720. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35721. protected _getTargetPosition(): Vector3;
  35722. private _storedAlpha;
  35723. private _storedBeta;
  35724. private _storedRadius;
  35725. private _storedTarget;
  35726. private _storedTargetScreenOffset;
  35727. /**
  35728. * Stores the current state of the camera (alpha, beta, radius and target)
  35729. * @returns the camera itself
  35730. */
  35731. storeState(): Camera;
  35732. /**
  35733. * @hidden
  35734. * Restored camera state. You must call storeState() first
  35735. */ private _restoreStateValues(): boolean;
  35736. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35737. /**
  35738. * Attached controls to the current camera.
  35739. * @param element Defines the element the controls should be listened from
  35740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35741. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35742. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35743. */
  35744. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35745. /**
  35746. * Detach the current controls from the camera.
  35747. * The camera will stop reacting to inputs.
  35748. * @param element Defines the element to stop listening the inputs from
  35749. */
  35750. detachControl(element: HTMLElement): void;
  35751. /** @hidden */ private _checkInputs(): void;
  35752. protected _checkLimits(): void;
  35753. /**
  35754. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35755. */
  35756. rebuildAnglesAndRadius(): void;
  35757. /**
  35758. * Use a position to define the current camera related information like aplha, beta and radius
  35759. * @param position Defines the position to set the camera at
  35760. */
  35761. setPosition(position: Vector3): void;
  35762. /**
  35763. * Defines the target the camera should look at.
  35764. * This will automatically adapt alpha beta and radius to fit within the new target.
  35765. * @param target Defines the new target as a Vector or a mesh
  35766. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35767. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35768. */
  35769. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35770. /** @hidden */ private _getViewMatrix(): Matrix;
  35771. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35772. /**
  35773. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35774. * @param meshes Defines the mesh to zoom on
  35775. * @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)
  35776. */
  35777. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35778. /**
  35779. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35780. * The target will be changed but the radius
  35781. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35782. * @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)
  35783. */
  35784. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35785. min: Vector3;
  35786. max: Vector3;
  35787. distance: number;
  35788. }, doNotUpdateMaxZ?: boolean): void;
  35789. /**
  35790. * @override
  35791. * Override Camera.createRigCamera
  35792. */
  35793. createRigCamera(name: string, cameraIndex: number): Camera;
  35794. /**
  35795. * @hidden
  35796. * @override
  35797. * Override Camera._updateRigCameras
  35798. */ private _updateRigCameras(): void;
  35799. /**
  35800. * Destroy the camera and release the current resources hold by it.
  35801. */
  35802. dispose(): void;
  35803. /**
  35804. * Gets the current object class name.
  35805. * @return the class name
  35806. */
  35807. getClassName(): string;
  35808. }
  35809. }
  35810. declare module BABYLON {
  35811. /**
  35812. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35813. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35814. */
  35815. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35816. /**
  35817. * Gets the name of the behavior.
  35818. */
  35819. readonly name: string;
  35820. private _zoomStopsAnimation;
  35821. private _idleRotationSpeed;
  35822. private _idleRotationWaitTime;
  35823. private _idleRotationSpinupTime;
  35824. /**
  35825. * Sets the flag that indicates if user zooming should stop animation.
  35826. */
  35827. /**
  35828. * Gets the flag that indicates if user zooming should stop animation.
  35829. */
  35830. zoomStopsAnimation: boolean;
  35831. /**
  35832. * Sets the default speed at which the camera rotates around the model.
  35833. */
  35834. /**
  35835. * Gets the default speed at which the camera rotates around the model.
  35836. */
  35837. idleRotationSpeed: number;
  35838. /**
  35839. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35840. */
  35841. /**
  35842. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35843. */
  35844. idleRotationWaitTime: number;
  35845. /**
  35846. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35847. */
  35848. /**
  35849. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35850. */
  35851. idleRotationSpinupTime: number;
  35852. /**
  35853. * Gets a value indicating if the camera is currently rotating because of this behavior
  35854. */
  35855. readonly rotationInProgress: boolean;
  35856. private _onPrePointerObservableObserver;
  35857. private _onAfterCheckInputsObserver;
  35858. private _attachedCamera;
  35859. private _isPointerDown;
  35860. private _lastFrameTime;
  35861. private _lastInteractionTime;
  35862. private _cameraRotationSpeed;
  35863. /**
  35864. * Initializes the behavior.
  35865. */
  35866. init(): void;
  35867. /**
  35868. * Attaches the behavior to its arc rotate camera.
  35869. * @param camera Defines the camera to attach the behavior to
  35870. */
  35871. attach(camera: ArcRotateCamera): void;
  35872. /**
  35873. * Detaches the behavior from its current arc rotate camera.
  35874. */
  35875. detach(): void;
  35876. /**
  35877. * Returns true if user is scrolling.
  35878. * @return true if user is scrolling.
  35879. */
  35880. private _userIsZooming;
  35881. private _lastFrameRadius;
  35882. private _shouldAnimationStopForInteraction;
  35883. /**
  35884. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35885. */
  35886. private _applyUserInteraction;
  35887. private _userIsMoving;
  35888. }
  35889. }
  35890. declare module BABYLON {
  35891. /**
  35892. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35893. */
  35894. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35895. private ui;
  35896. /**
  35897. * The name of the behavior
  35898. */
  35899. name: string;
  35900. /**
  35901. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35902. */
  35903. distanceAwayFromFace: number;
  35904. /**
  35905. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35906. */
  35907. distanceAwayFromBottomOfFace: number;
  35908. private _faceVectors;
  35909. private _target;
  35910. private _scene;
  35911. private _onRenderObserver;
  35912. private _tmpMatrix;
  35913. private _tmpVector;
  35914. /**
  35915. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35916. * @param ui The transform node that should be attched to the mesh
  35917. */
  35918. constructor(ui: TransformNode);
  35919. /**
  35920. * Initializes the behavior
  35921. */
  35922. init(): void;
  35923. private _closestFace;
  35924. private _zeroVector;
  35925. private _lookAtTmpMatrix;
  35926. private _lookAtToRef;
  35927. /**
  35928. * Attaches the AttachToBoxBehavior to the passed in mesh
  35929. * @param target The mesh that the specified node will be attached to
  35930. */
  35931. attach(target: Mesh): void;
  35932. /**
  35933. * Detaches the behavior from the mesh
  35934. */
  35935. detach(): void;
  35936. }
  35937. }
  35938. declare module BABYLON {
  35939. /**
  35940. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35941. */
  35942. export class FadeInOutBehavior implements Behavior<Mesh> {
  35943. /**
  35944. * Time in milliseconds to delay before fading in (Default: 0)
  35945. */
  35946. delay: number;
  35947. /**
  35948. * Time in milliseconds for the mesh to fade in (Default: 300)
  35949. */
  35950. fadeInTime: number;
  35951. private _millisecondsPerFrame;
  35952. private _hovered;
  35953. private _hoverValue;
  35954. private _ownerNode;
  35955. /**
  35956. * Instatiates the FadeInOutBehavior
  35957. */
  35958. constructor();
  35959. /**
  35960. * The name of the behavior
  35961. */
  35962. readonly name: string;
  35963. /**
  35964. * Initializes the behavior
  35965. */
  35966. init(): void;
  35967. /**
  35968. * Attaches the fade behavior on the passed in mesh
  35969. * @param ownerNode The mesh that will be faded in/out once attached
  35970. */
  35971. attach(ownerNode: Mesh): void;
  35972. /**
  35973. * Detaches the behavior from the mesh
  35974. */
  35975. detach(): void;
  35976. /**
  35977. * Triggers the mesh to begin fading in or out
  35978. * @param value if the object should fade in or out (true to fade in)
  35979. */
  35980. fadeIn(value: boolean): void;
  35981. private _update;
  35982. private _setAllVisibility;
  35983. }
  35984. }
  35985. declare module BABYLON {
  35986. /**
  35987. * Class containing a set of static utilities functions for managing Pivots
  35988. * @hidden
  35989. */
  35990. export class PivotTools {
  35991. private static _PivotCached;
  35992. private static _OldPivotPoint;
  35993. private static _PivotTranslation;
  35994. private static _PivotTmpVector;
  35995. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35996. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35997. }
  35998. }
  35999. declare module BABYLON {
  36000. /**
  36001. * Class containing static functions to help procedurally build meshes
  36002. */
  36003. export class PlaneBuilder {
  36004. /**
  36005. * Creates a plane mesh
  36006. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36007. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36008. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36010. * * 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
  36011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36012. * @param name defines the name of the mesh
  36013. * @param options defines the options used to create the mesh
  36014. * @param scene defines the hosting scene
  36015. * @returns the plane mesh
  36016. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36017. */
  36018. static CreatePlane(name: string, options: {
  36019. size?: number;
  36020. width?: number;
  36021. height?: number;
  36022. sideOrientation?: number;
  36023. frontUVs?: Vector4;
  36024. backUVs?: Vector4;
  36025. updatable?: boolean;
  36026. sourcePlane?: Plane;
  36027. }, scene?: Nullable<Scene>): Mesh;
  36028. }
  36029. }
  36030. declare module BABYLON {
  36031. /**
  36032. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36033. */
  36034. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36035. private static _AnyMouseID;
  36036. /**
  36037. * Abstract mesh the behavior is set on
  36038. */
  36039. attachedNode: AbstractMesh;
  36040. private _dragPlane;
  36041. private _scene;
  36042. private _pointerObserver;
  36043. private _beforeRenderObserver;
  36044. private static _planeScene;
  36045. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36046. /**
  36047. * 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)
  36048. */
  36049. maxDragAngle: number;
  36050. /**
  36051. * @hidden
  36052. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36053. /**
  36054. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36055. */
  36056. currentDraggingPointerID: number;
  36057. /**
  36058. * The last position where the pointer hit the drag plane in world space
  36059. */
  36060. lastDragPosition: Vector3;
  36061. /**
  36062. * If the behavior is currently in a dragging state
  36063. */
  36064. dragging: boolean;
  36065. /**
  36066. * 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)
  36067. */
  36068. dragDeltaRatio: number;
  36069. /**
  36070. * If the drag plane orientation should be updated during the dragging (Default: true)
  36071. */
  36072. updateDragPlane: boolean;
  36073. private _debugMode;
  36074. private _moving;
  36075. /**
  36076. * Fires each time the attached mesh is dragged with the pointer
  36077. * * delta between last drag position and current drag position in world space
  36078. * * dragDistance along the drag axis
  36079. * * dragPlaneNormal normal of the current drag plane used during the drag
  36080. * * dragPlanePoint in world space where the drag intersects the drag plane
  36081. */
  36082. onDragObservable: Observable<{
  36083. delta: Vector3;
  36084. dragPlanePoint: Vector3;
  36085. dragPlaneNormal: Vector3;
  36086. dragDistance: number;
  36087. pointerId: number;
  36088. }>;
  36089. /**
  36090. * Fires each time a drag begins (eg. mouse down on mesh)
  36091. */
  36092. onDragStartObservable: Observable<{
  36093. dragPlanePoint: Vector3;
  36094. pointerId: number;
  36095. }>;
  36096. /**
  36097. * Fires each time a drag ends (eg. mouse release after drag)
  36098. */
  36099. onDragEndObservable: Observable<{
  36100. dragPlanePoint: Vector3;
  36101. pointerId: number;
  36102. }>;
  36103. /**
  36104. * If the attached mesh should be moved when dragged
  36105. */
  36106. moveAttached: boolean;
  36107. /**
  36108. * If the drag behavior will react to drag events (Default: true)
  36109. */
  36110. enabled: boolean;
  36111. /**
  36112. * If pointer events should start and release the drag (Default: true)
  36113. */
  36114. startAndReleaseDragOnPointerEvents: boolean;
  36115. /**
  36116. * If camera controls should be detached during the drag
  36117. */
  36118. detachCameraControls: boolean;
  36119. /**
  36120. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36121. */
  36122. useObjectOrienationForDragging: boolean;
  36123. private _options;
  36124. /**
  36125. * Creates a pointer drag behavior that can be attached to a mesh
  36126. * @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)
  36127. */
  36128. constructor(options?: {
  36129. dragAxis?: Vector3;
  36130. dragPlaneNormal?: Vector3;
  36131. });
  36132. /**
  36133. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36134. */
  36135. validateDrag: (targetPosition: Vector3) => boolean;
  36136. /**
  36137. * The name of the behavior
  36138. */
  36139. readonly name: string;
  36140. /**
  36141. * Initializes the behavior
  36142. */
  36143. init(): void;
  36144. private _tmpVector;
  36145. private _alternatePickedPoint;
  36146. private _worldDragAxis;
  36147. private _targetPosition;
  36148. private _attachedElement;
  36149. /**
  36150. * Attaches the drag behavior the passed in mesh
  36151. * @param ownerNode The mesh that will be dragged around once attached
  36152. * @param predicate Predicate to use for pick filtering
  36153. */
  36154. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36155. /**
  36156. * Force relase the drag action by code.
  36157. */
  36158. releaseDrag(): void;
  36159. private _startDragRay;
  36160. private _lastPointerRay;
  36161. /**
  36162. * Simulates the start of a pointer drag event on the behavior
  36163. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36164. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36165. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36166. */
  36167. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36168. private _startDrag;
  36169. private _dragDelta;
  36170. private _moveDrag;
  36171. private _pickWithRayOnDragPlane;
  36172. private _pointA;
  36173. private _pointB;
  36174. private _pointC;
  36175. private _lineA;
  36176. private _lineB;
  36177. private _localAxis;
  36178. private _lookAt;
  36179. private _updateDragPlanePosition;
  36180. /**
  36181. * Detaches the behavior from the mesh
  36182. */
  36183. detach(): void;
  36184. }
  36185. }
  36186. declare module BABYLON {
  36187. /**
  36188. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36189. */
  36190. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36191. private _dragBehaviorA;
  36192. private _dragBehaviorB;
  36193. private _startDistance;
  36194. private _initialScale;
  36195. private _targetScale;
  36196. private _ownerNode;
  36197. private _sceneRenderObserver;
  36198. /**
  36199. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36200. */
  36201. constructor();
  36202. /**
  36203. * The name of the behavior
  36204. */
  36205. readonly name: string;
  36206. /**
  36207. * Initializes the behavior
  36208. */
  36209. init(): void;
  36210. private _getCurrentDistance;
  36211. /**
  36212. * Attaches the scale behavior the passed in mesh
  36213. * @param ownerNode The mesh that will be scaled around once attached
  36214. */
  36215. attach(ownerNode: Mesh): void;
  36216. /**
  36217. * Detaches the behavior from the mesh
  36218. */
  36219. detach(): void;
  36220. }
  36221. }
  36222. declare module BABYLON {
  36223. /**
  36224. * 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
  36225. */
  36226. export class SixDofDragBehavior implements Behavior<Mesh> {
  36227. private static _virtualScene;
  36228. private _ownerNode;
  36229. private _sceneRenderObserver;
  36230. private _scene;
  36231. private _targetPosition;
  36232. private _virtualOriginMesh;
  36233. private _virtualDragMesh;
  36234. private _pointerObserver;
  36235. private _moving;
  36236. private _startingOrientation;
  36237. /**
  36238. * 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)
  36239. */
  36240. private zDragFactor;
  36241. /**
  36242. * If the object should rotate to face the drag origin
  36243. */
  36244. rotateDraggedObject: boolean;
  36245. /**
  36246. * If the behavior is currently in a dragging state
  36247. */
  36248. dragging: boolean;
  36249. /**
  36250. * 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)
  36251. */
  36252. dragDeltaRatio: number;
  36253. /**
  36254. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36255. */
  36256. currentDraggingPointerID: number;
  36257. /**
  36258. * If camera controls should be detached during the drag
  36259. */
  36260. detachCameraControls: boolean;
  36261. /**
  36262. * Fires each time a drag starts
  36263. */
  36264. onDragStartObservable: Observable<{}>;
  36265. /**
  36266. * Fires each time a drag ends (eg. mouse release after drag)
  36267. */
  36268. onDragEndObservable: Observable<{}>;
  36269. /**
  36270. * 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
  36271. */
  36272. constructor();
  36273. /**
  36274. * The name of the behavior
  36275. */
  36276. readonly name: string;
  36277. /**
  36278. * Initializes the behavior
  36279. */
  36280. init(): void;
  36281. /**
  36282. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36283. */
  36284. private readonly _pointerCamera;
  36285. /**
  36286. * Attaches the scale behavior the passed in mesh
  36287. * @param ownerNode The mesh that will be scaled around once attached
  36288. */
  36289. attach(ownerNode: Mesh): void;
  36290. /**
  36291. * Detaches the behavior from the mesh
  36292. */
  36293. detach(): void;
  36294. }
  36295. }
  36296. declare module BABYLON {
  36297. /**
  36298. * Class used to apply inverse kinematics to bones
  36299. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36300. */
  36301. export class BoneIKController {
  36302. private static _tmpVecs;
  36303. private static _tmpQuat;
  36304. private static _tmpMats;
  36305. /**
  36306. * Gets or sets the target mesh
  36307. */
  36308. targetMesh: AbstractMesh;
  36309. /** Gets or sets the mesh used as pole */
  36310. poleTargetMesh: AbstractMesh;
  36311. /**
  36312. * Gets or sets the bone used as pole
  36313. */
  36314. poleTargetBone: Nullable<Bone>;
  36315. /**
  36316. * Gets or sets the target position
  36317. */
  36318. targetPosition: Vector3;
  36319. /**
  36320. * Gets or sets the pole target position
  36321. */
  36322. poleTargetPosition: Vector3;
  36323. /**
  36324. * Gets or sets the pole target local offset
  36325. */
  36326. poleTargetLocalOffset: Vector3;
  36327. /**
  36328. * Gets or sets the pole angle
  36329. */
  36330. poleAngle: number;
  36331. /**
  36332. * Gets or sets the mesh associated with the controller
  36333. */
  36334. mesh: AbstractMesh;
  36335. /**
  36336. * 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)
  36337. */
  36338. slerpAmount: number;
  36339. private _bone1Quat;
  36340. private _bone1Mat;
  36341. private _bone2Ang;
  36342. private _bone1;
  36343. private _bone2;
  36344. private _bone1Length;
  36345. private _bone2Length;
  36346. private _maxAngle;
  36347. private _maxReach;
  36348. private _rightHandedSystem;
  36349. private _bendAxis;
  36350. private _slerping;
  36351. private _adjustRoll;
  36352. /**
  36353. * Gets or sets maximum allowed angle
  36354. */
  36355. maxAngle: number;
  36356. /**
  36357. * Creates a new BoneIKController
  36358. * @param mesh defines the mesh to control
  36359. * @param bone defines the bone to control
  36360. * @param options defines options to set up the controller
  36361. */
  36362. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36363. targetMesh?: AbstractMesh;
  36364. poleTargetMesh?: AbstractMesh;
  36365. poleTargetBone?: Bone;
  36366. poleTargetLocalOffset?: Vector3;
  36367. poleAngle?: number;
  36368. bendAxis?: Vector3;
  36369. maxAngle?: number;
  36370. slerpAmount?: number;
  36371. });
  36372. private _setMaxAngle;
  36373. /**
  36374. * Force the controller to update the bones
  36375. */
  36376. update(): void;
  36377. }
  36378. }
  36379. declare module BABYLON {
  36380. /**
  36381. * Class used to make a bone look toward a point in space
  36382. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36383. */
  36384. export class BoneLookController {
  36385. private static _tmpVecs;
  36386. private static _tmpQuat;
  36387. private static _tmpMats;
  36388. /**
  36389. * The target Vector3 that the bone will look at
  36390. */
  36391. target: Vector3;
  36392. /**
  36393. * The mesh that the bone is attached to
  36394. */
  36395. mesh: AbstractMesh;
  36396. /**
  36397. * The bone that will be looking to the target
  36398. */
  36399. bone: Bone;
  36400. /**
  36401. * The up axis of the coordinate system that is used when the bone is rotated
  36402. */
  36403. upAxis: Vector3;
  36404. /**
  36405. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36406. */
  36407. upAxisSpace: Space;
  36408. /**
  36409. * Used to make an adjustment to the yaw of the bone
  36410. */
  36411. adjustYaw: number;
  36412. /**
  36413. * Used to make an adjustment to the pitch of the bone
  36414. */
  36415. adjustPitch: number;
  36416. /**
  36417. * Used to make an adjustment to the roll of the bone
  36418. */
  36419. adjustRoll: number;
  36420. /**
  36421. * 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)
  36422. */
  36423. slerpAmount: number;
  36424. private _minYaw;
  36425. private _maxYaw;
  36426. private _minPitch;
  36427. private _maxPitch;
  36428. private _minYawSin;
  36429. private _minYawCos;
  36430. private _maxYawSin;
  36431. private _maxYawCos;
  36432. private _midYawConstraint;
  36433. private _minPitchTan;
  36434. private _maxPitchTan;
  36435. private _boneQuat;
  36436. private _slerping;
  36437. private _transformYawPitch;
  36438. private _transformYawPitchInv;
  36439. private _firstFrameSkipped;
  36440. private _yawRange;
  36441. private _fowardAxis;
  36442. /**
  36443. * Gets or sets the minimum yaw angle that the bone can look to
  36444. */
  36445. minYaw: number;
  36446. /**
  36447. * Gets or sets the maximum yaw angle that the bone can look to
  36448. */
  36449. maxYaw: number;
  36450. /**
  36451. * Gets or sets the minimum pitch angle that the bone can look to
  36452. */
  36453. minPitch: number;
  36454. /**
  36455. * Gets or sets the maximum pitch angle that the bone can look to
  36456. */
  36457. maxPitch: number;
  36458. /**
  36459. * Create a BoneLookController
  36460. * @param mesh the mesh that the bone belongs to
  36461. * @param bone the bone that will be looking to the target
  36462. * @param target the target Vector3 to look at
  36463. * @param options optional settings:
  36464. * * maxYaw: the maximum angle the bone will yaw to
  36465. * * minYaw: the minimum angle the bone will yaw to
  36466. * * maxPitch: the maximum angle the bone will pitch to
  36467. * * minPitch: the minimum angle the bone will yaw to
  36468. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36469. * * upAxis: the up axis of the coordinate system
  36470. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36471. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36472. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36473. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36474. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36475. * * adjustRoll: used to make an adjustment to the roll of the bone
  36476. **/
  36477. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36478. maxYaw?: number;
  36479. minYaw?: number;
  36480. maxPitch?: number;
  36481. minPitch?: number;
  36482. slerpAmount?: number;
  36483. upAxis?: Vector3;
  36484. upAxisSpace?: Space;
  36485. yawAxis?: Vector3;
  36486. pitchAxis?: Vector3;
  36487. adjustYaw?: number;
  36488. adjustPitch?: number;
  36489. adjustRoll?: number;
  36490. });
  36491. /**
  36492. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36493. */
  36494. update(): void;
  36495. private _getAngleDiff;
  36496. private _getAngleBetween;
  36497. private _isAngleBetween;
  36498. }
  36499. }
  36500. declare module BABYLON {
  36501. /**
  36502. * Manage the gamepad inputs to control an arc rotate camera.
  36503. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36504. */
  36505. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36506. /**
  36507. * Defines the camera the input is attached to.
  36508. */
  36509. camera: ArcRotateCamera;
  36510. /**
  36511. * Defines the gamepad the input is gathering event from.
  36512. */
  36513. gamepad: Nullable<Gamepad>;
  36514. /**
  36515. * Defines the gamepad rotation sensiblity.
  36516. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36517. */
  36518. gamepadRotationSensibility: number;
  36519. /**
  36520. * Defines the gamepad move sensiblity.
  36521. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36522. */
  36523. gamepadMoveSensibility: number;
  36524. private _onGamepadConnectedObserver;
  36525. private _onGamepadDisconnectedObserver;
  36526. /**
  36527. * Attach the input controls to a specific dom element to get the input from.
  36528. * @param element Defines the element the controls should be listened from
  36529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36530. */
  36531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36532. /**
  36533. * Detach the current controls from the specified dom element.
  36534. * @param element Defines the element to stop listening the inputs from
  36535. */
  36536. detachControl(element: Nullable<HTMLElement>): void;
  36537. /**
  36538. * Update the current camera state depending on the inputs that have been used this frame.
  36539. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36540. */
  36541. checkInputs(): void;
  36542. /**
  36543. * Gets the class name of the current intput.
  36544. * @returns the class name
  36545. */
  36546. getClassName(): string;
  36547. /**
  36548. * Get the friendly name associated with the input class.
  36549. * @returns the input friendly name
  36550. */
  36551. getSimpleName(): string;
  36552. }
  36553. }
  36554. declare module BABYLON {
  36555. interface ArcRotateCameraInputsManager {
  36556. /**
  36557. * Add orientation input support to the input manager.
  36558. * @returns the current input manager
  36559. */
  36560. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36561. }
  36562. /**
  36563. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36565. */
  36566. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36567. /**
  36568. * Defines the camera the input is attached to.
  36569. */
  36570. camera: ArcRotateCamera;
  36571. /**
  36572. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36573. */
  36574. alphaCorrection: number;
  36575. /**
  36576. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36577. */
  36578. gammaCorrection: number;
  36579. private _alpha;
  36580. private _gamma;
  36581. private _dirty;
  36582. private _deviceOrientationHandler;
  36583. /**
  36584. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36585. */
  36586. constructor();
  36587. /**
  36588. * Attach the input controls to a specific dom element to get the input from.
  36589. * @param element Defines the element the controls should be listened from
  36590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36591. */
  36592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36593. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36594. /**
  36595. * Update the current camera state depending on the inputs that have been used this frame.
  36596. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36597. */
  36598. checkInputs(): void;
  36599. /**
  36600. * Detach the current controls from the specified dom element.
  36601. * @param element Defines the element to stop listening the inputs from
  36602. */
  36603. detachControl(element: Nullable<HTMLElement>): void;
  36604. /**
  36605. * Gets the class name of the current intput.
  36606. * @returns the class name
  36607. */
  36608. getClassName(): string;
  36609. /**
  36610. * Get the friendly name associated with the input class.
  36611. * @returns the input friendly name
  36612. */
  36613. getSimpleName(): string;
  36614. }
  36615. }
  36616. declare module BABYLON {
  36617. /**
  36618. * Listen to mouse events to control the camera.
  36619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36620. */
  36621. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36622. /**
  36623. * Defines the camera the input is attached to.
  36624. */
  36625. camera: FlyCamera;
  36626. /**
  36627. * Defines if touch is enabled. (Default is true.)
  36628. */
  36629. touchEnabled: boolean;
  36630. /**
  36631. * Defines the buttons associated with the input to handle camera rotation.
  36632. */
  36633. buttons: number[];
  36634. /**
  36635. * Assign buttons for Yaw control.
  36636. */
  36637. buttonsYaw: number[];
  36638. /**
  36639. * Assign buttons for Pitch control.
  36640. */
  36641. buttonsPitch: number[];
  36642. /**
  36643. * Assign buttons for Roll control.
  36644. */
  36645. buttonsRoll: number[];
  36646. /**
  36647. * Detect if any button is being pressed while mouse is moved.
  36648. * -1 = Mouse locked.
  36649. * 0 = Left button.
  36650. * 1 = Middle Button.
  36651. * 2 = Right Button.
  36652. */
  36653. activeButton: number;
  36654. /**
  36655. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36656. * Higher values reduce its sensitivity.
  36657. */
  36658. angularSensibility: number;
  36659. private _mousemoveCallback;
  36660. private _observer;
  36661. private _rollObserver;
  36662. private previousPosition;
  36663. private noPreventDefault;
  36664. private element;
  36665. /**
  36666. * Listen to mouse events to control the camera.
  36667. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36669. */
  36670. constructor(touchEnabled?: boolean);
  36671. /**
  36672. * Attach the mouse control to the HTML DOM element.
  36673. * @param element Defines the element that listens to the input events.
  36674. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36675. */
  36676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36677. /**
  36678. * Detach the current controls from the specified dom element.
  36679. * @param element Defines the element to stop listening the inputs from
  36680. */
  36681. detachControl(element: Nullable<HTMLElement>): void;
  36682. /**
  36683. * Gets the class name of the current input.
  36684. * @returns the class name.
  36685. */
  36686. getClassName(): string;
  36687. /**
  36688. * Get the friendly name associated with the input class.
  36689. * @returns the input's friendly name.
  36690. */
  36691. getSimpleName(): string;
  36692. private _pointerInput;
  36693. private _onMouseMove;
  36694. /**
  36695. * Rotate camera by mouse offset.
  36696. */
  36697. private rotateCamera;
  36698. }
  36699. }
  36700. declare module BABYLON {
  36701. /**
  36702. * Default Inputs manager for the FlyCamera.
  36703. * It groups all the default supported inputs for ease of use.
  36704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36705. */
  36706. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36707. /**
  36708. * Instantiates a new FlyCameraInputsManager.
  36709. * @param camera Defines the camera the inputs belong to.
  36710. */
  36711. constructor(camera: FlyCamera);
  36712. /**
  36713. * Add keyboard input support to the input manager.
  36714. * @returns the new FlyCameraKeyboardMoveInput().
  36715. */
  36716. addKeyboard(): FlyCameraInputsManager;
  36717. /**
  36718. * Add mouse input support to the input manager.
  36719. * @param touchEnabled Enable touch screen support.
  36720. * @returns the new FlyCameraMouseInput().
  36721. */
  36722. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36723. }
  36724. }
  36725. declare module BABYLON {
  36726. /**
  36727. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36728. * such as in a 3D Space Shooter or a Flight Simulator.
  36729. */
  36730. export class FlyCamera extends TargetCamera {
  36731. /**
  36732. * Define the collision ellipsoid of the camera.
  36733. * This is helpful for simulating a camera body, like a player's body.
  36734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36735. */
  36736. ellipsoid: Vector3;
  36737. /**
  36738. * Define an offset for the position of the ellipsoid around the camera.
  36739. * This can be helpful if the camera is attached away from the player's body center,
  36740. * such as at its head.
  36741. */
  36742. ellipsoidOffset: Vector3;
  36743. /**
  36744. * Enable or disable collisions of the camera with the rest of the scene objects.
  36745. */
  36746. checkCollisions: boolean;
  36747. /**
  36748. * Enable or disable gravity on the camera.
  36749. */
  36750. applyGravity: boolean;
  36751. /**
  36752. * Define the current direction the camera is moving to.
  36753. */
  36754. cameraDirection: Vector3;
  36755. /**
  36756. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36757. * This overrides and empties cameraRotation.
  36758. */
  36759. rotationQuaternion: Quaternion;
  36760. /**
  36761. * Track Roll to maintain the wanted Rolling when looking around.
  36762. */ private _trackRoll: number;
  36763. /**
  36764. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36765. */
  36766. rollCorrect: number;
  36767. /**
  36768. * Mimic a banked turn, Rolling the camera when Yawing.
  36769. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36770. */
  36771. bankedTurn: boolean;
  36772. /**
  36773. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36774. */
  36775. bankedTurnLimit: number;
  36776. /**
  36777. * Value of 0 disables the banked Roll.
  36778. * Value of 1 is equal to the Yaw angle in radians.
  36779. */
  36780. bankedTurnMultiplier: number;
  36781. /**
  36782. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36783. */
  36784. inputs: FlyCameraInputsManager;
  36785. /**
  36786. * Gets the input sensibility for mouse input.
  36787. * Higher values reduce sensitivity.
  36788. */
  36789. /**
  36790. * Sets the input sensibility for a mouse input.
  36791. * Higher values reduce sensitivity.
  36792. */
  36793. angularSensibility: number;
  36794. /**
  36795. * Get the keys for camera movement forward.
  36796. */
  36797. /**
  36798. * Set the keys for camera movement forward.
  36799. */
  36800. keysForward: number[];
  36801. /**
  36802. * Get the keys for camera movement backward.
  36803. */
  36804. keysBackward: number[];
  36805. /**
  36806. * Get the keys for camera movement up.
  36807. */
  36808. /**
  36809. * Set the keys for camera movement up.
  36810. */
  36811. keysUp: number[];
  36812. /**
  36813. * Get the keys for camera movement down.
  36814. */
  36815. /**
  36816. * Set the keys for camera movement down.
  36817. */
  36818. keysDown: number[];
  36819. /**
  36820. * Get the keys for camera movement left.
  36821. */
  36822. /**
  36823. * Set the keys for camera movement left.
  36824. */
  36825. keysLeft: number[];
  36826. /**
  36827. * Set the keys for camera movement right.
  36828. */
  36829. /**
  36830. * Set the keys for camera movement right.
  36831. */
  36832. keysRight: number[];
  36833. /**
  36834. * Event raised when the camera collides with a mesh in the scene.
  36835. */
  36836. onCollide: (collidedMesh: AbstractMesh) => void;
  36837. private _collider;
  36838. private _needMoveForGravity;
  36839. private _oldPosition;
  36840. private _diffPosition;
  36841. private _newPosition;
  36842. /** @hidden */ private _localDirection: Vector3;
  36843. /** @hidden */ private _transformedDirection: Vector3;
  36844. /**
  36845. * Instantiates a FlyCamera.
  36846. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36847. * such as in a 3D Space Shooter or a Flight Simulator.
  36848. * @param name Define the name of the camera in the scene.
  36849. * @param position Define the starting position of the camera in the scene.
  36850. * @param scene Define the scene the camera belongs to.
  36851. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36852. */
  36853. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36854. /**
  36855. * Attach a control to the HTML DOM element.
  36856. * @param element Defines the element that listens to the input events.
  36857. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36858. */
  36859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36860. /**
  36861. * Detach a control from the HTML DOM element.
  36862. * The camera will stop reacting to that input.
  36863. * @param element Defines the element that listens to the input events.
  36864. */
  36865. detachControl(element: HTMLElement): void;
  36866. private _collisionMask;
  36867. /**
  36868. * Get the mask that the camera ignores in collision events.
  36869. */
  36870. /**
  36871. * Set the mask that the camera ignores in collision events.
  36872. */
  36873. collisionMask: number;
  36874. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  36875. /** @hidden */
  36876. private _onCollisionPositionChange;
  36877. /** @hidden */ private _checkInputs(): void;
  36878. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  36879. /** @hidden */ private _updatePosition(): void;
  36880. /**
  36881. * Restore the Roll to its target value at the rate specified.
  36882. * @param rate - Higher means slower restoring.
  36883. * @hidden
  36884. */
  36885. restoreRoll(rate: number): void;
  36886. /**
  36887. * Destroy the camera and release the current resources held by it.
  36888. */
  36889. dispose(): void;
  36890. /**
  36891. * Get the current object class name.
  36892. * @returns the class name.
  36893. */
  36894. getClassName(): string;
  36895. }
  36896. }
  36897. declare module BABYLON {
  36898. /**
  36899. * Listen to keyboard events to control the camera.
  36900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36901. */
  36902. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36903. /**
  36904. * Defines the camera the input is attached to.
  36905. */
  36906. camera: FlyCamera;
  36907. /**
  36908. * The list of keyboard keys used to control the forward move of the camera.
  36909. */
  36910. keysForward: number[];
  36911. /**
  36912. * The list of keyboard keys used to control the backward move of the camera.
  36913. */
  36914. keysBackward: number[];
  36915. /**
  36916. * The list of keyboard keys used to control the forward move of the camera.
  36917. */
  36918. keysUp: number[];
  36919. /**
  36920. * The list of keyboard keys used to control the backward move of the camera.
  36921. */
  36922. keysDown: number[];
  36923. /**
  36924. * The list of keyboard keys used to control the right strafe move of the camera.
  36925. */
  36926. keysRight: number[];
  36927. /**
  36928. * The list of keyboard keys used to control the left strafe move of the camera.
  36929. */
  36930. keysLeft: number[];
  36931. private _keys;
  36932. private _onCanvasBlurObserver;
  36933. private _onKeyboardObserver;
  36934. private _engine;
  36935. private _scene;
  36936. /**
  36937. * Attach the input controls to a specific dom element to get the input from.
  36938. * @param element Defines the element the controls should be listened from
  36939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36940. */
  36941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36942. /**
  36943. * Detach the current controls from the specified dom element.
  36944. * @param element Defines the element to stop listening the inputs from
  36945. */
  36946. detachControl(element: Nullable<HTMLElement>): void;
  36947. /**
  36948. * Gets the class name of the current intput.
  36949. * @returns the class name
  36950. */
  36951. getClassName(): string;
  36952. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  36953. /**
  36954. * Get the friendly name associated with the input class.
  36955. * @returns the input friendly name
  36956. */
  36957. getSimpleName(): string;
  36958. /**
  36959. * Update the current camera state depending on the inputs that have been used this frame.
  36960. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36961. */
  36962. checkInputs(): void;
  36963. }
  36964. }
  36965. declare module BABYLON {
  36966. /**
  36967. * Manage the mouse wheel inputs to control a follow camera.
  36968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36969. */
  36970. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36971. /**
  36972. * Defines the camera the input is attached to.
  36973. */
  36974. camera: FollowCamera;
  36975. /**
  36976. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36977. */
  36978. axisControlRadius: boolean;
  36979. /**
  36980. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36981. */
  36982. axisControlHeight: boolean;
  36983. /**
  36984. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36985. */
  36986. axisControlRotation: boolean;
  36987. /**
  36988. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36989. * relation to mouseWheel events.
  36990. */
  36991. wheelPrecision: number;
  36992. /**
  36993. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36994. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36995. */
  36996. wheelDeltaPercentage: number;
  36997. private _wheel;
  36998. private _observer;
  36999. /**
  37000. * Attach the input controls to a specific dom element to get the input from.
  37001. * @param element Defines the element the controls should be listened from
  37002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37003. */
  37004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37005. /**
  37006. * Detach the current controls from the specified dom element.
  37007. * @param element Defines the element to stop listening the inputs from
  37008. */
  37009. detachControl(element: Nullable<HTMLElement>): void;
  37010. /**
  37011. * Gets the class name of the current intput.
  37012. * @returns the class name
  37013. */
  37014. getClassName(): string;
  37015. /**
  37016. * Get the friendly name associated with the input class.
  37017. * @returns the input friendly name
  37018. */
  37019. getSimpleName(): string;
  37020. }
  37021. }
  37022. declare module BABYLON {
  37023. /**
  37024. * Manage the pointers inputs to control an follow camera.
  37025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37026. */
  37027. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37028. /**
  37029. * Defines the camera the input is attached to.
  37030. */
  37031. camera: FollowCamera;
  37032. /**
  37033. * Gets the class name of the current input.
  37034. * @returns the class name
  37035. */
  37036. getClassName(): string;
  37037. /**
  37038. * Defines the pointer angular sensibility along the X axis or how fast is
  37039. * the camera rotating.
  37040. * A negative number will reverse the axis direction.
  37041. */
  37042. angularSensibilityX: number;
  37043. /**
  37044. * Defines the pointer angular sensibility along the Y axis or how fast is
  37045. * the camera rotating.
  37046. * A negative number will reverse the axis direction.
  37047. */
  37048. angularSensibilityY: number;
  37049. /**
  37050. * Defines the pointer pinch precision or how fast is the camera zooming.
  37051. * A negative number will reverse the axis direction.
  37052. */
  37053. pinchPrecision: number;
  37054. /**
  37055. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37056. * from 0.
  37057. * It defines the percentage of current camera.radius to use as delta when
  37058. * pinch zoom is used.
  37059. */
  37060. pinchDeltaPercentage: number;
  37061. /**
  37062. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37063. */
  37064. axisXControlRadius: boolean;
  37065. /**
  37066. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37067. */
  37068. axisXControlHeight: boolean;
  37069. /**
  37070. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37071. */
  37072. axisXControlRotation: boolean;
  37073. /**
  37074. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37075. */
  37076. axisYControlRadius: boolean;
  37077. /**
  37078. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37079. */
  37080. axisYControlHeight: boolean;
  37081. /**
  37082. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37083. */
  37084. axisYControlRotation: boolean;
  37085. /**
  37086. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37087. */
  37088. axisPinchControlRadius: boolean;
  37089. /**
  37090. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37091. */
  37092. axisPinchControlHeight: boolean;
  37093. /**
  37094. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37095. */
  37096. axisPinchControlRotation: boolean;
  37097. /**
  37098. * Log error messages if basic misconfiguration has occurred.
  37099. */
  37100. warningEnable: boolean;
  37101. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37102. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37103. private _warningCounter;
  37104. private _warning;
  37105. }
  37106. }
  37107. declare module BABYLON {
  37108. /**
  37109. * Default Inputs manager for the FollowCamera.
  37110. * It groups all the default supported inputs for ease of use.
  37111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37112. */
  37113. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37114. /**
  37115. * Instantiates a new FollowCameraInputsManager.
  37116. * @param camera Defines the camera the inputs belong to
  37117. */
  37118. constructor(camera: FollowCamera);
  37119. /**
  37120. * Add keyboard input support to the input manager.
  37121. * @returns the current input manager
  37122. */
  37123. addKeyboard(): FollowCameraInputsManager;
  37124. /**
  37125. * Add mouse wheel input support to the input manager.
  37126. * @returns the current input manager
  37127. */
  37128. addMouseWheel(): FollowCameraInputsManager;
  37129. /**
  37130. * Add pointers input support to the input manager.
  37131. * @returns the current input manager
  37132. */
  37133. addPointers(): FollowCameraInputsManager;
  37134. /**
  37135. * Add orientation input support to the input manager.
  37136. * @returns the current input manager
  37137. */
  37138. addVRDeviceOrientation(): FollowCameraInputsManager;
  37139. }
  37140. }
  37141. declare module BABYLON {
  37142. /**
  37143. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37144. * an arc rotate version arcFollowCamera are available.
  37145. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37146. */
  37147. export class FollowCamera extends TargetCamera {
  37148. /**
  37149. * Distance the follow camera should follow an object at
  37150. */
  37151. radius: number;
  37152. /**
  37153. * Minimum allowed distance of the camera to the axis of rotation
  37154. * (The camera can not get closer).
  37155. * This can help limiting how the Camera is able to move in the scene.
  37156. */
  37157. lowerRadiusLimit: Nullable<number>;
  37158. /**
  37159. * Maximum allowed distance of the camera to the axis of rotation
  37160. * (The camera can not get further).
  37161. * This can help limiting how the Camera is able to move in the scene.
  37162. */
  37163. upperRadiusLimit: Nullable<number>;
  37164. /**
  37165. * Define a rotation offset between the camera and the object it follows
  37166. */
  37167. rotationOffset: number;
  37168. /**
  37169. * Minimum allowed angle to camera position relative to target object.
  37170. * This can help limiting how the Camera is able to move in the scene.
  37171. */
  37172. lowerRotationOffsetLimit: Nullable<number>;
  37173. /**
  37174. * Maximum allowed angle to camera position relative to target object.
  37175. * This can help limiting how the Camera is able to move in the scene.
  37176. */
  37177. upperRotationOffsetLimit: Nullable<number>;
  37178. /**
  37179. * Define a height offset between the camera and the object it follows.
  37180. * It can help following an object from the top (like a car chaing a plane)
  37181. */
  37182. heightOffset: number;
  37183. /**
  37184. * Minimum allowed height of camera position relative to target object.
  37185. * This can help limiting how the Camera is able to move in the scene.
  37186. */
  37187. lowerHeightOffsetLimit: Nullable<number>;
  37188. /**
  37189. * Maximum allowed height of camera position relative to target object.
  37190. * This can help limiting how the Camera is able to move in the scene.
  37191. */
  37192. upperHeightOffsetLimit: Nullable<number>;
  37193. /**
  37194. * Define how fast the camera can accelerate to follow it s target.
  37195. */
  37196. cameraAcceleration: number;
  37197. /**
  37198. * Define the speed limit of the camera following an object.
  37199. */
  37200. maxCameraSpeed: number;
  37201. /**
  37202. * Define the target of the camera.
  37203. */
  37204. lockedTarget: Nullable<AbstractMesh>;
  37205. /**
  37206. * Defines the input associated with the camera.
  37207. */
  37208. inputs: FollowCameraInputsManager;
  37209. /**
  37210. * Instantiates the follow camera.
  37211. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37212. * @param name Define the name of the camera in the scene
  37213. * @param position Define the position of the camera
  37214. * @param scene Define the scene the camera belong to
  37215. * @param lockedTarget Define the target of the camera
  37216. */
  37217. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37218. private _follow;
  37219. /**
  37220. * Attached controls to the current camera.
  37221. * @param element Defines the element the controls should be listened from
  37222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37223. */
  37224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37225. /**
  37226. * Detach the current controls from the camera.
  37227. * The camera will stop reacting to inputs.
  37228. * @param element Defines the element to stop listening the inputs from
  37229. */
  37230. detachControl(element: HTMLElement): void;
  37231. /** @hidden */ private _checkInputs(): void;
  37232. private _checkLimits;
  37233. /**
  37234. * Gets the camera class name.
  37235. * @returns the class name
  37236. */
  37237. getClassName(): string;
  37238. }
  37239. /**
  37240. * Arc Rotate version of the follow camera.
  37241. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37242. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37243. */
  37244. export class ArcFollowCamera extends TargetCamera {
  37245. /** The longitudinal angle of the camera */
  37246. alpha: number;
  37247. /** The latitudinal angle of the camera */
  37248. beta: number;
  37249. /** The radius of the camera from its target */
  37250. radius: number;
  37251. /** Define the camera target (the messh it should follow) */
  37252. target: Nullable<AbstractMesh>;
  37253. private _cartesianCoordinates;
  37254. /**
  37255. * Instantiates a new ArcFollowCamera
  37256. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37257. * @param name Define the name of the camera
  37258. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37259. * @param beta Define the rotation angle of the camera around the elevation axis
  37260. * @param radius Define the radius of the camera from its target point
  37261. * @param target Define the target of the camera
  37262. * @param scene Define the scene the camera belongs to
  37263. */
  37264. constructor(name: string,
  37265. /** The longitudinal angle of the camera */
  37266. alpha: number,
  37267. /** The latitudinal angle of the camera */
  37268. beta: number,
  37269. /** The radius of the camera from its target */
  37270. radius: number,
  37271. /** Define the camera target (the messh it should follow) */
  37272. target: Nullable<AbstractMesh>, scene: Scene);
  37273. private _follow;
  37274. /** @hidden */ private _checkInputs(): void;
  37275. /**
  37276. * Returns the class name of the object.
  37277. * It is mostly used internally for serialization purposes.
  37278. */
  37279. getClassName(): string;
  37280. }
  37281. }
  37282. declare module BABYLON {
  37283. /**
  37284. * Manage the keyboard inputs to control the movement of a follow camera.
  37285. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37286. */
  37287. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37288. /**
  37289. * Defines the camera the input is attached to.
  37290. */
  37291. camera: FollowCamera;
  37292. /**
  37293. * Defines the list of key codes associated with the up action (increase heightOffset)
  37294. */
  37295. keysHeightOffsetIncr: number[];
  37296. /**
  37297. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37298. */
  37299. keysHeightOffsetDecr: number[];
  37300. /**
  37301. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37302. */
  37303. keysHeightOffsetModifierAlt: boolean;
  37304. /**
  37305. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37306. */
  37307. keysHeightOffsetModifierCtrl: boolean;
  37308. /**
  37309. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37310. */
  37311. keysHeightOffsetModifierShift: boolean;
  37312. /**
  37313. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37314. */
  37315. keysRotationOffsetIncr: number[];
  37316. /**
  37317. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37318. */
  37319. keysRotationOffsetDecr: number[];
  37320. /**
  37321. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37322. */
  37323. keysRotationOffsetModifierAlt: boolean;
  37324. /**
  37325. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37326. */
  37327. keysRotationOffsetModifierCtrl: boolean;
  37328. /**
  37329. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37330. */
  37331. keysRotationOffsetModifierShift: boolean;
  37332. /**
  37333. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37334. */
  37335. keysRadiusIncr: number[];
  37336. /**
  37337. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37338. */
  37339. keysRadiusDecr: number[];
  37340. /**
  37341. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37342. */
  37343. keysRadiusModifierAlt: boolean;
  37344. /**
  37345. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37346. */
  37347. keysRadiusModifierCtrl: boolean;
  37348. /**
  37349. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37350. */
  37351. keysRadiusModifierShift: boolean;
  37352. /**
  37353. * Defines the rate of change of heightOffset.
  37354. */
  37355. heightSensibility: number;
  37356. /**
  37357. * Defines the rate of change of rotationOffset.
  37358. */
  37359. rotationSensibility: number;
  37360. /**
  37361. * Defines the rate of change of radius.
  37362. */
  37363. radiusSensibility: number;
  37364. private _keys;
  37365. private _ctrlPressed;
  37366. private _altPressed;
  37367. private _shiftPressed;
  37368. private _onCanvasBlurObserver;
  37369. private _onKeyboardObserver;
  37370. private _engine;
  37371. private _scene;
  37372. /**
  37373. * Attach the input controls to a specific dom element to get the input from.
  37374. * @param element Defines the element the controls should be listened from
  37375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37376. */
  37377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37378. /**
  37379. * Detach the current controls from the specified dom element.
  37380. * @param element Defines the element to stop listening the inputs from
  37381. */
  37382. detachControl(element: Nullable<HTMLElement>): void;
  37383. /**
  37384. * Update the current camera state depending on the inputs that have been used this frame.
  37385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37386. */
  37387. checkInputs(): void;
  37388. /**
  37389. * Gets the class name of the current input.
  37390. * @returns the class name
  37391. */
  37392. getClassName(): string;
  37393. /**
  37394. * Get the friendly name associated with the input class.
  37395. * @returns the input friendly name
  37396. */
  37397. getSimpleName(): string;
  37398. /**
  37399. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37400. * allow modification of the heightOffset value.
  37401. */
  37402. private _modifierHeightOffset;
  37403. /**
  37404. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37405. * allow modification of the rotationOffset value.
  37406. */
  37407. private _modifierRotationOffset;
  37408. /**
  37409. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37410. * allow modification of the radius value.
  37411. */
  37412. private _modifierRadius;
  37413. }
  37414. }
  37415. declare module BABYLON {
  37416. interface FreeCameraInputsManager {
  37417. /**
  37418. * @hidden
  37419. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37420. /**
  37421. * Add orientation input support to the input manager.
  37422. * @returns the current input manager
  37423. */
  37424. addDeviceOrientation(): FreeCameraInputsManager;
  37425. }
  37426. /**
  37427. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37428. * Screen rotation is taken into account.
  37429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37430. */
  37431. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37432. private _camera;
  37433. private _screenOrientationAngle;
  37434. private _constantTranform;
  37435. private _screenQuaternion;
  37436. private _alpha;
  37437. private _beta;
  37438. private _gamma;
  37439. /**
  37440. * Can be used to detect if a device orientation sensor is availible on a device
  37441. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37442. * @returns a promise that will resolve on orientation change
  37443. */
  37444. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37445. /**
  37446. * @hidden
  37447. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37448. /**
  37449. * Instantiates a new input
  37450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37451. */
  37452. constructor();
  37453. /**
  37454. * Define the camera controlled by the input.
  37455. */
  37456. camera: FreeCamera;
  37457. /**
  37458. * Attach the input controls to a specific dom element to get the input from.
  37459. * @param element Defines the element the controls should be listened from
  37460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37461. */
  37462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37463. private _orientationChanged;
  37464. private _deviceOrientation;
  37465. /**
  37466. * Detach the current controls from the specified dom element.
  37467. * @param element Defines the element to stop listening the inputs from
  37468. */
  37469. detachControl(element: Nullable<HTMLElement>): void;
  37470. /**
  37471. * Update the current camera state depending on the inputs that have been used this frame.
  37472. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37473. */
  37474. checkInputs(): void;
  37475. /**
  37476. * Gets the class name of the current intput.
  37477. * @returns the class name
  37478. */
  37479. getClassName(): string;
  37480. /**
  37481. * Get the friendly name associated with the input class.
  37482. * @returns the input friendly name
  37483. */
  37484. getSimpleName(): string;
  37485. }
  37486. }
  37487. declare module BABYLON {
  37488. /**
  37489. * Manage the gamepad inputs to control a free camera.
  37490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37491. */
  37492. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37493. /**
  37494. * Define the camera the input is attached to.
  37495. */
  37496. camera: FreeCamera;
  37497. /**
  37498. * Define the Gamepad controlling the input
  37499. */
  37500. gamepad: Nullable<Gamepad>;
  37501. /**
  37502. * Defines the gamepad rotation sensiblity.
  37503. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37504. */
  37505. gamepadAngularSensibility: number;
  37506. /**
  37507. * Defines the gamepad move sensiblity.
  37508. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37509. */
  37510. gamepadMoveSensibility: number;
  37511. private _onGamepadConnectedObserver;
  37512. private _onGamepadDisconnectedObserver;
  37513. private _cameraTransform;
  37514. private _deltaTransform;
  37515. private _vector3;
  37516. private _vector2;
  37517. /**
  37518. * Attach the input controls to a specific dom element to get the input from.
  37519. * @param element Defines the element the controls should be listened from
  37520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37521. */
  37522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37523. /**
  37524. * Detach the current controls from the specified dom element.
  37525. * @param element Defines the element to stop listening the inputs from
  37526. */
  37527. detachControl(element: Nullable<HTMLElement>): void;
  37528. /**
  37529. * Update the current camera state depending on the inputs that have been used this frame.
  37530. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37531. */
  37532. checkInputs(): void;
  37533. /**
  37534. * Gets the class name of the current intput.
  37535. * @returns the class name
  37536. */
  37537. getClassName(): string;
  37538. /**
  37539. * Get the friendly name associated with the input class.
  37540. * @returns the input friendly name
  37541. */
  37542. getSimpleName(): string;
  37543. }
  37544. }
  37545. declare module BABYLON {
  37546. /**
  37547. * Defines the potential axis of a Joystick
  37548. */
  37549. export enum JoystickAxis {
  37550. /** X axis */
  37551. X = 0,
  37552. /** Y axis */
  37553. Y = 1,
  37554. /** Z axis */
  37555. Z = 2
  37556. }
  37557. /**
  37558. * Class used to define virtual joystick (used in touch mode)
  37559. */
  37560. export class VirtualJoystick {
  37561. /**
  37562. * Gets or sets a boolean indicating that left and right values must be inverted
  37563. */
  37564. reverseLeftRight: boolean;
  37565. /**
  37566. * Gets or sets a boolean indicating that up and down values must be inverted
  37567. */
  37568. reverseUpDown: boolean;
  37569. /**
  37570. * Gets the offset value for the position (ie. the change of the position value)
  37571. */
  37572. deltaPosition: Vector3;
  37573. /**
  37574. * Gets a boolean indicating if the virtual joystick was pressed
  37575. */
  37576. pressed: boolean;
  37577. /**
  37578. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37579. */
  37580. static Canvas: Nullable<HTMLCanvasElement>;
  37581. private static _globalJoystickIndex;
  37582. private static vjCanvasContext;
  37583. private static vjCanvasWidth;
  37584. private static vjCanvasHeight;
  37585. private static halfWidth;
  37586. private _action;
  37587. private _axisTargetedByLeftAndRight;
  37588. private _axisTargetedByUpAndDown;
  37589. private _joystickSensibility;
  37590. private _inversedSensibility;
  37591. private _joystickPointerID;
  37592. private _joystickColor;
  37593. private _joystickPointerPos;
  37594. private _joystickPreviousPointerPos;
  37595. private _joystickPointerStartPos;
  37596. private _deltaJoystickVector;
  37597. private _leftJoystick;
  37598. private _touches;
  37599. private _onPointerDownHandlerRef;
  37600. private _onPointerMoveHandlerRef;
  37601. private _onPointerUpHandlerRef;
  37602. private _onResize;
  37603. /**
  37604. * Creates a new virtual joystick
  37605. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37606. */
  37607. constructor(leftJoystick?: boolean);
  37608. /**
  37609. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37610. * @param newJoystickSensibility defines the new sensibility
  37611. */
  37612. setJoystickSensibility(newJoystickSensibility: number): void;
  37613. private _onPointerDown;
  37614. private _onPointerMove;
  37615. private _onPointerUp;
  37616. /**
  37617. * Change the color of the virtual joystick
  37618. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37619. */
  37620. setJoystickColor(newColor: string): void;
  37621. /**
  37622. * Defines a callback to call when the joystick is touched
  37623. * @param action defines the callback
  37624. */
  37625. setActionOnTouch(action: () => any): void;
  37626. /**
  37627. * Defines which axis you'd like to control for left & right
  37628. * @param axis defines the axis to use
  37629. */
  37630. setAxisForLeftRight(axis: JoystickAxis): void;
  37631. /**
  37632. * Defines which axis you'd like to control for up & down
  37633. * @param axis defines the axis to use
  37634. */
  37635. setAxisForUpDown(axis: JoystickAxis): void;
  37636. private _drawVirtualJoystick;
  37637. /**
  37638. * Release internal HTML canvas
  37639. */
  37640. releaseCanvas(): void;
  37641. }
  37642. }
  37643. declare module BABYLON {
  37644. interface FreeCameraInputsManager {
  37645. /**
  37646. * Add virtual joystick input support to the input manager.
  37647. * @returns the current input manager
  37648. */
  37649. addVirtualJoystick(): FreeCameraInputsManager;
  37650. }
  37651. /**
  37652. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37654. */
  37655. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37656. /**
  37657. * Defines the camera the input is attached to.
  37658. */
  37659. camera: FreeCamera;
  37660. private _leftjoystick;
  37661. private _rightjoystick;
  37662. /**
  37663. * Gets the left stick of the virtual joystick.
  37664. * @returns The virtual Joystick
  37665. */
  37666. getLeftJoystick(): VirtualJoystick;
  37667. /**
  37668. * Gets the right stick of the virtual joystick.
  37669. * @returns The virtual Joystick
  37670. */
  37671. getRightJoystick(): VirtualJoystick;
  37672. /**
  37673. * Update the current camera state depending on the inputs that have been used this frame.
  37674. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37675. */
  37676. checkInputs(): void;
  37677. /**
  37678. * Attach the input controls to a specific dom element to get the input from.
  37679. * @param element Defines the element the controls should be listened from
  37680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37681. */
  37682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37683. /**
  37684. * Detach the current controls from the specified dom element.
  37685. * @param element Defines the element to stop listening the inputs from
  37686. */
  37687. detachControl(element: Nullable<HTMLElement>): void;
  37688. /**
  37689. * Gets the class name of the current intput.
  37690. * @returns the class name
  37691. */
  37692. getClassName(): string;
  37693. /**
  37694. * Get the friendly name associated with the input class.
  37695. * @returns the input friendly name
  37696. */
  37697. getSimpleName(): string;
  37698. }
  37699. }
  37700. declare module BABYLON {
  37701. /**
  37702. * This represents a FPS type of camera controlled by touch.
  37703. * This is like a universal camera minus the Gamepad controls.
  37704. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37705. */
  37706. export class TouchCamera extends FreeCamera {
  37707. /**
  37708. * Defines the touch sensibility for rotation.
  37709. * The higher the faster.
  37710. */
  37711. touchAngularSensibility: number;
  37712. /**
  37713. * Defines the touch sensibility for move.
  37714. * The higher the faster.
  37715. */
  37716. touchMoveSensibility: number;
  37717. /**
  37718. * Instantiates a new touch camera.
  37719. * This represents a FPS type of camera controlled by touch.
  37720. * This is like a universal camera minus the Gamepad controls.
  37721. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37722. * @param name Define the name of the camera in the scene
  37723. * @param position Define the start position of the camera in the scene
  37724. * @param scene Define the scene the camera belongs to
  37725. */
  37726. constructor(name: string, position: Vector3, scene: Scene);
  37727. /**
  37728. * Gets the current object class name.
  37729. * @return the class name
  37730. */
  37731. getClassName(): string;
  37732. /** @hidden */ private _setupInputs(): void;
  37733. }
  37734. }
  37735. declare module BABYLON {
  37736. /**
  37737. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37738. * being tilted forward or back and left or right.
  37739. */
  37740. export class DeviceOrientationCamera extends FreeCamera {
  37741. private _initialQuaternion;
  37742. private _quaternionCache;
  37743. private _tmpDragQuaternion;
  37744. private _disablePointerInputWhenUsingDeviceOrientation;
  37745. /**
  37746. * Creates a new device orientation camera
  37747. * @param name The name of the camera
  37748. * @param position The start position camera
  37749. * @param scene The scene the camera belongs to
  37750. */
  37751. constructor(name: string, position: Vector3, scene: Scene);
  37752. /**
  37753. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  37754. */
  37755. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37756. private _dragFactor;
  37757. /**
  37758. * Enabled turning on the y axis when the orientation sensor is active
  37759. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37760. */
  37761. enableHorizontalDragging(dragFactor?: number): void;
  37762. /**
  37763. * Gets the current instance class name ("DeviceOrientationCamera").
  37764. * This helps avoiding instanceof at run time.
  37765. * @returns the class name
  37766. */
  37767. getClassName(): string;
  37768. /**
  37769. * @hidden
  37770. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37771. */ private _checkInputs(): void;
  37772. /**
  37773. * Reset the camera to its default orientation on the specified axis only.
  37774. * @param axis The axis to reset
  37775. */
  37776. resetToCurrentRotation(axis?: Axis): void;
  37777. }
  37778. }
  37779. declare module BABYLON {
  37780. /**
  37781. * Defines supported buttons for XBox360 compatible gamepads
  37782. */
  37783. export enum Xbox360Button {
  37784. /** A */
  37785. A = 0,
  37786. /** B */
  37787. B = 1,
  37788. /** X */
  37789. X = 2,
  37790. /** Y */
  37791. Y = 3,
  37792. /** Start */
  37793. Start = 4,
  37794. /** Back */
  37795. Back = 5,
  37796. /** Left button */
  37797. LB = 6,
  37798. /** Right button */
  37799. RB = 7,
  37800. /** Left stick */
  37801. LeftStick = 8,
  37802. /** Right stick */
  37803. RightStick = 9
  37804. }
  37805. /** Defines values for XBox360 DPad */
  37806. export enum Xbox360Dpad {
  37807. /** Up */
  37808. Up = 0,
  37809. /** Down */
  37810. Down = 1,
  37811. /** Left */
  37812. Left = 2,
  37813. /** Right */
  37814. Right = 3
  37815. }
  37816. /**
  37817. * Defines a XBox360 gamepad
  37818. */
  37819. export class Xbox360Pad extends Gamepad {
  37820. private _leftTrigger;
  37821. private _rightTrigger;
  37822. private _onlefttriggerchanged;
  37823. private _onrighttriggerchanged;
  37824. private _onbuttondown;
  37825. private _onbuttonup;
  37826. private _ondpaddown;
  37827. private _ondpadup;
  37828. /** Observable raised when a button is pressed */
  37829. onButtonDownObservable: Observable<Xbox360Button>;
  37830. /** Observable raised when a button is released */
  37831. onButtonUpObservable: Observable<Xbox360Button>;
  37832. /** Observable raised when a pad is pressed */
  37833. onPadDownObservable: Observable<Xbox360Dpad>;
  37834. /** Observable raised when a pad is released */
  37835. onPadUpObservable: Observable<Xbox360Dpad>;
  37836. private _buttonA;
  37837. private _buttonB;
  37838. private _buttonX;
  37839. private _buttonY;
  37840. private _buttonBack;
  37841. private _buttonStart;
  37842. private _buttonLB;
  37843. private _buttonRB;
  37844. private _buttonLeftStick;
  37845. private _buttonRightStick;
  37846. private _dPadUp;
  37847. private _dPadDown;
  37848. private _dPadLeft;
  37849. private _dPadRight;
  37850. private _isXboxOnePad;
  37851. /**
  37852. * Creates a new XBox360 gamepad object
  37853. * @param id defines the id of this gamepad
  37854. * @param index defines its index
  37855. * @param gamepad defines the internal HTML gamepad object
  37856. * @param xboxOne defines if it is a XBox One gamepad
  37857. */
  37858. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37859. /**
  37860. * Defines the callback to call when left trigger is pressed
  37861. * @param callback defines the callback to use
  37862. */
  37863. onlefttriggerchanged(callback: (value: number) => void): void;
  37864. /**
  37865. * Defines the callback to call when right trigger is pressed
  37866. * @param callback defines the callback to use
  37867. */
  37868. onrighttriggerchanged(callback: (value: number) => void): void;
  37869. /**
  37870. * Gets the left trigger value
  37871. */
  37872. /**
  37873. * Sets the left trigger value
  37874. */
  37875. leftTrigger: number;
  37876. /**
  37877. * Gets the right trigger value
  37878. */
  37879. /**
  37880. * Sets the right trigger value
  37881. */
  37882. rightTrigger: number;
  37883. /**
  37884. * Defines the callback to call when a button is pressed
  37885. * @param callback defines the callback to use
  37886. */
  37887. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37888. /**
  37889. * Defines the callback to call when a button is released
  37890. * @param callback defines the callback to use
  37891. */
  37892. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37893. /**
  37894. * Defines the callback to call when a pad is pressed
  37895. * @param callback defines the callback to use
  37896. */
  37897. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37898. /**
  37899. * Defines the callback to call when a pad is released
  37900. * @param callback defines the callback to use
  37901. */
  37902. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37903. private _setButtonValue;
  37904. private _setDPadValue;
  37905. /**
  37906. * Gets the value of the `A` button
  37907. */
  37908. /**
  37909. * Sets the value of the `A` button
  37910. */
  37911. buttonA: number;
  37912. /**
  37913. * Gets the value of the `B` button
  37914. */
  37915. /**
  37916. * Sets the value of the `B` button
  37917. */
  37918. buttonB: number;
  37919. /**
  37920. * Gets the value of the `X` button
  37921. */
  37922. /**
  37923. * Sets the value of the `X` button
  37924. */
  37925. buttonX: number;
  37926. /**
  37927. * Gets the value of the `Y` button
  37928. */
  37929. /**
  37930. * Sets the value of the `Y` button
  37931. */
  37932. buttonY: number;
  37933. /**
  37934. * Gets the value of the `Start` button
  37935. */
  37936. /**
  37937. * Sets the value of the `Start` button
  37938. */
  37939. buttonStart: number;
  37940. /**
  37941. * Gets the value of the `Back` button
  37942. */
  37943. /**
  37944. * Sets the value of the `Back` button
  37945. */
  37946. buttonBack: number;
  37947. /**
  37948. * Gets the value of the `Left` button
  37949. */
  37950. /**
  37951. * Sets the value of the `Left` button
  37952. */
  37953. buttonLB: number;
  37954. /**
  37955. * Gets the value of the `Right` button
  37956. */
  37957. /**
  37958. * Sets the value of the `Right` button
  37959. */
  37960. buttonRB: number;
  37961. /**
  37962. * Gets the value of the Left joystick
  37963. */
  37964. /**
  37965. * Sets the value of the Left joystick
  37966. */
  37967. buttonLeftStick: number;
  37968. /**
  37969. * Gets the value of the Right joystick
  37970. */
  37971. /**
  37972. * Sets the value of the Right joystick
  37973. */
  37974. buttonRightStick: number;
  37975. /**
  37976. * Gets the value of D-pad up
  37977. */
  37978. /**
  37979. * Sets the value of D-pad up
  37980. */
  37981. dPadUp: number;
  37982. /**
  37983. * Gets the value of D-pad down
  37984. */
  37985. /**
  37986. * Sets the value of D-pad down
  37987. */
  37988. dPadDown: number;
  37989. /**
  37990. * Gets the value of D-pad left
  37991. */
  37992. /**
  37993. * Sets the value of D-pad left
  37994. */
  37995. dPadLeft: number;
  37996. /**
  37997. * Gets the value of D-pad right
  37998. */
  37999. /**
  38000. * Sets the value of D-pad right
  38001. */
  38002. dPadRight: number;
  38003. /**
  38004. * Force the gamepad to synchronize with device values
  38005. */
  38006. update(): void;
  38007. /**
  38008. * Disposes the gamepad
  38009. */
  38010. dispose(): void;
  38011. }
  38012. }
  38013. declare module BABYLON {
  38014. /**
  38015. * Defines supported buttons for DualShock compatible gamepads
  38016. */
  38017. export enum DualShockButton {
  38018. /** Cross */
  38019. Cross = 0,
  38020. /** Circle */
  38021. Circle = 1,
  38022. /** Square */
  38023. Square = 2,
  38024. /** Triangle */
  38025. Triangle = 3,
  38026. /** Options */
  38027. Options = 4,
  38028. /** Share */
  38029. Share = 5,
  38030. /** L1 */
  38031. L1 = 6,
  38032. /** R1 */
  38033. R1 = 7,
  38034. /** Left stick */
  38035. LeftStick = 8,
  38036. /** Right stick */
  38037. RightStick = 9
  38038. }
  38039. /** Defines values for DualShock DPad */
  38040. export enum DualShockDpad {
  38041. /** Up */
  38042. Up = 0,
  38043. /** Down */
  38044. Down = 1,
  38045. /** Left */
  38046. Left = 2,
  38047. /** Right */
  38048. Right = 3
  38049. }
  38050. /**
  38051. * Defines a DualShock gamepad
  38052. */
  38053. export class DualShockPad extends Gamepad {
  38054. private _leftTrigger;
  38055. private _rightTrigger;
  38056. private _onlefttriggerchanged;
  38057. private _onrighttriggerchanged;
  38058. private _onbuttondown;
  38059. private _onbuttonup;
  38060. private _ondpaddown;
  38061. private _ondpadup;
  38062. /** Observable raised when a button is pressed */
  38063. onButtonDownObservable: Observable<DualShockButton>;
  38064. /** Observable raised when a button is released */
  38065. onButtonUpObservable: Observable<DualShockButton>;
  38066. /** Observable raised when a pad is pressed */
  38067. onPadDownObservable: Observable<DualShockDpad>;
  38068. /** Observable raised when a pad is released */
  38069. onPadUpObservable: Observable<DualShockDpad>;
  38070. private _buttonCross;
  38071. private _buttonCircle;
  38072. private _buttonSquare;
  38073. private _buttonTriangle;
  38074. private _buttonShare;
  38075. private _buttonOptions;
  38076. private _buttonL1;
  38077. private _buttonR1;
  38078. private _buttonLeftStick;
  38079. private _buttonRightStick;
  38080. private _dPadUp;
  38081. private _dPadDown;
  38082. private _dPadLeft;
  38083. private _dPadRight;
  38084. /**
  38085. * Creates a new DualShock gamepad object
  38086. * @param id defines the id of this gamepad
  38087. * @param index defines its index
  38088. * @param gamepad defines the internal HTML gamepad object
  38089. */
  38090. constructor(id: string, index: number, gamepad: any);
  38091. /**
  38092. * Defines the callback to call when left trigger is pressed
  38093. * @param callback defines the callback to use
  38094. */
  38095. onlefttriggerchanged(callback: (value: number) => void): void;
  38096. /**
  38097. * Defines the callback to call when right trigger is pressed
  38098. * @param callback defines the callback to use
  38099. */
  38100. onrighttriggerchanged(callback: (value: number) => void): void;
  38101. /**
  38102. * Gets the left trigger value
  38103. */
  38104. /**
  38105. * Sets the left trigger value
  38106. */
  38107. leftTrigger: number;
  38108. /**
  38109. * Gets the right trigger value
  38110. */
  38111. /**
  38112. * Sets the right trigger value
  38113. */
  38114. rightTrigger: number;
  38115. /**
  38116. * Defines the callback to call when a button is pressed
  38117. * @param callback defines the callback to use
  38118. */
  38119. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38120. /**
  38121. * Defines the callback to call when a button is released
  38122. * @param callback defines the callback to use
  38123. */
  38124. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38125. /**
  38126. * Defines the callback to call when a pad is pressed
  38127. * @param callback defines the callback to use
  38128. */
  38129. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38130. /**
  38131. * Defines the callback to call when a pad is released
  38132. * @param callback defines the callback to use
  38133. */
  38134. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38135. private _setButtonValue;
  38136. private _setDPadValue;
  38137. /**
  38138. * Gets the value of the `Cross` button
  38139. */
  38140. /**
  38141. * Sets the value of the `Cross` button
  38142. */
  38143. buttonCross: number;
  38144. /**
  38145. * Gets the value of the `Circle` button
  38146. */
  38147. /**
  38148. * Sets the value of the `Circle` button
  38149. */
  38150. buttonCircle: number;
  38151. /**
  38152. * Gets the value of the `Square` button
  38153. */
  38154. /**
  38155. * Sets the value of the `Square` button
  38156. */
  38157. buttonSquare: number;
  38158. /**
  38159. * Gets the value of the `Triangle` button
  38160. */
  38161. /**
  38162. * Sets the value of the `Triangle` button
  38163. */
  38164. buttonTriangle: number;
  38165. /**
  38166. * Gets the value of the `Options` button
  38167. */
  38168. /**
  38169. * Sets the value of the `Options` button
  38170. */
  38171. buttonOptions: number;
  38172. /**
  38173. * Gets the value of the `Share` button
  38174. */
  38175. /**
  38176. * Sets the value of the `Share` button
  38177. */
  38178. buttonShare: number;
  38179. /**
  38180. * Gets the value of the `L1` button
  38181. */
  38182. /**
  38183. * Sets the value of the `L1` button
  38184. */
  38185. buttonL1: number;
  38186. /**
  38187. * Gets the value of the `R1` button
  38188. */
  38189. /**
  38190. * Sets the value of the `R1` button
  38191. */
  38192. buttonR1: number;
  38193. /**
  38194. * Gets the value of the Left joystick
  38195. */
  38196. /**
  38197. * Sets the value of the Left joystick
  38198. */
  38199. buttonLeftStick: number;
  38200. /**
  38201. * Gets the value of the Right joystick
  38202. */
  38203. /**
  38204. * Sets the value of the Right joystick
  38205. */
  38206. buttonRightStick: number;
  38207. /**
  38208. * Gets the value of D-pad up
  38209. */
  38210. /**
  38211. * Sets the value of D-pad up
  38212. */
  38213. dPadUp: number;
  38214. /**
  38215. * Gets the value of D-pad down
  38216. */
  38217. /**
  38218. * Sets the value of D-pad down
  38219. */
  38220. dPadDown: number;
  38221. /**
  38222. * Gets the value of D-pad left
  38223. */
  38224. /**
  38225. * Sets the value of D-pad left
  38226. */
  38227. dPadLeft: number;
  38228. /**
  38229. * Gets the value of D-pad right
  38230. */
  38231. /**
  38232. * Sets the value of D-pad right
  38233. */
  38234. dPadRight: number;
  38235. /**
  38236. * Force the gamepad to synchronize with device values
  38237. */
  38238. update(): void;
  38239. /**
  38240. * Disposes the gamepad
  38241. */
  38242. dispose(): void;
  38243. }
  38244. }
  38245. declare module BABYLON {
  38246. /**
  38247. * Manager for handling gamepads
  38248. */
  38249. export class GamepadManager {
  38250. private _scene?;
  38251. private _babylonGamepads;
  38252. private _oneGamepadConnected;
  38253. /** @hidden */ private _isMonitoring: boolean;
  38254. private _gamepadEventSupported;
  38255. private _gamepadSupport;
  38256. /**
  38257. * observable to be triggered when the gamepad controller has been connected
  38258. */
  38259. onGamepadConnectedObservable: Observable<Gamepad>;
  38260. /**
  38261. * observable to be triggered when the gamepad controller has been disconnected
  38262. */
  38263. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38264. private _onGamepadConnectedEvent;
  38265. private _onGamepadDisconnectedEvent;
  38266. /**
  38267. * Initializes the gamepad manager
  38268. * @param _scene BabylonJS scene
  38269. */
  38270. constructor(_scene?: Scene | undefined);
  38271. /**
  38272. * The gamepads in the game pad manager
  38273. */
  38274. readonly gamepads: Gamepad[];
  38275. /**
  38276. * Get the gamepad controllers based on type
  38277. * @param type The type of gamepad controller
  38278. * @returns Nullable gamepad
  38279. */
  38280. getGamepadByType(type?: number): Nullable<Gamepad>;
  38281. /**
  38282. * Disposes the gamepad manager
  38283. */
  38284. dispose(): void;
  38285. private _addNewGamepad;
  38286. private _startMonitoringGamepads;
  38287. private _stopMonitoringGamepads;
  38288. /** @hidden */ private _checkGamepadsStatus(): void;
  38289. private _updateGamepadObjects;
  38290. }
  38291. }
  38292. declare module BABYLON {
  38293. interface Scene {
  38294. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38295. /**
  38296. * Gets the gamepad manager associated with the scene
  38297. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38298. */
  38299. gamepadManager: GamepadManager;
  38300. }
  38301. /**
  38302. * Interface representing a free camera inputs manager
  38303. */
  38304. interface FreeCameraInputsManager {
  38305. /**
  38306. * Adds gamepad input support to the FreeCameraInputsManager.
  38307. * @returns the FreeCameraInputsManager
  38308. */
  38309. addGamepad(): FreeCameraInputsManager;
  38310. }
  38311. /**
  38312. * Interface representing an arc rotate camera inputs manager
  38313. */
  38314. interface ArcRotateCameraInputsManager {
  38315. /**
  38316. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38317. * @returns the camera inputs manager
  38318. */
  38319. addGamepad(): ArcRotateCameraInputsManager;
  38320. }
  38321. /**
  38322. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38323. */
  38324. export class GamepadSystemSceneComponent implements ISceneComponent {
  38325. /**
  38326. * The component name helpfull to identify the component in the list of scene components.
  38327. */
  38328. readonly name: string;
  38329. /**
  38330. * The scene the component belongs to.
  38331. */
  38332. scene: Scene;
  38333. /**
  38334. * Creates a new instance of the component for the given scene
  38335. * @param scene Defines the scene to register the component in
  38336. */
  38337. constructor(scene: Scene);
  38338. /**
  38339. * Registers the component in a given scene
  38340. */
  38341. register(): void;
  38342. /**
  38343. * Rebuilds the elements related to this component in case of
  38344. * context lost for instance.
  38345. */
  38346. rebuild(): void;
  38347. /**
  38348. * Disposes the component and the associated ressources
  38349. */
  38350. dispose(): void;
  38351. private _beforeCameraUpdate;
  38352. }
  38353. }
  38354. declare module BABYLON {
  38355. /**
  38356. * 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,
  38357. * which still works and will still be found in many Playgrounds.
  38358. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38359. */
  38360. export class UniversalCamera extends TouchCamera {
  38361. /**
  38362. * Defines the gamepad rotation sensiblity.
  38363. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38364. */
  38365. gamepadAngularSensibility: number;
  38366. /**
  38367. * Defines the gamepad move sensiblity.
  38368. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38369. */
  38370. gamepadMoveSensibility: number;
  38371. /**
  38372. * 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,
  38373. * which still works and will still be found in many Playgrounds.
  38374. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38375. * @param name Define the name of the camera in the scene
  38376. * @param position Define the start position of the camera in the scene
  38377. * @param scene Define the scene the camera belongs to
  38378. */
  38379. constructor(name: string, position: Vector3, scene: Scene);
  38380. /**
  38381. * Gets the current object class name.
  38382. * @return the class name
  38383. */
  38384. getClassName(): string;
  38385. }
  38386. }
  38387. declare module BABYLON {
  38388. /**
  38389. * This represents a FPS type of camera. This is only here for back compat purpose.
  38390. * Please use the UniversalCamera instead as both are identical.
  38391. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38392. */
  38393. export class GamepadCamera extends UniversalCamera {
  38394. /**
  38395. * Instantiates a new Gamepad Camera
  38396. * This represents a FPS type of camera. This is only here for back compat purpose.
  38397. * Please use the UniversalCamera instead as both are identical.
  38398. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38399. * @param name Define the name of the camera in the scene
  38400. * @param position Define the start position of the camera in the scene
  38401. * @param scene Define the scene the camera belongs to
  38402. */
  38403. constructor(name: string, position: Vector3, scene: Scene);
  38404. /**
  38405. * Gets the current object class name.
  38406. * @return the class name
  38407. */
  38408. getClassName(): string;
  38409. }
  38410. }
  38411. declare module BABYLON {
  38412. /** @hidden */
  38413. export var passPixelShader: {
  38414. name: string;
  38415. shader: string;
  38416. };
  38417. }
  38418. declare module BABYLON {
  38419. /** @hidden */
  38420. export var passCubePixelShader: {
  38421. name: string;
  38422. shader: string;
  38423. };
  38424. }
  38425. declare module BABYLON {
  38426. /**
  38427. * PassPostProcess which produces an output the same as it's input
  38428. */
  38429. export class PassPostProcess extends PostProcess {
  38430. /**
  38431. * Creates the PassPostProcess
  38432. * @param name The name of the effect.
  38433. * @param options The required width/height ratio to downsize to before computing the render pass.
  38434. * @param camera The camera to apply the render pass to.
  38435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38436. * @param engine The engine which the post process will be applied. (default: current engine)
  38437. * @param reusable If the post process can be reused on the same frame. (default: false)
  38438. * @param textureType The type of texture to be used when performing the post processing.
  38439. * @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)
  38440. */
  38441. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38442. }
  38443. /**
  38444. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38445. */
  38446. export class PassCubePostProcess extends PostProcess {
  38447. private _face;
  38448. /**
  38449. * Gets or sets the cube face to display.
  38450. * * 0 is +X
  38451. * * 1 is -X
  38452. * * 2 is +Y
  38453. * * 3 is -Y
  38454. * * 4 is +Z
  38455. * * 5 is -Z
  38456. */
  38457. face: number;
  38458. /**
  38459. * Creates the PassCubePostProcess
  38460. * @param name The name of the effect.
  38461. * @param options The required width/height ratio to downsize to before computing the render pass.
  38462. * @param camera The camera to apply the render pass to.
  38463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38464. * @param engine The engine which the post process will be applied. (default: current engine)
  38465. * @param reusable If the post process can be reused on the same frame. (default: false)
  38466. * @param textureType The type of texture to be used when performing the post processing.
  38467. * @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)
  38468. */
  38469. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38470. }
  38471. }
  38472. declare module BABYLON {
  38473. /** @hidden */
  38474. export var anaglyphPixelShader: {
  38475. name: string;
  38476. shader: string;
  38477. };
  38478. }
  38479. declare module BABYLON {
  38480. /**
  38481. * Postprocess used to generate anaglyphic rendering
  38482. */
  38483. export class AnaglyphPostProcess extends PostProcess {
  38484. private _passedProcess;
  38485. /**
  38486. * Creates a new AnaglyphPostProcess
  38487. * @param name defines postprocess name
  38488. * @param options defines creation options or target ratio scale
  38489. * @param rigCameras defines cameras using this postprocess
  38490. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38491. * @param engine defines hosting engine
  38492. * @param reusable defines if the postprocess will be reused multiple times per frame
  38493. */
  38494. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38495. }
  38496. }
  38497. declare module BABYLON {
  38498. /**
  38499. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38500. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38501. */
  38502. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38503. /**
  38504. * Creates a new AnaglyphArcRotateCamera
  38505. * @param name defines camera name
  38506. * @param alpha defines alpha angle (in radians)
  38507. * @param beta defines beta angle (in radians)
  38508. * @param radius defines radius
  38509. * @param target defines camera target
  38510. * @param interaxialDistance defines distance between each color axis
  38511. * @param scene defines the hosting scene
  38512. */
  38513. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38514. /**
  38515. * Gets camera class name
  38516. * @returns AnaglyphArcRotateCamera
  38517. */
  38518. getClassName(): string;
  38519. }
  38520. }
  38521. declare module BABYLON {
  38522. /**
  38523. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38524. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38525. */
  38526. export class AnaglyphFreeCamera extends FreeCamera {
  38527. /**
  38528. * Creates a new AnaglyphFreeCamera
  38529. * @param name defines camera name
  38530. * @param position defines initial position
  38531. * @param interaxialDistance defines distance between each color axis
  38532. * @param scene defines the hosting scene
  38533. */
  38534. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38535. /**
  38536. * Gets camera class name
  38537. * @returns AnaglyphFreeCamera
  38538. */
  38539. getClassName(): string;
  38540. }
  38541. }
  38542. declare module BABYLON {
  38543. /**
  38544. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38545. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38546. */
  38547. export class AnaglyphGamepadCamera extends GamepadCamera {
  38548. /**
  38549. * Creates a new AnaglyphGamepadCamera
  38550. * @param name defines camera name
  38551. * @param position defines initial position
  38552. * @param interaxialDistance defines distance between each color axis
  38553. * @param scene defines the hosting scene
  38554. */
  38555. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38556. /**
  38557. * Gets camera class name
  38558. * @returns AnaglyphGamepadCamera
  38559. */
  38560. getClassName(): string;
  38561. }
  38562. }
  38563. declare module BABYLON {
  38564. /**
  38565. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38566. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38567. */
  38568. export class AnaglyphUniversalCamera extends UniversalCamera {
  38569. /**
  38570. * Creates a new AnaglyphUniversalCamera
  38571. * @param name defines camera name
  38572. * @param position defines initial position
  38573. * @param interaxialDistance defines distance between each color axis
  38574. * @param scene defines the hosting scene
  38575. */
  38576. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38577. /**
  38578. * Gets camera class name
  38579. * @returns AnaglyphUniversalCamera
  38580. */
  38581. getClassName(): string;
  38582. }
  38583. }
  38584. declare module BABYLON {
  38585. /** @hidden */
  38586. export var stereoscopicInterlacePixelShader: {
  38587. name: string;
  38588. shader: string;
  38589. };
  38590. }
  38591. declare module BABYLON {
  38592. /**
  38593. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38594. */
  38595. export class StereoscopicInterlacePostProcess extends PostProcess {
  38596. private _stepSize;
  38597. private _passedProcess;
  38598. /**
  38599. * Initializes a StereoscopicInterlacePostProcess
  38600. * @param name The name of the effect.
  38601. * @param rigCameras The rig cameras to be appled to the post process
  38602. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38604. * @param engine The engine which the post process will be applied. (default: current engine)
  38605. * @param reusable If the post process can be reused on the same frame. (default: false)
  38606. */
  38607. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38608. }
  38609. }
  38610. declare module BABYLON {
  38611. /**
  38612. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38613. * @see http://doc.babylonjs.com/features/cameras
  38614. */
  38615. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38616. /**
  38617. * Creates a new StereoscopicArcRotateCamera
  38618. * @param name defines camera name
  38619. * @param alpha defines alpha angle (in radians)
  38620. * @param beta defines beta angle (in radians)
  38621. * @param radius defines radius
  38622. * @param target defines camera target
  38623. * @param interaxialDistance defines distance between each color axis
  38624. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38625. * @param scene defines the hosting scene
  38626. */
  38627. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38628. /**
  38629. * Gets camera class name
  38630. * @returns StereoscopicArcRotateCamera
  38631. */
  38632. getClassName(): string;
  38633. }
  38634. }
  38635. declare module BABYLON {
  38636. /**
  38637. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38638. * @see http://doc.babylonjs.com/features/cameras
  38639. */
  38640. export class StereoscopicFreeCamera extends FreeCamera {
  38641. /**
  38642. * Creates a new StereoscopicFreeCamera
  38643. * @param name defines camera name
  38644. * @param position defines initial position
  38645. * @param interaxialDistance defines distance between each color axis
  38646. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38647. * @param scene defines the hosting scene
  38648. */
  38649. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38650. /**
  38651. * Gets camera class name
  38652. * @returns StereoscopicFreeCamera
  38653. */
  38654. getClassName(): string;
  38655. }
  38656. }
  38657. declare module BABYLON {
  38658. /**
  38659. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38660. * @see http://doc.babylonjs.com/features/cameras
  38661. */
  38662. export class StereoscopicGamepadCamera extends GamepadCamera {
  38663. /**
  38664. * Creates a new StereoscopicGamepadCamera
  38665. * @param name defines camera name
  38666. * @param position defines initial position
  38667. * @param interaxialDistance defines distance between each color axis
  38668. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38669. * @param scene defines the hosting scene
  38670. */
  38671. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38672. /**
  38673. * Gets camera class name
  38674. * @returns StereoscopicGamepadCamera
  38675. */
  38676. getClassName(): string;
  38677. }
  38678. }
  38679. declare module BABYLON {
  38680. /**
  38681. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38682. * @see http://doc.babylonjs.com/features/cameras
  38683. */
  38684. export class StereoscopicUniversalCamera extends UniversalCamera {
  38685. /**
  38686. * Creates a new StereoscopicUniversalCamera
  38687. * @param name defines camera name
  38688. * @param position defines initial position
  38689. * @param interaxialDistance defines distance between each color axis
  38690. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38691. * @param scene defines the hosting scene
  38692. */
  38693. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38694. /**
  38695. * Gets camera class name
  38696. * @returns StereoscopicUniversalCamera
  38697. */
  38698. getClassName(): string;
  38699. }
  38700. }
  38701. declare module BABYLON {
  38702. /**
  38703. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38704. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38705. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38706. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38707. */
  38708. export class VirtualJoysticksCamera extends FreeCamera {
  38709. /**
  38710. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38711. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38712. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38713. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38714. * @param name Define the name of the camera in the scene
  38715. * @param position Define the start position of the camera in the scene
  38716. * @param scene Define the scene the camera belongs to
  38717. */
  38718. constructor(name: string, position: Vector3, scene: Scene);
  38719. /**
  38720. * Gets the current object class name.
  38721. * @return the class name
  38722. */
  38723. getClassName(): string;
  38724. }
  38725. }
  38726. declare module BABYLON {
  38727. /**
  38728. * This represents all the required metrics to create a VR camera.
  38729. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38730. */
  38731. export class VRCameraMetrics {
  38732. /**
  38733. * Define the horizontal resolution off the screen.
  38734. */
  38735. hResolution: number;
  38736. /**
  38737. * Define the vertical resolution off the screen.
  38738. */
  38739. vResolution: number;
  38740. /**
  38741. * Define the horizontal screen size.
  38742. */
  38743. hScreenSize: number;
  38744. /**
  38745. * Define the vertical screen size.
  38746. */
  38747. vScreenSize: number;
  38748. /**
  38749. * Define the vertical screen center position.
  38750. */
  38751. vScreenCenter: number;
  38752. /**
  38753. * Define the distance of the eyes to the screen.
  38754. */
  38755. eyeToScreenDistance: number;
  38756. /**
  38757. * Define the distance between both lenses
  38758. */
  38759. lensSeparationDistance: number;
  38760. /**
  38761. * Define the distance between both viewer's eyes.
  38762. */
  38763. interpupillaryDistance: number;
  38764. /**
  38765. * Define the distortion factor of the VR postprocess.
  38766. * Please, touch with care.
  38767. */
  38768. distortionK: number[];
  38769. /**
  38770. * Define the chromatic aberration correction factors for the VR post process.
  38771. */
  38772. chromaAbCorrection: number[];
  38773. /**
  38774. * Define the scale factor of the post process.
  38775. * The smaller the better but the slower.
  38776. */
  38777. postProcessScaleFactor: number;
  38778. /**
  38779. * Define an offset for the lens center.
  38780. */
  38781. lensCenterOffset: number;
  38782. /**
  38783. * Define if the current vr camera should compensate the distortion of the lense or not.
  38784. */
  38785. compensateDistortion: boolean;
  38786. /**
  38787. * Defines if multiview should be enabled when rendering (Default: false)
  38788. */
  38789. multiviewEnabled: boolean;
  38790. /**
  38791. * Gets the rendering aspect ratio based on the provided resolutions.
  38792. */
  38793. readonly aspectRatio: number;
  38794. /**
  38795. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38796. */
  38797. readonly aspectRatioFov: number;
  38798. /**
  38799. * @hidden
  38800. */
  38801. readonly leftHMatrix: Matrix;
  38802. /**
  38803. * @hidden
  38804. */
  38805. readonly rightHMatrix: Matrix;
  38806. /**
  38807. * @hidden
  38808. */
  38809. readonly leftPreViewMatrix: Matrix;
  38810. /**
  38811. * @hidden
  38812. */
  38813. readonly rightPreViewMatrix: Matrix;
  38814. /**
  38815. * Get the default VRMetrics based on the most generic setup.
  38816. * @returns the default vr metrics
  38817. */
  38818. static GetDefault(): VRCameraMetrics;
  38819. }
  38820. }
  38821. declare module BABYLON {
  38822. /** @hidden */
  38823. export var vrDistortionCorrectionPixelShader: {
  38824. name: string;
  38825. shader: string;
  38826. };
  38827. }
  38828. declare module BABYLON {
  38829. /**
  38830. * VRDistortionCorrectionPostProcess used for mobile VR
  38831. */
  38832. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38833. private _isRightEye;
  38834. private _distortionFactors;
  38835. private _postProcessScaleFactor;
  38836. private _lensCenterOffset;
  38837. private _scaleIn;
  38838. private _scaleFactor;
  38839. private _lensCenter;
  38840. /**
  38841. * Initializes the VRDistortionCorrectionPostProcess
  38842. * @param name The name of the effect.
  38843. * @param camera The camera to apply the render pass to.
  38844. * @param isRightEye If this is for the right eye distortion
  38845. * @param vrMetrics All the required metrics for the VR camera
  38846. */
  38847. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38848. }
  38849. }
  38850. declare module BABYLON {
  38851. /**
  38852. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38853. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38854. */
  38855. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38856. /**
  38857. * Creates a new VRDeviceOrientationArcRotateCamera
  38858. * @param name defines camera name
  38859. * @param alpha defines the camera rotation along the logitudinal axis
  38860. * @param beta defines the camera rotation along the latitudinal axis
  38861. * @param radius defines the camera distance from its target
  38862. * @param target defines the camera target
  38863. * @param scene defines the scene the camera belongs to
  38864. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38865. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38866. */
  38867. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38868. /**
  38869. * Gets camera class name
  38870. * @returns VRDeviceOrientationArcRotateCamera
  38871. */
  38872. getClassName(): string;
  38873. }
  38874. }
  38875. declare module BABYLON {
  38876. /**
  38877. * Camera used to simulate VR rendering (based on FreeCamera)
  38878. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38879. */
  38880. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38881. /**
  38882. * Creates a new VRDeviceOrientationFreeCamera
  38883. * @param name defines camera name
  38884. * @param position defines the start position of the camera
  38885. * @param scene defines the scene the camera belongs to
  38886. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38887. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38888. */
  38889. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38890. /**
  38891. * Gets camera class name
  38892. * @returns VRDeviceOrientationFreeCamera
  38893. */
  38894. getClassName(): string;
  38895. }
  38896. }
  38897. declare module BABYLON {
  38898. /**
  38899. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38900. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38901. */
  38902. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38903. /**
  38904. * Creates a new VRDeviceOrientationGamepadCamera
  38905. * @param name defines camera name
  38906. * @param position defines the start position of the camera
  38907. * @param scene defines the scene the camera belongs to
  38908. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38909. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38910. */
  38911. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38912. /**
  38913. * Gets camera class name
  38914. * @returns VRDeviceOrientationGamepadCamera
  38915. */
  38916. getClassName(): string;
  38917. }
  38918. }
  38919. declare module BABYLON {
  38920. /**
  38921. * Base class of materials working in push mode in babylon JS
  38922. * @hidden
  38923. */
  38924. export class PushMaterial extends Material {
  38925. protected _activeEffect: Effect;
  38926. protected _normalMatrix: Matrix;
  38927. /**
  38928. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38929. * This means that the material can keep using a previous shader while a new one is being compiled.
  38930. * This is mostly used when shader parallel compilation is supported (true by default)
  38931. */
  38932. allowShaderHotSwapping: boolean;
  38933. constructor(name: string, scene: Scene);
  38934. getEffect(): Effect;
  38935. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38936. /**
  38937. * Binds the given world matrix to the active effect
  38938. *
  38939. * @param world the matrix to bind
  38940. */
  38941. bindOnlyWorldMatrix(world: Matrix): void;
  38942. /**
  38943. * Binds the given normal matrix to the active effect
  38944. *
  38945. * @param normalMatrix the matrix to bind
  38946. */
  38947. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38948. bind(world: Matrix, mesh?: Mesh): void;
  38949. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38950. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38951. }
  38952. }
  38953. declare module BABYLON {
  38954. /**
  38955. * This groups all the flags used to control the materials channel.
  38956. */
  38957. export class MaterialFlags {
  38958. private static _DiffuseTextureEnabled;
  38959. /**
  38960. * Are diffuse textures enabled in the application.
  38961. */
  38962. static DiffuseTextureEnabled: boolean;
  38963. private static _AmbientTextureEnabled;
  38964. /**
  38965. * Are ambient textures enabled in the application.
  38966. */
  38967. static AmbientTextureEnabled: boolean;
  38968. private static _OpacityTextureEnabled;
  38969. /**
  38970. * Are opacity textures enabled in the application.
  38971. */
  38972. static OpacityTextureEnabled: boolean;
  38973. private static _ReflectionTextureEnabled;
  38974. /**
  38975. * Are reflection textures enabled in the application.
  38976. */
  38977. static ReflectionTextureEnabled: boolean;
  38978. private static _EmissiveTextureEnabled;
  38979. /**
  38980. * Are emissive textures enabled in the application.
  38981. */
  38982. static EmissiveTextureEnabled: boolean;
  38983. private static _SpecularTextureEnabled;
  38984. /**
  38985. * Are specular textures enabled in the application.
  38986. */
  38987. static SpecularTextureEnabled: boolean;
  38988. private static _BumpTextureEnabled;
  38989. /**
  38990. * Are bump textures enabled in the application.
  38991. */
  38992. static BumpTextureEnabled: boolean;
  38993. private static _LightmapTextureEnabled;
  38994. /**
  38995. * Are lightmap textures enabled in the application.
  38996. */
  38997. static LightmapTextureEnabled: boolean;
  38998. private static _RefractionTextureEnabled;
  38999. /**
  39000. * Are refraction textures enabled in the application.
  39001. */
  39002. static RefractionTextureEnabled: boolean;
  39003. private static _ColorGradingTextureEnabled;
  39004. /**
  39005. * Are color grading textures enabled in the application.
  39006. */
  39007. static ColorGradingTextureEnabled: boolean;
  39008. private static _FresnelEnabled;
  39009. /**
  39010. * Are fresnels enabled in the application.
  39011. */
  39012. static FresnelEnabled: boolean;
  39013. private static _ClearCoatTextureEnabled;
  39014. /**
  39015. * Are clear coat textures enabled in the application.
  39016. */
  39017. static ClearCoatTextureEnabled: boolean;
  39018. private static _ClearCoatBumpTextureEnabled;
  39019. /**
  39020. * Are clear coat bump textures enabled in the application.
  39021. */
  39022. static ClearCoatBumpTextureEnabled: boolean;
  39023. private static _ClearCoatTintTextureEnabled;
  39024. /**
  39025. * Are clear coat tint textures enabled in the application.
  39026. */
  39027. static ClearCoatTintTextureEnabled: boolean;
  39028. private static _SheenTextureEnabled;
  39029. /**
  39030. * Are sheen textures enabled in the application.
  39031. */
  39032. static SheenTextureEnabled: boolean;
  39033. private static _AnisotropicTextureEnabled;
  39034. /**
  39035. * Are anisotropic textures enabled in the application.
  39036. */
  39037. static AnisotropicTextureEnabled: boolean;
  39038. private static _ThicknessTextureEnabled;
  39039. /**
  39040. * Are thickness textures enabled in the application.
  39041. */
  39042. static ThicknessTextureEnabled: boolean;
  39043. }
  39044. }
  39045. declare module BABYLON {
  39046. /** @hidden */
  39047. export var defaultFragmentDeclaration: {
  39048. name: string;
  39049. shader: string;
  39050. };
  39051. }
  39052. declare module BABYLON {
  39053. /** @hidden */
  39054. export var defaultUboDeclaration: {
  39055. name: string;
  39056. shader: string;
  39057. };
  39058. }
  39059. declare module BABYLON {
  39060. /** @hidden */
  39061. export var lightFragmentDeclaration: {
  39062. name: string;
  39063. shader: string;
  39064. };
  39065. }
  39066. declare module BABYLON {
  39067. /** @hidden */
  39068. export var lightUboDeclaration: {
  39069. name: string;
  39070. shader: string;
  39071. };
  39072. }
  39073. declare module BABYLON {
  39074. /** @hidden */
  39075. export var lightsFragmentFunctions: {
  39076. name: string;
  39077. shader: string;
  39078. };
  39079. }
  39080. declare module BABYLON {
  39081. /** @hidden */
  39082. export var shadowsFragmentFunctions: {
  39083. name: string;
  39084. shader: string;
  39085. };
  39086. }
  39087. declare module BABYLON {
  39088. /** @hidden */
  39089. export var fresnelFunction: {
  39090. name: string;
  39091. shader: string;
  39092. };
  39093. }
  39094. declare module BABYLON {
  39095. /** @hidden */
  39096. export var reflectionFunction: {
  39097. name: string;
  39098. shader: string;
  39099. };
  39100. }
  39101. declare module BABYLON {
  39102. /** @hidden */
  39103. export var bumpFragmentFunctions: {
  39104. name: string;
  39105. shader: string;
  39106. };
  39107. }
  39108. declare module BABYLON {
  39109. /** @hidden */
  39110. export var logDepthDeclaration: {
  39111. name: string;
  39112. shader: string;
  39113. };
  39114. }
  39115. declare module BABYLON {
  39116. /** @hidden */
  39117. export var bumpFragment: {
  39118. name: string;
  39119. shader: string;
  39120. };
  39121. }
  39122. declare module BABYLON {
  39123. /** @hidden */
  39124. export var depthPrePass: {
  39125. name: string;
  39126. shader: string;
  39127. };
  39128. }
  39129. declare module BABYLON {
  39130. /** @hidden */
  39131. export var lightFragment: {
  39132. name: string;
  39133. shader: string;
  39134. };
  39135. }
  39136. declare module BABYLON {
  39137. /** @hidden */
  39138. export var logDepthFragment: {
  39139. name: string;
  39140. shader: string;
  39141. };
  39142. }
  39143. declare module BABYLON {
  39144. /** @hidden */
  39145. export var defaultPixelShader: {
  39146. name: string;
  39147. shader: string;
  39148. };
  39149. }
  39150. declare module BABYLON {
  39151. /** @hidden */
  39152. export var defaultVertexDeclaration: {
  39153. name: string;
  39154. shader: string;
  39155. };
  39156. }
  39157. declare module BABYLON {
  39158. /** @hidden */
  39159. export var bumpVertexDeclaration: {
  39160. name: string;
  39161. shader: string;
  39162. };
  39163. }
  39164. declare module BABYLON {
  39165. /** @hidden */
  39166. export var bumpVertex: {
  39167. name: string;
  39168. shader: string;
  39169. };
  39170. }
  39171. declare module BABYLON {
  39172. /** @hidden */
  39173. export var fogVertex: {
  39174. name: string;
  39175. shader: string;
  39176. };
  39177. }
  39178. declare module BABYLON {
  39179. /** @hidden */
  39180. export var shadowsVertex: {
  39181. name: string;
  39182. shader: string;
  39183. };
  39184. }
  39185. declare module BABYLON {
  39186. /** @hidden */
  39187. export var pointCloudVertex: {
  39188. name: string;
  39189. shader: string;
  39190. };
  39191. }
  39192. declare module BABYLON {
  39193. /** @hidden */
  39194. export var logDepthVertex: {
  39195. name: string;
  39196. shader: string;
  39197. };
  39198. }
  39199. declare module BABYLON {
  39200. /** @hidden */
  39201. export var defaultVertexShader: {
  39202. name: string;
  39203. shader: string;
  39204. };
  39205. }
  39206. declare module BABYLON {
  39207. /** @hidden */
  39208. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39209. MAINUV1: boolean;
  39210. MAINUV2: boolean;
  39211. DIFFUSE: boolean;
  39212. DIFFUSEDIRECTUV: number;
  39213. AMBIENT: boolean;
  39214. AMBIENTDIRECTUV: number;
  39215. OPACITY: boolean;
  39216. OPACITYDIRECTUV: number;
  39217. OPACITYRGB: boolean;
  39218. REFLECTION: boolean;
  39219. EMISSIVE: boolean;
  39220. EMISSIVEDIRECTUV: number;
  39221. SPECULAR: boolean;
  39222. SPECULARDIRECTUV: number;
  39223. BUMP: boolean;
  39224. BUMPDIRECTUV: number;
  39225. PARALLAX: boolean;
  39226. PARALLAXOCCLUSION: boolean;
  39227. SPECULAROVERALPHA: boolean;
  39228. CLIPPLANE: boolean;
  39229. CLIPPLANE2: boolean;
  39230. CLIPPLANE3: boolean;
  39231. CLIPPLANE4: boolean;
  39232. ALPHATEST: boolean;
  39233. DEPTHPREPASS: boolean;
  39234. ALPHAFROMDIFFUSE: boolean;
  39235. POINTSIZE: boolean;
  39236. FOG: boolean;
  39237. SPECULARTERM: boolean;
  39238. DIFFUSEFRESNEL: boolean;
  39239. OPACITYFRESNEL: boolean;
  39240. REFLECTIONFRESNEL: boolean;
  39241. REFRACTIONFRESNEL: boolean;
  39242. EMISSIVEFRESNEL: boolean;
  39243. FRESNEL: boolean;
  39244. NORMAL: boolean;
  39245. UV1: boolean;
  39246. UV2: boolean;
  39247. VERTEXCOLOR: boolean;
  39248. VERTEXALPHA: boolean;
  39249. NUM_BONE_INFLUENCERS: number;
  39250. BonesPerMesh: number;
  39251. BONETEXTURE: boolean;
  39252. INSTANCES: boolean;
  39253. GLOSSINESS: boolean;
  39254. ROUGHNESS: boolean;
  39255. EMISSIVEASILLUMINATION: boolean;
  39256. LINKEMISSIVEWITHDIFFUSE: boolean;
  39257. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39258. LIGHTMAP: boolean;
  39259. LIGHTMAPDIRECTUV: number;
  39260. OBJECTSPACE_NORMALMAP: boolean;
  39261. USELIGHTMAPASSHADOWMAP: boolean;
  39262. REFLECTIONMAP_3D: boolean;
  39263. REFLECTIONMAP_SPHERICAL: boolean;
  39264. REFLECTIONMAP_PLANAR: boolean;
  39265. REFLECTIONMAP_CUBIC: boolean;
  39266. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39267. REFLECTIONMAP_PROJECTION: boolean;
  39268. REFLECTIONMAP_SKYBOX: boolean;
  39269. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39270. REFLECTIONMAP_EXPLICIT: boolean;
  39271. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39272. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39273. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39274. INVERTCUBICMAP: boolean;
  39275. LOGARITHMICDEPTH: boolean;
  39276. REFRACTION: boolean;
  39277. REFRACTIONMAP_3D: boolean;
  39278. REFLECTIONOVERALPHA: boolean;
  39279. TWOSIDEDLIGHTING: boolean;
  39280. SHADOWFLOAT: boolean;
  39281. MORPHTARGETS: boolean;
  39282. MORPHTARGETS_NORMAL: boolean;
  39283. MORPHTARGETS_TANGENT: boolean;
  39284. MORPHTARGETS_UV: boolean;
  39285. NUM_MORPH_INFLUENCERS: number;
  39286. NONUNIFORMSCALING: boolean;
  39287. PREMULTIPLYALPHA: boolean;
  39288. IMAGEPROCESSING: boolean;
  39289. VIGNETTE: boolean;
  39290. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39291. VIGNETTEBLENDMODEOPAQUE: boolean;
  39292. TONEMAPPING: boolean;
  39293. TONEMAPPING_ACES: boolean;
  39294. CONTRAST: boolean;
  39295. COLORCURVES: boolean;
  39296. COLORGRADING: boolean;
  39297. COLORGRADING3D: boolean;
  39298. SAMPLER3DGREENDEPTH: boolean;
  39299. SAMPLER3DBGRMAP: boolean;
  39300. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39301. MULTIVIEW: boolean;
  39302. /**
  39303. * If the reflection texture on this material is in linear color space
  39304. * @hidden
  39305. */
  39306. IS_REFLECTION_LINEAR: boolean;
  39307. /**
  39308. * If the refraction texture on this material is in linear color space
  39309. * @hidden
  39310. */
  39311. IS_REFRACTION_LINEAR: boolean;
  39312. EXPOSURE: boolean;
  39313. constructor();
  39314. setReflectionMode(modeToEnable: string): void;
  39315. }
  39316. /**
  39317. * This is the default material used in Babylon. It is the best trade off between quality
  39318. * and performances.
  39319. * @see http://doc.babylonjs.com/babylon101/materials
  39320. */
  39321. export class StandardMaterial extends PushMaterial {
  39322. private _diffuseTexture;
  39323. /**
  39324. * The basic texture of the material as viewed under a light.
  39325. */
  39326. diffuseTexture: Nullable<BaseTexture>;
  39327. private _ambientTexture;
  39328. /**
  39329. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39330. */
  39331. ambientTexture: Nullable<BaseTexture>;
  39332. private _opacityTexture;
  39333. /**
  39334. * Define the transparency of the material from a texture.
  39335. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39336. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39337. */
  39338. opacityTexture: Nullable<BaseTexture>;
  39339. private _reflectionTexture;
  39340. /**
  39341. * Define the texture used to display the reflection.
  39342. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39343. */
  39344. reflectionTexture: Nullable<BaseTexture>;
  39345. private _emissiveTexture;
  39346. /**
  39347. * Define texture of the material as if self lit.
  39348. * This will be mixed in the final result even in the absence of light.
  39349. */
  39350. emissiveTexture: Nullable<BaseTexture>;
  39351. private _specularTexture;
  39352. /**
  39353. * Define how the color and intensity of the highlight given by the light in the material.
  39354. */
  39355. specularTexture: Nullable<BaseTexture>;
  39356. private _bumpTexture;
  39357. /**
  39358. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39359. * 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.
  39360. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39361. */
  39362. bumpTexture: Nullable<BaseTexture>;
  39363. private _lightmapTexture;
  39364. /**
  39365. * Complex lighting can be computationally expensive to compute at runtime.
  39366. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39367. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39368. */
  39369. lightmapTexture: Nullable<BaseTexture>;
  39370. private _refractionTexture;
  39371. /**
  39372. * Define the texture used to display the refraction.
  39373. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39374. */
  39375. refractionTexture: Nullable<BaseTexture>;
  39376. /**
  39377. * The color of the material lit by the environmental background lighting.
  39378. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39379. */
  39380. ambientColor: Color3;
  39381. /**
  39382. * The basic color of the material as viewed under a light.
  39383. */
  39384. diffuseColor: Color3;
  39385. /**
  39386. * Define how the color and intensity of the highlight given by the light in the material.
  39387. */
  39388. specularColor: Color3;
  39389. /**
  39390. * Define the color of the material as if self lit.
  39391. * This will be mixed in the final result even in the absence of light.
  39392. */
  39393. emissiveColor: Color3;
  39394. /**
  39395. * Defines how sharp are the highlights in the material.
  39396. * The bigger the value the sharper giving a more glossy feeling to the result.
  39397. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39398. */
  39399. specularPower: number;
  39400. private _useAlphaFromDiffuseTexture;
  39401. /**
  39402. * Does the transparency come from the diffuse texture alpha channel.
  39403. */
  39404. useAlphaFromDiffuseTexture: boolean;
  39405. private _useEmissiveAsIllumination;
  39406. /**
  39407. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39408. */
  39409. useEmissiveAsIllumination: boolean;
  39410. private _linkEmissiveWithDiffuse;
  39411. /**
  39412. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39413. * the emissive level when the final color is close to one.
  39414. */
  39415. linkEmissiveWithDiffuse: boolean;
  39416. private _useSpecularOverAlpha;
  39417. /**
  39418. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39419. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39420. */
  39421. useSpecularOverAlpha: boolean;
  39422. private _useReflectionOverAlpha;
  39423. /**
  39424. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39425. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39426. */
  39427. useReflectionOverAlpha: boolean;
  39428. private _disableLighting;
  39429. /**
  39430. * Does lights from the scene impacts this material.
  39431. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39432. */
  39433. disableLighting: boolean;
  39434. private _useObjectSpaceNormalMap;
  39435. /**
  39436. * Allows using an object space normal map (instead of tangent space).
  39437. */
  39438. useObjectSpaceNormalMap: boolean;
  39439. private _useParallax;
  39440. /**
  39441. * Is parallax enabled or not.
  39442. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39443. */
  39444. useParallax: boolean;
  39445. private _useParallaxOcclusion;
  39446. /**
  39447. * Is parallax occlusion enabled or not.
  39448. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39449. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39450. */
  39451. useParallaxOcclusion: boolean;
  39452. /**
  39453. * 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.
  39454. */
  39455. parallaxScaleBias: number;
  39456. private _roughness;
  39457. /**
  39458. * Helps to define how blurry the reflections should appears in the material.
  39459. */
  39460. roughness: number;
  39461. /**
  39462. * In case of refraction, define the value of the index of refraction.
  39463. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39464. */
  39465. indexOfRefraction: number;
  39466. /**
  39467. * Invert the refraction texture alongside the y axis.
  39468. * It can be useful with procedural textures or probe for instance.
  39469. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39470. */
  39471. invertRefractionY: boolean;
  39472. /**
  39473. * Defines the alpha limits in alpha test mode.
  39474. */
  39475. alphaCutOff: number;
  39476. private _useLightmapAsShadowmap;
  39477. /**
  39478. * In case of light mapping, define whether the map contains light or shadow informations.
  39479. */
  39480. useLightmapAsShadowmap: boolean;
  39481. private _diffuseFresnelParameters;
  39482. /**
  39483. * Define the diffuse fresnel parameters of the material.
  39484. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39485. */
  39486. diffuseFresnelParameters: FresnelParameters;
  39487. private _opacityFresnelParameters;
  39488. /**
  39489. * Define the opacity fresnel parameters of the material.
  39490. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39491. */
  39492. opacityFresnelParameters: FresnelParameters;
  39493. private _reflectionFresnelParameters;
  39494. /**
  39495. * Define the reflection fresnel parameters of the material.
  39496. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39497. */
  39498. reflectionFresnelParameters: FresnelParameters;
  39499. private _refractionFresnelParameters;
  39500. /**
  39501. * Define the refraction fresnel parameters of the material.
  39502. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39503. */
  39504. refractionFresnelParameters: FresnelParameters;
  39505. private _emissiveFresnelParameters;
  39506. /**
  39507. * Define the emissive fresnel parameters of the material.
  39508. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39509. */
  39510. emissiveFresnelParameters: FresnelParameters;
  39511. private _useReflectionFresnelFromSpecular;
  39512. /**
  39513. * If true automatically deducts the fresnels values from the material specularity.
  39514. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39515. */
  39516. useReflectionFresnelFromSpecular: boolean;
  39517. private _useGlossinessFromSpecularMapAlpha;
  39518. /**
  39519. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39520. */
  39521. useGlossinessFromSpecularMapAlpha: boolean;
  39522. private _maxSimultaneousLights;
  39523. /**
  39524. * Defines the maximum number of lights that can be used in the material
  39525. */
  39526. maxSimultaneousLights: number;
  39527. private _invertNormalMapX;
  39528. /**
  39529. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39530. */
  39531. invertNormalMapX: boolean;
  39532. private _invertNormalMapY;
  39533. /**
  39534. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39535. */
  39536. invertNormalMapY: boolean;
  39537. private _twoSidedLighting;
  39538. /**
  39539. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39540. */
  39541. twoSidedLighting: boolean;
  39542. /**
  39543. * Default configuration related to image processing available in the standard Material.
  39544. */
  39545. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39546. /**
  39547. * Gets the image processing configuration used either in this material.
  39548. */
  39549. /**
  39550. * Sets the Default image processing configuration used either in the this material.
  39551. *
  39552. * If sets to null, the scene one is in use.
  39553. */
  39554. imageProcessingConfiguration: ImageProcessingConfiguration;
  39555. /**
  39556. * Keep track of the image processing observer to allow dispose and replace.
  39557. */
  39558. private _imageProcessingObserver;
  39559. /**
  39560. * Attaches a new image processing configuration to the Standard Material.
  39561. * @param configuration
  39562. */
  39563. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39564. /**
  39565. * Gets wether the color curves effect is enabled.
  39566. */
  39567. /**
  39568. * Sets wether the color curves effect is enabled.
  39569. */
  39570. cameraColorCurvesEnabled: boolean;
  39571. /**
  39572. * Gets wether the color grading effect is enabled.
  39573. */
  39574. /**
  39575. * Gets wether the color grading effect is enabled.
  39576. */
  39577. cameraColorGradingEnabled: boolean;
  39578. /**
  39579. * Gets wether tonemapping is enabled or not.
  39580. */
  39581. /**
  39582. * Sets wether tonemapping is enabled or not
  39583. */
  39584. cameraToneMappingEnabled: boolean;
  39585. /**
  39586. * The camera exposure used on this material.
  39587. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39588. * This corresponds to a photographic exposure.
  39589. */
  39590. /**
  39591. * The camera exposure used on this material.
  39592. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39593. * This corresponds to a photographic exposure.
  39594. */
  39595. cameraExposure: number;
  39596. /**
  39597. * Gets The camera contrast used on this material.
  39598. */
  39599. /**
  39600. * Sets The camera contrast used on this material.
  39601. */
  39602. cameraContrast: number;
  39603. /**
  39604. * Gets the Color Grading 2D Lookup Texture.
  39605. */
  39606. /**
  39607. * Sets the Color Grading 2D Lookup Texture.
  39608. */
  39609. cameraColorGradingTexture: Nullable<BaseTexture>;
  39610. /**
  39611. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39612. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39613. * 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;
  39614. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39615. */
  39616. /**
  39617. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39618. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39619. * 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;
  39620. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39621. */
  39622. cameraColorCurves: Nullable<ColorCurves>;
  39623. /**
  39624. * Custom callback helping to override the default shader used in the material.
  39625. */
  39626. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39627. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39628. protected _worldViewProjectionMatrix: Matrix;
  39629. protected _globalAmbientColor: Color3;
  39630. protected _useLogarithmicDepth: boolean;
  39631. protected _rebuildInParallel: boolean;
  39632. /**
  39633. * Instantiates a new standard material.
  39634. * This is the default material used in Babylon. It is the best trade off between quality
  39635. * and performances.
  39636. * @see http://doc.babylonjs.com/babylon101/materials
  39637. * @param name Define the name of the material in the scene
  39638. * @param scene Define the scene the material belong to
  39639. */
  39640. constructor(name: string, scene: Scene);
  39641. /**
  39642. * Gets a boolean indicating that current material needs to register RTT
  39643. */
  39644. readonly hasRenderTargetTextures: boolean;
  39645. /**
  39646. * Gets the current class name of the material e.g. "StandardMaterial"
  39647. * Mainly use in serialization.
  39648. * @returns the class name
  39649. */
  39650. getClassName(): string;
  39651. /**
  39652. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39653. * You can try switching to logarithmic depth.
  39654. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39655. */
  39656. useLogarithmicDepth: boolean;
  39657. /**
  39658. * Specifies if the material will require alpha blending
  39659. * @returns a boolean specifying if alpha blending is needed
  39660. */
  39661. needAlphaBlending(): boolean;
  39662. /**
  39663. * Specifies if this material should be rendered in alpha test mode
  39664. * @returns a boolean specifying if an alpha test is needed.
  39665. */
  39666. needAlphaTesting(): boolean;
  39667. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39668. /**
  39669. * Get the texture used for alpha test purpose.
  39670. * @returns the diffuse texture in case of the standard material.
  39671. */
  39672. getAlphaTestTexture(): Nullable<BaseTexture>;
  39673. /**
  39674. * Get if the submesh is ready to be used and all its information available.
  39675. * Child classes can use it to update shaders
  39676. * @param mesh defines the mesh to check
  39677. * @param subMesh defines which submesh to check
  39678. * @param useInstances specifies that instances should be used
  39679. * @returns a boolean indicating that the submesh is ready or not
  39680. */
  39681. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39682. /**
  39683. * Builds the material UBO layouts.
  39684. * Used internally during the effect preparation.
  39685. */
  39686. buildUniformLayout(): void;
  39687. /**
  39688. * Unbinds the material from the mesh
  39689. */
  39690. unbind(): void;
  39691. /**
  39692. * Binds the submesh to this material by preparing the effect and shader to draw
  39693. * @param world defines the world transformation matrix
  39694. * @param mesh defines the mesh containing the submesh
  39695. * @param subMesh defines the submesh to bind the material to
  39696. */
  39697. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39698. /**
  39699. * Get the list of animatables in the material.
  39700. * @returns the list of animatables object used in the material
  39701. */
  39702. getAnimatables(): IAnimatable[];
  39703. /**
  39704. * Gets the active textures from the material
  39705. * @returns an array of textures
  39706. */
  39707. getActiveTextures(): BaseTexture[];
  39708. /**
  39709. * Specifies if the material uses a texture
  39710. * @param texture defines the texture to check against the material
  39711. * @returns a boolean specifying if the material uses the texture
  39712. */
  39713. hasTexture(texture: BaseTexture): boolean;
  39714. /**
  39715. * Disposes the material
  39716. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39717. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39718. */
  39719. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39720. /**
  39721. * Makes a duplicate of the material, and gives it a new name
  39722. * @param name defines the new name for the duplicated material
  39723. * @returns the cloned material
  39724. */
  39725. clone(name: string): StandardMaterial;
  39726. /**
  39727. * Serializes this material in a JSON representation
  39728. * @returns the serialized material object
  39729. */
  39730. serialize(): any;
  39731. /**
  39732. * Creates a standard material from parsed material data
  39733. * @param source defines the JSON representation of the material
  39734. * @param scene defines the hosting scene
  39735. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39736. * @returns a new standard material
  39737. */
  39738. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39739. /**
  39740. * Are diffuse textures enabled in the application.
  39741. */
  39742. static DiffuseTextureEnabled: boolean;
  39743. /**
  39744. * Are ambient textures enabled in the application.
  39745. */
  39746. static AmbientTextureEnabled: boolean;
  39747. /**
  39748. * Are opacity textures enabled in the application.
  39749. */
  39750. static OpacityTextureEnabled: boolean;
  39751. /**
  39752. * Are reflection textures enabled in the application.
  39753. */
  39754. static ReflectionTextureEnabled: boolean;
  39755. /**
  39756. * Are emissive textures enabled in the application.
  39757. */
  39758. static EmissiveTextureEnabled: boolean;
  39759. /**
  39760. * Are specular textures enabled in the application.
  39761. */
  39762. static SpecularTextureEnabled: boolean;
  39763. /**
  39764. * Are bump textures enabled in the application.
  39765. */
  39766. static BumpTextureEnabled: boolean;
  39767. /**
  39768. * Are lightmap textures enabled in the application.
  39769. */
  39770. static LightmapTextureEnabled: boolean;
  39771. /**
  39772. * Are refraction textures enabled in the application.
  39773. */
  39774. static RefractionTextureEnabled: boolean;
  39775. /**
  39776. * Are color grading textures enabled in the application.
  39777. */
  39778. static ColorGradingTextureEnabled: boolean;
  39779. /**
  39780. * Are fresnels enabled in the application.
  39781. */
  39782. static FresnelEnabled: boolean;
  39783. }
  39784. }
  39785. declare module BABYLON {
  39786. /** @hidden */
  39787. export var imageProcessingPixelShader: {
  39788. name: string;
  39789. shader: string;
  39790. };
  39791. }
  39792. declare module BABYLON {
  39793. /**
  39794. * ImageProcessingPostProcess
  39795. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39796. */
  39797. export class ImageProcessingPostProcess extends PostProcess {
  39798. /**
  39799. * Default configuration related to image processing available in the PBR Material.
  39800. */
  39801. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39802. /**
  39803. * Gets the image processing configuration used either in this material.
  39804. */
  39805. /**
  39806. * Sets the Default image processing configuration used either in the this material.
  39807. *
  39808. * If sets to null, the scene one is in use.
  39809. */
  39810. imageProcessingConfiguration: ImageProcessingConfiguration;
  39811. /**
  39812. * Keep track of the image processing observer to allow dispose and replace.
  39813. */
  39814. private _imageProcessingObserver;
  39815. /**
  39816. * Attaches a new image processing configuration to the PBR Material.
  39817. * @param configuration
  39818. */
  39819. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39820. /**
  39821. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39822. */
  39823. /**
  39824. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39825. */
  39826. colorCurves: Nullable<ColorCurves>;
  39827. /**
  39828. * Gets wether the color curves effect is enabled.
  39829. */
  39830. /**
  39831. * Sets wether the color curves effect is enabled.
  39832. */
  39833. colorCurvesEnabled: boolean;
  39834. /**
  39835. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39836. */
  39837. /**
  39838. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39839. */
  39840. colorGradingTexture: Nullable<BaseTexture>;
  39841. /**
  39842. * Gets wether the color grading effect is enabled.
  39843. */
  39844. /**
  39845. * Gets wether the color grading effect is enabled.
  39846. */
  39847. colorGradingEnabled: boolean;
  39848. /**
  39849. * Gets exposure used in the effect.
  39850. */
  39851. /**
  39852. * Sets exposure used in the effect.
  39853. */
  39854. exposure: number;
  39855. /**
  39856. * Gets wether tonemapping is enabled or not.
  39857. */
  39858. /**
  39859. * Sets wether tonemapping is enabled or not
  39860. */
  39861. toneMappingEnabled: boolean;
  39862. /**
  39863. * Gets the type of tone mapping effect.
  39864. */
  39865. /**
  39866. * Sets the type of tone mapping effect.
  39867. */
  39868. toneMappingType: number;
  39869. /**
  39870. * Gets contrast used in the effect.
  39871. */
  39872. /**
  39873. * Sets contrast used in the effect.
  39874. */
  39875. contrast: number;
  39876. /**
  39877. * Gets Vignette stretch size.
  39878. */
  39879. /**
  39880. * Sets Vignette stretch size.
  39881. */
  39882. vignetteStretch: number;
  39883. /**
  39884. * Gets Vignette centre X Offset.
  39885. */
  39886. /**
  39887. * Sets Vignette centre X Offset.
  39888. */
  39889. vignetteCentreX: number;
  39890. /**
  39891. * Gets Vignette centre Y Offset.
  39892. */
  39893. /**
  39894. * Sets Vignette centre Y Offset.
  39895. */
  39896. vignetteCentreY: number;
  39897. /**
  39898. * Gets Vignette weight or intensity of the vignette effect.
  39899. */
  39900. /**
  39901. * Sets Vignette weight or intensity of the vignette effect.
  39902. */
  39903. vignetteWeight: number;
  39904. /**
  39905. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39906. * if vignetteEnabled is set to true.
  39907. */
  39908. /**
  39909. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39910. * if vignetteEnabled is set to true.
  39911. */
  39912. vignetteColor: Color4;
  39913. /**
  39914. * Gets Camera field of view used by the Vignette effect.
  39915. */
  39916. /**
  39917. * Sets Camera field of view used by the Vignette effect.
  39918. */
  39919. vignetteCameraFov: number;
  39920. /**
  39921. * Gets the vignette blend mode allowing different kind of effect.
  39922. */
  39923. /**
  39924. * Sets the vignette blend mode allowing different kind of effect.
  39925. */
  39926. vignetteBlendMode: number;
  39927. /**
  39928. * Gets wether the vignette effect is enabled.
  39929. */
  39930. /**
  39931. * Sets wether the vignette effect is enabled.
  39932. */
  39933. vignetteEnabled: boolean;
  39934. private _fromLinearSpace;
  39935. /**
  39936. * Gets wether the input of the processing is in Gamma or Linear Space.
  39937. */
  39938. /**
  39939. * Sets wether the input of the processing is in Gamma or Linear Space.
  39940. */
  39941. fromLinearSpace: boolean;
  39942. /**
  39943. * Defines cache preventing GC.
  39944. */
  39945. private _defines;
  39946. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39947. /**
  39948. * "ImageProcessingPostProcess"
  39949. * @returns "ImageProcessingPostProcess"
  39950. */
  39951. getClassName(): string;
  39952. protected _updateParameters(): void;
  39953. dispose(camera?: Camera): void;
  39954. }
  39955. }
  39956. declare module BABYLON {
  39957. /**
  39958. * Class containing static functions to help procedurally build meshes
  39959. */
  39960. export class GroundBuilder {
  39961. /**
  39962. * Creates a ground mesh
  39963. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39964. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39966. * @param name defines the name of the mesh
  39967. * @param options defines the options used to create the mesh
  39968. * @param scene defines the hosting scene
  39969. * @returns the ground mesh
  39970. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39971. */
  39972. static CreateGround(name: string, options: {
  39973. width?: number;
  39974. height?: number;
  39975. subdivisions?: number;
  39976. subdivisionsX?: number;
  39977. subdivisionsY?: number;
  39978. updatable?: boolean;
  39979. }, scene: any): Mesh;
  39980. /**
  39981. * Creates a tiled ground mesh
  39982. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39983. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39984. * * 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
  39985. * * 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
  39986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39987. * @param name defines the name of the mesh
  39988. * @param options defines the options used to create the mesh
  39989. * @param scene defines the hosting scene
  39990. * @returns the tiled ground mesh
  39991. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39992. */
  39993. static CreateTiledGround(name: string, options: {
  39994. xmin: number;
  39995. zmin: number;
  39996. xmax: number;
  39997. zmax: number;
  39998. subdivisions?: {
  39999. w: number;
  40000. h: number;
  40001. };
  40002. precision?: {
  40003. w: number;
  40004. h: number;
  40005. };
  40006. updatable?: boolean;
  40007. }, scene?: Nullable<Scene>): Mesh;
  40008. /**
  40009. * Creates a ground mesh from a height map
  40010. * * The parameter `url` sets the URL of the height map image resource.
  40011. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40012. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40013. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40014. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40015. * * 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.
  40016. * * 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).
  40017. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40019. * @param name defines the name of the mesh
  40020. * @param url defines the url to the height map
  40021. * @param options defines the options used to create the mesh
  40022. * @param scene defines the hosting scene
  40023. * @returns the ground mesh
  40024. * @see https://doc.babylonjs.com/babylon101/height_map
  40025. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40026. */
  40027. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40028. width?: number;
  40029. height?: number;
  40030. subdivisions?: number;
  40031. minHeight?: number;
  40032. maxHeight?: number;
  40033. colorFilter?: Color3;
  40034. alphaFilter?: number;
  40035. updatable?: boolean;
  40036. onReady?: (mesh: GroundMesh) => void;
  40037. }, scene?: Nullable<Scene>): GroundMesh;
  40038. }
  40039. }
  40040. declare module BABYLON {
  40041. /**
  40042. * Class containing static functions to help procedurally build meshes
  40043. */
  40044. export class TorusBuilder {
  40045. /**
  40046. * Creates a torus mesh
  40047. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40048. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40049. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40051. * * 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
  40052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40053. * @param name defines the name of the mesh
  40054. * @param options defines the options used to create the mesh
  40055. * @param scene defines the hosting scene
  40056. * @returns the torus mesh
  40057. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40058. */
  40059. static CreateTorus(name: string, options: {
  40060. diameter?: number;
  40061. thickness?: number;
  40062. tessellation?: number;
  40063. updatable?: boolean;
  40064. sideOrientation?: number;
  40065. frontUVs?: Vector4;
  40066. backUVs?: Vector4;
  40067. }, scene: any): Mesh;
  40068. }
  40069. }
  40070. declare module BABYLON {
  40071. /**
  40072. * Class containing static functions to help procedurally build meshes
  40073. */
  40074. export class CylinderBuilder {
  40075. /**
  40076. * Creates a cylinder or a cone mesh
  40077. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40078. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40079. * * 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.
  40080. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40081. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40082. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40083. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40084. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  40085. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40086. * * 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).
  40087. * * 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
  40088. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40089. * * 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
  40090. * * 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.
  40091. * * If `enclose` is false, a ring surface is one element.
  40092. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40093. * * 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
  40094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40095. * * 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
  40096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40097. * @param name defines the name of the mesh
  40098. * @param options defines the options used to create the mesh
  40099. * @param scene defines the hosting scene
  40100. * @returns the cylinder mesh
  40101. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40102. */
  40103. static CreateCylinder(name: string, options: {
  40104. height?: number;
  40105. diameterTop?: number;
  40106. diameterBottom?: number;
  40107. diameter?: number;
  40108. tessellation?: number;
  40109. subdivisions?: number;
  40110. arc?: number;
  40111. faceColors?: Color4[];
  40112. faceUV?: Vector4[];
  40113. updatable?: boolean;
  40114. hasRings?: boolean;
  40115. enclose?: boolean;
  40116. cap?: number;
  40117. sideOrientation?: number;
  40118. frontUVs?: Vector4;
  40119. backUVs?: Vector4;
  40120. }, scene: any): Mesh;
  40121. }
  40122. }
  40123. declare module BABYLON {
  40124. /**
  40125. * Options to modify the vr teleportation behavior.
  40126. */
  40127. export interface VRTeleportationOptions {
  40128. /**
  40129. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40130. */
  40131. floorMeshName?: string;
  40132. /**
  40133. * A list of meshes to be used as the teleportation floor. (default: empty)
  40134. */
  40135. floorMeshes?: Mesh[];
  40136. }
  40137. /**
  40138. * Options to modify the vr experience helper's behavior.
  40139. */
  40140. export interface VRExperienceHelperOptions extends WebVROptions {
  40141. /**
  40142. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40143. */
  40144. createDeviceOrientationCamera?: boolean;
  40145. /**
  40146. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40147. */
  40148. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40149. /**
  40150. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40151. */
  40152. laserToggle?: boolean;
  40153. /**
  40154. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40155. */
  40156. floorMeshes?: Mesh[];
  40157. /**
  40158. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40159. */
  40160. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40161. }
  40162. /**
  40163. * Event containing information after VR has been entered
  40164. */
  40165. export class OnAfterEnteringVRObservableEvent {
  40166. /**
  40167. * If entering vr was successful
  40168. */
  40169. success: boolean;
  40170. }
  40171. /**
  40172. * Helps to quickly add VR support to an existing scene.
  40173. * See http://doc.babylonjs.com/how_to/webvr_helper
  40174. */
  40175. export class VRExperienceHelper {
  40176. /** Options to modify the vr experience helper's behavior. */
  40177. webVROptions: VRExperienceHelperOptions;
  40178. private _scene;
  40179. private _position;
  40180. private _btnVR;
  40181. private _btnVRDisplayed;
  40182. private _webVRsupported;
  40183. private _webVRready;
  40184. private _webVRrequesting;
  40185. private _webVRpresenting;
  40186. private _hasEnteredVR;
  40187. private _fullscreenVRpresenting;
  40188. private _canvas;
  40189. private _webVRCamera;
  40190. private _vrDeviceOrientationCamera;
  40191. private _deviceOrientationCamera;
  40192. private _existingCamera;
  40193. private _onKeyDown;
  40194. private _onVrDisplayPresentChange;
  40195. private _onVRDisplayChanged;
  40196. private _onVRRequestPresentStart;
  40197. private _onVRRequestPresentComplete;
  40198. /**
  40199. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  40200. */
  40201. enableGazeEvenWhenNoPointerLock: boolean;
  40202. /**
  40203. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40204. */
  40205. exitVROnDoubleTap: boolean;
  40206. /**
  40207. * Observable raised right before entering VR.
  40208. */
  40209. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40210. /**
  40211. * Observable raised when entering VR has completed.
  40212. */
  40213. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40214. /**
  40215. * Observable raised when exiting VR.
  40216. */
  40217. onExitingVRObservable: Observable<VRExperienceHelper>;
  40218. /**
  40219. * Observable raised when controller mesh is loaded.
  40220. */
  40221. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40222. /** Return this.onEnteringVRObservable
  40223. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40224. */
  40225. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40226. /** Return this.onExitingVRObservable
  40227. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40228. */
  40229. readonly onExitingVR: Observable<VRExperienceHelper>;
  40230. /** Return this.onControllerMeshLoadedObservable
  40231. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40232. */
  40233. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40234. private _rayLength;
  40235. private _useCustomVRButton;
  40236. private _teleportationRequested;
  40237. private _teleportActive;
  40238. private _floorMeshName;
  40239. private _floorMeshesCollection;
  40240. private _rotationAllowed;
  40241. private _teleportBackwardsVector;
  40242. private _teleportationTarget;
  40243. private _isDefaultTeleportationTarget;
  40244. private _postProcessMove;
  40245. private _teleportationFillColor;
  40246. private _teleportationBorderColor;
  40247. private _rotationAngle;
  40248. private _haloCenter;
  40249. private _cameraGazer;
  40250. private _padSensibilityUp;
  40251. private _padSensibilityDown;
  40252. private _leftController;
  40253. private _rightController;
  40254. /**
  40255. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40256. */
  40257. onNewMeshSelected: Observable<AbstractMesh>;
  40258. /**
  40259. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40260. * This observable will provide the mesh and the controller used to select the mesh
  40261. */
  40262. onMeshSelectedWithController: Observable<{
  40263. mesh: AbstractMesh;
  40264. controller: WebVRController;
  40265. }>;
  40266. /**
  40267. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40268. */
  40269. onNewMeshPicked: Observable<PickingInfo>;
  40270. private _circleEase;
  40271. /**
  40272. * Observable raised before camera teleportation
  40273. */
  40274. onBeforeCameraTeleport: Observable<Vector3>;
  40275. /**
  40276. * Observable raised after camera teleportation
  40277. */
  40278. onAfterCameraTeleport: Observable<Vector3>;
  40279. /**
  40280. * Observable raised when current selected mesh gets unselected
  40281. */
  40282. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40283. private _raySelectionPredicate;
  40284. /**
  40285. * To be optionaly changed by user to define custom ray selection
  40286. */
  40287. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40288. /**
  40289. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40290. */
  40291. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40292. /**
  40293. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40294. */
  40295. teleportationEnabled: boolean;
  40296. private _defaultHeight;
  40297. private _teleportationInitialized;
  40298. private _interactionsEnabled;
  40299. private _interactionsRequested;
  40300. private _displayGaze;
  40301. private _displayLaserPointer;
  40302. /**
  40303. * The mesh used to display where the user is going to teleport.
  40304. */
  40305. /**
  40306. * Sets the mesh to be used to display where the user is going to teleport.
  40307. */
  40308. teleportationTarget: Mesh;
  40309. /**
  40310. * 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
  40311. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40312. * See http://doc.babylonjs.com/resources/baking_transformations
  40313. */
  40314. gazeTrackerMesh: Mesh;
  40315. /**
  40316. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40317. */
  40318. updateGazeTrackerScale: boolean;
  40319. /**
  40320. * If the gaze trackers color should be updated when selecting meshes
  40321. */
  40322. updateGazeTrackerColor: boolean;
  40323. /**
  40324. * If the controller laser color should be updated when selecting meshes
  40325. */
  40326. updateControllerLaserColor: boolean;
  40327. /**
  40328. * The gaze tracking mesh corresponding to the left controller
  40329. */
  40330. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40331. /**
  40332. * The gaze tracking mesh corresponding to the right controller
  40333. */
  40334. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40335. /**
  40336. * If the ray of the gaze should be displayed.
  40337. */
  40338. /**
  40339. * Sets if the ray of the gaze should be displayed.
  40340. */
  40341. displayGaze: boolean;
  40342. /**
  40343. * If the ray of the LaserPointer should be displayed.
  40344. */
  40345. /**
  40346. * Sets if the ray of the LaserPointer should be displayed.
  40347. */
  40348. displayLaserPointer: boolean;
  40349. /**
  40350. * The deviceOrientationCamera used as the camera when not in VR.
  40351. */
  40352. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40353. /**
  40354. * Based on the current WebVR support, returns the current VR camera used.
  40355. */
  40356. readonly currentVRCamera: Nullable<Camera>;
  40357. /**
  40358. * The webVRCamera which is used when in VR.
  40359. */
  40360. readonly webVRCamera: WebVRFreeCamera;
  40361. /**
  40362. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40363. */
  40364. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40365. /**
  40366. * The html button that is used to trigger entering into VR.
  40367. */
  40368. readonly vrButton: Nullable<HTMLButtonElement>;
  40369. private readonly _teleportationRequestInitiated;
  40370. /**
  40371. * Defines wether or not Pointer lock should be requested when switching to
  40372. * full screen.
  40373. */
  40374. requestPointerLockOnFullScreen: boolean;
  40375. /**
  40376. * Instantiates a VRExperienceHelper.
  40377. * Helps to quickly add VR support to an existing scene.
  40378. * @param scene The scene the VRExperienceHelper belongs to.
  40379. * @param webVROptions Options to modify the vr experience helper's behavior.
  40380. */
  40381. constructor(scene: Scene,
  40382. /** Options to modify the vr experience helper's behavior. */
  40383. webVROptions?: VRExperienceHelperOptions);
  40384. private _onDefaultMeshLoaded;
  40385. private _onResize;
  40386. private _onFullscreenChange;
  40387. /**
  40388. * Gets a value indicating if we are currently in VR mode.
  40389. */
  40390. readonly isInVRMode: boolean;
  40391. private onVrDisplayPresentChange;
  40392. private onVRDisplayChanged;
  40393. private moveButtonToBottomRight;
  40394. private displayVRButton;
  40395. private updateButtonVisibility;
  40396. private _cachedAngularSensibility;
  40397. /**
  40398. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40399. * Otherwise, will use the fullscreen API.
  40400. */
  40401. enterVR(): void;
  40402. /**
  40403. * Attempt to exit VR, or fullscreen.
  40404. */
  40405. exitVR(): void;
  40406. /**
  40407. * The position of the vr experience helper.
  40408. */
  40409. /**
  40410. * Sets the position of the vr experience helper.
  40411. */
  40412. position: Vector3;
  40413. /**
  40414. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40415. */
  40416. enableInteractions(): void;
  40417. private readonly _noControllerIsActive;
  40418. private beforeRender;
  40419. private _isTeleportationFloor;
  40420. /**
  40421. * Adds a floor mesh to be used for teleportation.
  40422. * @param floorMesh the mesh to be used for teleportation.
  40423. */
  40424. addFloorMesh(floorMesh: Mesh): void;
  40425. /**
  40426. * Removes a floor mesh from being used for teleportation.
  40427. * @param floorMesh the mesh to be removed.
  40428. */
  40429. removeFloorMesh(floorMesh: Mesh): void;
  40430. /**
  40431. * Enables interactions and teleportation using the VR controllers and gaze.
  40432. * @param vrTeleportationOptions options to modify teleportation behavior.
  40433. */
  40434. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40435. private _onNewGamepadConnected;
  40436. private _tryEnableInteractionOnController;
  40437. private _onNewGamepadDisconnected;
  40438. private _enableInteractionOnController;
  40439. private _checkTeleportWithRay;
  40440. private _checkRotate;
  40441. private _checkTeleportBackwards;
  40442. private _enableTeleportationOnController;
  40443. private _createTeleportationCircles;
  40444. private _displayTeleportationTarget;
  40445. private _hideTeleportationTarget;
  40446. private _rotateCamera;
  40447. private _moveTeleportationSelectorTo;
  40448. private _workingVector;
  40449. private _workingQuaternion;
  40450. private _workingMatrix;
  40451. /**
  40452. * Teleports the users feet to the desired location
  40453. * @param location The location where the user's feet should be placed
  40454. */
  40455. teleportCamera(location: Vector3): void;
  40456. private _convertNormalToDirectionOfRay;
  40457. private _castRayAndSelectObject;
  40458. private _notifySelectedMeshUnselected;
  40459. /**
  40460. * Sets the color of the laser ray from the vr controllers.
  40461. * @param color new color for the ray.
  40462. */
  40463. changeLaserColor(color: Color3): void;
  40464. /**
  40465. * Sets the color of the ray from the vr headsets gaze.
  40466. * @param color new color for the ray.
  40467. */
  40468. changeGazeColor(color: Color3): void;
  40469. /**
  40470. * Exits VR and disposes of the vr experience helper
  40471. */
  40472. dispose(): void;
  40473. /**
  40474. * Gets the name of the VRExperienceHelper class
  40475. * @returns "VRExperienceHelper"
  40476. */
  40477. getClassName(): string;
  40478. }
  40479. }
  40480. declare module BABYLON {
  40481. /**
  40482. * Manages an XRSession to work with Babylon's engine
  40483. * @see https://doc.babylonjs.com/how_to/webxr
  40484. */
  40485. export class WebXRSessionManager implements IDisposable {
  40486. private scene;
  40487. /**
  40488. * Fires every time a new xrFrame arrives which can be used to update the camera
  40489. */
  40490. onXRFrameObservable: Observable<any>;
  40491. /**
  40492. * Fires when the xr session is ended either by the device or manually done
  40493. */
  40494. onXRSessionEnded: Observable<any>;
  40495. /**
  40496. * Underlying xr session
  40497. */
  40498. session: XRSession;
  40499. /**
  40500. * Type of reference space used when creating the session
  40501. */
  40502. referenceSpace: XRReferenceSpace;
  40503. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40504. /**
  40505. * Current XR frame
  40506. */
  40507. currentFrame: Nullable<XRFrame>;
  40508. private _xrNavigator;
  40509. private baseLayer;
  40510. /**
  40511. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40512. * @param scene The scene which the session should be created for
  40513. */
  40514. constructor(scene: Scene);
  40515. /**
  40516. * Initializes the manager
  40517. * After initialization enterXR can be called to start an XR session
  40518. * @returns Promise which resolves after it is initialized
  40519. */
  40520. initializeAsync(): Promise<void>;
  40521. /**
  40522. * Initializes an xr session
  40523. * @param xrSessionMode mode to initialize
  40524. * @returns a promise which will resolve once the session has been initialized
  40525. */
  40526. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40527. /**
  40528. * Sets the reference space on the xr session
  40529. * @param referenceSpace space to set
  40530. * @returns a promise that will resolve once the reference space has been set
  40531. */
  40532. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40533. /**
  40534. * Updates the render state of the session
  40535. * @param state state to set
  40536. * @returns a promise that resolves once the render state has been updated
  40537. */
  40538. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40539. /**
  40540. * Starts rendering to the xr layer
  40541. * @returns a promise that will resolve once rendering has started
  40542. */
  40543. startRenderingToXRAsync(): Promise<void>;
  40544. /**
  40545. * Stops the xrSession and restores the renderloop
  40546. * @returns Promise which resolves after it exits XR
  40547. */
  40548. exitXRAsync(): Promise<unknown>;
  40549. /**
  40550. * Checks if a session would be supported for the creation options specified
  40551. * @param sessionMode session mode to check if supported eg. immersive-vr
  40552. * @returns true if supported
  40553. */
  40554. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40555. /**
  40556. * @hidden
  40557. * Converts the render layer of xrSession to a render target
  40558. * @param session session to create render target for
  40559. * @param scene scene the new render target should be created for
  40560. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40561. /**
  40562. * Disposes of the session manager
  40563. */
  40564. dispose(): void;
  40565. }
  40566. }
  40567. declare module BABYLON {
  40568. /**
  40569. * WebXR Camera which holds the views for the xrSession
  40570. * @see https://doc.babylonjs.com/how_to/webxr
  40571. */
  40572. export class WebXRCamera extends FreeCamera {
  40573. private static _TmpMatrix;
  40574. /**
  40575. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40576. * @param name the name of the camera
  40577. * @param scene the scene to add the camera to
  40578. */
  40579. constructor(name: string, scene: Scene);
  40580. private _updateNumberOfRigCameras;
  40581. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  40582. /**
  40583. * Updates the cameras position from the current pose information of the XR session
  40584. * @param xrSessionManager the session containing pose information
  40585. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40586. */
  40587. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40588. }
  40589. }
  40590. declare module BABYLON {
  40591. /**
  40592. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40593. */
  40594. export class WebXRManagedOutputCanvas implements IDisposable {
  40595. private helper;
  40596. private _canvas;
  40597. /**
  40598. * xrpresent context of the canvas which can be used to display/mirror xr content
  40599. */
  40600. canvasContext: WebGLRenderingContext;
  40601. /**
  40602. * xr layer for the canvas
  40603. */
  40604. xrLayer: Nullable<XRWebGLLayer>;
  40605. /**
  40606. * Initializes the xr layer for the session
  40607. * @param xrSession xr session
  40608. * @returns a promise that will resolve once the XR Layer has been created
  40609. */
  40610. initializeXRLayerAsync(xrSession: any): any;
  40611. /**
  40612. * Initializes the canvas to be added/removed upon entering/exiting xr
  40613. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40614. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40615. */
  40616. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40617. /**
  40618. * Disposes of the object
  40619. */
  40620. dispose(): void;
  40621. private _setManagedOutputCanvas;
  40622. private _addCanvas;
  40623. private _removeCanvas;
  40624. }
  40625. }
  40626. declare module BABYLON {
  40627. /**
  40628. * States of the webXR experience
  40629. */
  40630. export enum WebXRState {
  40631. /**
  40632. * Transitioning to being in XR mode
  40633. */
  40634. ENTERING_XR = 0,
  40635. /**
  40636. * Transitioning to non XR mode
  40637. */
  40638. EXITING_XR = 1,
  40639. /**
  40640. * In XR mode and presenting
  40641. */
  40642. IN_XR = 2,
  40643. /**
  40644. * Not entered XR mode
  40645. */
  40646. NOT_IN_XR = 3
  40647. }
  40648. /**
  40649. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40650. * @see https://doc.babylonjs.com/how_to/webxr
  40651. */
  40652. export class WebXRExperienceHelper implements IDisposable {
  40653. private scene;
  40654. /**
  40655. * 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
  40656. */
  40657. container: AbstractMesh;
  40658. /**
  40659. * Camera used to render xr content
  40660. */
  40661. camera: WebXRCamera;
  40662. /**
  40663. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40664. */
  40665. state: WebXRState;
  40666. private _setState;
  40667. private static _TmpVector;
  40668. /**
  40669. * Fires when the state of the experience helper has changed
  40670. */
  40671. onStateChangedObservable: Observable<WebXRState>;
  40672. /** Session manager used to keep track of xr session */
  40673. sessionManager: WebXRSessionManager;
  40674. private _nonVRCamera;
  40675. private _originalSceneAutoClear;
  40676. private _supported;
  40677. /**
  40678. * Creates the experience helper
  40679. * @param scene the scene to attach the experience helper to
  40680. * @returns a promise for the experience helper
  40681. */
  40682. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40683. /**
  40684. * Creates a WebXRExperienceHelper
  40685. * @param scene The scene the helper should be created in
  40686. */
  40687. private constructor();
  40688. /**
  40689. * Exits XR mode and returns the scene to its original state
  40690. * @returns promise that resolves after xr mode has exited
  40691. */
  40692. exitXRAsync(): Promise<unknown>;
  40693. /**
  40694. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40695. * @param sessionCreationOptions options for the XR session
  40696. * @param referenceSpaceType frame of reference of the XR session
  40697. * @param outputCanvas the output canvas that will be used to enter XR mode
  40698. * @returns promise that resolves after xr mode has entered
  40699. */
  40700. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40701. /**
  40702. * Updates the global position of the camera by moving the camera's container
  40703. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40704. * @param position The desired global position of the camera
  40705. */
  40706. setPositionOfCameraUsingContainer(position: Vector3): void;
  40707. /**
  40708. * Rotates the xr camera by rotating the camera's container around the camera's position
  40709. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40710. * @param rotation the desired quaternion rotation to apply to the camera
  40711. */
  40712. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40713. /**
  40714. * Disposes of the experience helper
  40715. */
  40716. dispose(): void;
  40717. }
  40718. }
  40719. declare module BABYLON {
  40720. /**
  40721. * Button which can be used to enter a different mode of XR
  40722. */
  40723. export class WebXREnterExitUIButton {
  40724. /** button element */
  40725. element: HTMLElement;
  40726. /** XR initialization options for the button */
  40727. sessionMode: XRSessionMode;
  40728. /** Reference space type */
  40729. referenceSpaceType: XRReferenceSpaceType;
  40730. /**
  40731. * Creates a WebXREnterExitUIButton
  40732. * @param element button element
  40733. * @param sessionMode XR initialization session mode
  40734. * @param referenceSpaceType the type of reference space to be used
  40735. */
  40736. constructor(
  40737. /** button element */
  40738. element: HTMLElement,
  40739. /** XR initialization options for the button */
  40740. sessionMode: XRSessionMode,
  40741. /** Reference space type */
  40742. referenceSpaceType: XRReferenceSpaceType);
  40743. /**
  40744. * Overwritable function which can be used to update the button's visuals when the state changes
  40745. * @param activeButton the current active button in the UI
  40746. */
  40747. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40748. }
  40749. /**
  40750. * Options to create the webXR UI
  40751. */
  40752. export class WebXREnterExitUIOptions {
  40753. /**
  40754. * Context to enter xr with
  40755. */
  40756. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40757. /**
  40758. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40759. */
  40760. customButtons?: Array<WebXREnterExitUIButton>;
  40761. }
  40762. /**
  40763. * UI to allow the user to enter/exit XR mode
  40764. */
  40765. export class WebXREnterExitUI implements IDisposable {
  40766. private scene;
  40767. private _overlay;
  40768. private _buttons;
  40769. private _activeButton;
  40770. /**
  40771. * Fired every time the active button is changed.
  40772. *
  40773. * When xr is entered via a button that launches xr that button will be the callback parameter
  40774. *
  40775. * When exiting xr the callback parameter will be null)
  40776. */
  40777. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40778. /**
  40779. * Creates UI to allow the user to enter/exit XR mode
  40780. * @param scene the scene to add the ui to
  40781. * @param helper the xr experience helper to enter/exit xr with
  40782. * @param options options to configure the UI
  40783. * @returns the created ui
  40784. */
  40785. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40786. private constructor();
  40787. private _updateButtons;
  40788. /**
  40789. * Disposes of the object
  40790. */
  40791. dispose(): void;
  40792. }
  40793. }
  40794. declare module BABYLON {
  40795. /**
  40796. * Represents an XR input
  40797. */
  40798. export class WebXRController {
  40799. private scene;
  40800. /** The underlying input source for the controller */
  40801. inputSource: XRInputSource;
  40802. private parentContainer;
  40803. /**
  40804. * 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
  40805. */
  40806. grip?: AbstractMesh;
  40807. /**
  40808. * Pointer which can be used to select objects or attach a visible laser to
  40809. */
  40810. pointer: AbstractMesh;
  40811. /**
  40812. * Event that fires when the controller is removed/disposed
  40813. */
  40814. onDisposeObservable: Observable<{}>;
  40815. private _tmpMatrix;
  40816. private _tmpQuaternion;
  40817. private _tmpVector;
  40818. /**
  40819. * Creates the controller
  40820. * @see https://doc.babylonjs.com/how_to/webxr
  40821. * @param scene the scene which the controller should be associated to
  40822. * @param inputSource the underlying input source for the controller
  40823. * @param parentContainer parent that the controller meshes should be children of
  40824. */
  40825. constructor(scene: Scene,
  40826. /** The underlying input source for the controller */
  40827. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  40828. /**
  40829. * Updates the controller pose based on the given XRFrame
  40830. * @param xrFrame xr frame to update the pose with
  40831. * @param referenceSpace reference space to use
  40832. */
  40833. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  40834. /**
  40835. * Gets a world space ray coming from the controller
  40836. * @param result the resulting ray
  40837. */
  40838. getWorldPointerRayToRef(result: Ray): void;
  40839. /**
  40840. * Disposes of the object
  40841. */
  40842. dispose(): void;
  40843. }
  40844. }
  40845. declare module BABYLON {
  40846. /**
  40847. * XR input used to track XR inputs such as controllers/rays
  40848. */
  40849. export class WebXRInput implements IDisposable {
  40850. /**
  40851. * Base experience the input listens to
  40852. */
  40853. baseExperience: WebXRExperienceHelper;
  40854. /**
  40855. * XR controllers being tracked
  40856. */
  40857. controllers: Array<WebXRController>;
  40858. private _frameObserver;
  40859. private _stateObserver;
  40860. /**
  40861. * Event when a controller has been connected/added
  40862. */
  40863. onControllerAddedObservable: Observable<WebXRController>;
  40864. /**
  40865. * Event when a controller has been removed/disconnected
  40866. */
  40867. onControllerRemovedObservable: Observable<WebXRController>;
  40868. /**
  40869. * Initializes the WebXRInput
  40870. * @param baseExperience experience helper which the input should be created for
  40871. */
  40872. constructor(
  40873. /**
  40874. * Base experience the input listens to
  40875. */
  40876. baseExperience: WebXRExperienceHelper);
  40877. private _onInputSourcesChange;
  40878. private _addAndRemoveControllers;
  40879. /**
  40880. * Disposes of the object
  40881. */
  40882. dispose(): void;
  40883. }
  40884. }
  40885. declare module BABYLON {
  40886. /**
  40887. * Enables teleportation
  40888. */
  40889. export class WebXRControllerTeleportation {
  40890. private _teleportationFillColor;
  40891. private _teleportationBorderColor;
  40892. private _tmpRay;
  40893. private _tmpVector;
  40894. /**
  40895. * Creates a WebXRControllerTeleportation
  40896. * @param input input manager to add teleportation to
  40897. * @param floorMeshes floormeshes which can be teleported to
  40898. */
  40899. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  40900. }
  40901. }
  40902. declare module BABYLON {
  40903. /**
  40904. * Handles pointer input automatically for the pointer of XR controllers
  40905. */
  40906. export class WebXRControllerPointerSelection {
  40907. private static _idCounter;
  40908. private _tmpRay;
  40909. /**
  40910. * Creates a WebXRControllerPointerSelection
  40911. * @param input input manager to setup pointer selection
  40912. */
  40913. constructor(input: WebXRInput);
  40914. private _convertNormalToDirectionOfRay;
  40915. private _updatePointerDistance;
  40916. }
  40917. }
  40918. declare module BABYLON {
  40919. /**
  40920. * Class used to represent data loading progression
  40921. */
  40922. export class SceneLoaderProgressEvent {
  40923. /** defines if data length to load can be evaluated */
  40924. readonly lengthComputable: boolean;
  40925. /** defines the loaded data length */
  40926. readonly loaded: number;
  40927. /** defines the data length to load */
  40928. readonly total: number;
  40929. /**
  40930. * Create a new progress event
  40931. * @param lengthComputable defines if data length to load can be evaluated
  40932. * @param loaded defines the loaded data length
  40933. * @param total defines the data length to load
  40934. */
  40935. constructor(
  40936. /** defines if data length to load can be evaluated */
  40937. lengthComputable: boolean,
  40938. /** defines the loaded data length */
  40939. loaded: number,
  40940. /** defines the data length to load */
  40941. total: number);
  40942. /**
  40943. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40944. * @param event defines the source event
  40945. * @returns a new SceneLoaderProgressEvent
  40946. */
  40947. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40948. }
  40949. /**
  40950. * Interface used by SceneLoader plugins to define supported file extensions
  40951. */
  40952. export interface ISceneLoaderPluginExtensions {
  40953. /**
  40954. * Defines the list of supported extensions
  40955. */
  40956. [extension: string]: {
  40957. isBinary: boolean;
  40958. };
  40959. }
  40960. /**
  40961. * Interface used by SceneLoader plugin factory
  40962. */
  40963. export interface ISceneLoaderPluginFactory {
  40964. /**
  40965. * Defines the name of the factory
  40966. */
  40967. name: string;
  40968. /**
  40969. * Function called to create a new plugin
  40970. * @return the new plugin
  40971. */
  40972. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40973. /**
  40974. * Boolean indicating if the plugin can direct load specific data
  40975. */
  40976. canDirectLoad?: (data: string) => boolean;
  40977. }
  40978. /**
  40979. * Interface used to define a SceneLoader plugin
  40980. */
  40981. export interface ISceneLoaderPlugin {
  40982. /**
  40983. * The friendly name of this plugin.
  40984. */
  40985. name: string;
  40986. /**
  40987. * The file extensions supported by this plugin.
  40988. */
  40989. extensions: string | ISceneLoaderPluginExtensions;
  40990. /**
  40991. * Import meshes into a scene.
  40992. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40993. * @param scene The scene to import into
  40994. * @param data The data to import
  40995. * @param rootUrl The root url for scene and resources
  40996. * @param meshes The meshes array to import into
  40997. * @param particleSystems The particle systems array to import into
  40998. * @param skeletons The skeletons array to import into
  40999. * @param onError The callback when import fails
  41000. * @returns True if successful or false otherwise
  41001. */
  41002. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41003. /**
  41004. * Load into a scene.
  41005. * @param scene The scene to load into
  41006. * @param data The data to import
  41007. * @param rootUrl The root url for scene and resources
  41008. * @param onError The callback when import fails
  41009. * @returns true if successful or false otherwise
  41010. */
  41011. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41012. /**
  41013. * The callback that returns true if the data can be directly loaded.
  41014. */
  41015. canDirectLoad?: (data: string) => boolean;
  41016. /**
  41017. * The callback that allows custom handling of the root url based on the response url.
  41018. */
  41019. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41020. /**
  41021. * Load into an asset container.
  41022. * @param scene The scene to load into
  41023. * @param data The data to import
  41024. * @param rootUrl The root url for scene and resources
  41025. * @param onError The callback when import fails
  41026. * @returns The loaded asset container
  41027. */
  41028. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41029. }
  41030. /**
  41031. * Interface used to define an async SceneLoader plugin
  41032. */
  41033. export interface ISceneLoaderPluginAsync {
  41034. /**
  41035. * The friendly name of this plugin.
  41036. */
  41037. name: string;
  41038. /**
  41039. * The file extensions supported by this plugin.
  41040. */
  41041. extensions: string | ISceneLoaderPluginExtensions;
  41042. /**
  41043. * Import meshes into a scene.
  41044. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41045. * @param scene The scene to import into
  41046. * @param data The data to import
  41047. * @param rootUrl The root url for scene and resources
  41048. * @param onProgress The callback when the load progresses
  41049. * @param fileName Defines the name of the file to load
  41050. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41051. */
  41052. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41053. meshes: AbstractMesh[];
  41054. particleSystems: IParticleSystem[];
  41055. skeletons: Skeleton[];
  41056. animationGroups: AnimationGroup[];
  41057. }>;
  41058. /**
  41059. * Load into a scene.
  41060. * @param scene The scene to load into
  41061. * @param data The data to import
  41062. * @param rootUrl The root url for scene and resources
  41063. * @param onProgress The callback when the load progresses
  41064. * @param fileName Defines the name of the file to load
  41065. * @returns Nothing
  41066. */
  41067. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41068. /**
  41069. * The callback that returns true if the data can be directly loaded.
  41070. */
  41071. canDirectLoad?: (data: string) => boolean;
  41072. /**
  41073. * The callback that allows custom handling of the root url based on the response url.
  41074. */
  41075. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41076. /**
  41077. * Load into an asset container.
  41078. * @param scene The scene to load into
  41079. * @param data The data to import
  41080. * @param rootUrl The root url for scene and resources
  41081. * @param onProgress The callback when the load progresses
  41082. * @param fileName Defines the name of the file to load
  41083. * @returns The loaded asset container
  41084. */
  41085. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41086. }
  41087. /**
  41088. * Class used to load scene from various file formats using registered plugins
  41089. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41090. */
  41091. export class SceneLoader {
  41092. /**
  41093. * No logging while loading
  41094. */
  41095. static readonly NO_LOGGING: number;
  41096. /**
  41097. * Minimal logging while loading
  41098. */
  41099. static readonly MINIMAL_LOGGING: number;
  41100. /**
  41101. * Summary logging while loading
  41102. */
  41103. static readonly SUMMARY_LOGGING: number;
  41104. /**
  41105. * Detailled logging while loading
  41106. */
  41107. static readonly DETAILED_LOGGING: number;
  41108. /**
  41109. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41110. */
  41111. static ForceFullSceneLoadingForIncremental: boolean;
  41112. /**
  41113. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41114. */
  41115. static ShowLoadingScreen: boolean;
  41116. /**
  41117. * Defines the current logging level (while loading the scene)
  41118. * @ignorenaming
  41119. */
  41120. static loggingLevel: number;
  41121. /**
  41122. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41123. */
  41124. static CleanBoneMatrixWeights: boolean;
  41125. /**
  41126. * Event raised when a plugin is used to load a scene
  41127. */
  41128. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41129. private static _registeredPlugins;
  41130. private static _getDefaultPlugin;
  41131. private static _getPluginForExtension;
  41132. private static _getPluginForDirectLoad;
  41133. private static _getPluginForFilename;
  41134. private static _getDirectLoad;
  41135. private static _loadData;
  41136. private static _getFileInfo;
  41137. /**
  41138. * Gets a plugin that can load the given extension
  41139. * @param extension defines the extension to load
  41140. * @returns a plugin or null if none works
  41141. */
  41142. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41143. /**
  41144. * Gets a boolean indicating that the given extension can be loaded
  41145. * @param extension defines the extension to load
  41146. * @returns true if the extension is supported
  41147. */
  41148. static IsPluginForExtensionAvailable(extension: string): boolean;
  41149. /**
  41150. * Adds a new plugin to the list of registered plugins
  41151. * @param plugin defines the plugin to add
  41152. */
  41153. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41154. /**
  41155. * Import meshes into a scene
  41156. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41157. * @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)
  41158. * @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)
  41159. * @param scene the instance of BABYLON.Scene to append to
  41160. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41161. * @param onProgress a callback with a progress event for each file being loaded
  41162. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41163. * @param pluginExtension the extension used to determine the plugin
  41164. * @returns The loaded plugin
  41165. */
  41166. 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>;
  41167. /**
  41168. * Import meshes into a scene
  41169. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41170. * @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)
  41171. * @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)
  41172. * @param scene the instance of BABYLON.Scene to append to
  41173. * @param onProgress a callback with a progress event for each file being loaded
  41174. * @param pluginExtension the extension used to determine the plugin
  41175. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41176. */
  41177. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41178. meshes: AbstractMesh[];
  41179. particleSystems: IParticleSystem[];
  41180. skeletons: Skeleton[];
  41181. animationGroups: AnimationGroup[];
  41182. }>;
  41183. /**
  41184. * Load a scene
  41185. * @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)
  41186. * @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)
  41187. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41188. * @param onSuccess a callback with the scene when import succeeds
  41189. * @param onProgress a callback with a progress event for each file being loaded
  41190. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41191. * @param pluginExtension the extension used to determine the plugin
  41192. * @returns The loaded plugin
  41193. */
  41194. 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>;
  41195. /**
  41196. * Load a scene
  41197. * @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)
  41198. * @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)
  41199. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41200. * @param onProgress a callback with a progress event for each file being loaded
  41201. * @param pluginExtension the extension used to determine the plugin
  41202. * @returns The loaded scene
  41203. */
  41204. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41205. /**
  41206. * Append a scene
  41207. * @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)
  41208. * @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)
  41209. * @param scene is the instance of BABYLON.Scene to append to
  41210. * @param onSuccess a callback with the scene when import succeeds
  41211. * @param onProgress a callback with a progress event for each file being loaded
  41212. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41213. * @param pluginExtension the extension used to determine the plugin
  41214. * @returns The loaded plugin
  41215. */
  41216. 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>;
  41217. /**
  41218. * Append a scene
  41219. * @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)
  41220. * @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)
  41221. * @param scene is the instance of BABYLON.Scene to append to
  41222. * @param onProgress a callback with a progress event for each file being loaded
  41223. * @param pluginExtension the extension used to determine the plugin
  41224. * @returns The given scene
  41225. */
  41226. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41227. /**
  41228. * Load a scene into an asset container
  41229. * @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)
  41230. * @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)
  41231. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41232. * @param onSuccess a callback with the scene when import succeeds
  41233. * @param onProgress a callback with a progress event for each file being loaded
  41234. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41235. * @param pluginExtension the extension used to determine the plugin
  41236. * @returns The loaded plugin
  41237. */
  41238. 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>;
  41239. /**
  41240. * Load a scene into an asset container
  41241. * @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)
  41242. * @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)
  41243. * @param scene is the instance of Scene to append to
  41244. * @param onProgress a callback with a progress event for each file being loaded
  41245. * @param pluginExtension the extension used to determine the plugin
  41246. * @returns The loaded asset container
  41247. */
  41248. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41249. }
  41250. }
  41251. declare module BABYLON {
  41252. /**
  41253. * Generic Controller
  41254. */
  41255. export class GenericController extends WebVRController {
  41256. /**
  41257. * Base Url for the controller model.
  41258. */
  41259. static readonly MODEL_BASE_URL: string;
  41260. /**
  41261. * File name for the controller model.
  41262. */
  41263. static readonly MODEL_FILENAME: string;
  41264. /**
  41265. * Creates a new GenericController from a gamepad
  41266. * @param vrGamepad the gamepad that the controller should be created from
  41267. */
  41268. constructor(vrGamepad: any);
  41269. /**
  41270. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41271. * @param scene scene in which to add meshes
  41272. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41273. */
  41274. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41275. /**
  41276. * Called once for each button that changed state since the last frame
  41277. * @param buttonIdx Which button index changed
  41278. * @param state New state of the button
  41279. * @param changes Which properties on the state changed since last frame
  41280. */
  41281. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41282. }
  41283. }
  41284. declare module BABYLON {
  41285. /**
  41286. * Defines the WindowsMotionController object that the state of the windows motion controller
  41287. */
  41288. export class WindowsMotionController extends WebVRController {
  41289. /**
  41290. * The base url used to load the left and right controller models
  41291. */
  41292. static MODEL_BASE_URL: string;
  41293. /**
  41294. * The name of the left controller model file
  41295. */
  41296. static MODEL_LEFT_FILENAME: string;
  41297. /**
  41298. * The name of the right controller model file
  41299. */
  41300. static MODEL_RIGHT_FILENAME: string;
  41301. /**
  41302. * The controller name prefix for this controller type
  41303. */
  41304. static readonly GAMEPAD_ID_PREFIX: string;
  41305. /**
  41306. * The controller id pattern for this controller type
  41307. */
  41308. private static readonly GAMEPAD_ID_PATTERN;
  41309. private _loadedMeshInfo;
  41310. private readonly _mapping;
  41311. /**
  41312. * Fired when the trackpad on this controller is clicked
  41313. */
  41314. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41315. /**
  41316. * Fired when the trackpad on this controller is modified
  41317. */
  41318. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41319. /**
  41320. * The current x and y values of this controller's trackpad
  41321. */
  41322. trackpad: StickValues;
  41323. /**
  41324. * Creates a new WindowsMotionController from a gamepad
  41325. * @param vrGamepad the gamepad that the controller should be created from
  41326. */
  41327. constructor(vrGamepad: any);
  41328. /**
  41329. * Fired when the trigger on this controller is modified
  41330. */
  41331. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41332. /**
  41333. * Fired when the menu button on this controller is modified
  41334. */
  41335. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41336. /**
  41337. * Fired when the grip button on this controller is modified
  41338. */
  41339. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41340. /**
  41341. * Fired when the thumbstick button on this controller is modified
  41342. */
  41343. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41344. /**
  41345. * Fired when the touchpad button on this controller is modified
  41346. */
  41347. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41348. /**
  41349. * Fired when the touchpad values on this controller are modified
  41350. */
  41351. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41352. private _updateTrackpad;
  41353. /**
  41354. * Called once per frame by the engine.
  41355. */
  41356. update(): void;
  41357. /**
  41358. * Called once for each button that changed state since the last frame
  41359. * @param buttonIdx Which button index changed
  41360. * @param state New state of the button
  41361. * @param changes Which properties on the state changed since last frame
  41362. */
  41363. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41364. /**
  41365. * Moves the buttons on the controller mesh based on their current state
  41366. * @param buttonName the name of the button to move
  41367. * @param buttonValue the value of the button which determines the buttons new position
  41368. */
  41369. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41370. /**
  41371. * Moves the axis on the controller mesh based on its current state
  41372. * @param axis the index of the axis
  41373. * @param axisValue the value of the axis which determines the meshes new position
  41374. * @hidden
  41375. */
  41376. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41377. /**
  41378. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41379. * @param scene scene in which to add meshes
  41380. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41381. */
  41382. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41383. /**
  41384. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41385. * can be transformed by button presses and axes values, based on this._mapping.
  41386. *
  41387. * @param scene scene in which the meshes exist
  41388. * @param meshes list of meshes that make up the controller model to process
  41389. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41390. */
  41391. private processModel;
  41392. private createMeshInfo;
  41393. /**
  41394. * Gets the ray of the controller in the direction the controller is pointing
  41395. * @param length the length the resulting ray should be
  41396. * @returns a ray in the direction the controller is pointing
  41397. */
  41398. getForwardRay(length?: number): Ray;
  41399. /**
  41400. * Disposes of the controller
  41401. */
  41402. dispose(): void;
  41403. }
  41404. }
  41405. declare module BABYLON {
  41406. /**
  41407. * Oculus Touch Controller
  41408. */
  41409. export class OculusTouchController extends WebVRController {
  41410. /**
  41411. * Base Url for the controller model.
  41412. */
  41413. static MODEL_BASE_URL: string;
  41414. /**
  41415. * File name for the left controller model.
  41416. */
  41417. static MODEL_LEFT_FILENAME: string;
  41418. /**
  41419. * File name for the right controller model.
  41420. */
  41421. static MODEL_RIGHT_FILENAME: string;
  41422. /**
  41423. * Base Url for the Quest controller model.
  41424. */
  41425. static QUEST_MODEL_BASE_URL: string;
  41426. /**
  41427. * @hidden
  41428. * If the controllers are running on a device that needs the updated Quest controller models
  41429. */ private static _IsQuest: boolean;
  41430. /**
  41431. * Fired when the secondary trigger on this controller is modified
  41432. */
  41433. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41434. /**
  41435. * Fired when the thumb rest on this controller is modified
  41436. */
  41437. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41438. /**
  41439. * Creates a new OculusTouchController from a gamepad
  41440. * @param vrGamepad the gamepad that the controller should be created from
  41441. */
  41442. constructor(vrGamepad: any);
  41443. /**
  41444. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41445. * @param scene scene in which to add meshes
  41446. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41447. */
  41448. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41449. /**
  41450. * Fired when the A button on this controller is modified
  41451. */
  41452. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41453. /**
  41454. * Fired when the B button on this controller is modified
  41455. */
  41456. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41457. /**
  41458. * Fired when the X button on this controller is modified
  41459. */
  41460. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41461. /**
  41462. * Fired when the Y button on this controller is modified
  41463. */
  41464. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41465. /**
  41466. * Called once for each button that changed state since the last frame
  41467. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41468. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41469. * 2) secondary trigger (same)
  41470. * 3) A (right) X (left), touch, pressed = value
  41471. * 4) B / Y
  41472. * 5) thumb rest
  41473. * @param buttonIdx Which button index changed
  41474. * @param state New state of the button
  41475. * @param changes Which properties on the state changed since last frame
  41476. */
  41477. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41478. }
  41479. }
  41480. declare module BABYLON {
  41481. /**
  41482. * Vive Controller
  41483. */
  41484. export class ViveController extends WebVRController {
  41485. /**
  41486. * Base Url for the controller model.
  41487. */
  41488. static MODEL_BASE_URL: string;
  41489. /**
  41490. * File name for the controller model.
  41491. */
  41492. static MODEL_FILENAME: string;
  41493. /**
  41494. * Creates a new ViveController from a gamepad
  41495. * @param vrGamepad the gamepad that the controller should be created from
  41496. */
  41497. constructor(vrGamepad: any);
  41498. /**
  41499. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41500. * @param scene scene in which to add meshes
  41501. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41502. */
  41503. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41504. /**
  41505. * Fired when the left button on this controller is modified
  41506. */
  41507. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41508. /**
  41509. * Fired when the right button on this controller is modified
  41510. */
  41511. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41512. /**
  41513. * Fired when the menu button on this controller is modified
  41514. */
  41515. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41516. /**
  41517. * Called once for each button that changed state since the last frame
  41518. * Vive mapping:
  41519. * 0: touchpad
  41520. * 1: trigger
  41521. * 2: left AND right buttons
  41522. * 3: menu button
  41523. * @param buttonIdx Which button index changed
  41524. * @param state New state of the button
  41525. * @param changes Which properties on the state changed since last frame
  41526. */
  41527. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41528. }
  41529. }
  41530. declare module BABYLON {
  41531. /**
  41532. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41533. */
  41534. export class WebXRControllerModelLoader {
  41535. /**
  41536. * Creates the WebXRControllerModelLoader
  41537. * @param input xr input that creates the controllers
  41538. */
  41539. constructor(input: WebXRInput);
  41540. }
  41541. }
  41542. declare module BABYLON {
  41543. /**
  41544. * Contains an array of blocks representing the octree
  41545. */
  41546. export interface IOctreeContainer<T> {
  41547. /**
  41548. * Blocks within the octree
  41549. */
  41550. blocks: Array<OctreeBlock<T>>;
  41551. }
  41552. /**
  41553. * Class used to store a cell in an octree
  41554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41555. */
  41556. export class OctreeBlock<T> {
  41557. /**
  41558. * Gets the content of the current block
  41559. */
  41560. entries: T[];
  41561. /**
  41562. * Gets the list of block children
  41563. */
  41564. blocks: Array<OctreeBlock<T>>;
  41565. private _depth;
  41566. private _maxDepth;
  41567. private _capacity;
  41568. private _minPoint;
  41569. private _maxPoint;
  41570. private _boundingVectors;
  41571. private _creationFunc;
  41572. /**
  41573. * Creates a new block
  41574. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41575. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41576. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41577. * @param depth defines the current depth of this block in the octree
  41578. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41579. * @param creationFunc defines a callback to call when an element is added to the block
  41580. */
  41581. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41582. /**
  41583. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41584. */
  41585. readonly capacity: number;
  41586. /**
  41587. * Gets the minimum vector (in world space) of the block's bounding box
  41588. */
  41589. readonly minPoint: Vector3;
  41590. /**
  41591. * Gets the maximum vector (in world space) of the block's bounding box
  41592. */
  41593. readonly maxPoint: Vector3;
  41594. /**
  41595. * Add a new element to this block
  41596. * @param entry defines the element to add
  41597. */
  41598. addEntry(entry: T): void;
  41599. /**
  41600. * Remove an element from this block
  41601. * @param entry defines the element to remove
  41602. */
  41603. removeEntry(entry: T): void;
  41604. /**
  41605. * Add an array of elements to this block
  41606. * @param entries defines the array of elements to add
  41607. */
  41608. addEntries(entries: T[]): void;
  41609. /**
  41610. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41611. * @param frustumPlanes defines the frustum planes to test
  41612. * @param selection defines the array to store current content if selection is positive
  41613. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41614. */
  41615. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41616. /**
  41617. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41618. * @param sphereCenter defines the bounding sphere center
  41619. * @param sphereRadius defines the bounding sphere radius
  41620. * @param selection defines the array to store current content if selection is positive
  41621. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41622. */
  41623. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41624. /**
  41625. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41626. * @param ray defines the ray to test with
  41627. * @param selection defines the array to store current content if selection is positive
  41628. */
  41629. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41630. /**
  41631. * Subdivide the content into child blocks (this block will then be empty)
  41632. */
  41633. createInnerBlocks(): void;
  41634. /**
  41635. * @hidden
  41636. */ 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;
  41637. }
  41638. }
  41639. declare module BABYLON {
  41640. /**
  41641. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41642. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41643. */
  41644. export class Octree<T> {
  41645. /** 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.) */
  41646. maxDepth: number;
  41647. /**
  41648. * Blocks within the octree containing objects
  41649. */
  41650. blocks: Array<OctreeBlock<T>>;
  41651. /**
  41652. * Content stored in the octree
  41653. */
  41654. dynamicContent: T[];
  41655. private _maxBlockCapacity;
  41656. private _selectionContent;
  41657. private _creationFunc;
  41658. /**
  41659. * Creates a octree
  41660. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41661. * @param creationFunc function to be used to instatiate the octree
  41662. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41663. * @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.)
  41664. */
  41665. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41666. /** 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.) */
  41667. maxDepth?: number);
  41668. /**
  41669. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41670. * @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);
  41671. * @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);
  41672. * @param entries meshes to be added to the octree blocks
  41673. */
  41674. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41675. /**
  41676. * Adds a mesh to the octree
  41677. * @param entry Mesh to add to the octree
  41678. */
  41679. addMesh(entry: T): void;
  41680. /**
  41681. * Remove an element from the octree
  41682. * @param entry defines the element to remove
  41683. */
  41684. removeMesh(entry: T): void;
  41685. /**
  41686. * Selects an array of meshes within the frustum
  41687. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41688. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41689. * @returns array of meshes within the frustum
  41690. */
  41691. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41692. /**
  41693. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41694. * @param sphereCenter defines the bounding sphere center
  41695. * @param sphereRadius defines the bounding sphere radius
  41696. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41697. * @returns an array of objects that intersect the sphere
  41698. */
  41699. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41700. /**
  41701. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41702. * @param ray defines the ray to test with
  41703. * @returns array of intersected objects
  41704. */
  41705. intersectsRay(ray: Ray): SmartArray<T>;
  41706. /**
  41707. * Adds a mesh into the octree block if it intersects the block
  41708. */
  41709. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41710. /**
  41711. * Adds a submesh into the octree block if it intersects the block
  41712. */
  41713. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41714. }
  41715. }
  41716. declare module BABYLON {
  41717. interface Scene {
  41718. /**
  41719. * @hidden
  41720. * Backing Filed
  41721. */ private _selectionOctree: Octree<AbstractMesh>;
  41722. /**
  41723. * Gets the octree used to boost mesh selection (picking)
  41724. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41725. */
  41726. selectionOctree: Octree<AbstractMesh>;
  41727. /**
  41728. * Creates or updates the octree used to boost selection (picking)
  41729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41730. * @param maxCapacity defines the maximum capacity per leaf
  41731. * @param maxDepth defines the maximum depth of the octree
  41732. * @returns an octree of AbstractMesh
  41733. */
  41734. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41735. }
  41736. interface AbstractMesh {
  41737. /**
  41738. * @hidden
  41739. * Backing Field
  41740. */ private _submeshesOctree: Octree<SubMesh>;
  41741. /**
  41742. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41743. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41744. * @param maxCapacity defines the maximum size of each block (64 by default)
  41745. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41746. * @returns the new octree
  41747. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41748. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41749. */
  41750. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41751. }
  41752. /**
  41753. * Defines the octree scene component responsible to manage any octrees
  41754. * in a given scene.
  41755. */
  41756. export class OctreeSceneComponent {
  41757. /**
  41758. * The component name help to identify the component in the list of scene components.
  41759. */
  41760. readonly name: string;
  41761. /**
  41762. * The scene the component belongs to.
  41763. */
  41764. scene: Scene;
  41765. /**
  41766. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41767. */
  41768. readonly checksIsEnabled: boolean;
  41769. /**
  41770. * Creates a new instance of the component for the given scene
  41771. * @param scene Defines the scene to register the component in
  41772. */
  41773. constructor(scene: Scene);
  41774. /**
  41775. * Registers the component in a given scene
  41776. */
  41777. register(): void;
  41778. /**
  41779. * Return the list of active meshes
  41780. * @returns the list of active meshes
  41781. */
  41782. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41783. /**
  41784. * Return the list of active sub meshes
  41785. * @param mesh The mesh to get the candidates sub meshes from
  41786. * @returns the list of active sub meshes
  41787. */
  41788. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41789. private _tempRay;
  41790. /**
  41791. * Return the list of sub meshes intersecting with a given local ray
  41792. * @param mesh defines the mesh to find the submesh for
  41793. * @param localRay defines the ray in local space
  41794. * @returns the list of intersecting sub meshes
  41795. */
  41796. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41797. /**
  41798. * Return the list of sub meshes colliding with a collider
  41799. * @param mesh defines the mesh to find the submesh for
  41800. * @param collider defines the collider to evaluate the collision against
  41801. * @returns the list of colliding sub meshes
  41802. */
  41803. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41804. /**
  41805. * Rebuilds the elements related to this component in case of
  41806. * context lost for instance.
  41807. */
  41808. rebuild(): void;
  41809. /**
  41810. * Disposes the component and the associated ressources.
  41811. */
  41812. dispose(): void;
  41813. }
  41814. }
  41815. declare module BABYLON {
  41816. /**
  41817. * Renders a layer on top of an existing scene
  41818. */
  41819. export class UtilityLayerRenderer implements IDisposable {
  41820. /** the original scene that will be rendered on top of */
  41821. originalScene: Scene;
  41822. private _pointerCaptures;
  41823. private _lastPointerEvents;
  41824. private static _DefaultUtilityLayer;
  41825. private static _DefaultKeepDepthUtilityLayer;
  41826. private _sharedGizmoLight;
  41827. private _renderCamera;
  41828. /**
  41829. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41830. * @returns the camera that is used when rendering the utility layer
  41831. */
  41832. getRenderCamera(): Nullable<Camera>;
  41833. /**
  41834. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41835. * @param cam the camera that should be used when rendering the utility layer
  41836. */
  41837. setRenderCamera(cam: Nullable<Camera>): void;
  41838. /**
  41839. * @hidden
  41840. * Light which used by gizmos to get light shading
  41841. */ private _getSharedGizmoLight(): HemisphericLight;
  41842. /**
  41843. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41844. */
  41845. pickUtilitySceneFirst: boolean;
  41846. /**
  41847. * 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)
  41848. */
  41849. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41850. /**
  41851. * 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)
  41852. */
  41853. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41854. /**
  41855. * The scene that is rendered on top of the original scene
  41856. */
  41857. utilityLayerScene: Scene;
  41858. /**
  41859. * If the utility layer should automatically be rendered on top of existing scene
  41860. */
  41861. shouldRender: boolean;
  41862. /**
  41863. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41864. */
  41865. onlyCheckPointerDownEvents: boolean;
  41866. /**
  41867. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41868. */
  41869. processAllEvents: boolean;
  41870. /**
  41871. * Observable raised when the pointer move from the utility layer scene to the main scene
  41872. */
  41873. onPointerOutObservable: Observable<number>;
  41874. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41875. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41876. private _afterRenderObserver;
  41877. private _sceneDisposeObserver;
  41878. private _originalPointerObserver;
  41879. /**
  41880. * Instantiates a UtilityLayerRenderer
  41881. * @param originalScene the original scene that will be rendered on top of
  41882. * @param handleEvents boolean indicating if the utility layer should handle events
  41883. */
  41884. constructor(
  41885. /** the original scene that will be rendered on top of */
  41886. originalScene: Scene, handleEvents?: boolean);
  41887. private _notifyObservers;
  41888. /**
  41889. * Renders the utility layers scene on top of the original scene
  41890. */
  41891. render(): void;
  41892. /**
  41893. * Disposes of the renderer
  41894. */
  41895. dispose(): void;
  41896. private _updateCamera;
  41897. }
  41898. }
  41899. declare module BABYLON {
  41900. /**
  41901. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41902. */
  41903. export class Gizmo implements IDisposable {
  41904. /** The utility layer the gizmo will be added to */
  41905. gizmoLayer: UtilityLayerRenderer;
  41906. /**
  41907. * The root mesh of the gizmo
  41908. */ private _rootMesh: Mesh;
  41909. private _attachedMesh;
  41910. /**
  41911. * Ratio for the scale of the gizmo (Default: 1)
  41912. */
  41913. scaleRatio: number;
  41914. /**
  41915. * If a custom mesh has been set (Default: false)
  41916. */
  41917. protected _customMeshSet: boolean;
  41918. /**
  41919. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41920. * * When set, interactions will be enabled
  41921. */
  41922. attachedMesh: Nullable<AbstractMesh>;
  41923. /**
  41924. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41925. * @param mesh The mesh to replace the default mesh of the gizmo
  41926. */
  41927. setCustomMesh(mesh: Mesh): void;
  41928. /**
  41929. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41930. */
  41931. updateGizmoRotationToMatchAttachedMesh: boolean;
  41932. /**
  41933. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41934. */
  41935. updateGizmoPositionToMatchAttachedMesh: boolean;
  41936. /**
  41937. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  41938. */
  41939. updateScale: boolean;
  41940. protected _interactionsEnabled: boolean;
  41941. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41942. private _beforeRenderObserver;
  41943. private _tempVector;
  41944. /**
  41945. * Creates a gizmo
  41946. * @param gizmoLayer The utility layer the gizmo will be added to
  41947. */
  41948. constructor(
  41949. /** The utility layer the gizmo will be added to */
  41950. gizmoLayer?: UtilityLayerRenderer);
  41951. /**
  41952. * Updates the gizmo to match the attached mesh's position/rotation
  41953. */
  41954. protected _update(): void;
  41955. /**
  41956. * Disposes of the gizmo
  41957. */
  41958. dispose(): void;
  41959. }
  41960. }
  41961. declare module BABYLON {
  41962. /**
  41963. * Single plane drag gizmo
  41964. */
  41965. export class PlaneDragGizmo extends Gizmo {
  41966. /**
  41967. * Drag behavior responsible for the gizmos dragging interactions
  41968. */
  41969. dragBehavior: PointerDragBehavior;
  41970. private _pointerObserver;
  41971. /**
  41972. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41973. */
  41974. snapDistance: number;
  41975. /**
  41976. * Event that fires each time the gizmo snaps to a new location.
  41977. * * snapDistance is the the change in distance
  41978. */
  41979. onSnapObservable: Observable<{
  41980. snapDistance: number;
  41981. }>;
  41982. private _plane;
  41983. private _coloredMaterial;
  41984. private _hoverMaterial;
  41985. private _isEnabled;
  41986. private _parent;
  41987. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41988. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41989. /**
  41990. * Creates a PlaneDragGizmo
  41991. * @param gizmoLayer The utility layer the gizmo will be added to
  41992. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41993. * @param color The color of the gizmo
  41994. */
  41995. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41996. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41997. /**
  41998. * If the gizmo is enabled
  41999. */
  42000. isEnabled: boolean;
  42001. /**
  42002. * Disposes of the gizmo
  42003. */
  42004. dispose(): void;
  42005. }
  42006. }
  42007. declare module BABYLON {
  42008. /**
  42009. * Gizmo that enables dragging a mesh along 3 axis
  42010. */
  42011. export class PositionGizmo extends Gizmo {
  42012. /**
  42013. * Internal gizmo used for interactions on the x axis
  42014. */
  42015. xGizmo: AxisDragGizmo;
  42016. /**
  42017. * Internal gizmo used for interactions on the y axis
  42018. */
  42019. yGizmo: AxisDragGizmo;
  42020. /**
  42021. * Internal gizmo used for interactions on the z axis
  42022. */
  42023. zGizmo: AxisDragGizmo;
  42024. /**
  42025. * Internal gizmo used for interactions on the yz plane
  42026. */
  42027. xPlaneGizmo: PlaneDragGizmo;
  42028. /**
  42029. * Internal gizmo used for interactions on the xz plane
  42030. */
  42031. yPlaneGizmo: PlaneDragGizmo;
  42032. /**
  42033. * Internal gizmo used for interactions on the xy plane
  42034. */
  42035. zPlaneGizmo: PlaneDragGizmo;
  42036. /**
  42037. * private variables
  42038. */
  42039. private _meshAttached;
  42040. private _updateGizmoRotationToMatchAttachedMesh;
  42041. private _snapDistance;
  42042. private _scaleRatio;
  42043. /** Fires an event when any of it's sub gizmos are dragged */
  42044. onDragStartObservable: Observable<unknown>;
  42045. /** Fires an event when any of it's sub gizmos are released from dragging */
  42046. onDragEndObservable: Observable<unknown>;
  42047. /**
  42048. * If set to true, planar drag is enabled
  42049. */
  42050. private _planarGizmoEnabled;
  42051. attachedMesh: Nullable<AbstractMesh>;
  42052. /**
  42053. * Creates a PositionGizmo
  42054. * @param gizmoLayer The utility layer the gizmo will be added to
  42055. */
  42056. constructor(gizmoLayer?: UtilityLayerRenderer);
  42057. /**
  42058. * If the planar drag gizmo is enabled
  42059. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42060. */
  42061. planarGizmoEnabled: boolean;
  42062. updateGizmoRotationToMatchAttachedMesh: boolean;
  42063. /**
  42064. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42065. */
  42066. snapDistance: number;
  42067. /**
  42068. * Ratio for the scale of the gizmo (Default: 1)
  42069. */
  42070. scaleRatio: number;
  42071. /**
  42072. * Disposes of the gizmo
  42073. */
  42074. dispose(): void;
  42075. /**
  42076. * CustomMeshes are not supported by this gizmo
  42077. * @param mesh The mesh to replace the default mesh of the gizmo
  42078. */
  42079. setCustomMesh(mesh: Mesh): void;
  42080. }
  42081. }
  42082. declare module BABYLON {
  42083. /**
  42084. * Single axis drag gizmo
  42085. */
  42086. export class AxisDragGizmo extends Gizmo {
  42087. /**
  42088. * Drag behavior responsible for the gizmos dragging interactions
  42089. */
  42090. dragBehavior: PointerDragBehavior;
  42091. private _pointerObserver;
  42092. /**
  42093. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42094. */
  42095. snapDistance: number;
  42096. /**
  42097. * Event that fires each time the gizmo snaps to a new location.
  42098. * * snapDistance is the the change in distance
  42099. */
  42100. onSnapObservable: Observable<{
  42101. snapDistance: number;
  42102. }>;
  42103. private _isEnabled;
  42104. private _parent;
  42105. private _arrow;
  42106. private _coloredMaterial;
  42107. private _hoverMaterial;
  42108. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42109. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42110. /**
  42111. * Creates an AxisDragGizmo
  42112. * @param gizmoLayer The utility layer the gizmo will be added to
  42113. * @param dragAxis The axis which the gizmo will be able to drag on
  42114. * @param color The color of the gizmo
  42115. */
  42116. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42117. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42118. /**
  42119. * If the gizmo is enabled
  42120. */
  42121. isEnabled: boolean;
  42122. /**
  42123. * Disposes of the gizmo
  42124. */
  42125. dispose(): void;
  42126. }
  42127. }
  42128. declare module BABYLON.Debug {
  42129. /**
  42130. * The Axes viewer will show 3 axes in a specific point in space
  42131. */
  42132. export class AxesViewer {
  42133. private _xAxis;
  42134. private _yAxis;
  42135. private _zAxis;
  42136. private _scaleLinesFactor;
  42137. private _instanced;
  42138. /**
  42139. * Gets the hosting scene
  42140. */
  42141. scene: Scene;
  42142. /**
  42143. * Gets or sets a number used to scale line length
  42144. */
  42145. scaleLines: number;
  42146. /** Gets the node hierarchy used to render x-axis */
  42147. readonly xAxis: TransformNode;
  42148. /** Gets the node hierarchy used to render y-axis */
  42149. readonly yAxis: TransformNode;
  42150. /** Gets the node hierarchy used to render z-axis */
  42151. readonly zAxis: TransformNode;
  42152. /**
  42153. * Creates a new AxesViewer
  42154. * @param scene defines the hosting scene
  42155. * @param scaleLines defines a number used to scale line length (1 by default)
  42156. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42157. * @param xAxis defines the node hierarchy used to render the x-axis
  42158. * @param yAxis defines the node hierarchy used to render the y-axis
  42159. * @param zAxis defines the node hierarchy used to render the z-axis
  42160. */
  42161. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42162. /**
  42163. * Force the viewer to update
  42164. * @param position defines the position of the viewer
  42165. * @param xaxis defines the x axis of the viewer
  42166. * @param yaxis defines the y axis of the viewer
  42167. * @param zaxis defines the z axis of the viewer
  42168. */
  42169. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42170. /**
  42171. * Creates an instance of this axes viewer.
  42172. * @returns a new axes viewer with instanced meshes
  42173. */
  42174. createInstance(): AxesViewer;
  42175. /** Releases resources */
  42176. dispose(): void;
  42177. private static _SetRenderingGroupId;
  42178. }
  42179. }
  42180. declare module BABYLON.Debug {
  42181. /**
  42182. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42183. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42184. */
  42185. export class BoneAxesViewer extends AxesViewer {
  42186. /**
  42187. * Gets or sets the target mesh where to display the axes viewer
  42188. */
  42189. mesh: Nullable<Mesh>;
  42190. /**
  42191. * Gets or sets the target bone where to display the axes viewer
  42192. */
  42193. bone: Nullable<Bone>;
  42194. /** Gets current position */
  42195. pos: Vector3;
  42196. /** Gets direction of X axis */
  42197. xaxis: Vector3;
  42198. /** Gets direction of Y axis */
  42199. yaxis: Vector3;
  42200. /** Gets direction of Z axis */
  42201. zaxis: Vector3;
  42202. /**
  42203. * Creates a new BoneAxesViewer
  42204. * @param scene defines the hosting scene
  42205. * @param bone defines the target bone
  42206. * @param mesh defines the target mesh
  42207. * @param scaleLines defines a scaling factor for line length (1 by default)
  42208. */
  42209. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42210. /**
  42211. * Force the viewer to update
  42212. */
  42213. update(): void;
  42214. /** Releases resources */
  42215. dispose(): void;
  42216. }
  42217. }
  42218. declare module BABYLON {
  42219. /**
  42220. * Interface used to define scene explorer extensibility option
  42221. */
  42222. export interface IExplorerExtensibilityOption {
  42223. /**
  42224. * Define the option label
  42225. */
  42226. label: string;
  42227. /**
  42228. * Defines the action to execute on click
  42229. */
  42230. action: (entity: any) => void;
  42231. }
  42232. /**
  42233. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42234. */
  42235. export interface IExplorerExtensibilityGroup {
  42236. /**
  42237. * Defines a predicate to test if a given type mut be extended
  42238. */
  42239. predicate: (entity: any) => boolean;
  42240. /**
  42241. * Gets the list of options added to a type
  42242. */
  42243. entries: IExplorerExtensibilityOption[];
  42244. }
  42245. /**
  42246. * Interface used to define the options to use to create the Inspector
  42247. */
  42248. export interface IInspectorOptions {
  42249. /**
  42250. * Display in overlay mode (default: false)
  42251. */
  42252. overlay?: boolean;
  42253. /**
  42254. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42255. */
  42256. globalRoot?: HTMLElement;
  42257. /**
  42258. * Display the Scene explorer
  42259. */
  42260. showExplorer?: boolean;
  42261. /**
  42262. * Display the property inspector
  42263. */
  42264. showInspector?: boolean;
  42265. /**
  42266. * Display in embed mode (both panes on the right)
  42267. */
  42268. embedMode?: boolean;
  42269. /**
  42270. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42271. */
  42272. handleResize?: boolean;
  42273. /**
  42274. * Allow the panes to popup (default: true)
  42275. */
  42276. enablePopup?: boolean;
  42277. /**
  42278. * Allow the panes to be closed by users (default: true)
  42279. */
  42280. enableClose?: boolean;
  42281. /**
  42282. * Optional list of extensibility entries
  42283. */
  42284. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42285. /**
  42286. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42287. */
  42288. inspectorURL?: string;
  42289. }
  42290. interface Scene {
  42291. /**
  42292. * @hidden
  42293. * Backing field
  42294. */ private _debugLayer: DebugLayer;
  42295. /**
  42296. * Gets the debug layer (aka Inspector) associated with the scene
  42297. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42298. */
  42299. debugLayer: DebugLayer;
  42300. }
  42301. /**
  42302. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42303. * what is happening in your scene
  42304. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42305. */
  42306. export class DebugLayer {
  42307. /**
  42308. * Define the url to get the inspector script from.
  42309. * By default it uses the babylonjs CDN.
  42310. * @ignoreNaming
  42311. */
  42312. static InspectorURL: string;
  42313. private _scene;
  42314. private BJSINSPECTOR;
  42315. private _onPropertyChangedObservable?;
  42316. /**
  42317. * Observable triggered when a property is changed through the inspector.
  42318. */
  42319. readonly onPropertyChangedObservable: any;
  42320. /**
  42321. * Instantiates a new debug layer.
  42322. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42323. * what is happening in your scene
  42324. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42325. * @param scene Defines the scene to inspect
  42326. */
  42327. constructor(scene: Scene);
  42328. /** Creates the inspector window. */
  42329. private _createInspector;
  42330. /**
  42331. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42332. * @param entity defines the entity to select
  42333. * @param lineContainerTitle defines the specific block to highlight
  42334. */
  42335. select(entity: any, lineContainerTitle?: string): void;
  42336. /** Get the inspector from bundle or global */
  42337. private _getGlobalInspector;
  42338. /**
  42339. * Get if the inspector is visible or not.
  42340. * @returns true if visible otherwise, false
  42341. */
  42342. isVisible(): boolean;
  42343. /**
  42344. * Hide the inspector and close its window.
  42345. */
  42346. hide(): void;
  42347. /**
  42348. * Launch the debugLayer.
  42349. * @param config Define the configuration of the inspector
  42350. * @return a promise fulfilled when the debug layer is visible
  42351. */
  42352. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42353. }
  42354. }
  42355. declare module BABYLON {
  42356. /**
  42357. * Class containing static functions to help procedurally build meshes
  42358. */
  42359. export class BoxBuilder {
  42360. /**
  42361. * Creates a box mesh
  42362. * * The parameter `size` sets the size (float) of each box side (default 1)
  42363. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42364. * * 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)
  42365. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42367. * * 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
  42368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42369. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42370. * @param name defines the name of the mesh
  42371. * @param options defines the options used to create the mesh
  42372. * @param scene defines the hosting scene
  42373. * @returns the box mesh
  42374. */
  42375. static CreateBox(name: string, options: {
  42376. size?: number;
  42377. width?: number;
  42378. height?: number;
  42379. depth?: number;
  42380. faceUV?: Vector4[];
  42381. faceColors?: Color4[];
  42382. sideOrientation?: number;
  42383. frontUVs?: Vector4;
  42384. backUVs?: Vector4;
  42385. wrap?: boolean;
  42386. topBaseAt?: number;
  42387. bottomBaseAt?: number;
  42388. updatable?: boolean;
  42389. }, scene?: Nullable<Scene>): Mesh;
  42390. }
  42391. }
  42392. declare module BABYLON {
  42393. /**
  42394. * Class containing static functions to help procedurally build meshes
  42395. */
  42396. export class SphereBuilder {
  42397. /**
  42398. * Creates a sphere mesh
  42399. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42400. * * 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`)
  42401. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42402. * * 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
  42403. * * 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)
  42404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42407. * @param name defines the name of the mesh
  42408. * @param options defines the options used to create the mesh
  42409. * @param scene defines the hosting scene
  42410. * @returns the sphere mesh
  42411. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42412. */
  42413. static CreateSphere(name: string, options: {
  42414. segments?: number;
  42415. diameter?: number;
  42416. diameterX?: number;
  42417. diameterY?: number;
  42418. diameterZ?: number;
  42419. arc?: number;
  42420. slice?: number;
  42421. sideOrientation?: number;
  42422. frontUVs?: Vector4;
  42423. backUVs?: Vector4;
  42424. updatable?: boolean;
  42425. }, scene?: Nullable<Scene>): Mesh;
  42426. }
  42427. }
  42428. declare module BABYLON.Debug {
  42429. /**
  42430. * Used to show the physics impostor around the specific mesh
  42431. */
  42432. export class PhysicsViewer {
  42433. /** @hidden */
  42434. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42435. /** @hidden */
  42436. protected _meshes: Array<Nullable<AbstractMesh>>;
  42437. /** @hidden */
  42438. protected _scene: Nullable<Scene>;
  42439. /** @hidden */
  42440. protected _numMeshes: number;
  42441. /** @hidden */
  42442. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42443. private _renderFunction;
  42444. private _utilityLayer;
  42445. private _debugBoxMesh;
  42446. private _debugSphereMesh;
  42447. private _debugCylinderMesh;
  42448. private _debugMaterial;
  42449. private _debugMeshMeshes;
  42450. /**
  42451. * Creates a new PhysicsViewer
  42452. * @param scene defines the hosting scene
  42453. */
  42454. constructor(scene: Scene);
  42455. /** @hidden */
  42456. protected _updateDebugMeshes(): void;
  42457. /**
  42458. * Renders a specified physic impostor
  42459. * @param impostor defines the impostor to render
  42460. * @param targetMesh defines the mesh represented by the impostor
  42461. * @returns the new debug mesh used to render the impostor
  42462. */
  42463. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42464. /**
  42465. * Hides a specified physic impostor
  42466. * @param impostor defines the impostor to hide
  42467. */
  42468. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42469. private _getDebugMaterial;
  42470. private _getDebugBoxMesh;
  42471. private _getDebugSphereMesh;
  42472. private _getDebugCylinderMesh;
  42473. private _getDebugMeshMesh;
  42474. private _getDebugMesh;
  42475. /** Releases all resources */
  42476. dispose(): void;
  42477. }
  42478. }
  42479. declare module BABYLON {
  42480. /**
  42481. * Class containing static functions to help procedurally build meshes
  42482. */
  42483. export class LinesBuilder {
  42484. /**
  42485. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42486. * * 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
  42487. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42488. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42489. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42490. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42491. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42492. * * 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
  42493. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42496. * @param name defines the name of the new line system
  42497. * @param options defines the options used to create the line system
  42498. * @param scene defines the hosting scene
  42499. * @returns a new line system mesh
  42500. */
  42501. static CreateLineSystem(name: string, options: {
  42502. lines: Vector3[][];
  42503. updatable?: boolean;
  42504. instance?: Nullable<LinesMesh>;
  42505. colors?: Nullable<Color4[][]>;
  42506. useVertexAlpha?: boolean;
  42507. }, scene: Nullable<Scene>): LinesMesh;
  42508. /**
  42509. * Creates a line mesh
  42510. * 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
  42511. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42512. * * The parameter `points` is an array successive Vector3
  42513. * * 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
  42514. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42515. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42516. * * When updating an instance, remember that only point positions can change, not the number of points
  42517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42519. * @param name defines the name of the new line system
  42520. * @param options defines the options used to create the line system
  42521. * @param scene defines the hosting scene
  42522. * @returns a new line mesh
  42523. */
  42524. static CreateLines(name: string, options: {
  42525. points: Vector3[];
  42526. updatable?: boolean;
  42527. instance?: Nullable<LinesMesh>;
  42528. colors?: Color4[];
  42529. useVertexAlpha?: boolean;
  42530. }, scene?: Nullable<Scene>): LinesMesh;
  42531. /**
  42532. * Creates a dashed line mesh
  42533. * * 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
  42534. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42535. * * The parameter `points` is an array successive Vector3
  42536. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42537. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42538. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42539. * * 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
  42540. * * When updating an instance, remember that only point positions can change, not the number of points
  42541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42542. * @param name defines the name of the mesh
  42543. * @param options defines the options used to create the mesh
  42544. * @param scene defines the hosting scene
  42545. * @returns the dashed line mesh
  42546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42547. */
  42548. static CreateDashedLines(name: string, options: {
  42549. points: Vector3[];
  42550. dashSize?: number;
  42551. gapSize?: number;
  42552. dashNb?: number;
  42553. updatable?: boolean;
  42554. instance?: LinesMesh;
  42555. }, scene?: Nullable<Scene>): LinesMesh;
  42556. }
  42557. }
  42558. declare module BABYLON {
  42559. /**
  42560. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42561. * in order to better appreciate the issue one might have.
  42562. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42563. */
  42564. export class RayHelper {
  42565. /**
  42566. * Defines the ray we are currently tryin to visualize.
  42567. */
  42568. ray: Nullable<Ray>;
  42569. private _renderPoints;
  42570. private _renderLine;
  42571. private _renderFunction;
  42572. private _scene;
  42573. private _updateToMeshFunction;
  42574. private _attachedToMesh;
  42575. private _meshSpaceDirection;
  42576. private _meshSpaceOrigin;
  42577. /**
  42578. * Helper function to create a colored helper in a scene in one line.
  42579. * @param ray Defines the ray we are currently tryin to visualize
  42580. * @param scene Defines the scene the ray is used in
  42581. * @param color Defines the color we want to see the ray in
  42582. * @returns The newly created ray helper.
  42583. */
  42584. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42585. /**
  42586. * Instantiate a new ray helper.
  42587. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42588. * in order to better appreciate the issue one might have.
  42589. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42590. * @param ray Defines the ray we are currently tryin to visualize
  42591. */
  42592. constructor(ray: Ray);
  42593. /**
  42594. * Shows the ray we are willing to debug.
  42595. * @param scene Defines the scene the ray needs to be rendered in
  42596. * @param color Defines the color the ray needs to be rendered in
  42597. */
  42598. show(scene: Scene, color?: Color3): void;
  42599. /**
  42600. * Hides the ray we are debugging.
  42601. */
  42602. hide(): void;
  42603. private _render;
  42604. /**
  42605. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42606. * @param mesh Defines the mesh we want the helper attached to
  42607. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42608. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42609. * @param length Defines the length of the ray
  42610. */
  42611. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42612. /**
  42613. * Detach the ray helper from the mesh it has previously been attached to.
  42614. */
  42615. detachFromMesh(): void;
  42616. private _updateToMesh;
  42617. /**
  42618. * Dispose the helper and release its associated resources.
  42619. */
  42620. dispose(): void;
  42621. }
  42622. }
  42623. declare module BABYLON.Debug {
  42624. /**
  42625. * Class used to render a debug view of a given skeleton
  42626. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42627. */
  42628. export class SkeletonViewer {
  42629. /** defines the skeleton to render */
  42630. skeleton: Skeleton;
  42631. /** defines the mesh attached to the skeleton */
  42632. mesh: AbstractMesh;
  42633. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42634. autoUpdateBonesMatrices: boolean;
  42635. /** defines the rendering group id to use with the viewer */
  42636. renderingGroupId: number;
  42637. /** Gets or sets the color used to render the skeleton */
  42638. color: Color3;
  42639. private _scene;
  42640. private _debugLines;
  42641. private _debugMesh;
  42642. private _isEnabled;
  42643. private _renderFunction;
  42644. private _utilityLayer;
  42645. /**
  42646. * Returns the mesh used to render the bones
  42647. */
  42648. readonly debugMesh: Nullable<LinesMesh>;
  42649. /**
  42650. * Creates a new SkeletonViewer
  42651. * @param skeleton defines the skeleton to render
  42652. * @param mesh defines the mesh attached to the skeleton
  42653. * @param scene defines the hosting scene
  42654. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42655. * @param renderingGroupId defines the rendering group id to use with the viewer
  42656. */
  42657. constructor(
  42658. /** defines the skeleton to render */
  42659. skeleton: Skeleton,
  42660. /** defines the mesh attached to the skeleton */
  42661. mesh: AbstractMesh, scene: Scene,
  42662. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42663. autoUpdateBonesMatrices?: boolean,
  42664. /** defines the rendering group id to use with the viewer */
  42665. renderingGroupId?: number);
  42666. /** Gets or sets a boolean indicating if the viewer is enabled */
  42667. isEnabled: boolean;
  42668. private _getBonePosition;
  42669. private _getLinesForBonesWithLength;
  42670. private _getLinesForBonesNoLength;
  42671. /** Update the viewer to sync with current skeleton state */
  42672. update(): void;
  42673. /** Release associated resources */
  42674. dispose(): void;
  42675. }
  42676. }
  42677. declare module BABYLON {
  42678. /**
  42679. * Options to create the null engine
  42680. */
  42681. export class NullEngineOptions {
  42682. /**
  42683. * Render width (Default: 512)
  42684. */
  42685. renderWidth: number;
  42686. /**
  42687. * Render height (Default: 256)
  42688. */
  42689. renderHeight: number;
  42690. /**
  42691. * Texture size (Default: 512)
  42692. */
  42693. textureSize: number;
  42694. /**
  42695. * If delta time between frames should be constant
  42696. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42697. */
  42698. deterministicLockstep: boolean;
  42699. /**
  42700. * Maximum about of steps between frames (Default: 4)
  42701. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42702. */
  42703. lockstepMaxSteps: number;
  42704. }
  42705. /**
  42706. * The null engine class provides support for headless version of babylon.js.
  42707. * This can be used in server side scenario or for testing purposes
  42708. */
  42709. export class NullEngine extends Engine {
  42710. private _options;
  42711. /**
  42712. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42713. */
  42714. isDeterministicLockStep(): boolean;
  42715. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42716. getLockstepMaxSteps(): number;
  42717. /**
  42718. * Sets hardware scaling, used to save performance if needed
  42719. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42720. */
  42721. getHardwareScalingLevel(): number;
  42722. constructor(options?: NullEngineOptions);
  42723. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42724. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42725. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42726. getRenderWidth(useScreen?: boolean): number;
  42727. getRenderHeight(useScreen?: boolean): number;
  42728. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42729. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42730. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42731. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42732. bindSamplers(effect: Effect): void;
  42733. enableEffect(effect: Effect): void;
  42734. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42735. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42736. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42737. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42738. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42739. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42740. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42741. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42742. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42743. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42744. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42745. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42746. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42747. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42748. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42749. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42750. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42751. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42752. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42753. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42754. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42755. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42756. bindBuffers(vertexBuffers: {
  42757. [key: string]: VertexBuffer;
  42758. }, indexBuffer: DataBuffer, effect: Effect): void;
  42759. wipeCaches(bruteForce?: boolean): void;
  42760. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42761. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42762. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42763. /** @hidden */ private _createTexture(): WebGLTexture;
  42764. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  42765. 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;
  42766. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42767. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42768. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42769. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42770. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42771. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42772. areAllEffectsReady(): boolean;
  42773. /**
  42774. * @hidden
  42775. * Get the current error code of the webGL context
  42776. * @returns the error code
  42777. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42778. */
  42779. getError(): number;
  42780. /** @hidden */ private _getUnpackAlignement(): number;
  42781. /** @hidden */ private _unpackFlipY(value: boolean): void;
  42782. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42783. /**
  42784. * Updates a dynamic vertex buffer.
  42785. * @param vertexBuffer the vertex buffer to update
  42786. * @param data the data used to update the vertex buffer
  42787. * @param byteOffset the byte offset of the data (optional)
  42788. * @param byteLength the byte length of the data (optional)
  42789. */
  42790. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42791. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  42792. protected _deleteBuffer(buffer: WebGLBuffer): void;
  42793. releaseEffects(): void;
  42794. displayLoadingUI(): void;
  42795. hideLoadingUI(): void;
  42796. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42797. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42798. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42799. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42800. }
  42801. }
  42802. declare module BABYLON {
  42803. /** @hidden */
  42804. export class _OcclusionDataStorage {
  42805. /** @hidden */
  42806. occlusionInternalRetryCounter: number;
  42807. /** @hidden */
  42808. isOcclusionQueryInProgress: boolean;
  42809. /** @hidden */
  42810. isOccluded: boolean;
  42811. /** @hidden */
  42812. occlusionRetryCount: number;
  42813. /** @hidden */
  42814. occlusionType: number;
  42815. /** @hidden */
  42816. occlusionQueryAlgorithmType: number;
  42817. }
  42818. interface Engine {
  42819. /**
  42820. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42821. * @return the new query
  42822. */
  42823. createQuery(): WebGLQuery;
  42824. /**
  42825. * Delete and release a webGL query
  42826. * @param query defines the query to delete
  42827. * @return the current engine
  42828. */
  42829. deleteQuery(query: WebGLQuery): Engine;
  42830. /**
  42831. * Check if a given query has resolved and got its value
  42832. * @param query defines the query to check
  42833. * @returns true if the query got its value
  42834. */
  42835. isQueryResultAvailable(query: WebGLQuery): boolean;
  42836. /**
  42837. * Gets the value of a given query
  42838. * @param query defines the query to check
  42839. * @returns the value of the query
  42840. */
  42841. getQueryResult(query: WebGLQuery): number;
  42842. /**
  42843. * Initiates an occlusion query
  42844. * @param algorithmType defines the algorithm to use
  42845. * @param query defines the query to use
  42846. * @returns the current engine
  42847. * @see http://doc.babylonjs.com/features/occlusionquery
  42848. */
  42849. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42850. /**
  42851. * Ends an occlusion query
  42852. * @see http://doc.babylonjs.com/features/occlusionquery
  42853. * @param algorithmType defines the algorithm to use
  42854. * @returns the current engine
  42855. */
  42856. endOcclusionQuery(algorithmType: number): Engine;
  42857. /**
  42858. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42859. * Please note that only one query can be issued at a time
  42860. * @returns a time token used to track the time span
  42861. */
  42862. startTimeQuery(): Nullable<_TimeToken>;
  42863. /**
  42864. * Ends a time query
  42865. * @param token defines the token used to measure the time span
  42866. * @returns the time spent (in ns)
  42867. */
  42868. endTimeQuery(token: _TimeToken): int;
  42869. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  42870. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  42871. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  42872. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  42873. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  42874. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  42875. }
  42876. interface AbstractMesh {
  42877. /**
  42878. * Backing filed
  42879. * @hidden
  42880. */ private __occlusionDataStorage: _OcclusionDataStorage;
  42881. /**
  42882. * Access property
  42883. * @hidden
  42884. */ private _occlusionDataStorage: _OcclusionDataStorage;
  42885. /**
  42886. * 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.
  42887. * The default value is -1 which means don't break the query and wait till the result
  42888. * @see http://doc.babylonjs.com/features/occlusionquery
  42889. */
  42890. occlusionRetryCount: number;
  42891. /**
  42892. * 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:
  42893. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42894. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42895. * * 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.
  42896. * @see http://doc.babylonjs.com/features/occlusionquery
  42897. */
  42898. occlusionType: number;
  42899. /**
  42900. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42901. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42902. * * 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.
  42903. * @see http://doc.babylonjs.com/features/occlusionquery
  42904. */
  42905. occlusionQueryAlgorithmType: number;
  42906. /**
  42907. * 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
  42908. * @see http://doc.babylonjs.com/features/occlusionquery
  42909. */
  42910. isOccluded: boolean;
  42911. /**
  42912. * Flag to check the progress status of the query
  42913. * @see http://doc.babylonjs.com/features/occlusionquery
  42914. */
  42915. isOcclusionQueryInProgress: boolean;
  42916. }
  42917. }
  42918. declare module BABYLON {
  42919. /** @hidden */
  42920. export var _forceTransformFeedbackToBundle: boolean;
  42921. interface Engine {
  42922. /**
  42923. * Creates a webGL transform feedback object
  42924. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42925. * @returns the webGL transform feedback object
  42926. */
  42927. createTransformFeedback(): WebGLTransformFeedback;
  42928. /**
  42929. * Delete a webGL transform feedback object
  42930. * @param value defines the webGL transform feedback object to delete
  42931. */
  42932. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42933. /**
  42934. * Bind a webGL transform feedback object to the webgl context
  42935. * @param value defines the webGL transform feedback object to bind
  42936. */
  42937. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42938. /**
  42939. * Begins a transform feedback operation
  42940. * @param usePoints defines if points or triangles must be used
  42941. */
  42942. beginTransformFeedback(usePoints: boolean): void;
  42943. /**
  42944. * Ends a transform feedback operation
  42945. */
  42946. endTransformFeedback(): void;
  42947. /**
  42948. * Specify the varyings to use with transform feedback
  42949. * @param program defines the associated webGL program
  42950. * @param value defines the list of strings representing the varying names
  42951. */
  42952. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42953. /**
  42954. * Bind a webGL buffer for a transform feedback operation
  42955. * @param value defines the webGL buffer to bind
  42956. */
  42957. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42958. }
  42959. }
  42960. declare module BABYLON {
  42961. /**
  42962. * Creation options of the multi render target texture.
  42963. */
  42964. export interface IMultiRenderTargetOptions {
  42965. /**
  42966. * Define if the texture needs to create mip maps after render.
  42967. */
  42968. generateMipMaps?: boolean;
  42969. /**
  42970. * Define the types of all the draw buffers we want to create
  42971. */
  42972. types?: number[];
  42973. /**
  42974. * Define the sampling modes of all the draw buffers we want to create
  42975. */
  42976. samplingModes?: number[];
  42977. /**
  42978. * Define if a depth buffer is required
  42979. */
  42980. generateDepthBuffer?: boolean;
  42981. /**
  42982. * Define if a stencil buffer is required
  42983. */
  42984. generateStencilBuffer?: boolean;
  42985. /**
  42986. * Define if a depth texture is required instead of a depth buffer
  42987. */
  42988. generateDepthTexture?: boolean;
  42989. /**
  42990. * Define the number of desired draw buffers
  42991. */
  42992. textureCount?: number;
  42993. /**
  42994. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42995. */
  42996. doNotChangeAspectRatio?: boolean;
  42997. /**
  42998. * Define the default type of the buffers we are creating
  42999. */
  43000. defaultType?: number;
  43001. }
  43002. /**
  43003. * A multi render target, like a render target provides the ability to render to a texture.
  43004. * Unlike the render target, it can render to several draw buffers in one draw.
  43005. * This is specially interesting in deferred rendering or for any effects requiring more than
  43006. * just one color from a single pass.
  43007. */
  43008. export class MultiRenderTarget extends RenderTargetTexture {
  43009. private _internalTextures;
  43010. private _textures;
  43011. private _multiRenderTargetOptions;
  43012. /**
  43013. * Get if draw buffers are currently supported by the used hardware and browser.
  43014. */
  43015. readonly isSupported: boolean;
  43016. /**
  43017. * Get the list of textures generated by the multi render target.
  43018. */
  43019. readonly textures: Texture[];
  43020. /**
  43021. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43022. */
  43023. readonly depthTexture: Texture;
  43024. /**
  43025. * Set the wrapping mode on U of all the textures we are rendering to.
  43026. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43027. */
  43028. wrapU: number;
  43029. /**
  43030. * Set the wrapping mode on V of all the textures we are rendering to.
  43031. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43032. */
  43033. wrapV: number;
  43034. /**
  43035. * Instantiate a new multi render target texture.
  43036. * A multi render target, like a render target provides the ability to render to a texture.
  43037. * Unlike the render target, it can render to several draw buffers in one draw.
  43038. * This is specially interesting in deferred rendering or for any effects requiring more than
  43039. * just one color from a single pass.
  43040. * @param name Define the name of the texture
  43041. * @param size Define the size of the buffers to render to
  43042. * @param count Define the number of target we are rendering into
  43043. * @param scene Define the scene the texture belongs to
  43044. * @param options Define the options used to create the multi render target
  43045. */
  43046. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43047. /** @hidden */ private _rebuild(): void;
  43048. private _createInternalTextures;
  43049. private _createTextures;
  43050. /**
  43051. * Define the number of samples used if MSAA is enabled.
  43052. */
  43053. samples: number;
  43054. /**
  43055. * Resize all the textures in the multi render target.
  43056. * Be carrefull as it will recreate all the data in the new texture.
  43057. * @param size Define the new size
  43058. */
  43059. resize(size: any): void;
  43060. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43061. /**
  43062. * Dispose the render targets and their associated resources
  43063. */
  43064. dispose(): void;
  43065. /**
  43066. * Release all the underlying texture used as draw buffers.
  43067. */
  43068. releaseInternalTextures(): void;
  43069. }
  43070. }
  43071. declare module BABYLON {
  43072. interface Engine {
  43073. /**
  43074. * Unbind a list of render target textures from the webGL context
  43075. * This is used only when drawBuffer extension or webGL2 are active
  43076. * @param textures defines the render target textures to unbind
  43077. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43078. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43079. */
  43080. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43081. /**
  43082. * Create a multi render target texture
  43083. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43084. * @param size defines the size of the texture
  43085. * @param options defines the creation options
  43086. * @returns the cube texture as an InternalTexture
  43087. */
  43088. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43089. /**
  43090. * Update the sample count for a given multiple render target texture
  43091. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43092. * @param textures defines the textures to update
  43093. * @param samples defines the sample count to set
  43094. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43095. */
  43096. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43097. }
  43098. }
  43099. declare module BABYLON {
  43100. /** @hidden */
  43101. export var rgbdEncodePixelShader: {
  43102. name: string;
  43103. shader: string;
  43104. };
  43105. }
  43106. declare module BABYLON {
  43107. /** @hidden */
  43108. export var rgbdDecodePixelShader: {
  43109. name: string;
  43110. shader: string;
  43111. };
  43112. }
  43113. declare module BABYLON {
  43114. /**
  43115. * Raw texture data and descriptor sufficient for WebGL texture upload
  43116. */
  43117. export interface EnvironmentTextureInfo {
  43118. /**
  43119. * Version of the environment map
  43120. */
  43121. version: number;
  43122. /**
  43123. * Width of image
  43124. */
  43125. width: number;
  43126. /**
  43127. * Irradiance information stored in the file.
  43128. */
  43129. irradiance: any;
  43130. /**
  43131. * Specular information stored in the file.
  43132. */
  43133. specular: any;
  43134. }
  43135. /**
  43136. * Defines One Image in the file. It requires only the position in the file
  43137. * as well as the length.
  43138. */
  43139. interface BufferImageData {
  43140. /**
  43141. * Length of the image data.
  43142. */
  43143. length: number;
  43144. /**
  43145. * Position of the data from the null terminator delimiting the end of the JSON.
  43146. */
  43147. position: number;
  43148. }
  43149. /**
  43150. * Defines the specular data enclosed in the file.
  43151. * This corresponds to the version 1 of the data.
  43152. */
  43153. export interface EnvironmentTextureSpecularInfoV1 {
  43154. /**
  43155. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43156. */
  43157. specularDataPosition?: number;
  43158. /**
  43159. * This contains all the images data needed to reconstruct the cubemap.
  43160. */
  43161. mipmaps: Array<BufferImageData>;
  43162. /**
  43163. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43164. */
  43165. lodGenerationScale: number;
  43166. }
  43167. /**
  43168. * Sets of helpers addressing the serialization and deserialization of environment texture
  43169. * stored in a BabylonJS env file.
  43170. * Those files are usually stored as .env files.
  43171. */
  43172. export class EnvironmentTextureTools {
  43173. /**
  43174. * Magic number identifying the env file.
  43175. */
  43176. private static _MagicBytes;
  43177. /**
  43178. * Gets the environment info from an env file.
  43179. * @param data The array buffer containing the .env bytes.
  43180. * @returns the environment file info (the json header) if successfully parsed.
  43181. */
  43182. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43183. /**
  43184. * Creates an environment texture from a loaded cube texture.
  43185. * @param texture defines the cube texture to convert in env file
  43186. * @return a promise containing the environment data if succesfull.
  43187. */
  43188. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43189. /**
  43190. * Creates a JSON representation of the spherical data.
  43191. * @param texture defines the texture containing the polynomials
  43192. * @return the JSON representation of the spherical info
  43193. */
  43194. private static _CreateEnvTextureIrradiance;
  43195. /**
  43196. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43197. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43198. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43199. * @return the views described by info providing access to the underlying buffer
  43200. */
  43201. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43202. /**
  43203. * Uploads the texture info contained in the env file to the GPU.
  43204. * @param texture defines the internal texture to upload to
  43205. * @param arrayBuffer defines the buffer cotaining the data to load
  43206. * @param info defines the texture info retrieved through the GetEnvInfo method
  43207. * @returns a promise
  43208. */
  43209. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43210. /**
  43211. * Uploads the levels of image data to the GPU.
  43212. * @param texture defines the internal texture to upload to
  43213. * @param imageData defines the array buffer views of image data [mipmap][face]
  43214. * @returns a promise
  43215. */
  43216. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43217. /**
  43218. * Uploads spherical polynomials information to the texture.
  43219. * @param texture defines the texture we are trying to upload the information to
  43220. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43221. */
  43222. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43223. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43224. }
  43225. }
  43226. declare module BABYLON {
  43227. /**
  43228. * Contains position and normal vectors for a vertex
  43229. */
  43230. export class PositionNormalVertex {
  43231. /** the position of the vertex (defaut: 0,0,0) */
  43232. position: Vector3;
  43233. /** the normal of the vertex (defaut: 0,1,0) */
  43234. normal: Vector3;
  43235. /**
  43236. * Creates a PositionNormalVertex
  43237. * @param position the position of the vertex (defaut: 0,0,0)
  43238. * @param normal the normal of the vertex (defaut: 0,1,0)
  43239. */
  43240. constructor(
  43241. /** the position of the vertex (defaut: 0,0,0) */
  43242. position?: Vector3,
  43243. /** the normal of the vertex (defaut: 0,1,0) */
  43244. normal?: Vector3);
  43245. /**
  43246. * Clones the PositionNormalVertex
  43247. * @returns the cloned PositionNormalVertex
  43248. */
  43249. clone(): PositionNormalVertex;
  43250. }
  43251. /**
  43252. * Contains position, normal and uv vectors for a vertex
  43253. */
  43254. export class PositionNormalTextureVertex {
  43255. /** the position of the vertex (defaut: 0,0,0) */
  43256. position: Vector3;
  43257. /** the normal of the vertex (defaut: 0,1,0) */
  43258. normal: Vector3;
  43259. /** the uv of the vertex (default: 0,0) */
  43260. uv: Vector2;
  43261. /**
  43262. * Creates a PositionNormalTextureVertex
  43263. * @param position the position of the vertex (defaut: 0,0,0)
  43264. * @param normal the normal of the vertex (defaut: 0,1,0)
  43265. * @param uv the uv of the vertex (default: 0,0)
  43266. */
  43267. constructor(
  43268. /** the position of the vertex (defaut: 0,0,0) */
  43269. position?: Vector3,
  43270. /** the normal of the vertex (defaut: 0,1,0) */
  43271. normal?: Vector3,
  43272. /** the uv of the vertex (default: 0,0) */
  43273. uv?: Vector2);
  43274. /**
  43275. * Clones the PositionNormalTextureVertex
  43276. * @returns the cloned PositionNormalTextureVertex
  43277. */
  43278. clone(): PositionNormalTextureVertex;
  43279. }
  43280. }
  43281. declare module BABYLON {
  43282. /** @hidden */
  43283. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  43284. private _genericAttributeLocation;
  43285. private _varyingLocationCount;
  43286. private _varyingLocationMap;
  43287. private _replacements;
  43288. private _textureCount;
  43289. private _uniforms;
  43290. lineProcessor(line: string): string;
  43291. attributeProcessor(attribute: string): string;
  43292. varyingProcessor(varying: string, isFragment: boolean): string;
  43293. uniformProcessor(uniform: string): string;
  43294. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  43295. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  43296. }
  43297. }
  43298. declare module BABYLON {
  43299. /**
  43300. * Container for accessors for natively-stored mesh data buffers.
  43301. */
  43302. class NativeDataBuffer extends DataBuffer {
  43303. /**
  43304. * Accessor value used to identify/retrieve a natively-stored index buffer.
  43305. */
  43306. nativeIndexBuffer?: any;
  43307. /**
  43308. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  43309. */
  43310. nativeVertexBuffer?: any;
  43311. }
  43312. /** @hidden */
  43313. export class NativeEngine extends Engine {
  43314. private readonly _native;
  43315. getHardwareScalingLevel(): number;
  43316. constructor();
  43317. /**
  43318. * Can be used to override the current requestAnimationFrame requester.
  43319. * @hidden
  43320. */
  43321. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  43322. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43323. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  43324. createVertexBuffer(data: DataArray): NativeDataBuffer;
  43325. recordVertexArrayObject(vertexBuffers: {
  43326. [key: string]: VertexBuffer;
  43327. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  43328. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43329. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43330. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43331. /**
  43332. * Draw a list of indexed primitives
  43333. * @param fillMode defines the primitive to use
  43334. * @param indexStart defines the starting index
  43335. * @param indexCount defines the number of index to draw
  43336. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43337. */
  43338. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43339. /**
  43340. * Draw a list of unindexed primitives
  43341. * @param fillMode defines the primitive to use
  43342. * @param verticesStart defines the index of first vertex to draw
  43343. * @param verticesCount defines the count of vertices to draw
  43344. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43345. */
  43346. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43347. createPipelineContext(): IPipelineContext; private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  43348. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  43349. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  43350. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43351. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43352. protected _setProgram(program: WebGLProgram): void; private _releaseEffect(effect: Effect): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43353. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  43354. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  43355. bindSamplers(effect: Effect): void;
  43356. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43357. getRenderWidth(useScreen?: boolean): number;
  43358. getRenderHeight(useScreen?: boolean): number;
  43359. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43360. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43361. /**
  43362. * Set the z offset to apply to current rendering
  43363. * @param value defines the offset to apply
  43364. */
  43365. setZOffset(value: number): void;
  43366. /**
  43367. * Gets the current value of the zOffset
  43368. * @returns the current zOffset state
  43369. */
  43370. getZOffset(): number;
  43371. /**
  43372. * Enable or disable depth buffering
  43373. * @param enable defines the state to set
  43374. */
  43375. setDepthBuffer(enable: boolean): void;
  43376. /**
  43377. * Gets a boolean indicating if depth writing is enabled
  43378. * @returns the current depth writing state
  43379. */
  43380. getDepthWrite(): boolean;
  43381. /**
  43382. * Enable or disable depth writing
  43383. * @param enable defines the state to set
  43384. */
  43385. setDepthWrite(enable: boolean): void;
  43386. /**
  43387. * Enable or disable color writing
  43388. * @param enable defines the state to set
  43389. */
  43390. setColorWrite(enable: boolean): void;
  43391. /**
  43392. * Gets a boolean indicating if color writing is enabled
  43393. * @returns the current color writing state
  43394. */
  43395. getColorWrite(): boolean;
  43396. /**
  43397. * Sets alpha constants used by some alpha blending modes
  43398. * @param r defines the red component
  43399. * @param g defines the green component
  43400. * @param b defines the blue component
  43401. * @param a defines the alpha component
  43402. */
  43403. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  43404. /**
  43405. * Sets the current alpha mode
  43406. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  43407. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43408. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43409. */
  43410. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43411. /**
  43412. * Gets the current alpha mode
  43413. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43414. * @returns the current alpha mode
  43415. */
  43416. getAlphaMode(): number;
  43417. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43418. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43419. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43420. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43421. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43422. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43423. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43424. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43425. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43426. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43427. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43428. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43429. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43430. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43431. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43432. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43433. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43434. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43435. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43436. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43437. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43438. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43439. wipeCaches(bruteForce?: boolean): void; private _createTexture(): WebGLTexture;
  43440. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  43441. /**
  43442. * Usually called from BABYLON.Texture.ts.
  43443. * Passed information to create a WebGLTexture
  43444. * @param urlArg defines a value which contains one of the following:
  43445. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43446. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43447. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43448. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43449. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  43450. * @param scene needed for loading to the correct scene
  43451. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  43452. * @param onLoad optional callback to be called upon successful completion
  43453. * @param onError optional callback to be called upon failure
  43454. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  43455. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43456. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43457. * @param forcedExtension defines the extension to use to pick the right loader
  43458. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43459. */
  43460. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  43461. /**
  43462. * Creates a cube texture
  43463. * @param rootUrl defines the url where the files to load is located
  43464. * @param scene defines the current scene
  43465. * @param files defines the list of files to load (1 per face)
  43466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  43467. * @param onLoad defines an optional callback raised when the texture is loaded
  43468. * @param onError defines an optional callback raised if there is an issue to load the texture
  43469. * @param format defines the format of the data
  43470. * @param forcedExtension defines the extension to use to pick the right loader
  43471. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  43472. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  43473. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  43474. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  43475. * @returns the cube texture as an InternalTexture
  43476. */
  43477. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  43478. private _getSamplingFilter;
  43479. private static _GetNativeTextureFormat;
  43480. createRenderTargetTexture(size: number | {
  43481. width: number;
  43482. height: number;
  43483. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43484. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43485. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43486. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43487. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  43488. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  43489. /**
  43490. * Updates a dynamic vertex buffer.
  43491. * @param vertexBuffer the vertex buffer to update
  43492. * @param data the data used to update the vertex buffer
  43493. * @param byteOffset the byte offset of the data (optional)
  43494. * @param byteLength the byte length of the data (optional)
  43495. */
  43496. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  43497. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  43498. private _updateAnisotropicLevel;
  43499. private _getAddressMode;
  43500. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43501. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  43502. releaseEffects(): void;
  43503. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43504. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43505. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43506. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43507. }
  43508. }
  43509. declare module BABYLON {
  43510. /**
  43511. * Gather the list of clipboard event types as constants.
  43512. */
  43513. export class ClipboardEventTypes {
  43514. /**
  43515. * The clipboard event is fired when a copy command is active (pressed).
  43516. */
  43517. static readonly COPY: number;
  43518. /**
  43519. * The clipboard event is fired when a cut command is active (pressed).
  43520. */
  43521. static readonly CUT: number;
  43522. /**
  43523. * The clipboard event is fired when a paste command is active (pressed).
  43524. */
  43525. static readonly PASTE: number;
  43526. }
  43527. /**
  43528. * This class is used to store clipboard related info for the onClipboardObservable event.
  43529. */
  43530. export class ClipboardInfo {
  43531. /**
  43532. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43533. */
  43534. type: number;
  43535. /**
  43536. * Defines the related dom event
  43537. */
  43538. event: ClipboardEvent;
  43539. /**
  43540. *Creates an instance of ClipboardInfo.
  43541. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43542. * @param event Defines the related dom event
  43543. */
  43544. constructor(
  43545. /**
  43546. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43547. */
  43548. type: number,
  43549. /**
  43550. * Defines the related dom event
  43551. */
  43552. event: ClipboardEvent);
  43553. /**
  43554. * Get the clipboard event's type from the keycode.
  43555. * @param keyCode Defines the keyCode for the current keyboard event.
  43556. * @return {number}
  43557. */
  43558. static GetTypeFromCharacter(keyCode: number): number;
  43559. }
  43560. }
  43561. declare module BABYLON {
  43562. /**
  43563. * Google Daydream controller
  43564. */
  43565. export class DaydreamController extends WebVRController {
  43566. /**
  43567. * Base Url for the controller model.
  43568. */
  43569. static MODEL_BASE_URL: string;
  43570. /**
  43571. * File name for the controller model.
  43572. */
  43573. static MODEL_FILENAME: string;
  43574. /**
  43575. * Gamepad Id prefix used to identify Daydream Controller.
  43576. */
  43577. static readonly GAMEPAD_ID_PREFIX: string;
  43578. /**
  43579. * Creates a new DaydreamController from a gamepad
  43580. * @param vrGamepad the gamepad that the controller should be created from
  43581. */
  43582. constructor(vrGamepad: any);
  43583. /**
  43584. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43585. * @param scene scene in which to add meshes
  43586. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43587. */
  43588. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43589. /**
  43590. * Called once for each button that changed state since the last frame
  43591. * @param buttonIdx Which button index changed
  43592. * @param state New state of the button
  43593. * @param changes Which properties on the state changed since last frame
  43594. */
  43595. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43596. }
  43597. }
  43598. declare module BABYLON {
  43599. /**
  43600. * Gear VR Controller
  43601. */
  43602. export class GearVRController extends WebVRController {
  43603. /**
  43604. * Base Url for the controller model.
  43605. */
  43606. static MODEL_BASE_URL: string;
  43607. /**
  43608. * File name for the controller model.
  43609. */
  43610. static MODEL_FILENAME: string;
  43611. /**
  43612. * Gamepad Id prefix used to identify this controller.
  43613. */
  43614. static readonly GAMEPAD_ID_PREFIX: string;
  43615. private readonly _buttonIndexToObservableNameMap;
  43616. /**
  43617. * Creates a new GearVRController from a gamepad
  43618. * @param vrGamepad the gamepad that the controller should be created from
  43619. */
  43620. constructor(vrGamepad: any);
  43621. /**
  43622. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43623. * @param scene scene in which to add meshes
  43624. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43625. */
  43626. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43627. /**
  43628. * Called once for each button that changed state since the last frame
  43629. * @param buttonIdx Which button index changed
  43630. * @param state New state of the button
  43631. * @param changes Which properties on the state changed since last frame
  43632. */
  43633. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43634. }
  43635. }
  43636. declare module BABYLON {
  43637. /**
  43638. * Class containing static functions to help procedurally build meshes
  43639. */
  43640. export class PolyhedronBuilder {
  43641. /**
  43642. * Creates a polyhedron mesh
  43643. * * 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
  43644. * * The parameter `size` (positive float, default 1) sets the polygon size
  43645. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43646. * * 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`
  43647. * * 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
  43648. * * 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)`)
  43649. * * 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
  43650. * * 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
  43651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43652. * * 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
  43653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43654. * @param name defines the name of the mesh
  43655. * @param options defines the options used to create the mesh
  43656. * @param scene defines the hosting scene
  43657. * @returns the polyhedron mesh
  43658. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43659. */
  43660. static CreatePolyhedron(name: string, options: {
  43661. type?: number;
  43662. size?: number;
  43663. sizeX?: number;
  43664. sizeY?: number;
  43665. sizeZ?: number;
  43666. custom?: any;
  43667. faceUV?: Vector4[];
  43668. faceColors?: Color4[];
  43669. flat?: boolean;
  43670. updatable?: boolean;
  43671. sideOrientation?: number;
  43672. frontUVs?: Vector4;
  43673. backUVs?: Vector4;
  43674. }, scene?: Nullable<Scene>): Mesh;
  43675. }
  43676. }
  43677. declare module BABYLON {
  43678. /**
  43679. * Gizmo that enables scaling a mesh along 3 axis
  43680. */
  43681. export class ScaleGizmo extends Gizmo {
  43682. /**
  43683. * Internal gizmo used for interactions on the x axis
  43684. */
  43685. xGizmo: AxisScaleGizmo;
  43686. /**
  43687. * Internal gizmo used for interactions on the y axis
  43688. */
  43689. yGizmo: AxisScaleGizmo;
  43690. /**
  43691. * Internal gizmo used for interactions on the z axis
  43692. */
  43693. zGizmo: AxisScaleGizmo;
  43694. /**
  43695. * Internal gizmo used to scale all axis equally
  43696. */
  43697. uniformScaleGizmo: AxisScaleGizmo;
  43698. private _meshAttached;
  43699. private _updateGizmoRotationToMatchAttachedMesh;
  43700. private _snapDistance;
  43701. private _scaleRatio;
  43702. private _uniformScalingMesh;
  43703. private _octahedron;
  43704. /** Fires an event when any of it's sub gizmos are dragged */
  43705. onDragStartObservable: Observable<unknown>;
  43706. /** Fires an event when any of it's sub gizmos are released from dragging */
  43707. onDragEndObservable: Observable<unknown>;
  43708. attachedMesh: Nullable<AbstractMesh>;
  43709. /**
  43710. * Creates a ScaleGizmo
  43711. * @param gizmoLayer The utility layer the gizmo will be added to
  43712. */
  43713. constructor(gizmoLayer?: UtilityLayerRenderer);
  43714. updateGizmoRotationToMatchAttachedMesh: boolean;
  43715. /**
  43716. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43717. */
  43718. snapDistance: number;
  43719. /**
  43720. * Ratio for the scale of the gizmo (Default: 1)
  43721. */
  43722. scaleRatio: number;
  43723. /**
  43724. * Disposes of the gizmo
  43725. */
  43726. dispose(): void;
  43727. }
  43728. }
  43729. declare module BABYLON {
  43730. /**
  43731. * Single axis scale gizmo
  43732. */
  43733. export class AxisScaleGizmo extends Gizmo {
  43734. /**
  43735. * Drag behavior responsible for the gizmos dragging interactions
  43736. */
  43737. dragBehavior: PointerDragBehavior;
  43738. private _pointerObserver;
  43739. /**
  43740. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43741. */
  43742. snapDistance: number;
  43743. /**
  43744. * Event that fires each time the gizmo snaps to a new location.
  43745. * * snapDistance is the the change in distance
  43746. */
  43747. onSnapObservable: Observable<{
  43748. snapDistance: number;
  43749. }>;
  43750. /**
  43751. * If the scaling operation should be done on all axis (default: false)
  43752. */
  43753. uniformScaling: boolean;
  43754. private _isEnabled;
  43755. private _parent;
  43756. private _arrow;
  43757. private _coloredMaterial;
  43758. private _hoverMaterial;
  43759. /**
  43760. * Creates an AxisScaleGizmo
  43761. * @param gizmoLayer The utility layer the gizmo will be added to
  43762. * @param dragAxis The axis which the gizmo will be able to scale on
  43763. * @param color The color of the gizmo
  43764. */
  43765. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43766. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43767. /**
  43768. * If the gizmo is enabled
  43769. */
  43770. isEnabled: boolean;
  43771. /**
  43772. * Disposes of the gizmo
  43773. */
  43774. dispose(): void;
  43775. /**
  43776. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43777. * @param mesh The mesh to replace the default mesh of the gizmo
  43778. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43779. */
  43780. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43781. }
  43782. }
  43783. declare module BABYLON {
  43784. /**
  43785. * Bounding box gizmo
  43786. */
  43787. export class BoundingBoxGizmo extends Gizmo {
  43788. private _lineBoundingBox;
  43789. private _rotateSpheresParent;
  43790. private _scaleBoxesParent;
  43791. private _boundingDimensions;
  43792. private _renderObserver;
  43793. private _pointerObserver;
  43794. private _scaleDragSpeed;
  43795. private _tmpQuaternion;
  43796. private _tmpVector;
  43797. private _tmpRotationMatrix;
  43798. /**
  43799. * 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)
  43800. */
  43801. ignoreChildren: boolean;
  43802. /**
  43803. * 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)
  43804. */
  43805. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43806. /**
  43807. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43808. */
  43809. rotationSphereSize: number;
  43810. /**
  43811. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43812. */
  43813. scaleBoxSize: number;
  43814. /**
  43815. * 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)
  43816. */
  43817. fixedDragMeshScreenSize: boolean;
  43818. /**
  43819. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43820. */
  43821. fixedDragMeshScreenSizeDistanceFactor: number;
  43822. /**
  43823. * Fired when a rotation sphere or scale box is dragged
  43824. */
  43825. onDragStartObservable: Observable<{}>;
  43826. /**
  43827. * Fired when a scale box is dragged
  43828. */
  43829. onScaleBoxDragObservable: Observable<{}>;
  43830. /**
  43831. * Fired when a scale box drag is ended
  43832. */
  43833. onScaleBoxDragEndObservable: Observable<{}>;
  43834. /**
  43835. * Fired when a rotation sphere is dragged
  43836. */
  43837. onRotationSphereDragObservable: Observable<{}>;
  43838. /**
  43839. * Fired when a rotation sphere drag is ended
  43840. */
  43841. onRotationSphereDragEndObservable: Observable<{}>;
  43842. /**
  43843. * 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)
  43844. */
  43845. scalePivot: Nullable<Vector3>;
  43846. /**
  43847. * Mesh used as a pivot to rotate the attached mesh
  43848. */
  43849. private _anchorMesh;
  43850. private _existingMeshScale;
  43851. private _dragMesh;
  43852. private pointerDragBehavior;
  43853. private coloredMaterial;
  43854. private hoverColoredMaterial;
  43855. /**
  43856. * Sets the color of the bounding box gizmo
  43857. * @param color the color to set
  43858. */
  43859. setColor(color: Color3): void;
  43860. /**
  43861. * Creates an BoundingBoxGizmo
  43862. * @param gizmoLayer The utility layer the gizmo will be added to
  43863. * @param color The color of the gizmo
  43864. */
  43865. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43866. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43867. private _selectNode;
  43868. /**
  43869. * Updates the bounding box information for the Gizmo
  43870. */
  43871. updateBoundingBox(): void;
  43872. private _updateRotationSpheres;
  43873. private _updateScaleBoxes;
  43874. /**
  43875. * Enables rotation on the specified axis and disables rotation on the others
  43876. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43877. */
  43878. setEnabledRotationAxis(axis: string): void;
  43879. /**
  43880. * Enables/disables scaling
  43881. * @param enable if scaling should be enabled
  43882. */
  43883. setEnabledScaling(enable: boolean): void;
  43884. private _updateDummy;
  43885. /**
  43886. * Enables a pointer drag behavior on the bounding box of the gizmo
  43887. */
  43888. enableDragBehavior(): void;
  43889. /**
  43890. * Disposes of the gizmo
  43891. */
  43892. dispose(): void;
  43893. /**
  43894. * 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)
  43895. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43896. * @returns the bounding box mesh with the passed in mesh as a child
  43897. */
  43898. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43899. /**
  43900. * CustomMeshes are not supported by this gizmo
  43901. * @param mesh The mesh to replace the default mesh of the gizmo
  43902. */
  43903. setCustomMesh(mesh: Mesh): void;
  43904. }
  43905. }
  43906. declare module BABYLON {
  43907. /**
  43908. * Single plane rotation gizmo
  43909. */
  43910. export class PlaneRotationGizmo extends Gizmo {
  43911. /**
  43912. * Drag behavior responsible for the gizmos dragging interactions
  43913. */
  43914. dragBehavior: PointerDragBehavior;
  43915. private _pointerObserver;
  43916. /**
  43917. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43918. */
  43919. snapDistance: number;
  43920. /**
  43921. * Event that fires each time the gizmo snaps to a new location.
  43922. * * snapDistance is the the change in distance
  43923. */
  43924. onSnapObservable: Observable<{
  43925. snapDistance: number;
  43926. }>;
  43927. private _isEnabled;
  43928. private _parent;
  43929. /**
  43930. * Creates a PlaneRotationGizmo
  43931. * @param gizmoLayer The utility layer the gizmo will be added to
  43932. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43933. * @param color The color of the gizmo
  43934. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43935. * @param useEulerRotation Use and update Euler angle instead of quaternion
  43936. */
  43937. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  43938. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43939. /**
  43940. * If the gizmo is enabled
  43941. */
  43942. isEnabled: boolean;
  43943. /**
  43944. * Disposes of the gizmo
  43945. */
  43946. dispose(): void;
  43947. }
  43948. }
  43949. declare module BABYLON {
  43950. /**
  43951. * Gizmo that enables rotating a mesh along 3 axis
  43952. */
  43953. export class RotationGizmo extends Gizmo {
  43954. /**
  43955. * Internal gizmo used for interactions on the x axis
  43956. */
  43957. xGizmo: PlaneRotationGizmo;
  43958. /**
  43959. * Internal gizmo used for interactions on the y axis
  43960. */
  43961. yGizmo: PlaneRotationGizmo;
  43962. /**
  43963. * Internal gizmo used for interactions on the z axis
  43964. */
  43965. zGizmo: PlaneRotationGizmo;
  43966. /** Fires an event when any of it's sub gizmos are dragged */
  43967. onDragStartObservable: Observable<unknown>;
  43968. /** Fires an event when any of it's sub gizmos are released from dragging */
  43969. onDragEndObservable: Observable<unknown>;
  43970. private _meshAttached;
  43971. attachedMesh: Nullable<AbstractMesh>;
  43972. /**
  43973. * Creates a RotationGizmo
  43974. * @param gizmoLayer The utility layer the gizmo will be added to
  43975. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43976. * @param useEulerRotation Use and update Euler angle instead of quaternion
  43977. */
  43978. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  43979. updateGizmoRotationToMatchAttachedMesh: boolean;
  43980. /**
  43981. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43982. */
  43983. snapDistance: number;
  43984. /**
  43985. * Ratio for the scale of the gizmo (Default: 1)
  43986. */
  43987. scaleRatio: number;
  43988. /**
  43989. * Disposes of the gizmo
  43990. */
  43991. dispose(): void;
  43992. /**
  43993. * CustomMeshes are not supported by this gizmo
  43994. * @param mesh The mesh to replace the default mesh of the gizmo
  43995. */
  43996. setCustomMesh(mesh: Mesh): void;
  43997. }
  43998. }
  43999. declare module BABYLON {
  44000. /**
  44001. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44002. */
  44003. export class GizmoManager implements IDisposable {
  44004. private scene;
  44005. /**
  44006. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44007. */
  44008. gizmos: {
  44009. positionGizmo: Nullable<PositionGizmo>;
  44010. rotationGizmo: Nullable<RotationGizmo>;
  44011. scaleGizmo: Nullable<ScaleGizmo>;
  44012. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44013. };
  44014. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44015. clearGizmoOnEmptyPointerEvent: boolean;
  44016. /** Fires an event when the manager is attached to a mesh */
  44017. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44018. private _gizmosEnabled;
  44019. private _pointerObserver;
  44020. private _attachedMesh;
  44021. private _boundingBoxColor;
  44022. private _defaultUtilityLayer;
  44023. private _defaultKeepDepthUtilityLayer;
  44024. /**
  44025. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44026. */
  44027. boundingBoxDragBehavior: SixDofDragBehavior;
  44028. /**
  44029. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44030. */
  44031. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44032. /**
  44033. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44034. */
  44035. usePointerToAttachGizmos: boolean;
  44036. /**
  44037. * Utility layer that the bounding box gizmo belongs to
  44038. */
  44039. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44040. /**
  44041. * Utility layer that all gizmos besides bounding box belong to
  44042. */
  44043. readonly utilityLayer: UtilityLayerRenderer;
  44044. /**
  44045. * Instatiates a gizmo manager
  44046. * @param scene the scene to overlay the gizmos on top of
  44047. */
  44048. constructor(scene: Scene);
  44049. /**
  44050. * Attaches a set of gizmos to the specified mesh
  44051. * @param mesh The mesh the gizmo's should be attached to
  44052. */
  44053. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44054. /**
  44055. * If the position gizmo is enabled
  44056. */
  44057. positionGizmoEnabled: boolean;
  44058. /**
  44059. * If the rotation gizmo is enabled
  44060. */
  44061. rotationGizmoEnabled: boolean;
  44062. /**
  44063. * If the scale gizmo is enabled
  44064. */
  44065. scaleGizmoEnabled: boolean;
  44066. /**
  44067. * If the boundingBox gizmo is enabled
  44068. */
  44069. boundingBoxGizmoEnabled: boolean;
  44070. /**
  44071. * Disposes of the gizmo manager
  44072. */
  44073. dispose(): void;
  44074. }
  44075. }
  44076. declare module BABYLON {
  44077. /**
  44078. * A directional light is defined by a direction (what a surprise!).
  44079. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44080. * 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.
  44081. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44082. */
  44083. export class DirectionalLight extends ShadowLight {
  44084. private _shadowFrustumSize;
  44085. /**
  44086. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44087. */
  44088. /**
  44089. * Specifies a fix frustum size for the shadow generation.
  44090. */
  44091. shadowFrustumSize: number;
  44092. private _shadowOrthoScale;
  44093. /**
  44094. * Gets the shadow projection scale against the optimal computed one.
  44095. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44096. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44097. */
  44098. /**
  44099. * Sets the shadow projection scale against the optimal computed one.
  44100. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44101. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44102. */
  44103. shadowOrthoScale: number;
  44104. /**
  44105. * Automatically compute the projection matrix to best fit (including all the casters)
  44106. * on each frame.
  44107. */
  44108. autoUpdateExtends: boolean;
  44109. private _orthoLeft;
  44110. private _orthoRight;
  44111. private _orthoTop;
  44112. private _orthoBottom;
  44113. /**
  44114. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44115. * The directional light is emitted from everywhere in the given direction.
  44116. * It can cast shadows.
  44117. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44118. * @param name The friendly name of the light
  44119. * @param direction The direction of the light
  44120. * @param scene The scene the light belongs to
  44121. */
  44122. constructor(name: string, direction: Vector3, scene: Scene);
  44123. /**
  44124. * Returns the string "DirectionalLight".
  44125. * @return The class name
  44126. */
  44127. getClassName(): string;
  44128. /**
  44129. * Returns the integer 1.
  44130. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44131. */
  44132. getTypeID(): number;
  44133. /**
  44134. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44135. * Returns the DirectionalLight Shadow projection matrix.
  44136. */
  44137. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44138. /**
  44139. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44140. * Returns the DirectionalLight Shadow projection matrix.
  44141. */
  44142. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44143. /**
  44144. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44145. * Returns the DirectionalLight Shadow projection matrix.
  44146. */
  44147. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44148. protected _buildUniformLayout(): void;
  44149. /**
  44150. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44151. * @param effect The effect to update
  44152. * @param lightIndex The index of the light in the effect to update
  44153. * @returns The directional light
  44154. */
  44155. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44156. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44157. /**
  44158. * Gets the minZ used for shadow according to both the scene and the light.
  44159. *
  44160. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44161. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44162. * @param activeCamera The camera we are returning the min for
  44163. * @returns the depth min z
  44164. */
  44165. getDepthMinZ(activeCamera: Camera): number;
  44166. /**
  44167. * Gets the maxZ used for shadow according to both the scene and the light.
  44168. *
  44169. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44170. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44171. * @param activeCamera The camera we are returning the max for
  44172. * @returns the depth max z
  44173. */
  44174. getDepthMaxZ(activeCamera: Camera): number;
  44175. /**
  44176. * Prepares the list of defines specific to the light type.
  44177. * @param defines the list of defines
  44178. * @param lightIndex defines the index of the light for the effect
  44179. */
  44180. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44181. }
  44182. }
  44183. declare module BABYLON {
  44184. /**
  44185. * Class containing static functions to help procedurally build meshes
  44186. */
  44187. export class HemisphereBuilder {
  44188. /**
  44189. * Creates a hemisphere mesh
  44190. * @param name defines the name of the mesh
  44191. * @param options defines the options used to create the mesh
  44192. * @param scene defines the hosting scene
  44193. * @returns the hemisphere mesh
  44194. */
  44195. static CreateHemisphere(name: string, options: {
  44196. segments?: number;
  44197. diameter?: number;
  44198. sideOrientation?: number;
  44199. }, scene: any): Mesh;
  44200. }
  44201. }
  44202. declare module BABYLON {
  44203. /**
  44204. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44205. * These values define a cone of light starting from the position, emitting toward the direction.
  44206. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44207. * and the exponent defines the speed of the decay of the light with distance (reach).
  44208. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44209. */
  44210. export class SpotLight extends ShadowLight {
  44211. private _angle;
  44212. private _innerAngle;
  44213. private _cosHalfAngle;
  44214. private _lightAngleScale;
  44215. private _lightAngleOffset;
  44216. /**
  44217. * Gets the cone angle of the spot light in Radians.
  44218. */
  44219. /**
  44220. * Sets the cone angle of the spot light in Radians.
  44221. */
  44222. angle: number;
  44223. /**
  44224. * Only used in gltf falloff mode, this defines the angle where
  44225. * the directional falloff will start before cutting at angle which could be seen
  44226. * as outer angle.
  44227. */
  44228. /**
  44229. * Only used in gltf falloff mode, this defines the angle where
  44230. * the directional falloff will start before cutting at angle which could be seen
  44231. * as outer angle.
  44232. */
  44233. innerAngle: number;
  44234. private _shadowAngleScale;
  44235. /**
  44236. * Allows scaling the angle of the light for shadow generation only.
  44237. */
  44238. /**
  44239. * Allows scaling the angle of the light for shadow generation only.
  44240. */
  44241. shadowAngleScale: number;
  44242. /**
  44243. * The light decay speed with the distance from the emission spot.
  44244. */
  44245. exponent: number;
  44246. private _projectionTextureMatrix;
  44247. /**
  44248. * Allows reading the projecton texture
  44249. */
  44250. readonly projectionTextureMatrix: Matrix;
  44251. protected _projectionTextureLightNear: number;
  44252. /**
  44253. * Gets the near clip of the Spotlight for texture projection.
  44254. */
  44255. /**
  44256. * Sets the near clip of the Spotlight for texture projection.
  44257. */
  44258. projectionTextureLightNear: number;
  44259. protected _projectionTextureLightFar: number;
  44260. /**
  44261. * Gets the far clip of the Spotlight for texture projection.
  44262. */
  44263. /**
  44264. * Sets the far clip of the Spotlight for texture projection.
  44265. */
  44266. projectionTextureLightFar: number;
  44267. protected _projectionTextureUpDirection: Vector3;
  44268. /**
  44269. * Gets the Up vector of the Spotlight for texture projection.
  44270. */
  44271. /**
  44272. * Sets the Up vector of the Spotlight for texture projection.
  44273. */
  44274. projectionTextureUpDirection: Vector3;
  44275. private _projectionTexture;
  44276. /**
  44277. * Gets the projection texture of the light.
  44278. */
  44279. /**
  44280. * Sets the projection texture of the light.
  44281. */
  44282. projectionTexture: Nullable<BaseTexture>;
  44283. private _projectionTextureViewLightDirty;
  44284. private _projectionTextureProjectionLightDirty;
  44285. private _projectionTextureDirty;
  44286. private _projectionTextureViewTargetVector;
  44287. private _projectionTextureViewLightMatrix;
  44288. private _projectionTextureProjectionLightMatrix;
  44289. private _projectionTextureScalingMatrix;
  44290. /**
  44291. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44292. * It can cast shadows.
  44293. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44294. * @param name The light friendly name
  44295. * @param position The position of the spot light in the scene
  44296. * @param direction The direction of the light in the scene
  44297. * @param angle The cone angle of the light in Radians
  44298. * @param exponent The light decay speed with the distance from the emission spot
  44299. * @param scene The scene the lights belongs to
  44300. */
  44301. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44302. /**
  44303. * Returns the string "SpotLight".
  44304. * @returns the class name
  44305. */
  44306. getClassName(): string;
  44307. /**
  44308. * Returns the integer 2.
  44309. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44310. */
  44311. getTypeID(): number;
  44312. /**
  44313. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44314. */
  44315. protected _setDirection(value: Vector3): void;
  44316. /**
  44317. * Overrides the position setter to recompute the projection texture view light Matrix.
  44318. */
  44319. protected _setPosition(value: Vector3): void;
  44320. /**
  44321. * 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.
  44322. * Returns the SpotLight.
  44323. */
  44324. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44325. protected _computeProjectionTextureViewLightMatrix(): void;
  44326. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44327. /**
  44328. * Main function for light texture projection matrix computing.
  44329. */
  44330. protected _computeProjectionTextureMatrix(): void;
  44331. protected _buildUniformLayout(): void;
  44332. private _computeAngleValues;
  44333. /**
  44334. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44335. * @param effect The effect to update
  44336. * @param lightIndex The index of the light in the effect to update
  44337. * @returns The spot light
  44338. */
  44339. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44340. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  44341. /**
  44342. * Disposes the light and the associated resources.
  44343. */
  44344. dispose(): void;
  44345. /**
  44346. * Prepares the list of defines specific to the light type.
  44347. * @param defines the list of defines
  44348. * @param lightIndex defines the index of the light for the effect
  44349. */
  44350. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44351. }
  44352. }
  44353. declare module BABYLON {
  44354. /**
  44355. * Gizmo that enables viewing a light
  44356. */
  44357. export class LightGizmo extends Gizmo {
  44358. private _lightMesh;
  44359. private _material;
  44360. private cachedPosition;
  44361. private cachedForward;
  44362. /**
  44363. * Creates a LightGizmo
  44364. * @param gizmoLayer The utility layer the gizmo will be added to
  44365. */
  44366. constructor(gizmoLayer?: UtilityLayerRenderer);
  44367. private _light;
  44368. /**
  44369. * The light that the gizmo is attached to
  44370. */
  44371. light: Nullable<Light>;
  44372. /**
  44373. * Gets the material used to render the light gizmo
  44374. */
  44375. readonly material: StandardMaterial;
  44376. /**
  44377. * @hidden
  44378. * Updates the gizmo to match the attached mesh's position/rotation
  44379. */
  44380. protected _update(): void;
  44381. private static _Scale;
  44382. /**
  44383. * Creates the lines for a light mesh
  44384. */
  44385. private static _createLightLines;
  44386. /**
  44387. * Disposes of the light gizmo
  44388. */
  44389. dispose(): void;
  44390. private static _CreateHemisphericLightMesh;
  44391. private static _CreatePointLightMesh;
  44392. private static _CreateSpotLightMesh;
  44393. private static _CreateDirectionalLightMesh;
  44394. }
  44395. }
  44396. declare module BABYLON {
  44397. /** @hidden */
  44398. export var backgroundFragmentDeclaration: {
  44399. name: string;
  44400. shader: string;
  44401. };
  44402. }
  44403. declare module BABYLON {
  44404. /** @hidden */
  44405. export var backgroundUboDeclaration: {
  44406. name: string;
  44407. shader: string;
  44408. };
  44409. }
  44410. declare module BABYLON {
  44411. /** @hidden */
  44412. export var backgroundPixelShader: {
  44413. name: string;
  44414. shader: string;
  44415. };
  44416. }
  44417. declare module BABYLON {
  44418. /** @hidden */
  44419. export var backgroundVertexDeclaration: {
  44420. name: string;
  44421. shader: string;
  44422. };
  44423. }
  44424. declare module BABYLON {
  44425. /** @hidden */
  44426. export var backgroundVertexShader: {
  44427. name: string;
  44428. shader: string;
  44429. };
  44430. }
  44431. declare module BABYLON {
  44432. /**
  44433. * Background material used to create an efficient environement around your scene.
  44434. */
  44435. export class BackgroundMaterial extends PushMaterial {
  44436. /**
  44437. * Standard reflectance value at parallel view angle.
  44438. */
  44439. static StandardReflectance0: number;
  44440. /**
  44441. * Standard reflectance value at grazing angle.
  44442. */
  44443. static StandardReflectance90: number;
  44444. protected _primaryColor: Color3;
  44445. /**
  44446. * Key light Color (multiply against the environement texture)
  44447. */
  44448. primaryColor: Color3;
  44449. protected __perceptualColor: Nullable<Color3>;
  44450. /**
  44451. * Experimental Internal Use Only.
  44452. *
  44453. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44454. * This acts as a helper to set the primary color to a more "human friendly" value.
  44455. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44456. * output color as close as possible from the chosen value.
  44457. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44458. * part of lighting setup.)
  44459. */ private _perceptualColor: Nullable<Color3>;
  44460. protected _primaryColorShadowLevel: float;
  44461. /**
  44462. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44463. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44464. */
  44465. primaryColorShadowLevel: float;
  44466. protected _primaryColorHighlightLevel: float;
  44467. /**
  44468. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44469. * The primary color is used at the level chosen to define what the white area would look.
  44470. */
  44471. primaryColorHighlightLevel: float;
  44472. protected _reflectionTexture: Nullable<BaseTexture>;
  44473. /**
  44474. * Reflection Texture used in the material.
  44475. * Should be author in a specific way for the best result (refer to the documentation).
  44476. */
  44477. reflectionTexture: Nullable<BaseTexture>;
  44478. protected _reflectionBlur: float;
  44479. /**
  44480. * Reflection Texture level of blur.
  44481. *
  44482. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44483. * texture twice.
  44484. */
  44485. reflectionBlur: float;
  44486. protected _diffuseTexture: Nullable<BaseTexture>;
  44487. /**
  44488. * Diffuse Texture used in the material.
  44489. * Should be author in a specific way for the best result (refer to the documentation).
  44490. */
  44491. diffuseTexture: Nullable<BaseTexture>;
  44492. protected _shadowLights: Nullable<IShadowLight[]>;
  44493. /**
  44494. * Specify the list of lights casting shadow on the material.
  44495. * All scene shadow lights will be included if null.
  44496. */
  44497. shadowLights: Nullable<IShadowLight[]>;
  44498. protected _shadowLevel: float;
  44499. /**
  44500. * Helps adjusting the shadow to a softer level if required.
  44501. * 0 means black shadows and 1 means no shadows.
  44502. */
  44503. shadowLevel: float;
  44504. protected _sceneCenter: Vector3;
  44505. /**
  44506. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44507. * It is usually zero but might be interesting to modify according to your setup.
  44508. */
  44509. sceneCenter: Vector3;
  44510. protected _opacityFresnel: boolean;
  44511. /**
  44512. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44513. * This helps ensuring a nice transition when the camera goes under the ground.
  44514. */
  44515. opacityFresnel: boolean;
  44516. protected _reflectionFresnel: boolean;
  44517. /**
  44518. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44519. * This helps adding a mirror texture on the ground.
  44520. */
  44521. reflectionFresnel: boolean;
  44522. protected _reflectionFalloffDistance: number;
  44523. /**
  44524. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44525. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44526. */
  44527. reflectionFalloffDistance: number;
  44528. protected _reflectionAmount: number;
  44529. /**
  44530. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44531. */
  44532. reflectionAmount: number;
  44533. protected _reflectionReflectance0: number;
  44534. /**
  44535. * This specifies the weight of the reflection at grazing angle.
  44536. */
  44537. reflectionReflectance0: number;
  44538. protected _reflectionReflectance90: number;
  44539. /**
  44540. * This specifies the weight of the reflection at a perpendicular point of view.
  44541. */
  44542. reflectionReflectance90: number;
  44543. /**
  44544. * Sets the reflection reflectance fresnel values according to the default standard
  44545. * empirically know to work well :-)
  44546. */
  44547. reflectionStandardFresnelWeight: number;
  44548. protected _useRGBColor: boolean;
  44549. /**
  44550. * Helps to directly use the maps channels instead of their level.
  44551. */
  44552. useRGBColor: boolean;
  44553. protected _enableNoise: boolean;
  44554. /**
  44555. * This helps reducing the banding effect that could occur on the background.
  44556. */
  44557. enableNoise: boolean;
  44558. /**
  44559. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44560. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44561. * Recommended to be keep at 1.0 except for special cases.
  44562. */
  44563. fovMultiplier: number;
  44564. private _fovMultiplier;
  44565. /**
  44566. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44567. */
  44568. useEquirectangularFOV: boolean;
  44569. private _maxSimultaneousLights;
  44570. /**
  44571. * Number of Simultaneous lights allowed on the material.
  44572. */
  44573. maxSimultaneousLights: int;
  44574. /**
  44575. * Default configuration related to image processing available in the Background Material.
  44576. */
  44577. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44578. /**
  44579. * Keep track of the image processing observer to allow dispose and replace.
  44580. */
  44581. private _imageProcessingObserver;
  44582. /**
  44583. * Attaches a new image processing configuration to the PBR Material.
  44584. * @param configuration (if null the scene configuration will be use)
  44585. */
  44586. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44587. /**
  44588. * Gets the image processing configuration used either in this material.
  44589. */
  44590. /**
  44591. * Sets the Default image processing configuration used either in the this material.
  44592. *
  44593. * If sets to null, the scene one is in use.
  44594. */
  44595. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44596. /**
  44597. * Gets wether the color curves effect is enabled.
  44598. */
  44599. /**
  44600. * Sets wether the color curves effect is enabled.
  44601. */
  44602. cameraColorCurvesEnabled: boolean;
  44603. /**
  44604. * Gets wether the color grading effect is enabled.
  44605. */
  44606. /**
  44607. * Gets wether the color grading effect is enabled.
  44608. */
  44609. cameraColorGradingEnabled: boolean;
  44610. /**
  44611. * Gets wether tonemapping is enabled or not.
  44612. */
  44613. /**
  44614. * Sets wether tonemapping is enabled or not
  44615. */
  44616. cameraToneMappingEnabled: boolean;
  44617. /**
  44618. * The camera exposure used on this material.
  44619. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44620. * This corresponds to a photographic exposure.
  44621. */
  44622. /**
  44623. * The camera exposure used on this material.
  44624. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44625. * This corresponds to a photographic exposure.
  44626. */
  44627. cameraExposure: float;
  44628. /**
  44629. * Gets The camera contrast used on this material.
  44630. */
  44631. /**
  44632. * Sets The camera contrast used on this material.
  44633. */
  44634. cameraContrast: float;
  44635. /**
  44636. * Gets the Color Grading 2D Lookup Texture.
  44637. */
  44638. /**
  44639. * Sets the Color Grading 2D Lookup Texture.
  44640. */
  44641. cameraColorGradingTexture: Nullable<BaseTexture>;
  44642. /**
  44643. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44644. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44645. * 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;
  44646. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44647. */
  44648. /**
  44649. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44650. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44651. * 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;
  44652. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44653. */
  44654. cameraColorCurves: Nullable<ColorCurves>;
  44655. /**
  44656. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44657. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44658. */
  44659. switchToBGR: boolean;
  44660. private _renderTargets;
  44661. private _reflectionControls;
  44662. private _white;
  44663. private _primaryShadowColor;
  44664. private _primaryHighlightColor;
  44665. /**
  44666. * Instantiates a Background Material in the given scene
  44667. * @param name The friendly name of the material
  44668. * @param scene The scene to add the material to
  44669. */
  44670. constructor(name: string, scene: Scene);
  44671. /**
  44672. * Gets a boolean indicating that current material needs to register RTT
  44673. */
  44674. readonly hasRenderTargetTextures: boolean;
  44675. /**
  44676. * The entire material has been created in order to prevent overdraw.
  44677. * @returns false
  44678. */
  44679. needAlphaTesting(): boolean;
  44680. /**
  44681. * The entire material has been created in order to prevent overdraw.
  44682. * @returns true if blending is enable
  44683. */
  44684. needAlphaBlending(): boolean;
  44685. /**
  44686. * Checks wether the material is ready to be rendered for a given mesh.
  44687. * @param mesh The mesh to render
  44688. * @param subMesh The submesh to check against
  44689. * @param useInstances Specify wether or not the material is used with instances
  44690. * @returns true if all the dependencies are ready (Textures, Effects...)
  44691. */
  44692. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44693. /**
  44694. * Compute the primary color according to the chosen perceptual color.
  44695. */
  44696. private _computePrimaryColorFromPerceptualColor;
  44697. /**
  44698. * Compute the highlights and shadow colors according to their chosen levels.
  44699. */
  44700. private _computePrimaryColors;
  44701. /**
  44702. * Build the uniform buffer used in the material.
  44703. */
  44704. buildUniformLayout(): void;
  44705. /**
  44706. * Unbind the material.
  44707. */
  44708. unbind(): void;
  44709. /**
  44710. * Bind only the world matrix to the material.
  44711. * @param world The world matrix to bind.
  44712. */
  44713. bindOnlyWorldMatrix(world: Matrix): void;
  44714. /**
  44715. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44716. * @param world The world matrix to bind.
  44717. * @param subMesh The submesh to bind for.
  44718. */
  44719. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44720. /**
  44721. * Checks to see if a texture is used in the material.
  44722. * @param texture - Base texture to use.
  44723. * @returns - Boolean specifying if a texture is used in the material.
  44724. */
  44725. hasTexture(texture: BaseTexture): boolean;
  44726. /**
  44727. * Dispose the material.
  44728. * @param forceDisposeEffect Force disposal of the associated effect.
  44729. * @param forceDisposeTextures Force disposal of the associated textures.
  44730. */
  44731. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44732. /**
  44733. * Clones the material.
  44734. * @param name The cloned name.
  44735. * @returns The cloned material.
  44736. */
  44737. clone(name: string): BackgroundMaterial;
  44738. /**
  44739. * Serializes the current material to its JSON representation.
  44740. * @returns The JSON representation.
  44741. */
  44742. serialize(): any;
  44743. /**
  44744. * Gets the class name of the material
  44745. * @returns "BackgroundMaterial"
  44746. */
  44747. getClassName(): string;
  44748. /**
  44749. * Parse a JSON input to create back a background material.
  44750. * @param source The JSON data to parse
  44751. * @param scene The scene to create the parsed material in
  44752. * @param rootUrl The root url of the assets the material depends upon
  44753. * @returns the instantiated BackgroundMaterial.
  44754. */
  44755. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44756. }
  44757. }
  44758. declare module BABYLON {
  44759. /**
  44760. * Represents the different options available during the creation of
  44761. * a Environment helper.
  44762. *
  44763. * This can control the default ground, skybox and image processing setup of your scene.
  44764. */
  44765. export interface IEnvironmentHelperOptions {
  44766. /**
  44767. * Specifies wether or not to create a ground.
  44768. * True by default.
  44769. */
  44770. createGround: boolean;
  44771. /**
  44772. * Specifies the ground size.
  44773. * 15 by default.
  44774. */
  44775. groundSize: number;
  44776. /**
  44777. * The texture used on the ground for the main color.
  44778. * Comes from the BabylonJS CDN by default.
  44779. *
  44780. * Remarks: Can be either a texture or a url.
  44781. */
  44782. groundTexture: string | BaseTexture;
  44783. /**
  44784. * The color mixed in the ground texture by default.
  44785. * BabylonJS clearColor by default.
  44786. */
  44787. groundColor: Color3;
  44788. /**
  44789. * Specifies the ground opacity.
  44790. * 1 by default.
  44791. */
  44792. groundOpacity: number;
  44793. /**
  44794. * Enables the ground to receive shadows.
  44795. * True by default.
  44796. */
  44797. enableGroundShadow: boolean;
  44798. /**
  44799. * Helps preventing the shadow to be fully black on the ground.
  44800. * 0.5 by default.
  44801. */
  44802. groundShadowLevel: number;
  44803. /**
  44804. * Creates a mirror texture attach to the ground.
  44805. * false by default.
  44806. */
  44807. enableGroundMirror: boolean;
  44808. /**
  44809. * Specifies the ground mirror size ratio.
  44810. * 0.3 by default as the default kernel is 64.
  44811. */
  44812. groundMirrorSizeRatio: number;
  44813. /**
  44814. * Specifies the ground mirror blur kernel size.
  44815. * 64 by default.
  44816. */
  44817. groundMirrorBlurKernel: number;
  44818. /**
  44819. * Specifies the ground mirror visibility amount.
  44820. * 1 by default
  44821. */
  44822. groundMirrorAmount: number;
  44823. /**
  44824. * Specifies the ground mirror reflectance weight.
  44825. * This uses the standard weight of the background material to setup the fresnel effect
  44826. * of the mirror.
  44827. * 1 by default.
  44828. */
  44829. groundMirrorFresnelWeight: number;
  44830. /**
  44831. * Specifies the ground mirror Falloff distance.
  44832. * This can helps reducing the size of the reflection.
  44833. * 0 by Default.
  44834. */
  44835. groundMirrorFallOffDistance: number;
  44836. /**
  44837. * Specifies the ground mirror texture type.
  44838. * Unsigned Int by Default.
  44839. */
  44840. groundMirrorTextureType: number;
  44841. /**
  44842. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44843. * the shown objects.
  44844. */
  44845. groundYBias: number;
  44846. /**
  44847. * Specifies wether or not to create a skybox.
  44848. * True by default.
  44849. */
  44850. createSkybox: boolean;
  44851. /**
  44852. * Specifies the skybox size.
  44853. * 20 by default.
  44854. */
  44855. skyboxSize: number;
  44856. /**
  44857. * The texture used on the skybox for the main color.
  44858. * Comes from the BabylonJS CDN by default.
  44859. *
  44860. * Remarks: Can be either a texture or a url.
  44861. */
  44862. skyboxTexture: string | BaseTexture;
  44863. /**
  44864. * The color mixed in the skybox texture by default.
  44865. * BabylonJS clearColor by default.
  44866. */
  44867. skyboxColor: Color3;
  44868. /**
  44869. * The background rotation around the Y axis of the scene.
  44870. * This helps aligning the key lights of your scene with the background.
  44871. * 0 by default.
  44872. */
  44873. backgroundYRotation: number;
  44874. /**
  44875. * Compute automatically the size of the elements to best fit with the scene.
  44876. */
  44877. sizeAuto: boolean;
  44878. /**
  44879. * Default position of the rootMesh if autoSize is not true.
  44880. */
  44881. rootPosition: Vector3;
  44882. /**
  44883. * Sets up the image processing in the scene.
  44884. * true by default.
  44885. */
  44886. setupImageProcessing: boolean;
  44887. /**
  44888. * The texture used as your environment texture in the scene.
  44889. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44890. *
  44891. * Remarks: Can be either a texture or a url.
  44892. */
  44893. environmentTexture: string | BaseTexture;
  44894. /**
  44895. * The value of the exposure to apply to the scene.
  44896. * 0.6 by default if setupImageProcessing is true.
  44897. */
  44898. cameraExposure: number;
  44899. /**
  44900. * The value of the contrast to apply to the scene.
  44901. * 1.6 by default if setupImageProcessing is true.
  44902. */
  44903. cameraContrast: number;
  44904. /**
  44905. * Specifies wether or not tonemapping should be enabled in the scene.
  44906. * true by default if setupImageProcessing is true.
  44907. */
  44908. toneMappingEnabled: boolean;
  44909. }
  44910. /**
  44911. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44912. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44913. * It also helps with the default setup of your imageProcessing configuration.
  44914. */
  44915. export class EnvironmentHelper {
  44916. /**
  44917. * Default ground texture URL.
  44918. */
  44919. private static _groundTextureCDNUrl;
  44920. /**
  44921. * Default skybox texture URL.
  44922. */
  44923. private static _skyboxTextureCDNUrl;
  44924. /**
  44925. * Default environment texture URL.
  44926. */
  44927. private static _environmentTextureCDNUrl;
  44928. /**
  44929. * Creates the default options for the helper.
  44930. */
  44931. private static _getDefaultOptions;
  44932. private _rootMesh;
  44933. /**
  44934. * Gets the root mesh created by the helper.
  44935. */
  44936. readonly rootMesh: Mesh;
  44937. private _skybox;
  44938. /**
  44939. * Gets the skybox created by the helper.
  44940. */
  44941. readonly skybox: Nullable<Mesh>;
  44942. private _skyboxTexture;
  44943. /**
  44944. * Gets the skybox texture created by the helper.
  44945. */
  44946. readonly skyboxTexture: Nullable<BaseTexture>;
  44947. private _skyboxMaterial;
  44948. /**
  44949. * Gets the skybox material created by the helper.
  44950. */
  44951. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44952. private _ground;
  44953. /**
  44954. * Gets the ground mesh created by the helper.
  44955. */
  44956. readonly ground: Nullable<Mesh>;
  44957. private _groundTexture;
  44958. /**
  44959. * Gets the ground texture created by the helper.
  44960. */
  44961. readonly groundTexture: Nullable<BaseTexture>;
  44962. private _groundMirror;
  44963. /**
  44964. * Gets the ground mirror created by the helper.
  44965. */
  44966. readonly groundMirror: Nullable<MirrorTexture>;
  44967. /**
  44968. * Gets the ground mirror render list to helps pushing the meshes
  44969. * you wish in the ground reflection.
  44970. */
  44971. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44972. private _groundMaterial;
  44973. /**
  44974. * Gets the ground material created by the helper.
  44975. */
  44976. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44977. /**
  44978. * Stores the creation options.
  44979. */
  44980. private readonly _scene;
  44981. private _options;
  44982. /**
  44983. * This observable will be notified with any error during the creation of the environment,
  44984. * mainly texture creation errors.
  44985. */
  44986. onErrorObservable: Observable<{
  44987. message?: string;
  44988. exception?: any;
  44989. }>;
  44990. /**
  44991. * constructor
  44992. * @param options Defines the options we want to customize the helper
  44993. * @param scene The scene to add the material to
  44994. */
  44995. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44996. /**
  44997. * Updates the background according to the new options
  44998. * @param options
  44999. */
  45000. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45001. /**
  45002. * Sets the primary color of all the available elements.
  45003. * @param color the main color to affect to the ground and the background
  45004. */
  45005. setMainColor(color: Color3): void;
  45006. /**
  45007. * Setup the image processing according to the specified options.
  45008. */
  45009. private _setupImageProcessing;
  45010. /**
  45011. * Setup the environment texture according to the specified options.
  45012. */
  45013. private _setupEnvironmentTexture;
  45014. /**
  45015. * Setup the background according to the specified options.
  45016. */
  45017. private _setupBackground;
  45018. /**
  45019. * Get the scene sizes according to the setup.
  45020. */
  45021. private _getSceneSize;
  45022. /**
  45023. * Setup the ground according to the specified options.
  45024. */
  45025. private _setupGround;
  45026. /**
  45027. * Setup the ground material according to the specified options.
  45028. */
  45029. private _setupGroundMaterial;
  45030. /**
  45031. * Setup the ground diffuse texture according to the specified options.
  45032. */
  45033. private _setupGroundDiffuseTexture;
  45034. /**
  45035. * Setup the ground mirror texture according to the specified options.
  45036. */
  45037. private _setupGroundMirrorTexture;
  45038. /**
  45039. * Setup the ground to receive the mirror texture.
  45040. */
  45041. private _setupMirrorInGroundMaterial;
  45042. /**
  45043. * Setup the skybox according to the specified options.
  45044. */
  45045. private _setupSkybox;
  45046. /**
  45047. * Setup the skybox material according to the specified options.
  45048. */
  45049. private _setupSkyboxMaterial;
  45050. /**
  45051. * Setup the skybox reflection texture according to the specified options.
  45052. */
  45053. private _setupSkyboxReflectionTexture;
  45054. private _errorHandler;
  45055. /**
  45056. * Dispose all the elements created by the Helper.
  45057. */
  45058. dispose(): void;
  45059. }
  45060. }
  45061. declare module BABYLON {
  45062. /**
  45063. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45064. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45065. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45066. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45067. */
  45068. export class PhotoDome extends TransformNode {
  45069. /**
  45070. * Define the image as a Monoscopic panoramic 360 image.
  45071. */
  45072. static readonly MODE_MONOSCOPIC: number;
  45073. /**
  45074. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45075. */
  45076. static readonly MODE_TOPBOTTOM: number;
  45077. /**
  45078. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45079. */
  45080. static readonly MODE_SIDEBYSIDE: number;
  45081. private _useDirectMapping;
  45082. /**
  45083. * The texture being displayed on the sphere
  45084. */
  45085. protected _photoTexture: Texture;
  45086. /**
  45087. * Gets or sets the texture being displayed on the sphere
  45088. */
  45089. photoTexture: Texture;
  45090. /**
  45091. * Observable raised when an error occured while loading the 360 image
  45092. */
  45093. onLoadErrorObservable: Observable<string>;
  45094. /**
  45095. * The skybox material
  45096. */
  45097. protected _material: BackgroundMaterial;
  45098. /**
  45099. * The surface used for the skybox
  45100. */
  45101. protected _mesh: Mesh;
  45102. /**
  45103. * Gets the mesh used for the skybox.
  45104. */
  45105. readonly mesh: Mesh;
  45106. /**
  45107. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45108. * Also see the options.resolution property.
  45109. */
  45110. fovMultiplier: number;
  45111. private _imageMode;
  45112. /**
  45113. * Gets or set the current video mode for the video. It can be:
  45114. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45115. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45116. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45117. */
  45118. imageMode: number;
  45119. /**
  45120. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45121. * @param name Element's name, child elements will append suffixes for their own names.
  45122. * @param urlsOfPhoto defines the url of the photo to display
  45123. * @param options defines an object containing optional or exposed sub element properties
  45124. * @param onError defines a callback called when an error occured while loading the texture
  45125. */
  45126. constructor(name: string, urlOfPhoto: string, options: {
  45127. resolution?: number;
  45128. size?: number;
  45129. useDirectMapping?: boolean;
  45130. faceForward?: boolean;
  45131. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45132. private _onBeforeCameraRenderObserver;
  45133. private _changeImageMode;
  45134. /**
  45135. * Releases resources associated with this node.
  45136. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45137. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45138. */
  45139. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45140. }
  45141. }
  45142. declare module BABYLON {
  45143. /**
  45144. * Class used to host RGBD texture specific utilities
  45145. */
  45146. export class RGBDTextureTools {
  45147. /**
  45148. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45149. * @param texture the texture to expand.
  45150. */
  45151. static ExpandRGBDTexture(texture: Texture): void;
  45152. }
  45153. }
  45154. declare module BABYLON {
  45155. /**
  45156. * Class used to host texture specific utilities
  45157. */
  45158. export class BRDFTextureTools {
  45159. /**
  45160. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45161. * @param scene defines the hosting scene
  45162. * @returns the environment BRDF texture
  45163. */
  45164. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45165. private static _environmentBRDFBase64Texture;
  45166. }
  45167. }
  45168. declare module BABYLON {
  45169. /**
  45170. * @hidden
  45171. */
  45172. export interface IMaterialClearCoatDefines {
  45173. CLEARCOAT: boolean;
  45174. CLEARCOAT_DEFAULTIOR: boolean;
  45175. CLEARCOAT_TEXTURE: boolean;
  45176. CLEARCOAT_TEXTUREDIRECTUV: number;
  45177. CLEARCOAT_BUMP: boolean;
  45178. CLEARCOAT_BUMPDIRECTUV: number;
  45179. CLEARCOAT_TINT: boolean;
  45180. CLEARCOAT_TINT_TEXTURE: boolean;
  45181. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45182. /** @hidden */ private _areTexturesDirty: boolean;
  45183. }
  45184. /**
  45185. * Define the code related to the clear coat parameters of the pbr material.
  45186. */
  45187. export class PBRClearCoatConfiguration {
  45188. /**
  45189. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45190. * The default fits with a polyurethane material.
  45191. */
  45192. private static readonly _DefaultIndexOfRefraction;
  45193. private _isEnabled;
  45194. /**
  45195. * Defines if the clear coat is enabled in the material.
  45196. */
  45197. isEnabled: boolean;
  45198. /**
  45199. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45200. */
  45201. intensity: number;
  45202. /**
  45203. * Defines the clear coat layer roughness.
  45204. */
  45205. roughness: number;
  45206. private _indexOfRefraction;
  45207. /**
  45208. * Defines the index of refraction of the clear coat.
  45209. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45210. * The default fits with a polyurethane material.
  45211. * Changing the default value is more performance intensive.
  45212. */
  45213. indexOfRefraction: number;
  45214. private _texture;
  45215. /**
  45216. * Stores the clear coat values in a texture.
  45217. */
  45218. texture: Nullable<BaseTexture>;
  45219. private _bumpTexture;
  45220. /**
  45221. * Define the clear coat specific bump texture.
  45222. */
  45223. bumpTexture: Nullable<BaseTexture>;
  45224. private _isTintEnabled;
  45225. /**
  45226. * Defines if the clear coat tint is enabled in the material.
  45227. */
  45228. isTintEnabled: boolean;
  45229. /**
  45230. * Defines the clear coat tint of the material.
  45231. * This is only use if tint is enabled
  45232. */
  45233. tintColor: Color3;
  45234. /**
  45235. * Defines the distance at which the tint color should be found in the
  45236. * clear coat media.
  45237. * This is only use if tint is enabled
  45238. */
  45239. tintColorAtDistance: number;
  45240. /**
  45241. * Defines the clear coat layer thickness.
  45242. * This is only use if tint is enabled
  45243. */
  45244. tintThickness: number;
  45245. private _tintTexture;
  45246. /**
  45247. * Stores the clear tint values in a texture.
  45248. * rgb is tint
  45249. * a is a thickness factor
  45250. */
  45251. tintTexture: Nullable<BaseTexture>;
  45252. /** @hidden */
  45253. private _internalMarkAllSubMeshesAsTexturesDirty;
  45254. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45255. /**
  45256. * Instantiate a new istance of clear coat configuration.
  45257. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45258. */
  45259. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45260. /**
  45261. * Gets wehter the submesh is ready to be used or not.
  45262. * @param defines the list of "defines" to update.
  45263. * @param scene defines the scene the material belongs to.
  45264. * @param engine defines the engine the material belongs to.
  45265. * @param disableBumpMap defines wether the material disables bump or not.
  45266. * @returns - boolean indicating that the submesh is ready or not.
  45267. */
  45268. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45269. /**
  45270. * Checks to see if a texture is used in the material.
  45271. * @param defines the list of "defines" to update.
  45272. * @param scene defines the scene to the material belongs to.
  45273. */
  45274. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45275. /**
  45276. * Binds the material data.
  45277. * @param uniformBuffer defines the Uniform buffer to fill in.
  45278. * @param scene defines the scene the material belongs to.
  45279. * @param engine defines the engine the material belongs to.
  45280. * @param disableBumpMap defines wether the material disables bump or not.
  45281. * @param isFrozen defines wether the material is frozen or not.
  45282. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45283. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45284. */
  45285. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45286. /**
  45287. * Checks to see if a texture is used in the material.
  45288. * @param texture - Base texture to use.
  45289. * @returns - Boolean specifying if a texture is used in the material.
  45290. */
  45291. hasTexture(texture: BaseTexture): boolean;
  45292. /**
  45293. * Returns an array of the actively used textures.
  45294. * @param activeTextures Array of BaseTextures
  45295. */
  45296. getActiveTextures(activeTextures: BaseTexture[]): void;
  45297. /**
  45298. * Returns the animatable textures.
  45299. * @param animatables Array of animatable textures.
  45300. */
  45301. getAnimatables(animatables: IAnimatable[]): void;
  45302. /**
  45303. * Disposes the resources of the material.
  45304. * @param forceDisposeTextures - Forces the disposal of all textures.
  45305. */
  45306. dispose(forceDisposeTextures?: boolean): void;
  45307. /**
  45308. * Get the current class name of the texture useful for serialization or dynamic coding.
  45309. * @returns "PBRClearCoatConfiguration"
  45310. */
  45311. getClassName(): string;
  45312. /**
  45313. * Add fallbacks to the effect fallbacks list.
  45314. * @param defines defines the Base texture to use.
  45315. * @param fallbacks defines the current fallback list.
  45316. * @param currentRank defines the current fallback rank.
  45317. * @returns the new fallback rank.
  45318. */
  45319. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45320. /**
  45321. * Add the required uniforms to the current list.
  45322. * @param uniforms defines the current uniform list.
  45323. */
  45324. static AddUniforms(uniforms: string[]): void;
  45325. /**
  45326. * Add the required samplers to the current list.
  45327. * @param samplers defines the current sampler list.
  45328. */
  45329. static AddSamplers(samplers: string[]): void;
  45330. /**
  45331. * Add the required uniforms to the current buffer.
  45332. * @param uniformBuffer defines the current uniform buffer.
  45333. */
  45334. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45335. /**
  45336. * Makes a duplicate of the current configuration into another one.
  45337. * @param clearCoatConfiguration define the config where to copy the info
  45338. */
  45339. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45340. /**
  45341. * Serializes this clear coat configuration.
  45342. * @returns - An object with the serialized config.
  45343. */
  45344. serialize(): any;
  45345. /**
  45346. * Parses a anisotropy Configuration from a serialized object.
  45347. * @param source - Serialized object.
  45348. * @param scene Defines the scene we are parsing for
  45349. * @param rootUrl Defines the rootUrl to load from
  45350. */
  45351. parse(source: any, scene: Scene, rootUrl: string): void;
  45352. }
  45353. }
  45354. declare module BABYLON {
  45355. /**
  45356. * @hidden
  45357. */
  45358. export interface IMaterialAnisotropicDefines {
  45359. ANISOTROPIC: boolean;
  45360. ANISOTROPIC_TEXTURE: boolean;
  45361. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45362. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  45363. }
  45364. /**
  45365. * Define the code related to the anisotropic parameters of the pbr material.
  45366. */
  45367. export class PBRAnisotropicConfiguration {
  45368. private _isEnabled;
  45369. /**
  45370. * Defines if the anisotropy is enabled in the material.
  45371. */
  45372. isEnabled: boolean;
  45373. /**
  45374. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45375. */
  45376. intensity: number;
  45377. /**
  45378. * Defines if the effect is along the tangents, bitangents or in between.
  45379. * By default, the effect is "strectching" the highlights along the tangents.
  45380. */
  45381. direction: Vector2;
  45382. private _texture;
  45383. /**
  45384. * Stores the anisotropy values in a texture.
  45385. * rg is direction (like normal from -1 to 1)
  45386. * b is a intensity
  45387. */
  45388. texture: Nullable<BaseTexture>;
  45389. /** @hidden */
  45390. private _internalMarkAllSubMeshesAsTexturesDirty;
  45391. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45392. /**
  45393. * Instantiate a new istance of anisotropy configuration.
  45394. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45395. */
  45396. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45397. /**
  45398. * Specifies that the submesh is ready to be used.
  45399. * @param defines the list of "defines" to update.
  45400. * @param scene defines the scene the material belongs to.
  45401. * @returns - boolean indicating that the submesh is ready or not.
  45402. */
  45403. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45404. /**
  45405. * Checks to see if a texture is used in the material.
  45406. * @param defines the list of "defines" to update.
  45407. * @param mesh the mesh we are preparing the defines for.
  45408. * @param scene defines the scene the material belongs to.
  45409. */
  45410. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45411. /**
  45412. * Binds the material data.
  45413. * @param uniformBuffer defines the Uniform buffer to fill in.
  45414. * @param scene defines the scene the material belongs to.
  45415. * @param isFrozen defines wether the material is frozen or not.
  45416. */
  45417. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45418. /**
  45419. * Checks to see if a texture is used in the material.
  45420. * @param texture - Base texture to use.
  45421. * @returns - Boolean specifying if a texture is used in the material.
  45422. */
  45423. hasTexture(texture: BaseTexture): boolean;
  45424. /**
  45425. * Returns an array of the actively used textures.
  45426. * @param activeTextures Array of BaseTextures
  45427. */
  45428. getActiveTextures(activeTextures: BaseTexture[]): void;
  45429. /**
  45430. * Returns the animatable textures.
  45431. * @param animatables Array of animatable textures.
  45432. */
  45433. getAnimatables(animatables: IAnimatable[]): void;
  45434. /**
  45435. * Disposes the resources of the material.
  45436. * @param forceDisposeTextures - Forces the disposal of all textures.
  45437. */
  45438. dispose(forceDisposeTextures?: boolean): void;
  45439. /**
  45440. * Get the current class name of the texture useful for serialization or dynamic coding.
  45441. * @returns "PBRAnisotropicConfiguration"
  45442. */
  45443. getClassName(): string;
  45444. /**
  45445. * Add fallbacks to the effect fallbacks list.
  45446. * @param defines defines the Base texture to use.
  45447. * @param fallbacks defines the current fallback list.
  45448. * @param currentRank defines the current fallback rank.
  45449. * @returns the new fallback rank.
  45450. */
  45451. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45452. /**
  45453. * Add the required uniforms to the current list.
  45454. * @param uniforms defines the current uniform list.
  45455. */
  45456. static AddUniforms(uniforms: string[]): void;
  45457. /**
  45458. * Add the required uniforms to the current buffer.
  45459. * @param uniformBuffer defines the current uniform buffer.
  45460. */
  45461. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45462. /**
  45463. * Add the required samplers to the current list.
  45464. * @param samplers defines the current sampler list.
  45465. */
  45466. static AddSamplers(samplers: string[]): void;
  45467. /**
  45468. * Makes a duplicate of the current configuration into another one.
  45469. * @param anisotropicConfiguration define the config where to copy the info
  45470. */
  45471. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45472. /**
  45473. * Serializes this anisotropy configuration.
  45474. * @returns - An object with the serialized config.
  45475. */
  45476. serialize(): any;
  45477. /**
  45478. * Parses a anisotropy Configuration from a serialized object.
  45479. * @param source - Serialized object.
  45480. * @param scene Defines the scene we are parsing for
  45481. * @param rootUrl Defines the rootUrl to load from
  45482. */
  45483. parse(source: any, scene: Scene, rootUrl: string): void;
  45484. }
  45485. }
  45486. declare module BABYLON {
  45487. /**
  45488. * @hidden
  45489. */
  45490. export interface IMaterialBRDFDefines {
  45491. BRDF_V_HEIGHT_CORRELATED: boolean;
  45492. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45493. SPHERICAL_HARMONICS: boolean;
  45494. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  45495. /** @hidden */ private _areMiscDirty: boolean;
  45496. }
  45497. /**
  45498. * Define the code related to the BRDF parameters of the pbr material.
  45499. */
  45500. export class PBRBRDFConfiguration {
  45501. /**
  45502. * Default value used for the energy conservation.
  45503. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45504. */
  45505. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45506. /**
  45507. * Default value used for the Smith Visibility Height Correlated mode.
  45508. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45509. */
  45510. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45511. /**
  45512. * Default value used for the IBL diffuse part.
  45513. * This can help switching back to the polynomials mode globally which is a tiny bit
  45514. * less GPU intensive at the drawback of a lower quality.
  45515. */
  45516. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45517. /**
  45518. * Default value used for activating energy conservation for the specular workflow.
  45519. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  45520. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  45521. */
  45522. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  45523. private _useEnergyConservation;
  45524. /**
  45525. * Defines if the material uses energy conservation.
  45526. */
  45527. useEnergyConservation: boolean;
  45528. private _useSmithVisibilityHeightCorrelated;
  45529. /**
  45530. * LEGACY Mode set to false
  45531. * Defines if the material uses height smith correlated visibility term.
  45532. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45533. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45534. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45535. * Not relying on height correlated will also disable energy conservation.
  45536. */
  45537. useSmithVisibilityHeightCorrelated: boolean;
  45538. private _useSphericalHarmonics;
  45539. /**
  45540. * LEGACY Mode set to false
  45541. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45542. * diffuse part of the IBL.
  45543. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45544. * to the ground truth.
  45545. */
  45546. useSphericalHarmonics: boolean;
  45547. private _useSpecularGlossinessInputEnergyConservation;
  45548. /**
  45549. * Defines if the material uses energy conservation, when the specular workflow is active.
  45550. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  45551. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  45552. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  45553. */
  45554. useSpecularGlossinessInputEnergyConservation: boolean;
  45555. /** @hidden */
  45556. private _internalMarkAllSubMeshesAsMiscDirty;
  45557. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  45558. /**
  45559. * Instantiate a new istance of clear coat configuration.
  45560. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45561. */
  45562. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45563. /**
  45564. * Checks to see if a texture is used in the material.
  45565. * @param defines the list of "defines" to update.
  45566. */
  45567. prepareDefines(defines: IMaterialBRDFDefines): void;
  45568. /**
  45569. * Get the current class name of the texture useful for serialization or dynamic coding.
  45570. * @returns "PBRClearCoatConfiguration"
  45571. */
  45572. getClassName(): string;
  45573. /**
  45574. * Makes a duplicate of the current configuration into another one.
  45575. * @param brdfConfiguration define the config where to copy the info
  45576. */
  45577. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45578. /**
  45579. * Serializes this BRDF configuration.
  45580. * @returns - An object with the serialized config.
  45581. */
  45582. serialize(): any;
  45583. /**
  45584. * Parses a anisotropy Configuration from a serialized object.
  45585. * @param source - Serialized object.
  45586. * @param scene Defines the scene we are parsing for
  45587. * @param rootUrl Defines the rootUrl to load from
  45588. */
  45589. parse(source: any, scene: Scene, rootUrl: string): void;
  45590. }
  45591. }
  45592. declare module BABYLON {
  45593. /**
  45594. * @hidden
  45595. */
  45596. export interface IMaterialSheenDefines {
  45597. SHEEN: boolean;
  45598. SHEEN_TEXTURE: boolean;
  45599. SHEEN_TEXTUREDIRECTUV: number;
  45600. SHEEN_LINKWITHALBEDO: boolean;
  45601. /** @hidden */ private _areTexturesDirty: boolean;
  45602. }
  45603. /**
  45604. * Define the code related to the Sheen parameters of the pbr material.
  45605. */
  45606. export class PBRSheenConfiguration {
  45607. private _isEnabled;
  45608. /**
  45609. * Defines if the material uses sheen.
  45610. */
  45611. isEnabled: boolean;
  45612. private _linkSheenWithAlbedo;
  45613. /**
  45614. * Defines if the sheen is linked to the sheen color.
  45615. */
  45616. linkSheenWithAlbedo: boolean;
  45617. /**
  45618. * Defines the sheen intensity.
  45619. */
  45620. intensity: number;
  45621. /**
  45622. * Defines the sheen color.
  45623. */
  45624. color: Color3;
  45625. private _texture;
  45626. /**
  45627. * Stores the sheen tint values in a texture.
  45628. * rgb is tint
  45629. * a is a intensity
  45630. */
  45631. texture: Nullable<BaseTexture>;
  45632. /** @hidden */
  45633. private _internalMarkAllSubMeshesAsTexturesDirty;
  45634. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45635. /**
  45636. * Instantiate a new istance of clear coat configuration.
  45637. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45638. */
  45639. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45640. /**
  45641. * Specifies that the submesh is ready to be used.
  45642. * @param defines the list of "defines" to update.
  45643. * @param scene defines the scene the material belongs to.
  45644. * @returns - boolean indicating that the submesh is ready or not.
  45645. */
  45646. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45647. /**
  45648. * Checks to see if a texture is used in the material.
  45649. * @param defines the list of "defines" to update.
  45650. * @param scene defines the scene the material belongs to.
  45651. */
  45652. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45653. /**
  45654. * Binds the material data.
  45655. * @param uniformBuffer defines the Uniform buffer to fill in.
  45656. * @param scene defines the scene the material belongs to.
  45657. * @param isFrozen defines wether the material is frozen or not.
  45658. */
  45659. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45660. /**
  45661. * Checks to see if a texture is used in the material.
  45662. * @param texture - Base texture to use.
  45663. * @returns - Boolean specifying if a texture is used in the material.
  45664. */
  45665. hasTexture(texture: BaseTexture): boolean;
  45666. /**
  45667. * Returns an array of the actively used textures.
  45668. * @param activeTextures Array of BaseTextures
  45669. */
  45670. getActiveTextures(activeTextures: BaseTexture[]): void;
  45671. /**
  45672. * Returns the animatable textures.
  45673. * @param animatables Array of animatable textures.
  45674. */
  45675. getAnimatables(animatables: IAnimatable[]): void;
  45676. /**
  45677. * Disposes the resources of the material.
  45678. * @param forceDisposeTextures - Forces the disposal of all textures.
  45679. */
  45680. dispose(forceDisposeTextures?: boolean): void;
  45681. /**
  45682. * Get the current class name of the texture useful for serialization or dynamic coding.
  45683. * @returns "PBRSheenConfiguration"
  45684. */
  45685. getClassName(): string;
  45686. /**
  45687. * Add fallbacks to the effect fallbacks list.
  45688. * @param defines defines the Base texture to use.
  45689. * @param fallbacks defines the current fallback list.
  45690. * @param currentRank defines the current fallback rank.
  45691. * @returns the new fallback rank.
  45692. */
  45693. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45694. /**
  45695. * Add the required uniforms to the current list.
  45696. * @param uniforms defines the current uniform list.
  45697. */
  45698. static AddUniforms(uniforms: string[]): void;
  45699. /**
  45700. * Add the required uniforms to the current buffer.
  45701. * @param uniformBuffer defines the current uniform buffer.
  45702. */
  45703. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45704. /**
  45705. * Add the required samplers to the current list.
  45706. * @param samplers defines the current sampler list.
  45707. */
  45708. static AddSamplers(samplers: string[]): void;
  45709. /**
  45710. * Makes a duplicate of the current configuration into another one.
  45711. * @param sheenConfiguration define the config where to copy the info
  45712. */
  45713. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45714. /**
  45715. * Serializes this BRDF configuration.
  45716. * @returns - An object with the serialized config.
  45717. */
  45718. serialize(): any;
  45719. /**
  45720. * Parses a anisotropy Configuration from a serialized object.
  45721. * @param source - Serialized object.
  45722. * @param scene Defines the scene we are parsing for
  45723. * @param rootUrl Defines the rootUrl to load from
  45724. */
  45725. parse(source: any, scene: Scene, rootUrl: string): void;
  45726. }
  45727. }
  45728. declare module BABYLON {
  45729. /**
  45730. * @hidden
  45731. */
  45732. export interface IMaterialSubSurfaceDefines {
  45733. SUBSURFACE: boolean;
  45734. SS_REFRACTION: boolean;
  45735. SS_TRANSLUCENCY: boolean;
  45736. SS_SCATERRING: boolean;
  45737. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45738. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45739. SS_REFRACTIONMAP_3D: boolean;
  45740. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45741. SS_LODINREFRACTIONALPHA: boolean;
  45742. SS_GAMMAREFRACTION: boolean;
  45743. SS_RGBDREFRACTION: boolean;
  45744. SS_LINEARSPECULARREFRACTION: boolean;
  45745. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45746. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45747. /** @hidden */ private _areTexturesDirty: boolean;
  45748. }
  45749. /**
  45750. * Define the code related to the sub surface parameters of the pbr material.
  45751. */
  45752. export class PBRSubSurfaceConfiguration {
  45753. private _isRefractionEnabled;
  45754. /**
  45755. * Defines if the refraction is enabled in the material.
  45756. */
  45757. isRefractionEnabled: boolean;
  45758. private _isTranslucencyEnabled;
  45759. /**
  45760. * Defines if the translucency is enabled in the material.
  45761. */
  45762. isTranslucencyEnabled: boolean;
  45763. private _isScatteringEnabled;
  45764. /**
  45765. * Defines the refraction intensity of the material.
  45766. * The refraction when enabled replaces the Diffuse part of the material.
  45767. * The intensity helps transitionning between diffuse and refraction.
  45768. */
  45769. refractionIntensity: number;
  45770. /**
  45771. * Defines the translucency intensity of the material.
  45772. * When translucency has been enabled, this defines how much of the "translucency"
  45773. * is addded to the diffuse part of the material.
  45774. */
  45775. translucencyIntensity: number;
  45776. /**
  45777. * Defines the scattering intensity of the material.
  45778. * When scattering has been enabled, this defines how much of the "scattered light"
  45779. * is addded to the diffuse part of the material.
  45780. */
  45781. scatteringIntensity: number;
  45782. private _thicknessTexture;
  45783. /**
  45784. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45785. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45786. * 0 would mean minimumThickness
  45787. * 1 would mean maximumThickness
  45788. * The other channels might be use as a mask to vary the different effects intensity.
  45789. */
  45790. thicknessTexture: Nullable<BaseTexture>;
  45791. private _refractionTexture;
  45792. /**
  45793. * Defines the texture to use for refraction.
  45794. */
  45795. refractionTexture: Nullable<BaseTexture>;
  45796. private _indexOfRefraction;
  45797. /**
  45798. * Defines the index of refraction used in the material.
  45799. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45800. */
  45801. indexOfRefraction: number;
  45802. private _invertRefractionY;
  45803. /**
  45804. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45805. */
  45806. invertRefractionY: boolean;
  45807. private _linkRefractionWithTransparency;
  45808. /**
  45809. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45810. * Materials half opaque for instance using refraction could benefit from this control.
  45811. */
  45812. linkRefractionWithTransparency: boolean;
  45813. /**
  45814. * Defines the minimum thickness stored in the thickness map.
  45815. * If no thickness map is defined, this value will be used to simulate thickness.
  45816. */
  45817. minimumThickness: number;
  45818. /**
  45819. * Defines the maximum thickness stored in the thickness map.
  45820. */
  45821. maximumThickness: number;
  45822. /**
  45823. * Defines the volume tint of the material.
  45824. * This is used for both translucency and scattering.
  45825. */
  45826. tintColor: Color3;
  45827. /**
  45828. * Defines the distance at which the tint color should be found in the media.
  45829. * This is used for refraction only.
  45830. */
  45831. tintColorAtDistance: number;
  45832. /**
  45833. * Defines how far each channel transmit through the media.
  45834. * It is defined as a color to simplify it selection.
  45835. */
  45836. diffusionDistance: Color3;
  45837. private _useMaskFromThicknessTexture;
  45838. /**
  45839. * Stores the intensity of the different subsurface effects in the thickness texture.
  45840. * * the green channel is the translucency intensity.
  45841. * * the blue channel is the scattering intensity.
  45842. * * the alpha channel is the refraction intensity.
  45843. */
  45844. useMaskFromThicknessTexture: boolean;
  45845. /** @hidden */
  45846. private _internalMarkAllSubMeshesAsTexturesDirty;
  45847. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45848. /**
  45849. * Instantiate a new istance of sub surface configuration.
  45850. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45851. */
  45852. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45853. /**
  45854. * Gets wehter the submesh is ready to be used or not.
  45855. * @param defines the list of "defines" to update.
  45856. * @param scene defines the scene the material belongs to.
  45857. * @returns - boolean indicating that the submesh is ready or not.
  45858. */
  45859. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45860. /**
  45861. * Checks to see if a texture is used in the material.
  45862. * @param defines the list of "defines" to update.
  45863. * @param scene defines the scene to the material belongs to.
  45864. */
  45865. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45866. /**
  45867. * Binds the material data.
  45868. * @param uniformBuffer defines the Uniform buffer to fill in.
  45869. * @param scene defines the scene the material belongs to.
  45870. * @param engine defines the engine the material belongs to.
  45871. * @param isFrozen defines wether the material is frozen or not.
  45872. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45873. */
  45874. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45875. /**
  45876. * Unbinds the material from the mesh.
  45877. * @param activeEffect defines the effect that should be unbound from.
  45878. * @returns true if unbound, otherwise false
  45879. */
  45880. unbind(activeEffect: Effect): boolean;
  45881. /**
  45882. * Returns the texture used for refraction or null if none is used.
  45883. * @param scene defines the scene the material belongs to.
  45884. * @returns - Refraction texture if present. If no refraction texture and refraction
  45885. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45886. */
  45887. private _getRefractionTexture;
  45888. /**
  45889. * Returns true if alpha blending should be disabled.
  45890. */
  45891. readonly disableAlphaBlending: boolean;
  45892. /**
  45893. * Fills the list of render target textures.
  45894. * @param renderTargets the list of render targets to update
  45895. */
  45896. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45897. /**
  45898. * Checks to see if a texture is used in the material.
  45899. * @param texture - Base texture to use.
  45900. * @returns - Boolean specifying if a texture is used in the material.
  45901. */
  45902. hasTexture(texture: BaseTexture): boolean;
  45903. /**
  45904. * Gets a boolean indicating that current material needs to register RTT
  45905. * @returns true if this uses a render target otherwise false.
  45906. */
  45907. hasRenderTargetTextures(): boolean;
  45908. /**
  45909. * Returns an array of the actively used textures.
  45910. * @param activeTextures Array of BaseTextures
  45911. */
  45912. getActiveTextures(activeTextures: BaseTexture[]): void;
  45913. /**
  45914. * Returns the animatable textures.
  45915. * @param animatables Array of animatable textures.
  45916. */
  45917. getAnimatables(animatables: IAnimatable[]): void;
  45918. /**
  45919. * Disposes the resources of the material.
  45920. * @param forceDisposeTextures - Forces the disposal of all textures.
  45921. */
  45922. dispose(forceDisposeTextures?: boolean): void;
  45923. /**
  45924. * Get the current class name of the texture useful for serialization or dynamic coding.
  45925. * @returns "PBRSubSurfaceConfiguration"
  45926. */
  45927. getClassName(): string;
  45928. /**
  45929. * Add fallbacks to the effect fallbacks list.
  45930. * @param defines defines the Base texture to use.
  45931. * @param fallbacks defines the current fallback list.
  45932. * @param currentRank defines the current fallback rank.
  45933. * @returns the new fallback rank.
  45934. */
  45935. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45936. /**
  45937. * Add the required uniforms to the current list.
  45938. * @param uniforms defines the current uniform list.
  45939. */
  45940. static AddUniforms(uniforms: string[]): void;
  45941. /**
  45942. * Add the required samplers to the current list.
  45943. * @param samplers defines the current sampler list.
  45944. */
  45945. static AddSamplers(samplers: string[]): void;
  45946. /**
  45947. * Add the required uniforms to the current buffer.
  45948. * @param uniformBuffer defines the current uniform buffer.
  45949. */
  45950. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45951. /**
  45952. * Makes a duplicate of the current configuration into another one.
  45953. * @param configuration define the config where to copy the info
  45954. */
  45955. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45956. /**
  45957. * Serializes this Sub Surface configuration.
  45958. * @returns - An object with the serialized config.
  45959. */
  45960. serialize(): any;
  45961. /**
  45962. * Parses a anisotropy Configuration from a serialized object.
  45963. * @param source - Serialized object.
  45964. * @param scene Defines the scene we are parsing for
  45965. * @param rootUrl Defines the rootUrl to load from
  45966. */
  45967. parse(source: any, scene: Scene, rootUrl: string): void;
  45968. }
  45969. }
  45970. declare module BABYLON {
  45971. /** @hidden */
  45972. export var pbrFragmentDeclaration: {
  45973. name: string;
  45974. shader: string;
  45975. };
  45976. }
  45977. declare module BABYLON {
  45978. /** @hidden */
  45979. export var pbrUboDeclaration: {
  45980. name: string;
  45981. shader: string;
  45982. };
  45983. }
  45984. declare module BABYLON {
  45985. /** @hidden */
  45986. export var pbrFragmentExtraDeclaration: {
  45987. name: string;
  45988. shader: string;
  45989. };
  45990. }
  45991. declare module BABYLON {
  45992. /** @hidden */
  45993. export var pbrFragmentSamplersDeclaration: {
  45994. name: string;
  45995. shader: string;
  45996. };
  45997. }
  45998. declare module BABYLON {
  45999. /** @hidden */
  46000. export var pbrHelperFunctions: {
  46001. name: string;
  46002. shader: string;
  46003. };
  46004. }
  46005. declare module BABYLON {
  46006. /** @hidden */
  46007. export var harmonicsFunctions: {
  46008. name: string;
  46009. shader: string;
  46010. };
  46011. }
  46012. declare module BABYLON {
  46013. /** @hidden */
  46014. export var pbrDirectLightingSetupFunctions: {
  46015. name: string;
  46016. shader: string;
  46017. };
  46018. }
  46019. declare module BABYLON {
  46020. /** @hidden */
  46021. export var pbrDirectLightingFalloffFunctions: {
  46022. name: string;
  46023. shader: string;
  46024. };
  46025. }
  46026. declare module BABYLON {
  46027. /** @hidden */
  46028. export var pbrBRDFFunctions: {
  46029. name: string;
  46030. shader: string;
  46031. };
  46032. }
  46033. declare module BABYLON {
  46034. /** @hidden */
  46035. export var pbrDirectLightingFunctions: {
  46036. name: string;
  46037. shader: string;
  46038. };
  46039. }
  46040. declare module BABYLON {
  46041. /** @hidden */
  46042. export var pbrIBLFunctions: {
  46043. name: string;
  46044. shader: string;
  46045. };
  46046. }
  46047. declare module BABYLON {
  46048. /** @hidden */
  46049. export var pbrDebug: {
  46050. name: string;
  46051. shader: string;
  46052. };
  46053. }
  46054. declare module BABYLON {
  46055. /** @hidden */
  46056. export var pbrPixelShader: {
  46057. name: string;
  46058. shader: string;
  46059. };
  46060. }
  46061. declare module BABYLON {
  46062. /** @hidden */
  46063. export var pbrVertexDeclaration: {
  46064. name: string;
  46065. shader: string;
  46066. };
  46067. }
  46068. declare module BABYLON {
  46069. /** @hidden */
  46070. export var pbrVertexShader: {
  46071. name: string;
  46072. shader: string;
  46073. };
  46074. }
  46075. declare module BABYLON {
  46076. /**
  46077. * Manages the defines for the PBR Material.
  46078. * @hidden
  46079. */
  46080. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46081. PBR: boolean;
  46082. MAINUV1: boolean;
  46083. MAINUV2: boolean;
  46084. UV1: boolean;
  46085. UV2: boolean;
  46086. ALBEDO: boolean;
  46087. ALBEDODIRECTUV: number;
  46088. VERTEXCOLOR: boolean;
  46089. AMBIENT: boolean;
  46090. AMBIENTDIRECTUV: number;
  46091. AMBIENTINGRAYSCALE: boolean;
  46092. OPACITY: boolean;
  46093. VERTEXALPHA: boolean;
  46094. OPACITYDIRECTUV: number;
  46095. OPACITYRGB: boolean;
  46096. ALPHATEST: boolean;
  46097. DEPTHPREPASS: boolean;
  46098. ALPHABLEND: boolean;
  46099. ALPHAFROMALBEDO: boolean;
  46100. ALPHATESTVALUE: string;
  46101. SPECULAROVERALPHA: boolean;
  46102. RADIANCEOVERALPHA: boolean;
  46103. ALPHAFRESNEL: boolean;
  46104. LINEARALPHAFRESNEL: boolean;
  46105. PREMULTIPLYALPHA: boolean;
  46106. EMISSIVE: boolean;
  46107. EMISSIVEDIRECTUV: number;
  46108. REFLECTIVITY: boolean;
  46109. REFLECTIVITYDIRECTUV: number;
  46110. SPECULARTERM: boolean;
  46111. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46112. MICROSURFACEAUTOMATIC: boolean;
  46113. LODBASEDMICROSFURACE: boolean;
  46114. MICROSURFACEMAP: boolean;
  46115. MICROSURFACEMAPDIRECTUV: number;
  46116. METALLICWORKFLOW: boolean;
  46117. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46118. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46119. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46120. AOSTOREINMETALMAPRED: boolean;
  46121. ENVIRONMENTBRDF: boolean;
  46122. ENVIRONMENTBRDF_RGBD: boolean;
  46123. NORMAL: boolean;
  46124. TANGENT: boolean;
  46125. BUMP: boolean;
  46126. BUMPDIRECTUV: number;
  46127. OBJECTSPACE_NORMALMAP: boolean;
  46128. PARALLAX: boolean;
  46129. PARALLAXOCCLUSION: boolean;
  46130. NORMALXYSCALE: boolean;
  46131. LIGHTMAP: boolean;
  46132. LIGHTMAPDIRECTUV: number;
  46133. USELIGHTMAPASSHADOWMAP: boolean;
  46134. GAMMALIGHTMAP: boolean;
  46135. RGBDLIGHTMAP: boolean;
  46136. REFLECTION: boolean;
  46137. REFLECTIONMAP_3D: boolean;
  46138. REFLECTIONMAP_SPHERICAL: boolean;
  46139. REFLECTIONMAP_PLANAR: boolean;
  46140. REFLECTIONMAP_CUBIC: boolean;
  46141. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46142. REFLECTIONMAP_PROJECTION: boolean;
  46143. REFLECTIONMAP_SKYBOX: boolean;
  46144. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46145. REFLECTIONMAP_EXPLICIT: boolean;
  46146. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46147. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46148. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46149. INVERTCUBICMAP: boolean;
  46150. USESPHERICALFROMREFLECTIONMAP: boolean;
  46151. USEIRRADIANCEMAP: boolean;
  46152. SPHERICAL_HARMONICS: boolean;
  46153. USESPHERICALINVERTEX: boolean;
  46154. REFLECTIONMAP_OPPOSITEZ: boolean;
  46155. LODINREFLECTIONALPHA: boolean;
  46156. GAMMAREFLECTION: boolean;
  46157. RGBDREFLECTION: boolean;
  46158. LINEARSPECULARREFLECTION: boolean;
  46159. RADIANCEOCCLUSION: boolean;
  46160. HORIZONOCCLUSION: boolean;
  46161. INSTANCES: boolean;
  46162. NUM_BONE_INFLUENCERS: number;
  46163. BonesPerMesh: number;
  46164. BONETEXTURE: boolean;
  46165. NONUNIFORMSCALING: boolean;
  46166. MORPHTARGETS: boolean;
  46167. MORPHTARGETS_NORMAL: boolean;
  46168. MORPHTARGETS_TANGENT: boolean;
  46169. MORPHTARGETS_UV: boolean;
  46170. NUM_MORPH_INFLUENCERS: number;
  46171. IMAGEPROCESSING: boolean;
  46172. VIGNETTE: boolean;
  46173. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46174. VIGNETTEBLENDMODEOPAQUE: boolean;
  46175. TONEMAPPING: boolean;
  46176. TONEMAPPING_ACES: boolean;
  46177. CONTRAST: boolean;
  46178. COLORCURVES: boolean;
  46179. COLORGRADING: boolean;
  46180. COLORGRADING3D: boolean;
  46181. SAMPLER3DGREENDEPTH: boolean;
  46182. SAMPLER3DBGRMAP: boolean;
  46183. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46184. EXPOSURE: boolean;
  46185. MULTIVIEW: boolean;
  46186. USEPHYSICALLIGHTFALLOFF: boolean;
  46187. USEGLTFLIGHTFALLOFF: boolean;
  46188. TWOSIDEDLIGHTING: boolean;
  46189. SHADOWFLOAT: boolean;
  46190. CLIPPLANE: boolean;
  46191. CLIPPLANE2: boolean;
  46192. CLIPPLANE3: boolean;
  46193. CLIPPLANE4: boolean;
  46194. POINTSIZE: boolean;
  46195. FOG: boolean;
  46196. LOGARITHMICDEPTH: boolean;
  46197. FORCENORMALFORWARD: boolean;
  46198. SPECULARAA: boolean;
  46199. CLEARCOAT: boolean;
  46200. CLEARCOAT_DEFAULTIOR: boolean;
  46201. CLEARCOAT_TEXTURE: boolean;
  46202. CLEARCOAT_TEXTUREDIRECTUV: number;
  46203. CLEARCOAT_BUMP: boolean;
  46204. CLEARCOAT_BUMPDIRECTUV: number;
  46205. CLEARCOAT_TINT: boolean;
  46206. CLEARCOAT_TINT_TEXTURE: boolean;
  46207. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46208. ANISOTROPIC: boolean;
  46209. ANISOTROPIC_TEXTURE: boolean;
  46210. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46211. BRDF_V_HEIGHT_CORRELATED: boolean;
  46212. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46213. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46214. SHEEN: boolean;
  46215. SHEEN_TEXTURE: boolean;
  46216. SHEEN_TEXTUREDIRECTUV: number;
  46217. SHEEN_LINKWITHALBEDO: boolean;
  46218. SUBSURFACE: boolean;
  46219. SS_REFRACTION: boolean;
  46220. SS_TRANSLUCENCY: boolean;
  46221. SS_SCATERRING: boolean;
  46222. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46223. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46224. SS_REFRACTIONMAP_3D: boolean;
  46225. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46226. SS_LODINREFRACTIONALPHA: boolean;
  46227. SS_GAMMAREFRACTION: boolean;
  46228. SS_RGBDREFRACTION: boolean;
  46229. SS_LINEARSPECULARREFRACTION: boolean;
  46230. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46231. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46232. UNLIT: boolean;
  46233. DEBUGMODE: number;
  46234. /**
  46235. * Initializes the PBR Material defines.
  46236. */
  46237. constructor();
  46238. /**
  46239. * Resets the PBR Material defines.
  46240. */
  46241. reset(): void;
  46242. }
  46243. /**
  46244. * The Physically based material base class of BJS.
  46245. *
  46246. * This offers the main features of a standard PBR material.
  46247. * For more information, please refer to the documentation :
  46248. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46249. */
  46250. export abstract class PBRBaseMaterial extends PushMaterial {
  46251. /**
  46252. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46253. */
  46254. static readonly PBRMATERIAL_OPAQUE: number;
  46255. /**
  46256. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46257. */
  46258. static readonly PBRMATERIAL_ALPHATEST: number;
  46259. /**
  46260. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46261. */
  46262. static readonly PBRMATERIAL_ALPHABLEND: number;
  46263. /**
  46264. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46265. * They are also discarded below the alpha cutoff threshold to improve performances.
  46266. */
  46267. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46268. /**
  46269. * Defines the default value of how much AO map is occluding the analytical lights
  46270. * (point spot...).
  46271. */
  46272. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46273. /**
  46274. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46275. */
  46276. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46277. /**
  46278. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46279. * to enhance interoperability with other engines.
  46280. */
  46281. static readonly LIGHTFALLOFF_GLTF: number;
  46282. /**
  46283. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46284. * to enhance interoperability with other materials.
  46285. */
  46286. static readonly LIGHTFALLOFF_STANDARD: number;
  46287. /**
  46288. * Intensity of the direct lights e.g. the four lights available in your scene.
  46289. * This impacts both the direct diffuse and specular highlights.
  46290. */
  46291. protected _directIntensity: number;
  46292. /**
  46293. * Intensity of the emissive part of the material.
  46294. * This helps controlling the emissive effect without modifying the emissive color.
  46295. */
  46296. protected _emissiveIntensity: number;
  46297. /**
  46298. * Intensity of the environment e.g. how much the environment will light the object
  46299. * either through harmonics for rough material or through the refelction for shiny ones.
  46300. */
  46301. protected _environmentIntensity: number;
  46302. /**
  46303. * This is a special control allowing the reduction of the specular highlights coming from the
  46304. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46305. */
  46306. protected _specularIntensity: number;
  46307. /**
  46308. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46309. */
  46310. private _lightingInfos;
  46311. /**
  46312. * Debug Control allowing disabling the bump map on this material.
  46313. */
  46314. protected _disableBumpMap: boolean;
  46315. /**
  46316. * AKA Diffuse Texture in standard nomenclature.
  46317. */
  46318. protected _albedoTexture: Nullable<BaseTexture>;
  46319. /**
  46320. * AKA Occlusion Texture in other nomenclature.
  46321. */
  46322. protected _ambientTexture: Nullable<BaseTexture>;
  46323. /**
  46324. * AKA Occlusion Texture Intensity in other nomenclature.
  46325. */
  46326. protected _ambientTextureStrength: number;
  46327. /**
  46328. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46329. * 1 means it completely occludes it
  46330. * 0 mean it has no impact
  46331. */
  46332. protected _ambientTextureImpactOnAnalyticalLights: number;
  46333. /**
  46334. * Stores the alpha values in a texture.
  46335. */
  46336. protected _opacityTexture: Nullable<BaseTexture>;
  46337. /**
  46338. * Stores the reflection values in a texture.
  46339. */
  46340. protected _reflectionTexture: Nullable<BaseTexture>;
  46341. /**
  46342. * Stores the emissive values in a texture.
  46343. */
  46344. protected _emissiveTexture: Nullable<BaseTexture>;
  46345. /**
  46346. * AKA Specular texture in other nomenclature.
  46347. */
  46348. protected _reflectivityTexture: Nullable<BaseTexture>;
  46349. /**
  46350. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46351. */
  46352. protected _metallicTexture: Nullable<BaseTexture>;
  46353. /**
  46354. * Specifies the metallic scalar of the metallic/roughness workflow.
  46355. * Can also be used to scale the metalness values of the metallic texture.
  46356. */
  46357. protected _metallic: Nullable<number>;
  46358. /**
  46359. * Specifies the roughness scalar of the metallic/roughness workflow.
  46360. * Can also be used to scale the roughness values of the metallic texture.
  46361. */
  46362. protected _roughness: Nullable<number>;
  46363. /**
  46364. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46365. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46366. */
  46367. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46368. /**
  46369. * Stores surface normal data used to displace a mesh in a texture.
  46370. */
  46371. protected _bumpTexture: Nullable<BaseTexture>;
  46372. /**
  46373. * Stores the pre-calculated light information of a mesh in a texture.
  46374. */
  46375. protected _lightmapTexture: Nullable<BaseTexture>;
  46376. /**
  46377. * The color of a material in ambient lighting.
  46378. */
  46379. protected _ambientColor: Color3;
  46380. /**
  46381. * AKA Diffuse Color in other nomenclature.
  46382. */
  46383. protected _albedoColor: Color3;
  46384. /**
  46385. * AKA Specular Color in other nomenclature.
  46386. */
  46387. protected _reflectivityColor: Color3;
  46388. /**
  46389. * The color applied when light is reflected from a material.
  46390. */
  46391. protected _reflectionColor: Color3;
  46392. /**
  46393. * The color applied when light is emitted from a material.
  46394. */
  46395. protected _emissiveColor: Color3;
  46396. /**
  46397. * AKA Glossiness in other nomenclature.
  46398. */
  46399. protected _microSurface: number;
  46400. /**
  46401. * Specifies that the material will use the light map as a show map.
  46402. */
  46403. protected _useLightmapAsShadowmap: boolean;
  46404. /**
  46405. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46406. * makes the reflect vector face the model (under horizon).
  46407. */
  46408. protected _useHorizonOcclusion: boolean;
  46409. /**
  46410. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46411. * too much the area relying on ambient texture to define their ambient occlusion.
  46412. */
  46413. protected _useRadianceOcclusion: boolean;
  46414. /**
  46415. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46416. */
  46417. protected _useAlphaFromAlbedoTexture: boolean;
  46418. /**
  46419. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46420. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46421. */
  46422. protected _useSpecularOverAlpha: boolean;
  46423. /**
  46424. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46425. */
  46426. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46427. /**
  46428. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46429. */
  46430. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46431. /**
  46432. * Specifies if the metallic texture contains the roughness information in its green channel.
  46433. */
  46434. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46435. /**
  46436. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46437. */
  46438. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46439. /**
  46440. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46441. */
  46442. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46443. /**
  46444. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46445. */
  46446. protected _useAmbientInGrayScale: boolean;
  46447. /**
  46448. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46449. * The material will try to infer what glossiness each pixel should be.
  46450. */
  46451. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46452. /**
  46453. * Defines the falloff type used in this material.
  46454. * It by default is Physical.
  46455. */
  46456. protected _lightFalloff: number;
  46457. /**
  46458. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46459. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46460. */
  46461. protected _useRadianceOverAlpha: boolean;
  46462. /**
  46463. * Allows using an object space normal map (instead of tangent space).
  46464. */
  46465. protected _useObjectSpaceNormalMap: boolean;
  46466. /**
  46467. * Allows using the bump map in parallax mode.
  46468. */
  46469. protected _useParallax: boolean;
  46470. /**
  46471. * Allows using the bump map in parallax occlusion mode.
  46472. */
  46473. protected _useParallaxOcclusion: boolean;
  46474. /**
  46475. * Controls the scale bias of the parallax mode.
  46476. */
  46477. protected _parallaxScaleBias: number;
  46478. /**
  46479. * If sets to true, disables all the lights affecting the material.
  46480. */
  46481. protected _disableLighting: boolean;
  46482. /**
  46483. * Number of Simultaneous lights allowed on the material.
  46484. */
  46485. protected _maxSimultaneousLights: number;
  46486. /**
  46487. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46488. */
  46489. protected _invertNormalMapX: boolean;
  46490. /**
  46491. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46492. */
  46493. protected _invertNormalMapY: boolean;
  46494. /**
  46495. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46496. */
  46497. protected _twoSidedLighting: boolean;
  46498. /**
  46499. * Defines the alpha limits in alpha test mode.
  46500. */
  46501. protected _alphaCutOff: number;
  46502. /**
  46503. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46504. */
  46505. protected _forceAlphaTest: boolean;
  46506. /**
  46507. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46508. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46509. */
  46510. protected _useAlphaFresnel: boolean;
  46511. /**
  46512. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46513. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46514. */
  46515. protected _useLinearAlphaFresnel: boolean;
  46516. /**
  46517. * The transparency mode of the material.
  46518. */
  46519. protected _transparencyMode: Nullable<number>;
  46520. /**
  46521. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46522. * from cos thetav and roughness:
  46523. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46524. */
  46525. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46526. /**
  46527. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46528. */
  46529. protected _forceIrradianceInFragment: boolean;
  46530. /**
  46531. * Force normal to face away from face.
  46532. */
  46533. protected _forceNormalForward: boolean;
  46534. /**
  46535. * Enables specular anti aliasing in the PBR shader.
  46536. * It will both interacts on the Geometry for analytical and IBL lighting.
  46537. * It also prefilter the roughness map based on the bump values.
  46538. */
  46539. protected _enableSpecularAntiAliasing: boolean;
  46540. /**
  46541. * Default configuration related to image processing available in the PBR Material.
  46542. */
  46543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46544. /**
  46545. * Keep track of the image processing observer to allow dispose and replace.
  46546. */
  46547. private _imageProcessingObserver;
  46548. /**
  46549. * Attaches a new image processing configuration to the PBR Material.
  46550. * @param configuration
  46551. */
  46552. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46553. /**
  46554. * Stores the available render targets.
  46555. */
  46556. private _renderTargets;
  46557. /**
  46558. * Sets the global ambient color for the material used in lighting calculations.
  46559. */
  46560. private _globalAmbientColor;
  46561. /**
  46562. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46563. */
  46564. private _useLogarithmicDepth;
  46565. /**
  46566. * If set to true, no lighting calculations will be applied.
  46567. */
  46568. private _unlit;
  46569. private _debugMode;
  46570. /**
  46571. * @hidden
  46572. * This is reserved for the inspector.
  46573. * Defines the material debug mode.
  46574. * It helps seeing only some components of the material while troubleshooting.
  46575. */
  46576. debugMode: number;
  46577. /**
  46578. * @hidden
  46579. * This is reserved for the inspector.
  46580. * Specify from where on screen the debug mode should start.
  46581. * The value goes from -1 (full screen) to 1 (not visible)
  46582. * It helps with side by side comparison against the final render
  46583. * This defaults to -1
  46584. */
  46585. private debugLimit;
  46586. /**
  46587. * @hidden
  46588. * This is reserved for the inspector.
  46589. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46590. * You can use the factor to better multiply the final value.
  46591. */
  46592. private debugFactor;
  46593. /**
  46594. * Defines the clear coat layer parameters for the material.
  46595. */
  46596. readonly clearCoat: PBRClearCoatConfiguration;
  46597. /**
  46598. * Defines the anisotropic parameters for the material.
  46599. */
  46600. readonly anisotropy: PBRAnisotropicConfiguration;
  46601. /**
  46602. * Defines the BRDF parameters for the material.
  46603. */
  46604. readonly brdf: PBRBRDFConfiguration;
  46605. /**
  46606. * Defines the Sheen parameters for the material.
  46607. */
  46608. readonly sheen: PBRSheenConfiguration;
  46609. /**
  46610. * Defines the SubSurface parameters for the material.
  46611. */
  46612. readonly subSurface: PBRSubSurfaceConfiguration;
  46613. /**
  46614. * Custom callback helping to override the default shader used in the material.
  46615. */
  46616. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46617. protected _rebuildInParallel: boolean;
  46618. /**
  46619. * Instantiates a new PBRMaterial instance.
  46620. *
  46621. * @param name The material name
  46622. * @param scene The scene the material will be use in.
  46623. */
  46624. constructor(name: string, scene: Scene);
  46625. /**
  46626. * Gets a boolean indicating that current material needs to register RTT
  46627. */
  46628. readonly hasRenderTargetTextures: boolean;
  46629. /**
  46630. * Gets the name of the material class.
  46631. */
  46632. getClassName(): string;
  46633. /**
  46634. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46635. */
  46636. /**
  46637. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46638. */
  46639. useLogarithmicDepth: boolean;
  46640. /**
  46641. * Gets the current transparency mode.
  46642. */
  46643. /**
  46644. * Sets the transparency mode of the material.
  46645. *
  46646. * | Value | Type | Description |
  46647. * | ----- | ----------------------------------- | ----------- |
  46648. * | 0 | OPAQUE | |
  46649. * | 1 | ALPHATEST | |
  46650. * | 2 | ALPHABLEND | |
  46651. * | 3 | ALPHATESTANDBLEND | |
  46652. *
  46653. */
  46654. transparencyMode: Nullable<number>;
  46655. /**
  46656. * Returns true if alpha blending should be disabled.
  46657. */
  46658. private readonly _disableAlphaBlending;
  46659. /**
  46660. * Specifies whether or not this material should be rendered in alpha blend mode.
  46661. */
  46662. needAlphaBlending(): boolean;
  46663. /**
  46664. * Specifies if the mesh will require alpha blending.
  46665. * @param mesh - BJS mesh.
  46666. */
  46667. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46668. /**
  46669. * Specifies whether or not this material should be rendered in alpha test mode.
  46670. */
  46671. needAlphaTesting(): boolean;
  46672. /**
  46673. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46674. */
  46675. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46676. /**
  46677. * Gets the texture used for the alpha test.
  46678. */
  46679. getAlphaTestTexture(): Nullable<BaseTexture>;
  46680. /**
  46681. * Specifies that the submesh is ready to be used.
  46682. * @param mesh - BJS mesh.
  46683. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46684. * @param useInstances - Specifies that instances should be used.
  46685. * @returns - boolean indicating that the submesh is ready or not.
  46686. */
  46687. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46688. /**
  46689. * Specifies if the material uses metallic roughness workflow.
  46690. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46691. */
  46692. isMetallicWorkflow(): boolean;
  46693. private _prepareEffect;
  46694. private _prepareDefines;
  46695. /**
  46696. * Force shader compilation
  46697. */
  46698. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46699. clipPlane: boolean;
  46700. }>): void;
  46701. /**
  46702. * Initializes the uniform buffer layout for the shader.
  46703. */
  46704. buildUniformLayout(): void;
  46705. /**
  46706. * Unbinds the material from the mesh
  46707. */
  46708. unbind(): void;
  46709. /**
  46710. * Binds the submesh data.
  46711. * @param world - The world matrix.
  46712. * @param mesh - The BJS mesh.
  46713. * @param subMesh - A submesh of the BJS mesh.
  46714. */
  46715. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46716. /**
  46717. * Returns the animatable textures.
  46718. * @returns - Array of animatable textures.
  46719. */
  46720. getAnimatables(): IAnimatable[];
  46721. /**
  46722. * Returns the texture used for reflections.
  46723. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46724. */
  46725. private _getReflectionTexture;
  46726. /**
  46727. * Returns an array of the actively used textures.
  46728. * @returns - Array of BaseTextures
  46729. */
  46730. getActiveTextures(): BaseTexture[];
  46731. /**
  46732. * Checks to see if a texture is used in the material.
  46733. * @param texture - Base texture to use.
  46734. * @returns - Boolean specifying if a texture is used in the material.
  46735. */
  46736. hasTexture(texture: BaseTexture): boolean;
  46737. /**
  46738. * Disposes the resources of the material.
  46739. * @param forceDisposeEffect - Forces the disposal of effects.
  46740. * @param forceDisposeTextures - Forces the disposal of all textures.
  46741. */
  46742. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46743. }
  46744. }
  46745. declare module BABYLON {
  46746. /**
  46747. * The Physically based material of BJS.
  46748. *
  46749. * This offers the main features of a standard PBR material.
  46750. * For more information, please refer to the documentation :
  46751. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46752. */
  46753. export class PBRMaterial extends PBRBaseMaterial {
  46754. /**
  46755. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46756. */
  46757. static readonly PBRMATERIAL_OPAQUE: number;
  46758. /**
  46759. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46760. */
  46761. static readonly PBRMATERIAL_ALPHATEST: number;
  46762. /**
  46763. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46764. */
  46765. static readonly PBRMATERIAL_ALPHABLEND: number;
  46766. /**
  46767. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46768. * They are also discarded below the alpha cutoff threshold to improve performances.
  46769. */
  46770. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46771. /**
  46772. * Defines the default value of how much AO map is occluding the analytical lights
  46773. * (point spot...).
  46774. */
  46775. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46776. /**
  46777. * Intensity of the direct lights e.g. the four lights available in your scene.
  46778. * This impacts both the direct diffuse and specular highlights.
  46779. */
  46780. directIntensity: number;
  46781. /**
  46782. * Intensity of the emissive part of the material.
  46783. * This helps controlling the emissive effect without modifying the emissive color.
  46784. */
  46785. emissiveIntensity: number;
  46786. /**
  46787. * Intensity of the environment e.g. how much the environment will light the object
  46788. * either through harmonics for rough material or through the refelction for shiny ones.
  46789. */
  46790. environmentIntensity: number;
  46791. /**
  46792. * This is a special control allowing the reduction of the specular highlights coming from the
  46793. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46794. */
  46795. specularIntensity: number;
  46796. /**
  46797. * Debug Control allowing disabling the bump map on this material.
  46798. */
  46799. disableBumpMap: boolean;
  46800. /**
  46801. * AKA Diffuse Texture in standard nomenclature.
  46802. */
  46803. albedoTexture: BaseTexture;
  46804. /**
  46805. * AKA Occlusion Texture in other nomenclature.
  46806. */
  46807. ambientTexture: BaseTexture;
  46808. /**
  46809. * AKA Occlusion Texture Intensity in other nomenclature.
  46810. */
  46811. ambientTextureStrength: number;
  46812. /**
  46813. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46814. * 1 means it completely occludes it
  46815. * 0 mean it has no impact
  46816. */
  46817. ambientTextureImpactOnAnalyticalLights: number;
  46818. /**
  46819. * Stores the alpha values in a texture.
  46820. */
  46821. opacityTexture: BaseTexture;
  46822. /**
  46823. * Stores the reflection values in a texture.
  46824. */
  46825. reflectionTexture: Nullable<BaseTexture>;
  46826. /**
  46827. * Stores the emissive values in a texture.
  46828. */
  46829. emissiveTexture: BaseTexture;
  46830. /**
  46831. * AKA Specular texture in other nomenclature.
  46832. */
  46833. reflectivityTexture: BaseTexture;
  46834. /**
  46835. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46836. */
  46837. metallicTexture: BaseTexture;
  46838. /**
  46839. * Specifies the metallic scalar of the metallic/roughness workflow.
  46840. * Can also be used to scale the metalness values of the metallic texture.
  46841. */
  46842. metallic: Nullable<number>;
  46843. /**
  46844. * Specifies the roughness scalar of the metallic/roughness workflow.
  46845. * Can also be used to scale the roughness values of the metallic texture.
  46846. */
  46847. roughness: Nullable<number>;
  46848. /**
  46849. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46850. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46851. */
  46852. microSurfaceTexture: BaseTexture;
  46853. /**
  46854. * Stores surface normal data used to displace a mesh in a texture.
  46855. */
  46856. bumpTexture: BaseTexture;
  46857. /**
  46858. * Stores the pre-calculated light information of a mesh in a texture.
  46859. */
  46860. lightmapTexture: BaseTexture;
  46861. /**
  46862. * Stores the refracted light information in a texture.
  46863. */
  46864. refractionTexture: Nullable<BaseTexture>;
  46865. /**
  46866. * The color of a material in ambient lighting.
  46867. */
  46868. ambientColor: Color3;
  46869. /**
  46870. * AKA Diffuse Color in other nomenclature.
  46871. */
  46872. albedoColor: Color3;
  46873. /**
  46874. * AKA Specular Color in other nomenclature.
  46875. */
  46876. reflectivityColor: Color3;
  46877. /**
  46878. * The color reflected from the material.
  46879. */
  46880. reflectionColor: Color3;
  46881. /**
  46882. * The color emitted from the material.
  46883. */
  46884. emissiveColor: Color3;
  46885. /**
  46886. * AKA Glossiness in other nomenclature.
  46887. */
  46888. microSurface: number;
  46889. /**
  46890. * source material index of refraction (IOR)' / 'destination material IOR.
  46891. */
  46892. indexOfRefraction: number;
  46893. /**
  46894. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46895. */
  46896. invertRefractionY: boolean;
  46897. /**
  46898. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46899. * Materials half opaque for instance using refraction could benefit from this control.
  46900. */
  46901. linkRefractionWithTransparency: boolean;
  46902. /**
  46903. * If true, the light map contains occlusion information instead of lighting info.
  46904. */
  46905. useLightmapAsShadowmap: boolean;
  46906. /**
  46907. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46908. */
  46909. useAlphaFromAlbedoTexture: boolean;
  46910. /**
  46911. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46912. */
  46913. forceAlphaTest: boolean;
  46914. /**
  46915. * Defines the alpha limits in alpha test mode.
  46916. */
  46917. alphaCutOff: number;
  46918. /**
  46919. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46920. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46921. */
  46922. useSpecularOverAlpha: boolean;
  46923. /**
  46924. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46925. */
  46926. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46927. /**
  46928. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46929. */
  46930. useRoughnessFromMetallicTextureAlpha: boolean;
  46931. /**
  46932. * Specifies if the metallic texture contains the roughness information in its green channel.
  46933. */
  46934. useRoughnessFromMetallicTextureGreen: boolean;
  46935. /**
  46936. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46937. */
  46938. useMetallnessFromMetallicTextureBlue: boolean;
  46939. /**
  46940. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46941. */
  46942. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46943. /**
  46944. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46945. */
  46946. useAmbientInGrayScale: boolean;
  46947. /**
  46948. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46949. * The material will try to infer what glossiness each pixel should be.
  46950. */
  46951. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46952. /**
  46953. * BJS is using an harcoded light falloff based on a manually sets up range.
  46954. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46955. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46956. */
  46957. /**
  46958. * BJS is using an harcoded light falloff based on a manually sets up range.
  46959. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46960. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46961. */
  46962. usePhysicalLightFalloff: boolean;
  46963. /**
  46964. * In order to support the falloff compatibility with gltf, a special mode has been added
  46965. * to reproduce the gltf light falloff.
  46966. */
  46967. /**
  46968. * In order to support the falloff compatibility with gltf, a special mode has been added
  46969. * to reproduce the gltf light falloff.
  46970. */
  46971. useGLTFLightFalloff: boolean;
  46972. /**
  46973. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46974. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46975. */
  46976. useRadianceOverAlpha: boolean;
  46977. /**
  46978. * Allows using an object space normal map (instead of tangent space).
  46979. */
  46980. useObjectSpaceNormalMap: boolean;
  46981. /**
  46982. * Allows using the bump map in parallax mode.
  46983. */
  46984. useParallax: boolean;
  46985. /**
  46986. * Allows using the bump map in parallax occlusion mode.
  46987. */
  46988. useParallaxOcclusion: boolean;
  46989. /**
  46990. * Controls the scale bias of the parallax mode.
  46991. */
  46992. parallaxScaleBias: number;
  46993. /**
  46994. * If sets to true, disables all the lights affecting the material.
  46995. */
  46996. disableLighting: boolean;
  46997. /**
  46998. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46999. */
  47000. forceIrradianceInFragment: boolean;
  47001. /**
  47002. * Number of Simultaneous lights allowed on the material.
  47003. */
  47004. maxSimultaneousLights: number;
  47005. /**
  47006. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47007. */
  47008. invertNormalMapX: boolean;
  47009. /**
  47010. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47011. */
  47012. invertNormalMapY: boolean;
  47013. /**
  47014. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47015. */
  47016. twoSidedLighting: boolean;
  47017. /**
  47018. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47019. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47020. */
  47021. useAlphaFresnel: boolean;
  47022. /**
  47023. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47024. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47025. */
  47026. useLinearAlphaFresnel: boolean;
  47027. /**
  47028. * Let user defines the brdf lookup texture used for IBL.
  47029. * A default 8bit version is embedded but you could point at :
  47030. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47031. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47032. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47033. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47034. */
  47035. environmentBRDFTexture: Nullable<BaseTexture>;
  47036. /**
  47037. * Force normal to face away from face.
  47038. */
  47039. forceNormalForward: boolean;
  47040. /**
  47041. * Enables specular anti aliasing in the PBR shader.
  47042. * It will both interacts on the Geometry for analytical and IBL lighting.
  47043. * It also prefilter the roughness map based on the bump values.
  47044. */
  47045. enableSpecularAntiAliasing: boolean;
  47046. /**
  47047. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47048. * makes the reflect vector face the model (under horizon).
  47049. */
  47050. useHorizonOcclusion: boolean;
  47051. /**
  47052. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47053. * too much the area relying on ambient texture to define their ambient occlusion.
  47054. */
  47055. useRadianceOcclusion: boolean;
  47056. /**
  47057. * If set to true, no lighting calculations will be applied.
  47058. */
  47059. unlit: boolean;
  47060. /**
  47061. * Gets the image processing configuration used either in this material.
  47062. */
  47063. /**
  47064. * Sets the Default image processing configuration used either in the this material.
  47065. *
  47066. * If sets to null, the scene one is in use.
  47067. */
  47068. imageProcessingConfiguration: ImageProcessingConfiguration;
  47069. /**
  47070. * Gets wether the color curves effect is enabled.
  47071. */
  47072. /**
  47073. * Sets wether the color curves effect is enabled.
  47074. */
  47075. cameraColorCurvesEnabled: boolean;
  47076. /**
  47077. * Gets wether the color grading effect is enabled.
  47078. */
  47079. /**
  47080. * Gets wether the color grading effect is enabled.
  47081. */
  47082. cameraColorGradingEnabled: boolean;
  47083. /**
  47084. * Gets wether tonemapping is enabled or not.
  47085. */
  47086. /**
  47087. * Sets wether tonemapping is enabled or not
  47088. */
  47089. cameraToneMappingEnabled: boolean;
  47090. /**
  47091. * The camera exposure used on this material.
  47092. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47093. * This corresponds to a photographic exposure.
  47094. */
  47095. /**
  47096. * The camera exposure used on this material.
  47097. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47098. * This corresponds to a photographic exposure.
  47099. */
  47100. cameraExposure: number;
  47101. /**
  47102. * Gets The camera contrast used on this material.
  47103. */
  47104. /**
  47105. * Sets The camera contrast used on this material.
  47106. */
  47107. cameraContrast: number;
  47108. /**
  47109. * Gets the Color Grading 2D Lookup Texture.
  47110. */
  47111. /**
  47112. * Sets the Color Grading 2D Lookup Texture.
  47113. */
  47114. cameraColorGradingTexture: Nullable<BaseTexture>;
  47115. /**
  47116. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47117. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47118. * 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;
  47119. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47120. */
  47121. /**
  47122. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47123. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47124. * 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;
  47125. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47126. */
  47127. cameraColorCurves: Nullable<ColorCurves>;
  47128. /**
  47129. * Instantiates a new PBRMaterial instance.
  47130. *
  47131. * @param name The material name
  47132. * @param scene The scene the material will be use in.
  47133. */
  47134. constructor(name: string, scene: Scene);
  47135. /**
  47136. * Returns the name of this material class.
  47137. */
  47138. getClassName(): string;
  47139. /**
  47140. * Makes a duplicate of the current material.
  47141. * @param name - name to use for the new material.
  47142. */
  47143. clone(name: string): PBRMaterial;
  47144. /**
  47145. * Serializes this PBR Material.
  47146. * @returns - An object with the serialized material.
  47147. */
  47148. serialize(): any;
  47149. /**
  47150. * Parses a PBR Material from a serialized object.
  47151. * @param source - Serialized object.
  47152. * @param scene - BJS scene instance.
  47153. * @param rootUrl - url for the scene object
  47154. * @returns - PBRMaterial
  47155. */
  47156. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47157. }
  47158. }
  47159. declare module BABYLON {
  47160. /**
  47161. * Direct draw surface info
  47162. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47163. */
  47164. export interface DDSInfo {
  47165. /**
  47166. * Width of the texture
  47167. */
  47168. width: number;
  47169. /**
  47170. * Width of the texture
  47171. */
  47172. height: number;
  47173. /**
  47174. * Number of Mipmaps for the texture
  47175. * @see https://en.wikipedia.org/wiki/Mipmap
  47176. */
  47177. mipmapCount: number;
  47178. /**
  47179. * If the textures format is a known fourCC format
  47180. * @see https://www.fourcc.org/
  47181. */
  47182. isFourCC: boolean;
  47183. /**
  47184. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47185. */
  47186. isRGB: boolean;
  47187. /**
  47188. * If the texture is a lumincance format
  47189. */
  47190. isLuminance: boolean;
  47191. /**
  47192. * If this is a cube texture
  47193. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47194. */
  47195. isCube: boolean;
  47196. /**
  47197. * If the texture is a compressed format eg. FOURCC_DXT1
  47198. */
  47199. isCompressed: boolean;
  47200. /**
  47201. * The dxgiFormat of the texture
  47202. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47203. */
  47204. dxgiFormat: number;
  47205. /**
  47206. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47207. */
  47208. textureType: number;
  47209. /**
  47210. * Sphericle polynomial created for the dds texture
  47211. */
  47212. sphericalPolynomial?: SphericalPolynomial;
  47213. }
  47214. /**
  47215. * Class used to provide DDS decompression tools
  47216. */
  47217. export class DDSTools {
  47218. /**
  47219. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47220. */
  47221. static StoreLODInAlphaChannel: boolean;
  47222. /**
  47223. * Gets DDS information from an array buffer
  47224. * @param arrayBuffer defines the array buffer to read data from
  47225. * @returns the DDS information
  47226. */
  47227. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47228. private static _FloatView;
  47229. private static _Int32View;
  47230. private static _ToHalfFloat;
  47231. private static _FromHalfFloat;
  47232. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47233. private static _GetHalfFloatRGBAArrayBuffer;
  47234. private static _GetFloatRGBAArrayBuffer;
  47235. private static _GetFloatAsUIntRGBAArrayBuffer;
  47236. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47237. private static _GetRGBAArrayBuffer;
  47238. private static _ExtractLongWordOrder;
  47239. private static _GetRGBArrayBuffer;
  47240. private static _GetLuminanceArrayBuffer;
  47241. /**
  47242. * Uploads DDS Levels to a Babylon Texture
  47243. * @hidden
  47244. */
  47245. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47246. }
  47247. interface Engine {
  47248. /**
  47249. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47250. * @param rootUrl defines the url where the file to load is located
  47251. * @param scene defines the current scene
  47252. * @param lodScale defines scale to apply to the mip map selection
  47253. * @param lodOffset defines offset to apply to the mip map selection
  47254. * @param onLoad defines an optional callback raised when the texture is loaded
  47255. * @param onError defines an optional callback raised if there is an issue to load the texture
  47256. * @param format defines the format of the data
  47257. * @param forcedExtension defines the extension to use to pick the right loader
  47258. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47259. * @returns the cube texture as an InternalTexture
  47260. */
  47261. 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;
  47262. }
  47263. }
  47264. declare module BABYLON {
  47265. /**
  47266. * Implementation of the DDS Texture Loader.
  47267. * @hidden
  47268. */
  47269. export class _DDSTextureLoader implements IInternalTextureLoader {
  47270. /**
  47271. * Defines wether the loader supports cascade loading the different faces.
  47272. */
  47273. readonly supportCascades: boolean;
  47274. /**
  47275. * This returns if the loader support the current file information.
  47276. * @param extension defines the file extension of the file being loaded
  47277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47278. * @param fallback defines the fallback internal texture if any
  47279. * @param isBase64 defines whether the texture is encoded as a base64
  47280. * @param isBuffer defines whether the texture data are stored as a buffer
  47281. * @returns true if the loader can load the specified file
  47282. */
  47283. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47284. /**
  47285. * Transform the url before loading if required.
  47286. * @param rootUrl the url of the texture
  47287. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47288. * @returns the transformed texture
  47289. */
  47290. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47291. /**
  47292. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47293. * @param rootUrl the url of the texture
  47294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47295. * @returns the fallback texture
  47296. */
  47297. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47298. /**
  47299. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47300. * @param data contains the texture data
  47301. * @param texture defines the BabylonJS internal texture
  47302. * @param createPolynomials will be true if polynomials have been requested
  47303. * @param onLoad defines the callback to trigger once the texture is ready
  47304. * @param onError defines the callback to trigger in case of error
  47305. */
  47306. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47307. /**
  47308. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47309. * @param data contains the texture data
  47310. * @param texture defines the BabylonJS internal texture
  47311. * @param callback defines the method to call once ready to upload
  47312. */
  47313. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47314. }
  47315. }
  47316. declare module BABYLON {
  47317. /**
  47318. * Implementation of the ENV Texture Loader.
  47319. * @hidden
  47320. */
  47321. export class _ENVTextureLoader implements IInternalTextureLoader {
  47322. /**
  47323. * Defines wether the loader supports cascade loading the different faces.
  47324. */
  47325. readonly supportCascades: boolean;
  47326. /**
  47327. * This returns if the loader support the current file information.
  47328. * @param extension defines the file extension of the file being loaded
  47329. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47330. * @param fallback defines the fallback internal texture if any
  47331. * @param isBase64 defines whether the texture is encoded as a base64
  47332. * @param isBuffer defines whether the texture data are stored as a buffer
  47333. * @returns true if the loader can load the specified file
  47334. */
  47335. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47336. /**
  47337. * Transform the url before loading if required.
  47338. * @param rootUrl the url of the texture
  47339. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47340. * @returns the transformed texture
  47341. */
  47342. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47343. /**
  47344. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47345. * @param rootUrl the url of the texture
  47346. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47347. * @returns the fallback texture
  47348. */
  47349. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47350. /**
  47351. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47352. * @param data contains the texture data
  47353. * @param texture defines the BabylonJS internal texture
  47354. * @param createPolynomials will be true if polynomials have been requested
  47355. * @param onLoad defines the callback to trigger once the texture is ready
  47356. * @param onError defines the callback to trigger in case of error
  47357. */
  47358. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47359. /**
  47360. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47361. * @param data contains the texture data
  47362. * @param texture defines the BabylonJS internal texture
  47363. * @param callback defines the method to call once ready to upload
  47364. */
  47365. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47366. }
  47367. }
  47368. declare module BABYLON {
  47369. /**
  47370. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47371. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47372. */
  47373. export class KhronosTextureContainer {
  47374. /** contents of the KTX container file */
  47375. arrayBuffer: any;
  47376. private static HEADER_LEN;
  47377. private static COMPRESSED_2D;
  47378. private static COMPRESSED_3D;
  47379. private static TEX_2D;
  47380. private static TEX_3D;
  47381. /**
  47382. * Gets the openGL type
  47383. */
  47384. glType: number;
  47385. /**
  47386. * Gets the openGL type size
  47387. */
  47388. glTypeSize: number;
  47389. /**
  47390. * Gets the openGL format
  47391. */
  47392. glFormat: number;
  47393. /**
  47394. * Gets the openGL internal format
  47395. */
  47396. glInternalFormat: number;
  47397. /**
  47398. * Gets the base internal format
  47399. */
  47400. glBaseInternalFormat: number;
  47401. /**
  47402. * Gets image width in pixel
  47403. */
  47404. pixelWidth: number;
  47405. /**
  47406. * Gets image height in pixel
  47407. */
  47408. pixelHeight: number;
  47409. /**
  47410. * Gets image depth in pixels
  47411. */
  47412. pixelDepth: number;
  47413. /**
  47414. * Gets the number of array elements
  47415. */
  47416. numberOfArrayElements: number;
  47417. /**
  47418. * Gets the number of faces
  47419. */
  47420. numberOfFaces: number;
  47421. /**
  47422. * Gets the number of mipmap levels
  47423. */
  47424. numberOfMipmapLevels: number;
  47425. /**
  47426. * Gets the bytes of key value data
  47427. */
  47428. bytesOfKeyValueData: number;
  47429. /**
  47430. * Gets the load type
  47431. */
  47432. loadType: number;
  47433. /**
  47434. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47435. */
  47436. isInvalid: boolean;
  47437. /**
  47438. * Creates a new KhronosTextureContainer
  47439. * @param arrayBuffer contents of the KTX container file
  47440. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47441. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47442. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47443. */
  47444. constructor(
  47445. /** contents of the KTX container file */
  47446. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47447. /**
  47448. * Uploads KTX content to a Babylon Texture.
  47449. * It is assumed that the texture has already been created & is currently bound
  47450. * @hidden
  47451. */
  47452. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47453. private _upload2DCompressedLevels;
  47454. }
  47455. }
  47456. declare module BABYLON {
  47457. /**
  47458. * Implementation of the KTX Texture Loader.
  47459. * @hidden
  47460. */
  47461. export class _KTXTextureLoader implements IInternalTextureLoader {
  47462. /**
  47463. * Defines wether the loader supports cascade loading the different faces.
  47464. */
  47465. readonly supportCascades: boolean;
  47466. /**
  47467. * This returns if the loader support the current file information.
  47468. * @param extension defines the file extension of the file being loaded
  47469. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47470. * @param fallback defines the fallback internal texture if any
  47471. * @param isBase64 defines whether the texture is encoded as a base64
  47472. * @param isBuffer defines whether the texture data are stored as a buffer
  47473. * @returns true if the loader can load the specified file
  47474. */
  47475. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47476. /**
  47477. * Transform the url before loading if required.
  47478. * @param rootUrl the url of the texture
  47479. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47480. * @returns the transformed texture
  47481. */
  47482. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47483. /**
  47484. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47485. * @param rootUrl the url of the texture
  47486. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47487. * @returns the fallback texture
  47488. */
  47489. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47490. /**
  47491. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47492. * @param data contains the texture data
  47493. * @param texture defines the BabylonJS internal texture
  47494. * @param createPolynomials will be true if polynomials have been requested
  47495. * @param onLoad defines the callback to trigger once the texture is ready
  47496. * @param onError defines the callback to trigger in case of error
  47497. */
  47498. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47499. /**
  47500. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47501. * @param data contains the texture data
  47502. * @param texture defines the BabylonJS internal texture
  47503. * @param callback defines the method to call once ready to upload
  47504. */
  47505. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47506. }
  47507. }
  47508. declare module BABYLON {
  47509. /**
  47510. * Options for the default xr helper
  47511. */
  47512. export class WebXRDefaultExperienceOptions {
  47513. /**
  47514. * Floor meshes that should be used for teleporting
  47515. */
  47516. floorMeshes: Array<AbstractMesh>;
  47517. }
  47518. /**
  47519. * Default experience which provides a similar setup to the previous webVRExperience
  47520. */
  47521. export class WebXRDefaultExperience {
  47522. /**
  47523. * Base experience
  47524. */
  47525. baseExperience: WebXRExperienceHelper;
  47526. /**
  47527. * Input experience extension
  47528. */
  47529. input: WebXRInput;
  47530. /**
  47531. * Loads the controller models
  47532. */
  47533. controllerModelLoader: WebXRControllerModelLoader;
  47534. /**
  47535. * Enables laser pointer and selection
  47536. */
  47537. pointerSelection: WebXRControllerPointerSelection;
  47538. /**
  47539. * Enables teleportation
  47540. */
  47541. teleportation: WebXRControllerTeleportation;
  47542. /**
  47543. * Enables ui for enetering/exiting xr
  47544. */
  47545. enterExitUI: WebXREnterExitUI;
  47546. /**
  47547. * Default output canvas xr should render to
  47548. */
  47549. outputCanvas: WebXRManagedOutputCanvas;
  47550. /**
  47551. * Creates the default xr experience
  47552. * @param scene scene
  47553. * @param options options for basic configuration
  47554. * @returns resulting WebXRDefaultExperience
  47555. */
  47556. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47557. private constructor();
  47558. /**
  47559. * DIsposes of the experience helper
  47560. */
  47561. dispose(): void;
  47562. }
  47563. }
  47564. declare module BABYLON {
  47565. /** @hidden */
  47566. export var _forceSceneHelpersToBundle: boolean;
  47567. interface Scene {
  47568. /**
  47569. * Creates a default light for the scene.
  47570. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47571. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47572. */
  47573. createDefaultLight(replace?: boolean): void;
  47574. /**
  47575. * Creates a default camera for the scene.
  47576. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47577. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47578. * @param replace has default false, when true replaces the active camera in the scene
  47579. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47580. */
  47581. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47582. /**
  47583. * Creates a default camera and a default light.
  47584. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47585. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47586. * @param replace has the default false, when true replaces the active camera/light in the scene
  47587. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47588. */
  47589. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47590. /**
  47591. * Creates a new sky box
  47592. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47593. * @param environmentTexture defines the texture to use as environment texture
  47594. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47595. * @param scale defines the overall scale of the skybox
  47596. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47597. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47598. * @returns a new mesh holding the sky box
  47599. */
  47600. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47601. /**
  47602. * Creates a new environment
  47603. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47604. * @param options defines the options you can use to configure the environment
  47605. * @returns the new EnvironmentHelper
  47606. */
  47607. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47608. /**
  47609. * Creates a new VREXperienceHelper
  47610. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47611. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47612. * @returns a new VREXperienceHelper
  47613. */
  47614. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47615. /**
  47616. * Creates a new WebXRDefaultExperience
  47617. * @see http://doc.babylonjs.com/how_to/webxr
  47618. * @param options experience options
  47619. * @returns a promise for a new WebXRDefaultExperience
  47620. */
  47621. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47622. }
  47623. }
  47624. declare module BABYLON {
  47625. /**
  47626. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47627. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47628. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47629. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47630. */
  47631. export class VideoDome extends TransformNode {
  47632. /**
  47633. * Define the video source as a Monoscopic panoramic 360 video.
  47634. */
  47635. static readonly MODE_MONOSCOPIC: number;
  47636. /**
  47637. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47638. */
  47639. static readonly MODE_TOPBOTTOM: number;
  47640. /**
  47641. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47642. */
  47643. static readonly MODE_SIDEBYSIDE: number;
  47644. private _halfDome;
  47645. private _useDirectMapping;
  47646. /**
  47647. * The video texture being displayed on the sphere
  47648. */
  47649. protected _videoTexture: VideoTexture;
  47650. /**
  47651. * Gets the video texture being displayed on the sphere
  47652. */
  47653. readonly videoTexture: VideoTexture;
  47654. /**
  47655. * The skybox material
  47656. */
  47657. protected _material: BackgroundMaterial;
  47658. /**
  47659. * The surface used for the skybox
  47660. */
  47661. protected _mesh: Mesh;
  47662. /**
  47663. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  47664. */
  47665. private _halfDomeMask;
  47666. /**
  47667. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47668. * Also see the options.resolution property.
  47669. */
  47670. fovMultiplier: number;
  47671. private _videoMode;
  47672. /**
  47673. * Gets or set the current video mode for the video. It can be:
  47674. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47675. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47676. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47677. */
  47678. videoMode: number;
  47679. /**
  47680. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  47681. *
  47682. */
  47683. /**
  47684. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  47685. */
  47686. halfDome: boolean;
  47687. /**
  47688. * Oberserver used in Stereoscopic VR Mode.
  47689. */
  47690. private _onBeforeCameraRenderObserver;
  47691. /**
  47692. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47693. * @param name Element's name, child elements will append suffixes for their own names.
  47694. * @param urlsOrVideo defines the url(s) or the video element to use
  47695. * @param options An object containing optional or exposed sub element properties
  47696. */
  47697. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47698. resolution?: number;
  47699. clickToPlay?: boolean;
  47700. autoPlay?: boolean;
  47701. loop?: boolean;
  47702. size?: number;
  47703. poster?: string;
  47704. faceForward?: boolean;
  47705. useDirectMapping?: boolean;
  47706. halfDomeMode?: boolean;
  47707. }, scene: Scene);
  47708. private _changeVideoMode;
  47709. /**
  47710. * Releases resources associated with this node.
  47711. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47712. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47713. */
  47714. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47715. }
  47716. }
  47717. declare module BABYLON {
  47718. /**
  47719. * This class can be used to get instrumentation data from a Babylon engine
  47720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47721. */
  47722. export class EngineInstrumentation implements IDisposable {
  47723. /**
  47724. * Define the instrumented engine.
  47725. */
  47726. engine: Engine;
  47727. private _captureGPUFrameTime;
  47728. private _gpuFrameTimeToken;
  47729. private _gpuFrameTime;
  47730. private _captureShaderCompilationTime;
  47731. private _shaderCompilationTime;
  47732. private _onBeginFrameObserver;
  47733. private _onEndFrameObserver;
  47734. private _onBeforeShaderCompilationObserver;
  47735. private _onAfterShaderCompilationObserver;
  47736. /**
  47737. * Gets the perf counter used for GPU frame time
  47738. */
  47739. readonly gpuFrameTimeCounter: PerfCounter;
  47740. /**
  47741. * Gets the GPU frame time capture status
  47742. */
  47743. /**
  47744. * Enable or disable the GPU frame time capture
  47745. */
  47746. captureGPUFrameTime: boolean;
  47747. /**
  47748. * Gets the perf counter used for shader compilation time
  47749. */
  47750. readonly shaderCompilationTimeCounter: PerfCounter;
  47751. /**
  47752. * Gets the shader compilation time capture status
  47753. */
  47754. /**
  47755. * Enable or disable the shader compilation time capture
  47756. */
  47757. captureShaderCompilationTime: boolean;
  47758. /**
  47759. * Instantiates a new engine instrumentation.
  47760. * This class can be used to get instrumentation data from a Babylon engine
  47761. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47762. * @param engine Defines the engine to instrument
  47763. */
  47764. constructor(
  47765. /**
  47766. * Define the instrumented engine.
  47767. */
  47768. engine: Engine);
  47769. /**
  47770. * Dispose and release associated resources.
  47771. */
  47772. dispose(): void;
  47773. }
  47774. }
  47775. declare module BABYLON {
  47776. /**
  47777. * This class can be used to get instrumentation data from a Babylon engine
  47778. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47779. */
  47780. export class SceneInstrumentation implements IDisposable {
  47781. /**
  47782. * Defines the scene to instrument
  47783. */
  47784. scene: Scene;
  47785. private _captureActiveMeshesEvaluationTime;
  47786. private _activeMeshesEvaluationTime;
  47787. private _captureRenderTargetsRenderTime;
  47788. private _renderTargetsRenderTime;
  47789. private _captureFrameTime;
  47790. private _frameTime;
  47791. private _captureRenderTime;
  47792. private _renderTime;
  47793. private _captureInterFrameTime;
  47794. private _interFrameTime;
  47795. private _captureParticlesRenderTime;
  47796. private _particlesRenderTime;
  47797. private _captureSpritesRenderTime;
  47798. private _spritesRenderTime;
  47799. private _capturePhysicsTime;
  47800. private _physicsTime;
  47801. private _captureAnimationsTime;
  47802. private _animationsTime;
  47803. private _captureCameraRenderTime;
  47804. private _cameraRenderTime;
  47805. private _onBeforeActiveMeshesEvaluationObserver;
  47806. private _onAfterActiveMeshesEvaluationObserver;
  47807. private _onBeforeRenderTargetsRenderObserver;
  47808. private _onAfterRenderTargetsRenderObserver;
  47809. private _onAfterRenderObserver;
  47810. private _onBeforeDrawPhaseObserver;
  47811. private _onAfterDrawPhaseObserver;
  47812. private _onBeforeAnimationsObserver;
  47813. private _onBeforeParticlesRenderingObserver;
  47814. private _onAfterParticlesRenderingObserver;
  47815. private _onBeforeSpritesRenderingObserver;
  47816. private _onAfterSpritesRenderingObserver;
  47817. private _onBeforePhysicsObserver;
  47818. private _onAfterPhysicsObserver;
  47819. private _onAfterAnimationsObserver;
  47820. private _onBeforeCameraRenderObserver;
  47821. private _onAfterCameraRenderObserver;
  47822. /**
  47823. * Gets the perf counter used for active meshes evaluation time
  47824. */
  47825. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47826. /**
  47827. * Gets the active meshes evaluation time capture status
  47828. */
  47829. /**
  47830. * Enable or disable the active meshes evaluation time capture
  47831. */
  47832. captureActiveMeshesEvaluationTime: boolean;
  47833. /**
  47834. * Gets the perf counter used for render targets render time
  47835. */
  47836. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47837. /**
  47838. * Gets the render targets render time capture status
  47839. */
  47840. /**
  47841. * Enable or disable the render targets render time capture
  47842. */
  47843. captureRenderTargetsRenderTime: boolean;
  47844. /**
  47845. * Gets the perf counter used for particles render time
  47846. */
  47847. readonly particlesRenderTimeCounter: PerfCounter;
  47848. /**
  47849. * Gets the particles render time capture status
  47850. */
  47851. /**
  47852. * Enable or disable the particles render time capture
  47853. */
  47854. captureParticlesRenderTime: boolean;
  47855. /**
  47856. * Gets the perf counter used for sprites render time
  47857. */
  47858. readonly spritesRenderTimeCounter: PerfCounter;
  47859. /**
  47860. * Gets the sprites render time capture status
  47861. */
  47862. /**
  47863. * Enable or disable the sprites render time capture
  47864. */
  47865. captureSpritesRenderTime: boolean;
  47866. /**
  47867. * Gets the perf counter used for physics time
  47868. */
  47869. readonly physicsTimeCounter: PerfCounter;
  47870. /**
  47871. * Gets the physics time capture status
  47872. */
  47873. /**
  47874. * Enable or disable the physics time capture
  47875. */
  47876. capturePhysicsTime: boolean;
  47877. /**
  47878. * Gets the perf counter used for animations time
  47879. */
  47880. readonly animationsTimeCounter: PerfCounter;
  47881. /**
  47882. * Gets the animations time capture status
  47883. */
  47884. /**
  47885. * Enable or disable the animations time capture
  47886. */
  47887. captureAnimationsTime: boolean;
  47888. /**
  47889. * Gets the perf counter used for frame time capture
  47890. */
  47891. readonly frameTimeCounter: PerfCounter;
  47892. /**
  47893. * Gets the frame time capture status
  47894. */
  47895. /**
  47896. * Enable or disable the frame time capture
  47897. */
  47898. captureFrameTime: boolean;
  47899. /**
  47900. * Gets the perf counter used for inter-frames time capture
  47901. */
  47902. readonly interFrameTimeCounter: PerfCounter;
  47903. /**
  47904. * Gets the inter-frames time capture status
  47905. */
  47906. /**
  47907. * Enable or disable the inter-frames time capture
  47908. */
  47909. captureInterFrameTime: boolean;
  47910. /**
  47911. * Gets the perf counter used for render time capture
  47912. */
  47913. readonly renderTimeCounter: PerfCounter;
  47914. /**
  47915. * Gets the render time capture status
  47916. */
  47917. /**
  47918. * Enable or disable the render time capture
  47919. */
  47920. captureRenderTime: boolean;
  47921. /**
  47922. * Gets the perf counter used for camera render time capture
  47923. */
  47924. readonly cameraRenderTimeCounter: PerfCounter;
  47925. /**
  47926. * Gets the camera render time capture status
  47927. */
  47928. /**
  47929. * Enable or disable the camera render time capture
  47930. */
  47931. captureCameraRenderTime: boolean;
  47932. /**
  47933. * Gets the perf counter used for draw calls
  47934. */
  47935. readonly drawCallsCounter: PerfCounter;
  47936. /**
  47937. * Instantiates a new scene instrumentation.
  47938. * This class can be used to get instrumentation data from a Babylon engine
  47939. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47940. * @param scene Defines the scene to instrument
  47941. */
  47942. constructor(
  47943. /**
  47944. * Defines the scene to instrument
  47945. */
  47946. scene: Scene);
  47947. /**
  47948. * Dispose and release associated resources.
  47949. */
  47950. dispose(): void;
  47951. }
  47952. }
  47953. declare module BABYLON {
  47954. /** @hidden */
  47955. export var glowMapGenerationPixelShader: {
  47956. name: string;
  47957. shader: string;
  47958. };
  47959. }
  47960. declare module BABYLON {
  47961. /** @hidden */
  47962. export var glowMapGenerationVertexShader: {
  47963. name: string;
  47964. shader: string;
  47965. };
  47966. }
  47967. declare module BABYLON {
  47968. /**
  47969. * Effect layer options. This helps customizing the behaviour
  47970. * of the effect layer.
  47971. */
  47972. export interface IEffectLayerOptions {
  47973. /**
  47974. * Multiplication factor apply to the canvas size to compute the render target size
  47975. * used to generated the objects (the smaller the faster).
  47976. */
  47977. mainTextureRatio: number;
  47978. /**
  47979. * Enforces a fixed size texture to ensure effect stability across devices.
  47980. */
  47981. mainTextureFixedSize?: number;
  47982. /**
  47983. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47984. */
  47985. alphaBlendingMode: number;
  47986. /**
  47987. * The camera attached to the layer.
  47988. */
  47989. camera: Nullable<Camera>;
  47990. /**
  47991. * The rendering group to draw the layer in.
  47992. */
  47993. renderingGroupId: number;
  47994. }
  47995. /**
  47996. * The effect layer Helps adding post process effect blended with the main pass.
  47997. *
  47998. * This can be for instance use to generate glow or higlight effects on the scene.
  47999. *
  48000. * The effect layer class can not be used directly and is intented to inherited from to be
  48001. * customized per effects.
  48002. */
  48003. export abstract class EffectLayer {
  48004. private _vertexBuffers;
  48005. private _indexBuffer;
  48006. private _cachedDefines;
  48007. private _effectLayerMapGenerationEffect;
  48008. private _effectLayerOptions;
  48009. private _mergeEffect;
  48010. protected _scene: Scene;
  48011. protected _engine: Engine;
  48012. protected _maxSize: number;
  48013. protected _mainTextureDesiredSize: ISize;
  48014. protected _mainTexture: RenderTargetTexture;
  48015. protected _shouldRender: boolean;
  48016. protected _postProcesses: PostProcess[];
  48017. protected _textures: BaseTexture[];
  48018. protected _emissiveTextureAndColor: {
  48019. texture: Nullable<BaseTexture>;
  48020. color: Color4;
  48021. };
  48022. /**
  48023. * The name of the layer
  48024. */
  48025. name: string;
  48026. /**
  48027. * The clear color of the texture used to generate the glow map.
  48028. */
  48029. neutralColor: Color4;
  48030. /**
  48031. * Specifies wether the highlight layer is enabled or not.
  48032. */
  48033. isEnabled: boolean;
  48034. /**
  48035. * Gets the camera attached to the layer.
  48036. */
  48037. readonly camera: Nullable<Camera>;
  48038. /**
  48039. * Gets the rendering group id the layer should render in.
  48040. */
  48041. renderingGroupId: number;
  48042. /**
  48043. * An event triggered when the effect layer has been disposed.
  48044. */
  48045. onDisposeObservable: Observable<EffectLayer>;
  48046. /**
  48047. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48048. */
  48049. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48050. /**
  48051. * An event triggered when the generated texture is being merged in the scene.
  48052. */
  48053. onBeforeComposeObservable: Observable<EffectLayer>;
  48054. /**
  48055. * An event triggered when the generated texture has been merged in the scene.
  48056. */
  48057. onAfterComposeObservable: Observable<EffectLayer>;
  48058. /**
  48059. * An event triggered when the efffect layer changes its size.
  48060. */
  48061. onSizeChangedObservable: Observable<EffectLayer>;
  48062. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48063. /**
  48064. * Instantiates a new effect Layer and references it in the scene.
  48065. * @param name The name of the layer
  48066. * @param scene The scene to use the layer in
  48067. */
  48068. constructor(
  48069. /** The Friendly of the effect in the scene */
  48070. name: string, scene: Scene);
  48071. /**
  48072. * Get the effect name of the layer.
  48073. * @return The effect name
  48074. */
  48075. abstract getEffectName(): string;
  48076. /**
  48077. * Checks for the readiness of the element composing the layer.
  48078. * @param subMesh the mesh to check for
  48079. * @param useInstances specify wether or not to use instances to render the mesh
  48080. * @return true if ready otherwise, false
  48081. */
  48082. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48083. /**
  48084. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48085. * @returns true if the effect requires stencil during the main canvas render pass.
  48086. */
  48087. abstract needStencil(): boolean;
  48088. /**
  48089. * Create the merge effect. This is the shader use to blit the information back
  48090. * to the main canvas at the end of the scene rendering.
  48091. * @returns The effect containing the shader used to merge the effect on the main canvas
  48092. */
  48093. protected abstract _createMergeEffect(): Effect;
  48094. /**
  48095. * Creates the render target textures and post processes used in the effect layer.
  48096. */
  48097. protected abstract _createTextureAndPostProcesses(): void;
  48098. /**
  48099. * Implementation specific of rendering the generating effect on the main canvas.
  48100. * @param effect The effect used to render through
  48101. */
  48102. protected abstract _internalRender(effect: Effect): void;
  48103. /**
  48104. * Sets the required values for both the emissive texture and and the main color.
  48105. */
  48106. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48107. /**
  48108. * Free any resources and references associated to a mesh.
  48109. * Internal use
  48110. * @param mesh The mesh to free.
  48111. */
  48112. abstract _disposeMesh(mesh: Mesh): void;
  48113. /**
  48114. * Serializes this layer (Glow or Highlight for example)
  48115. * @returns a serialized layer object
  48116. */
  48117. abstract serialize?(): any;
  48118. /**
  48119. * Initializes the effect layer with the required options.
  48120. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48121. */
  48122. protected _init(options: Partial<IEffectLayerOptions>): void;
  48123. /**
  48124. * Generates the index buffer of the full screen quad blending to the main canvas.
  48125. */
  48126. private _generateIndexBuffer;
  48127. /**
  48128. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48129. */
  48130. private _generateVertexBuffer;
  48131. /**
  48132. * Sets the main texture desired size which is the closest power of two
  48133. * of the engine canvas size.
  48134. */
  48135. private _setMainTextureSize;
  48136. /**
  48137. * Creates the main texture for the effect layer.
  48138. */
  48139. protected _createMainTexture(): void;
  48140. /**
  48141. * Adds specific effects defines.
  48142. * @param defines The defines to add specifics to.
  48143. */
  48144. protected _addCustomEffectDefines(defines: string[]): void;
  48145. /**
  48146. * Checks for the readiness of the element composing the layer.
  48147. * @param subMesh the mesh to check for
  48148. * @param useInstances specify wether or not to use instances to render the mesh
  48149. * @param emissiveTexture the associated emissive texture used to generate the glow
  48150. * @return true if ready otherwise, false
  48151. */
  48152. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48153. /**
  48154. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48155. */
  48156. render(): void;
  48157. /**
  48158. * Determine if a given mesh will be used in the current effect.
  48159. * @param mesh mesh to test
  48160. * @returns true if the mesh will be used
  48161. */
  48162. hasMesh(mesh: AbstractMesh): boolean;
  48163. /**
  48164. * Returns true if the layer contains information to display, otherwise false.
  48165. * @returns true if the glow layer should be rendered
  48166. */
  48167. shouldRender(): boolean;
  48168. /**
  48169. * Returns true if the mesh should render, otherwise false.
  48170. * @param mesh The mesh to render
  48171. * @returns true if it should render otherwise false
  48172. */
  48173. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48174. /**
  48175. * Returns true if the mesh can be rendered, otherwise false.
  48176. * @param mesh The mesh to render
  48177. * @param material The material used on the mesh
  48178. * @returns true if it can be rendered otherwise false
  48179. */
  48180. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48181. /**
  48182. * Returns true if the mesh should render, otherwise false.
  48183. * @param mesh The mesh to render
  48184. * @returns true if it should render otherwise false
  48185. */
  48186. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48187. /**
  48188. * Renders the submesh passed in parameter to the generation map.
  48189. */
  48190. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48191. /**
  48192. * Rebuild the required buffers.
  48193. * @hidden Internal use only.
  48194. */ private _rebuild(): void;
  48195. /**
  48196. * Dispose only the render target textures and post process.
  48197. */
  48198. private _disposeTextureAndPostProcesses;
  48199. /**
  48200. * Dispose the highlight layer and free resources.
  48201. */
  48202. dispose(): void;
  48203. /**
  48204. * Gets the class name of the effect layer
  48205. * @returns the string with the class name of the effect layer
  48206. */
  48207. getClassName(): string;
  48208. /**
  48209. * Creates an effect layer from parsed effect layer data
  48210. * @param parsedEffectLayer defines effect layer data
  48211. * @param scene defines the current scene
  48212. * @param rootUrl defines the root URL containing the effect layer information
  48213. * @returns a parsed effect Layer
  48214. */
  48215. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48216. }
  48217. }
  48218. declare module BABYLON {
  48219. interface AbstractScene {
  48220. /**
  48221. * The list of effect layers (highlights/glow) added to the scene
  48222. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48223. * @see http://doc.babylonjs.com/how_to/glow_layer
  48224. */
  48225. effectLayers: Array<EffectLayer>;
  48226. /**
  48227. * Removes the given effect layer from this scene.
  48228. * @param toRemove defines the effect layer to remove
  48229. * @returns the index of the removed effect layer
  48230. */
  48231. removeEffectLayer(toRemove: EffectLayer): number;
  48232. /**
  48233. * Adds the given effect layer to this scene
  48234. * @param newEffectLayer defines the effect layer to add
  48235. */
  48236. addEffectLayer(newEffectLayer: EffectLayer): void;
  48237. }
  48238. /**
  48239. * Defines the layer scene component responsible to manage any effect layers
  48240. * in a given scene.
  48241. */
  48242. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48243. /**
  48244. * The component name helpfull to identify the component in the list of scene components.
  48245. */
  48246. readonly name: string;
  48247. /**
  48248. * The scene the component belongs to.
  48249. */
  48250. scene: Scene;
  48251. private _engine;
  48252. private _renderEffects;
  48253. private _needStencil;
  48254. private _previousStencilState;
  48255. /**
  48256. * Creates a new instance of the component for the given scene
  48257. * @param scene Defines the scene to register the component in
  48258. */
  48259. constructor(scene: Scene);
  48260. /**
  48261. * Registers the component in a given scene
  48262. */
  48263. register(): void;
  48264. /**
  48265. * Rebuilds the elements related to this component in case of
  48266. * context lost for instance.
  48267. */
  48268. rebuild(): void;
  48269. /**
  48270. * Serializes the component data to the specified json object
  48271. * @param serializationObject The object to serialize to
  48272. */
  48273. serialize(serializationObject: any): void;
  48274. /**
  48275. * Adds all the elements from the container to the scene
  48276. * @param container the container holding the elements
  48277. */
  48278. addFromContainer(container: AbstractScene): void;
  48279. /**
  48280. * Removes all the elements in the container from the scene
  48281. * @param container contains the elements to remove
  48282. * @param dispose if the removed element should be disposed (default: false)
  48283. */
  48284. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48285. /**
  48286. * Disposes the component and the associated ressources.
  48287. */
  48288. dispose(): void;
  48289. private _isReadyForMesh;
  48290. private _renderMainTexture;
  48291. private _setStencil;
  48292. private _setStencilBack;
  48293. private _draw;
  48294. private _drawCamera;
  48295. private _drawRenderingGroup;
  48296. }
  48297. }
  48298. declare module BABYLON {
  48299. /** @hidden */
  48300. export var glowMapMergePixelShader: {
  48301. name: string;
  48302. shader: string;
  48303. };
  48304. }
  48305. declare module BABYLON {
  48306. /** @hidden */
  48307. export var glowMapMergeVertexShader: {
  48308. name: string;
  48309. shader: string;
  48310. };
  48311. }
  48312. declare module BABYLON {
  48313. interface AbstractScene {
  48314. /**
  48315. * Return a the first highlight layer of the scene with a given name.
  48316. * @param name The name of the highlight layer to look for.
  48317. * @return The highlight layer if found otherwise null.
  48318. */
  48319. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48320. }
  48321. /**
  48322. * Glow layer options. This helps customizing the behaviour
  48323. * of the glow layer.
  48324. */
  48325. export interface IGlowLayerOptions {
  48326. /**
  48327. * Multiplication factor apply to the canvas size to compute the render target size
  48328. * used to generated the glowing objects (the smaller the faster).
  48329. */
  48330. mainTextureRatio: number;
  48331. /**
  48332. * Enforces a fixed size texture to ensure resize independant blur.
  48333. */
  48334. mainTextureFixedSize?: number;
  48335. /**
  48336. * How big is the kernel of the blur texture.
  48337. */
  48338. blurKernelSize: number;
  48339. /**
  48340. * The camera attached to the layer.
  48341. */
  48342. camera: Nullable<Camera>;
  48343. /**
  48344. * Enable MSAA by chosing the number of samples.
  48345. */
  48346. mainTextureSamples?: number;
  48347. /**
  48348. * The rendering group to draw the layer in.
  48349. */
  48350. renderingGroupId: number;
  48351. }
  48352. /**
  48353. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48354. *
  48355. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48356. * glowy meshes to your scene.
  48357. *
  48358. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48359. */
  48360. export class GlowLayer extends EffectLayer {
  48361. /**
  48362. * Effect Name of the layer.
  48363. */
  48364. static readonly EffectName: string;
  48365. /**
  48366. * The default blur kernel size used for the glow.
  48367. */
  48368. static DefaultBlurKernelSize: number;
  48369. /**
  48370. * The default texture size ratio used for the glow.
  48371. */
  48372. static DefaultTextureRatio: number;
  48373. /**
  48374. * Sets the kernel size of the blur.
  48375. */
  48376. /**
  48377. * Gets the kernel size of the blur.
  48378. */
  48379. blurKernelSize: number;
  48380. /**
  48381. * Sets the glow intensity.
  48382. */
  48383. /**
  48384. * Gets the glow intensity.
  48385. */
  48386. intensity: number;
  48387. private _options;
  48388. private _intensity;
  48389. private _horizontalBlurPostprocess1;
  48390. private _verticalBlurPostprocess1;
  48391. private _horizontalBlurPostprocess2;
  48392. private _verticalBlurPostprocess2;
  48393. private _blurTexture1;
  48394. private _blurTexture2;
  48395. private _postProcesses1;
  48396. private _postProcesses2;
  48397. private _includedOnlyMeshes;
  48398. private _excludedMeshes;
  48399. /**
  48400. * Callback used to let the user override the color selection on a per mesh basis
  48401. */
  48402. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48403. /**
  48404. * Callback used to let the user override the texture selection on a per mesh basis
  48405. */
  48406. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48407. /**
  48408. * Instantiates a new glow Layer and references it to the scene.
  48409. * @param name The name of the layer
  48410. * @param scene The scene to use the layer in
  48411. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48412. */
  48413. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48414. /**
  48415. * Get the effect name of the layer.
  48416. * @return The effect name
  48417. */
  48418. getEffectName(): string;
  48419. /**
  48420. * Create the merge effect. This is the shader use to blit the information back
  48421. * to the main canvas at the end of the scene rendering.
  48422. */
  48423. protected _createMergeEffect(): Effect;
  48424. /**
  48425. * Creates the render target textures and post processes used in the glow layer.
  48426. */
  48427. protected _createTextureAndPostProcesses(): void;
  48428. /**
  48429. * Checks for the readiness of the element composing the layer.
  48430. * @param subMesh the mesh to check for
  48431. * @param useInstances specify wether or not to use instances to render the mesh
  48432. * @param emissiveTexture the associated emissive texture used to generate the glow
  48433. * @return true if ready otherwise, false
  48434. */
  48435. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48436. /**
  48437. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48438. */
  48439. needStencil(): boolean;
  48440. /**
  48441. * Returns true if the mesh can be rendered, otherwise false.
  48442. * @param mesh The mesh to render
  48443. * @param material The material used on the mesh
  48444. * @returns true if it can be rendered otherwise false
  48445. */
  48446. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48447. /**
  48448. * Implementation specific of rendering the generating effect on the main canvas.
  48449. * @param effect The effect used to render through
  48450. */
  48451. protected _internalRender(effect: Effect): void;
  48452. /**
  48453. * Sets the required values for both the emissive texture and and the main color.
  48454. */
  48455. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48456. /**
  48457. * Returns true if the mesh should render, otherwise false.
  48458. * @param mesh The mesh to render
  48459. * @returns true if it should render otherwise false
  48460. */
  48461. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48462. /**
  48463. * Adds specific effects defines.
  48464. * @param defines The defines to add specifics to.
  48465. */
  48466. protected _addCustomEffectDefines(defines: string[]): void;
  48467. /**
  48468. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48469. * @param mesh The mesh to exclude from the glow layer
  48470. */
  48471. addExcludedMesh(mesh: Mesh): void;
  48472. /**
  48473. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48474. * @param mesh The mesh to remove
  48475. */
  48476. removeExcludedMesh(mesh: Mesh): void;
  48477. /**
  48478. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48479. * @param mesh The mesh to include in the glow layer
  48480. */
  48481. addIncludedOnlyMesh(mesh: Mesh): void;
  48482. /**
  48483. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48484. * @param mesh The mesh to remove
  48485. */
  48486. removeIncludedOnlyMesh(mesh: Mesh): void;
  48487. /**
  48488. * Determine if a given mesh will be used in the glow layer
  48489. * @param mesh The mesh to test
  48490. * @returns true if the mesh will be highlighted by the current glow layer
  48491. */
  48492. hasMesh(mesh: AbstractMesh): boolean;
  48493. /**
  48494. * Free any resources and references associated to a mesh.
  48495. * Internal use
  48496. * @param mesh The mesh to free.
  48497. * @hidden
  48498. */ private _disposeMesh(mesh: Mesh): void;
  48499. /**
  48500. * Gets the class name of the effect layer
  48501. * @returns the string with the class name of the effect layer
  48502. */
  48503. getClassName(): string;
  48504. /**
  48505. * Serializes this glow layer
  48506. * @returns a serialized glow layer object
  48507. */
  48508. serialize(): any;
  48509. /**
  48510. * Creates a Glow Layer from parsed glow layer data
  48511. * @param parsedGlowLayer defines glow layer data
  48512. * @param scene defines the current scene
  48513. * @param rootUrl defines the root URL containing the glow layer information
  48514. * @returns a parsed Glow Layer
  48515. */
  48516. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48517. }
  48518. }
  48519. declare module BABYLON {
  48520. /** @hidden */
  48521. export var glowBlurPostProcessPixelShader: {
  48522. name: string;
  48523. shader: string;
  48524. };
  48525. }
  48526. declare module BABYLON {
  48527. interface AbstractScene {
  48528. /**
  48529. * Return a the first highlight layer of the scene with a given name.
  48530. * @param name The name of the highlight layer to look for.
  48531. * @return The highlight layer if found otherwise null.
  48532. */
  48533. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48534. }
  48535. /**
  48536. * Highlight layer options. This helps customizing the behaviour
  48537. * of the highlight layer.
  48538. */
  48539. export interface IHighlightLayerOptions {
  48540. /**
  48541. * Multiplication factor apply to the canvas size to compute the render target size
  48542. * used to generated the glowing objects (the smaller the faster).
  48543. */
  48544. mainTextureRatio: number;
  48545. /**
  48546. * Enforces a fixed size texture to ensure resize independant blur.
  48547. */
  48548. mainTextureFixedSize?: number;
  48549. /**
  48550. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48551. * of the picture to blur (the smaller the faster).
  48552. */
  48553. blurTextureSizeRatio: number;
  48554. /**
  48555. * How big in texel of the blur texture is the vertical blur.
  48556. */
  48557. blurVerticalSize: number;
  48558. /**
  48559. * How big in texel of the blur texture is the horizontal blur.
  48560. */
  48561. blurHorizontalSize: number;
  48562. /**
  48563. * Alpha blending mode used to apply the blur. Default is combine.
  48564. */
  48565. alphaBlendingMode: number;
  48566. /**
  48567. * The camera attached to the layer.
  48568. */
  48569. camera: Nullable<Camera>;
  48570. /**
  48571. * Should we display highlight as a solid stroke?
  48572. */
  48573. isStroke?: boolean;
  48574. /**
  48575. * The rendering group to draw the layer in.
  48576. */
  48577. renderingGroupId: number;
  48578. }
  48579. /**
  48580. * The highlight layer Helps adding a glow effect around a mesh.
  48581. *
  48582. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48583. * glowy meshes to your scene.
  48584. *
  48585. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48586. */
  48587. export class HighlightLayer extends EffectLayer {
  48588. name: string;
  48589. /**
  48590. * Effect Name of the highlight layer.
  48591. */
  48592. static readonly EffectName: string;
  48593. /**
  48594. * The neutral color used during the preparation of the glow effect.
  48595. * This is black by default as the blend operation is a blend operation.
  48596. */
  48597. static NeutralColor: Color4;
  48598. /**
  48599. * Stencil value used for glowing meshes.
  48600. */
  48601. static GlowingMeshStencilReference: number;
  48602. /**
  48603. * Stencil value used for the other meshes in the scene.
  48604. */
  48605. static NormalMeshStencilReference: number;
  48606. /**
  48607. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48608. */
  48609. innerGlow: boolean;
  48610. /**
  48611. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48612. */
  48613. outerGlow: boolean;
  48614. /**
  48615. * Specifies the horizontal size of the blur.
  48616. */
  48617. /**
  48618. * Gets the horizontal size of the blur.
  48619. */
  48620. blurHorizontalSize: number;
  48621. /**
  48622. * Specifies the vertical size of the blur.
  48623. */
  48624. /**
  48625. * Gets the vertical size of the blur.
  48626. */
  48627. blurVerticalSize: number;
  48628. /**
  48629. * An event triggered when the highlight layer is being blurred.
  48630. */
  48631. onBeforeBlurObservable: Observable<HighlightLayer>;
  48632. /**
  48633. * An event triggered when the highlight layer has been blurred.
  48634. */
  48635. onAfterBlurObservable: Observable<HighlightLayer>;
  48636. private _instanceGlowingMeshStencilReference;
  48637. private _options;
  48638. private _downSamplePostprocess;
  48639. private _horizontalBlurPostprocess;
  48640. private _verticalBlurPostprocess;
  48641. private _blurTexture;
  48642. private _meshes;
  48643. private _excludedMeshes;
  48644. /**
  48645. * Instantiates a new highlight Layer and references it to the scene..
  48646. * @param name The name of the layer
  48647. * @param scene The scene to use the layer in
  48648. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48649. */
  48650. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48651. /**
  48652. * Get the effect name of the layer.
  48653. * @return The effect name
  48654. */
  48655. getEffectName(): string;
  48656. /**
  48657. * Create the merge effect. This is the shader use to blit the information back
  48658. * to the main canvas at the end of the scene rendering.
  48659. */
  48660. protected _createMergeEffect(): Effect;
  48661. /**
  48662. * Creates the render target textures and post processes used in the highlight layer.
  48663. */
  48664. protected _createTextureAndPostProcesses(): void;
  48665. /**
  48666. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48667. */
  48668. needStencil(): boolean;
  48669. /**
  48670. * Checks for the readiness of the element composing the layer.
  48671. * @param subMesh the mesh to check for
  48672. * @param useInstances specify wether or not to use instances to render the mesh
  48673. * @param emissiveTexture the associated emissive texture used to generate the glow
  48674. * @return true if ready otherwise, false
  48675. */
  48676. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48677. /**
  48678. * Implementation specific of rendering the generating effect on the main canvas.
  48679. * @param effect The effect used to render through
  48680. */
  48681. protected _internalRender(effect: Effect): void;
  48682. /**
  48683. * Returns true if the layer contains information to display, otherwise false.
  48684. */
  48685. shouldRender(): boolean;
  48686. /**
  48687. * Returns true if the mesh should render, otherwise false.
  48688. * @param mesh The mesh to render
  48689. * @returns true if it should render otherwise false
  48690. */
  48691. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48692. /**
  48693. * Sets the required values for both the emissive texture and and the main color.
  48694. */
  48695. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48696. /**
  48697. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48698. * @param mesh The mesh to exclude from the highlight layer
  48699. */
  48700. addExcludedMesh(mesh: Mesh): void;
  48701. /**
  48702. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48703. * @param mesh The mesh to highlight
  48704. */
  48705. removeExcludedMesh(mesh: Mesh): void;
  48706. /**
  48707. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48708. * @param mesh mesh to test
  48709. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48710. */
  48711. hasMesh(mesh: AbstractMesh): boolean;
  48712. /**
  48713. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48714. * @param mesh The mesh to highlight
  48715. * @param color The color of the highlight
  48716. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48717. */
  48718. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48719. /**
  48720. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48721. * @param mesh The mesh to highlight
  48722. */
  48723. removeMesh(mesh: Mesh): void;
  48724. /**
  48725. * Force the stencil to the normal expected value for none glowing parts
  48726. */
  48727. private _defaultStencilReference;
  48728. /**
  48729. * Free any resources and references associated to a mesh.
  48730. * Internal use
  48731. * @param mesh The mesh to free.
  48732. * @hidden
  48733. */ private _disposeMesh(mesh: Mesh): void;
  48734. /**
  48735. * Dispose the highlight layer and free resources.
  48736. */
  48737. dispose(): void;
  48738. /**
  48739. * Gets the class name of the effect layer
  48740. * @returns the string with the class name of the effect layer
  48741. */
  48742. getClassName(): string;
  48743. /**
  48744. * Serializes this Highlight layer
  48745. * @returns a serialized Highlight layer object
  48746. */
  48747. serialize(): any;
  48748. /**
  48749. * Creates a Highlight layer from parsed Highlight layer data
  48750. * @param parsedHightlightLayer defines the Highlight layer data
  48751. * @param scene defines the current scene
  48752. * @param rootUrl defines the root URL containing the Highlight layer information
  48753. * @returns a parsed Highlight layer
  48754. */
  48755. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48756. }
  48757. }
  48758. declare module BABYLON {
  48759. interface AbstractScene {
  48760. /**
  48761. * The list of layers (background and foreground) of the scene
  48762. */
  48763. layers: Array<Layer>;
  48764. }
  48765. /**
  48766. * Defines the layer scene component responsible to manage any layers
  48767. * in a given scene.
  48768. */
  48769. export class LayerSceneComponent implements ISceneComponent {
  48770. /**
  48771. * The component name helpfull to identify the component in the list of scene components.
  48772. */
  48773. readonly name: string;
  48774. /**
  48775. * The scene the component belongs to.
  48776. */
  48777. scene: Scene;
  48778. private _engine;
  48779. /**
  48780. * Creates a new instance of the component for the given scene
  48781. * @param scene Defines the scene to register the component in
  48782. */
  48783. constructor(scene: Scene);
  48784. /**
  48785. * Registers the component in a given scene
  48786. */
  48787. register(): void;
  48788. /**
  48789. * Rebuilds the elements related to this component in case of
  48790. * context lost for instance.
  48791. */
  48792. rebuild(): void;
  48793. /**
  48794. * Disposes the component and the associated ressources.
  48795. */
  48796. dispose(): void;
  48797. private _draw;
  48798. private _drawCameraPredicate;
  48799. private _drawCameraBackground;
  48800. private _drawCameraForeground;
  48801. private _drawRenderTargetPredicate;
  48802. private _drawRenderTargetBackground;
  48803. private _drawRenderTargetForeground;
  48804. /**
  48805. * Adds all the elements from the container to the scene
  48806. * @param container the container holding the elements
  48807. */
  48808. addFromContainer(container: AbstractScene): void;
  48809. /**
  48810. * Removes all the elements in the container from the scene
  48811. * @param container contains the elements to remove
  48812. * @param dispose if the removed element should be disposed (default: false)
  48813. */
  48814. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48815. }
  48816. }
  48817. declare module BABYLON {
  48818. /** @hidden */
  48819. export var layerPixelShader: {
  48820. name: string;
  48821. shader: string;
  48822. };
  48823. }
  48824. declare module BABYLON {
  48825. /** @hidden */
  48826. export var layerVertexShader: {
  48827. name: string;
  48828. shader: string;
  48829. };
  48830. }
  48831. declare module BABYLON {
  48832. /**
  48833. * This represents a full screen 2d layer.
  48834. * This can be useful to display a picture in the background of your scene for instance.
  48835. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48836. */
  48837. export class Layer {
  48838. /**
  48839. * Define the name of the layer.
  48840. */
  48841. name: string;
  48842. /**
  48843. * Define the texture the layer should display.
  48844. */
  48845. texture: Nullable<Texture>;
  48846. /**
  48847. * Is the layer in background or foreground.
  48848. */
  48849. isBackground: boolean;
  48850. /**
  48851. * Define the color of the layer (instead of texture).
  48852. */
  48853. color: Color4;
  48854. /**
  48855. * Define the scale of the layer in order to zoom in out of the texture.
  48856. */
  48857. scale: Vector2;
  48858. /**
  48859. * Define an offset for the layer in order to shift the texture.
  48860. */
  48861. offset: Vector2;
  48862. /**
  48863. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48864. */
  48865. alphaBlendingMode: number;
  48866. /**
  48867. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48868. * Alpha test will not mix with the background color in case of transparency.
  48869. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48870. */
  48871. alphaTest: boolean;
  48872. /**
  48873. * Define a mask to restrict the layer to only some of the scene cameras.
  48874. */
  48875. layerMask: number;
  48876. /**
  48877. * Define the list of render target the layer is visible into.
  48878. */
  48879. renderTargetTextures: RenderTargetTexture[];
  48880. /**
  48881. * Define if the layer is only used in renderTarget or if it also
  48882. * renders in the main frame buffer of the canvas.
  48883. */
  48884. renderOnlyInRenderTargetTextures: boolean;
  48885. private _scene;
  48886. private _vertexBuffers;
  48887. private _indexBuffer;
  48888. private _effect;
  48889. private _alphaTestEffect;
  48890. /**
  48891. * An event triggered when the layer is disposed.
  48892. */
  48893. onDisposeObservable: Observable<Layer>;
  48894. private _onDisposeObserver;
  48895. /**
  48896. * Back compatibility with callback before the onDisposeObservable existed.
  48897. * The set callback will be triggered when the layer has been disposed.
  48898. */
  48899. onDispose: () => void;
  48900. /**
  48901. * An event triggered before rendering the scene
  48902. */
  48903. onBeforeRenderObservable: Observable<Layer>;
  48904. private _onBeforeRenderObserver;
  48905. /**
  48906. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48907. * The set callback will be triggered just before rendering the layer.
  48908. */
  48909. onBeforeRender: () => void;
  48910. /**
  48911. * An event triggered after rendering the scene
  48912. */
  48913. onAfterRenderObservable: Observable<Layer>;
  48914. private _onAfterRenderObserver;
  48915. /**
  48916. * Back compatibility with callback before the onAfterRenderObservable existed.
  48917. * The set callback will be triggered just after rendering the layer.
  48918. */
  48919. onAfterRender: () => void;
  48920. /**
  48921. * Instantiates a new layer.
  48922. * This represents a full screen 2d layer.
  48923. * This can be useful to display a picture in the background of your scene for instance.
  48924. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48925. * @param name Define the name of the layer in the scene
  48926. * @param imgUrl Define the url of the texture to display in the layer
  48927. * @param scene Define the scene the layer belongs to
  48928. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48929. * @param color Defines a color for the layer
  48930. */
  48931. constructor(
  48932. /**
  48933. * Define the name of the layer.
  48934. */
  48935. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48936. private _createIndexBuffer;
  48937. /** @hidden */ private _rebuild(): void;
  48938. /**
  48939. * Renders the layer in the scene.
  48940. */
  48941. render(): void;
  48942. /**
  48943. * Disposes and releases the associated ressources.
  48944. */
  48945. dispose(): void;
  48946. }
  48947. }
  48948. declare module BABYLON {
  48949. /** @hidden */
  48950. export var lensFlarePixelShader: {
  48951. name: string;
  48952. shader: string;
  48953. };
  48954. }
  48955. declare module BABYLON {
  48956. /** @hidden */
  48957. export var lensFlareVertexShader: {
  48958. name: string;
  48959. shader: string;
  48960. };
  48961. }
  48962. declare module BABYLON {
  48963. /**
  48964. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48965. * It is usually composed of several `lensFlare`.
  48966. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48967. */
  48968. export class LensFlareSystem {
  48969. /**
  48970. * Define the name of the lens flare system
  48971. */
  48972. name: string;
  48973. /**
  48974. * List of lens flares used in this system.
  48975. */
  48976. lensFlares: LensFlare[];
  48977. /**
  48978. * Define a limit from the border the lens flare can be visible.
  48979. */
  48980. borderLimit: number;
  48981. /**
  48982. * Define a viewport border we do not want to see the lens flare in.
  48983. */
  48984. viewportBorder: number;
  48985. /**
  48986. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48987. */
  48988. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48989. /**
  48990. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48991. */
  48992. layerMask: number;
  48993. /**
  48994. * Define the id of the lens flare system in the scene.
  48995. * (equal to name by default)
  48996. */
  48997. id: string;
  48998. private _scene;
  48999. private _emitter;
  49000. private _vertexBuffers;
  49001. private _indexBuffer;
  49002. private _effect;
  49003. private _positionX;
  49004. private _positionY;
  49005. private _isEnabled;
  49006. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49007. /**
  49008. * Instantiates a lens flare system.
  49009. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49010. * It is usually composed of several `lensFlare`.
  49011. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49012. * @param name Define the name of the lens flare system in the scene
  49013. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49014. * @param scene Define the scene the lens flare system belongs to
  49015. */
  49016. constructor(
  49017. /**
  49018. * Define the name of the lens flare system
  49019. */
  49020. name: string, emitter: any, scene: Scene);
  49021. /**
  49022. * Define if the lens flare system is enabled.
  49023. */
  49024. isEnabled: boolean;
  49025. /**
  49026. * Get the scene the effects belongs to.
  49027. * @returns the scene holding the lens flare system
  49028. */
  49029. getScene(): Scene;
  49030. /**
  49031. * Get the emitter of the lens flare system.
  49032. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49033. * @returns the emitter of the lens flare system
  49034. */
  49035. getEmitter(): any;
  49036. /**
  49037. * Set the emitter of the lens flare system.
  49038. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49039. * @param newEmitter Define the new emitter of the system
  49040. */
  49041. setEmitter(newEmitter: any): void;
  49042. /**
  49043. * Get the lens flare system emitter position.
  49044. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49045. * @returns the position
  49046. */
  49047. getEmitterPosition(): Vector3;
  49048. /**
  49049. * @hidden
  49050. */
  49051. computeEffectivePosition(globalViewport: Viewport): boolean;
  49052. /** @hidden */ private _isVisible(): boolean;
  49053. /**
  49054. * @hidden
  49055. */
  49056. render(): boolean;
  49057. /**
  49058. * Dispose and release the lens flare with its associated resources.
  49059. */
  49060. dispose(): void;
  49061. /**
  49062. * Parse a lens flare system from a JSON repressentation
  49063. * @param parsedLensFlareSystem Define the JSON to parse
  49064. * @param scene Define the scene the parsed system should be instantiated in
  49065. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49066. * @returns the parsed system
  49067. */
  49068. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49069. /**
  49070. * Serialize the current Lens Flare System into a JSON representation.
  49071. * @returns the serialized JSON
  49072. */
  49073. serialize(): any;
  49074. }
  49075. }
  49076. declare module BABYLON {
  49077. /**
  49078. * This represents one of the lens effect in a `lensFlareSystem`.
  49079. * It controls one of the indiviual texture used in the effect.
  49080. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49081. */
  49082. export class LensFlare {
  49083. /**
  49084. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49085. */
  49086. size: number;
  49087. /**
  49088. * 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.
  49089. */
  49090. position: number;
  49091. /**
  49092. * Define the lens color.
  49093. */
  49094. color: Color3;
  49095. /**
  49096. * Define the lens texture.
  49097. */
  49098. texture: Nullable<Texture>;
  49099. /**
  49100. * Define the alpha mode to render this particular lens.
  49101. */
  49102. alphaMode: number;
  49103. private _system;
  49104. /**
  49105. * Creates a new Lens Flare.
  49106. * This represents one of the lens effect in a `lensFlareSystem`.
  49107. * It controls one of the indiviual texture used in the effect.
  49108. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49109. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49110. * @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.
  49111. * @param color Define the lens color
  49112. * @param imgUrl Define the lens texture url
  49113. * @param system Define the `lensFlareSystem` this flare is part of
  49114. * @returns The newly created Lens Flare
  49115. */
  49116. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49117. /**
  49118. * Instantiates a new Lens Flare.
  49119. * This represents one of the lens effect in a `lensFlareSystem`.
  49120. * It controls one of the indiviual texture used in the effect.
  49121. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49122. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49123. * @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.
  49124. * @param color Define the lens color
  49125. * @param imgUrl Define the lens texture url
  49126. * @param system Define the `lensFlareSystem` this flare is part of
  49127. */
  49128. constructor(
  49129. /**
  49130. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49131. */
  49132. size: number,
  49133. /**
  49134. * 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.
  49135. */
  49136. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49137. /**
  49138. * Dispose and release the lens flare with its associated resources.
  49139. */
  49140. dispose(): void;
  49141. }
  49142. }
  49143. declare module BABYLON {
  49144. interface AbstractScene {
  49145. /**
  49146. * The list of lens flare system added to the scene
  49147. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49148. */
  49149. lensFlareSystems: Array<LensFlareSystem>;
  49150. /**
  49151. * Removes the given lens flare system from this scene.
  49152. * @param toRemove The lens flare system to remove
  49153. * @returns The index of the removed lens flare system
  49154. */
  49155. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49156. /**
  49157. * Adds the given lens flare system to this scene
  49158. * @param newLensFlareSystem The lens flare system to add
  49159. */
  49160. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49161. /**
  49162. * Gets a lens flare system using its name
  49163. * @param name defines the name to look for
  49164. * @returns the lens flare system or null if not found
  49165. */
  49166. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49167. /**
  49168. * Gets a lens flare system using its id
  49169. * @param id defines the id to look for
  49170. * @returns the lens flare system or null if not found
  49171. */
  49172. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49173. }
  49174. /**
  49175. * Defines the lens flare scene component responsible to manage any lens flares
  49176. * in a given scene.
  49177. */
  49178. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49179. /**
  49180. * The component name helpfull to identify the component in the list of scene components.
  49181. */
  49182. readonly name: string;
  49183. /**
  49184. * The scene the component belongs to.
  49185. */
  49186. scene: Scene;
  49187. /**
  49188. * Creates a new instance of the component for the given scene
  49189. * @param scene Defines the scene to register the component in
  49190. */
  49191. constructor(scene: Scene);
  49192. /**
  49193. * Registers the component in a given scene
  49194. */
  49195. register(): void;
  49196. /**
  49197. * Rebuilds the elements related to this component in case of
  49198. * context lost for instance.
  49199. */
  49200. rebuild(): void;
  49201. /**
  49202. * Adds all the elements from the container to the scene
  49203. * @param container the container holding the elements
  49204. */
  49205. addFromContainer(container: AbstractScene): void;
  49206. /**
  49207. * Removes all the elements in the container from the scene
  49208. * @param container contains the elements to remove
  49209. * @param dispose if the removed element should be disposed (default: false)
  49210. */
  49211. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49212. /**
  49213. * Serializes the component data to the specified json object
  49214. * @param serializationObject The object to serialize to
  49215. */
  49216. serialize(serializationObject: any): void;
  49217. /**
  49218. * Disposes the component and the associated ressources.
  49219. */
  49220. dispose(): void;
  49221. private _draw;
  49222. }
  49223. }
  49224. declare module BABYLON {
  49225. /**
  49226. * Defines the shadow generator component responsible to manage any shadow generators
  49227. * in a given scene.
  49228. */
  49229. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49230. /**
  49231. * The component name helpfull to identify the component in the list of scene components.
  49232. */
  49233. readonly name: string;
  49234. /**
  49235. * The scene the component belongs to.
  49236. */
  49237. scene: Scene;
  49238. /**
  49239. * Creates a new instance of the component for the given scene
  49240. * @param scene Defines the scene to register the component in
  49241. */
  49242. constructor(scene: Scene);
  49243. /**
  49244. * Registers the component in a given scene
  49245. */
  49246. register(): void;
  49247. /**
  49248. * Rebuilds the elements related to this component in case of
  49249. * context lost for instance.
  49250. */
  49251. rebuild(): void;
  49252. /**
  49253. * Serializes the component data to the specified json object
  49254. * @param serializationObject The object to serialize to
  49255. */
  49256. serialize(serializationObject: any): void;
  49257. /**
  49258. * Adds all the elements from the container to the scene
  49259. * @param container the container holding the elements
  49260. */
  49261. addFromContainer(container: AbstractScene): void;
  49262. /**
  49263. * Removes all the elements in the container from the scene
  49264. * @param container contains the elements to remove
  49265. * @param dispose if the removed element should be disposed (default: false)
  49266. */
  49267. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49268. /**
  49269. * Rebuilds the elements related to this component in case of
  49270. * context lost for instance.
  49271. */
  49272. dispose(): void;
  49273. private _gatherRenderTargets;
  49274. }
  49275. }
  49276. declare module BABYLON {
  49277. /**
  49278. * A point light is a light defined by an unique point in world space.
  49279. * The light is emitted in every direction from this point.
  49280. * A good example of a point light is a standard light bulb.
  49281. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49282. */
  49283. export class PointLight extends ShadowLight {
  49284. private _shadowAngle;
  49285. /**
  49286. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49287. * This specifies what angle the shadow will use to be created.
  49288. *
  49289. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49290. */
  49291. /**
  49292. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49293. * This specifies what angle the shadow will use to be created.
  49294. *
  49295. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49296. */
  49297. shadowAngle: number;
  49298. /**
  49299. * Gets the direction if it has been set.
  49300. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49301. */
  49302. /**
  49303. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49304. */
  49305. direction: Vector3;
  49306. /**
  49307. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49308. * A PointLight emits the light in every direction.
  49309. * It can cast shadows.
  49310. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49311. * ```javascript
  49312. * var pointLight = new PointLight("pl", camera.position, scene);
  49313. * ```
  49314. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49315. * @param name The light friendly name
  49316. * @param position The position of the point light in the scene
  49317. * @param scene The scene the lights belongs to
  49318. */
  49319. constructor(name: string, position: Vector3, scene: Scene);
  49320. /**
  49321. * Returns the string "PointLight"
  49322. * @returns the class name
  49323. */
  49324. getClassName(): string;
  49325. /**
  49326. * Returns the integer 0.
  49327. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49328. */
  49329. getTypeID(): number;
  49330. /**
  49331. * Specifies wether or not the shadowmap should be a cube texture.
  49332. * @returns true if the shadowmap needs to be a cube texture.
  49333. */
  49334. needCube(): boolean;
  49335. /**
  49336. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49337. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49338. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49339. */
  49340. getShadowDirection(faceIndex?: number): Vector3;
  49341. /**
  49342. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49343. * - fov = PI / 2
  49344. * - aspect ratio : 1.0
  49345. * - z-near and far equal to the active camera minZ and maxZ.
  49346. * Returns the PointLight.
  49347. */
  49348. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49349. protected _buildUniformLayout(): void;
  49350. /**
  49351. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49352. * @param effect The effect to update
  49353. * @param lightIndex The index of the light in the effect to update
  49354. * @returns The point light
  49355. */
  49356. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49357. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49358. /**
  49359. * Prepares the list of defines specific to the light type.
  49360. * @param defines the list of defines
  49361. * @param lightIndex defines the index of the light for the effect
  49362. */
  49363. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49364. }
  49365. }
  49366. declare module BABYLON {
  49367. /**
  49368. * Header information of HDR texture files.
  49369. */
  49370. export interface HDRInfo {
  49371. /**
  49372. * The height of the texture in pixels.
  49373. */
  49374. height: number;
  49375. /**
  49376. * The width of the texture in pixels.
  49377. */
  49378. width: number;
  49379. /**
  49380. * The index of the beginning of the data in the binary file.
  49381. */
  49382. dataPosition: number;
  49383. }
  49384. /**
  49385. * This groups tools to convert HDR texture to native colors array.
  49386. */
  49387. export class HDRTools {
  49388. private static Ldexp;
  49389. private static Rgbe2float;
  49390. private static readStringLine;
  49391. /**
  49392. * Reads header information from an RGBE texture stored in a native array.
  49393. * More information on this format are available here:
  49394. * https://en.wikipedia.org/wiki/RGBE_image_format
  49395. *
  49396. * @param uint8array The binary file stored in native array.
  49397. * @return The header information.
  49398. */
  49399. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49400. /**
  49401. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49402. * This RGBE texture needs to store the information as a panorama.
  49403. *
  49404. * More information on this format are available here:
  49405. * https://en.wikipedia.org/wiki/RGBE_image_format
  49406. *
  49407. * @param buffer The binary file stored in an array buffer.
  49408. * @param size The expected size of the extracted cubemap.
  49409. * @return The Cube Map information.
  49410. */
  49411. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49412. /**
  49413. * Returns the pixels data extracted from an RGBE texture.
  49414. * This pixels will be stored left to right up to down in the R G B order in one array.
  49415. *
  49416. * More information on this format are available here:
  49417. * https://en.wikipedia.org/wiki/RGBE_image_format
  49418. *
  49419. * @param uint8array The binary file stored in an array buffer.
  49420. * @param hdrInfo The header information of the file.
  49421. * @return The pixels data in RGB right to left up to down order.
  49422. */
  49423. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49424. private static RGBE_ReadPixels_RLE;
  49425. }
  49426. }
  49427. declare module BABYLON {
  49428. /**
  49429. * This represents a texture coming from an HDR input.
  49430. *
  49431. * The only supported format is currently panorama picture stored in RGBE format.
  49432. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49433. */
  49434. export class HDRCubeTexture extends BaseTexture {
  49435. private static _facesMapping;
  49436. private _generateHarmonics;
  49437. private _noMipmap;
  49438. private _textureMatrix;
  49439. private _size;
  49440. private _onLoad;
  49441. private _onError;
  49442. /**
  49443. * The texture URL.
  49444. */
  49445. url: string;
  49446. /**
  49447. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49448. */
  49449. coordinatesMode: number;
  49450. protected _isBlocking: boolean;
  49451. /**
  49452. * Sets wether or not the texture is blocking during loading.
  49453. */
  49454. /**
  49455. * Gets wether or not the texture is blocking during loading.
  49456. */
  49457. isBlocking: boolean;
  49458. protected _rotationY: number;
  49459. /**
  49460. * Sets texture matrix rotation angle around Y axis in radians.
  49461. */
  49462. /**
  49463. * Gets texture matrix rotation angle around Y axis radians.
  49464. */
  49465. rotationY: number;
  49466. /**
  49467. * Gets or sets the center of the bounding box associated with the cube texture
  49468. * It must define where the camera used to render the texture was set
  49469. */
  49470. boundingBoxPosition: Vector3;
  49471. private _boundingBoxSize;
  49472. /**
  49473. * Gets or sets the size of the bounding box associated with the cube texture
  49474. * When defined, the cubemap will switch to local mode
  49475. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49476. * @example https://www.babylonjs-playground.com/#RNASML
  49477. */
  49478. boundingBoxSize: Vector3;
  49479. /**
  49480. * Instantiates an HDRTexture from the following parameters.
  49481. *
  49482. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49483. * @param scene The scene the texture will be used in
  49484. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49485. * @param noMipmap Forces to not generate the mipmap if true
  49486. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49487. * @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)
  49488. * @param reserved Reserved flag for internal use.
  49489. */
  49490. 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>);
  49491. /**
  49492. * Get the current class name of the texture useful for serialization or dynamic coding.
  49493. * @returns "HDRCubeTexture"
  49494. */
  49495. getClassName(): string;
  49496. /**
  49497. * Occurs when the file is raw .hdr file.
  49498. */
  49499. private loadTexture;
  49500. clone(): HDRCubeTexture;
  49501. delayLoad(): void;
  49502. /**
  49503. * Get the texture reflection matrix used to rotate/transform the reflection.
  49504. * @returns the reflection matrix
  49505. */
  49506. getReflectionTextureMatrix(): Matrix;
  49507. /**
  49508. * Set the texture reflection matrix used to rotate/transform the reflection.
  49509. * @param value Define the reflection matrix to set
  49510. */
  49511. setReflectionTextureMatrix(value: Matrix): void;
  49512. /**
  49513. * Parses a JSON representation of an HDR Texture in order to create the texture
  49514. * @param parsedTexture Define the JSON representation
  49515. * @param scene Define the scene the texture should be created in
  49516. * @param rootUrl Define the root url in case we need to load relative dependencies
  49517. * @returns the newly created texture after parsing
  49518. */
  49519. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49520. serialize(): any;
  49521. }
  49522. }
  49523. declare module BABYLON {
  49524. /**
  49525. * Class used to control physics engine
  49526. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49527. */
  49528. export class PhysicsEngine implements IPhysicsEngine {
  49529. private _physicsPlugin;
  49530. /**
  49531. * Global value used to control the smallest number supported by the simulation
  49532. */
  49533. static Epsilon: number;
  49534. private _impostors;
  49535. private _joints;
  49536. /**
  49537. * Gets the gravity vector used by the simulation
  49538. */
  49539. gravity: Vector3;
  49540. /**
  49541. * Factory used to create the default physics plugin.
  49542. * @returns The default physics plugin
  49543. */
  49544. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49545. /**
  49546. * Creates a new Physics Engine
  49547. * @param gravity defines the gravity vector used by the simulation
  49548. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49549. */
  49550. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49551. /**
  49552. * Sets the gravity vector used by the simulation
  49553. * @param gravity defines the gravity vector to use
  49554. */
  49555. setGravity(gravity: Vector3): void;
  49556. /**
  49557. * Set the time step of the physics engine.
  49558. * Default is 1/60.
  49559. * To slow it down, enter 1/600 for example.
  49560. * To speed it up, 1/30
  49561. * @param newTimeStep defines the new timestep to apply to this world.
  49562. */
  49563. setTimeStep(newTimeStep?: number): void;
  49564. /**
  49565. * Get the time step of the physics engine.
  49566. * @returns the current time step
  49567. */
  49568. getTimeStep(): number;
  49569. /**
  49570. * Release all resources
  49571. */
  49572. dispose(): void;
  49573. /**
  49574. * Gets the name of the current physics plugin
  49575. * @returns the name of the plugin
  49576. */
  49577. getPhysicsPluginName(): string;
  49578. /**
  49579. * Adding a new impostor for the impostor tracking.
  49580. * This will be done by the impostor itself.
  49581. * @param impostor the impostor to add
  49582. */
  49583. addImpostor(impostor: PhysicsImpostor): void;
  49584. /**
  49585. * Remove an impostor from the engine.
  49586. * This impostor and its mesh will not longer be updated by the physics engine.
  49587. * @param impostor the impostor to remove
  49588. */
  49589. removeImpostor(impostor: PhysicsImpostor): void;
  49590. /**
  49591. * Add a joint to the physics engine
  49592. * @param mainImpostor defines the main impostor to which the joint is added.
  49593. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49594. * @param joint defines the joint that will connect both impostors.
  49595. */
  49596. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49597. /**
  49598. * Removes a joint from the simulation
  49599. * @param mainImpostor defines the impostor used with the joint
  49600. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49601. * @param joint defines the joint to remove
  49602. */
  49603. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49604. /**
  49605. * Called by the scene. No need to call it.
  49606. * @param delta defines the timespam between frames
  49607. */ private _step(delta: number): void;
  49608. /**
  49609. * Gets the current plugin used to run the simulation
  49610. * @returns current plugin
  49611. */
  49612. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49613. /**
  49614. * Gets the list of physic impostors
  49615. * @returns an array of PhysicsImpostor
  49616. */
  49617. getImpostors(): Array<PhysicsImpostor>;
  49618. /**
  49619. * Gets the impostor for a physics enabled object
  49620. * @param object defines the object impersonated by the impostor
  49621. * @returns the PhysicsImpostor or null if not found
  49622. */
  49623. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49624. /**
  49625. * Gets the impostor for a physics body object
  49626. * @param body defines physics body used by the impostor
  49627. * @returns the PhysicsImpostor or null if not found
  49628. */
  49629. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49630. /**
  49631. * Does a raycast in the physics world
  49632. * @param from when should the ray start?
  49633. * @param to when should the ray end?
  49634. * @returns PhysicsRaycastResult
  49635. */
  49636. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49637. }
  49638. }
  49639. declare module BABYLON {
  49640. /** @hidden */
  49641. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49642. private _useDeltaForWorldStep;
  49643. world: any;
  49644. name: string;
  49645. private _physicsMaterials;
  49646. private _fixedTimeStep;
  49647. private _cannonRaycastResult;
  49648. private _raycastResult;
  49649. private _physicsBodysToRemoveAfterStep;
  49650. BJSCANNON: any;
  49651. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49652. setGravity(gravity: Vector3): void;
  49653. setTimeStep(timeStep: number): void;
  49654. getTimeStep(): number;
  49655. executeStep(delta: number): void;
  49656. private _removeMarkedPhysicsBodiesFromWorld;
  49657. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49658. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49659. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49660. private _processChildMeshes;
  49661. removePhysicsBody(impostor: PhysicsImpostor): void;
  49662. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49663. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49664. private _addMaterial;
  49665. private _checkWithEpsilon;
  49666. private _createShape;
  49667. private _createHeightmap;
  49668. private _minus90X;
  49669. private _plus90X;
  49670. private _tmpPosition;
  49671. private _tmpDeltaPosition;
  49672. private _tmpUnityRotation;
  49673. private _updatePhysicsBodyTransformation;
  49674. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49675. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49676. isSupported(): boolean;
  49677. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49678. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49679. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49680. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49681. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49682. getBodyMass(impostor: PhysicsImpostor): number;
  49683. getBodyFriction(impostor: PhysicsImpostor): number;
  49684. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49685. getBodyRestitution(impostor: PhysicsImpostor): number;
  49686. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49687. sleepBody(impostor: PhysicsImpostor): void;
  49688. wakeUpBody(impostor: PhysicsImpostor): void;
  49689. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49690. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49691. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49692. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49693. getRadius(impostor: PhysicsImpostor): number;
  49694. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49695. dispose(): void;
  49696. private _extendNamespace;
  49697. /**
  49698. * Does a raycast in the physics world
  49699. * @param from when should the ray start?
  49700. * @param to when should the ray end?
  49701. * @returns PhysicsRaycastResult
  49702. */
  49703. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49704. }
  49705. }
  49706. declare module BABYLON {
  49707. /** @hidden */
  49708. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49709. world: any;
  49710. name: string;
  49711. BJSOIMO: any;
  49712. private _raycastResult;
  49713. constructor(iterations?: number, oimoInjection?: any);
  49714. setGravity(gravity: Vector3): void;
  49715. setTimeStep(timeStep: number): void;
  49716. getTimeStep(): number;
  49717. private _tmpImpostorsArray;
  49718. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49719. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49720. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49721. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49722. private _tmpPositionVector;
  49723. removePhysicsBody(impostor: PhysicsImpostor): void;
  49724. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49725. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49726. isSupported(): boolean;
  49727. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49728. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49729. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49730. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49731. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49732. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49733. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49734. getBodyMass(impostor: PhysicsImpostor): number;
  49735. getBodyFriction(impostor: PhysicsImpostor): number;
  49736. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49737. getBodyRestitution(impostor: PhysicsImpostor): number;
  49738. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49739. sleepBody(impostor: PhysicsImpostor): void;
  49740. wakeUpBody(impostor: PhysicsImpostor): void;
  49741. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49742. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49743. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49744. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49745. getRadius(impostor: PhysicsImpostor): number;
  49746. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49747. dispose(): void;
  49748. /**
  49749. * Does a raycast in the physics world
  49750. * @param from when should the ray start?
  49751. * @param to when should the ray end?
  49752. * @returns PhysicsRaycastResult
  49753. */
  49754. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49755. }
  49756. }
  49757. declare module BABYLON {
  49758. /**
  49759. * Class containing static functions to help procedurally build meshes
  49760. */
  49761. export class RibbonBuilder {
  49762. /**
  49763. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49764. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49765. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49766. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49767. * * 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
  49768. * * 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
  49769. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49773. * * 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
  49774. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49775. * * 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
  49776. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49778. * @param name defines the name of the mesh
  49779. * @param options defines the options used to create the mesh
  49780. * @param scene defines the hosting scene
  49781. * @returns the ribbon mesh
  49782. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49783. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49784. */
  49785. static CreateRibbon(name: string, options: {
  49786. pathArray: Vector3[][];
  49787. closeArray?: boolean;
  49788. closePath?: boolean;
  49789. offset?: number;
  49790. updatable?: boolean;
  49791. sideOrientation?: number;
  49792. frontUVs?: Vector4;
  49793. backUVs?: Vector4;
  49794. instance?: Mesh;
  49795. invertUV?: boolean;
  49796. uvs?: Vector2[];
  49797. colors?: Color4[];
  49798. }, scene?: Nullable<Scene>): Mesh;
  49799. }
  49800. }
  49801. declare module BABYLON {
  49802. /**
  49803. * Class containing static functions to help procedurally build meshes
  49804. */
  49805. export class ShapeBuilder {
  49806. /**
  49807. * 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.
  49808. * * 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.
  49809. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49810. * * 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.
  49811. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49812. * * 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
  49813. * * 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
  49814. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49816. * * 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
  49817. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49819. * @param name defines the name of the mesh
  49820. * @param options defines the options used to create the mesh
  49821. * @param scene defines the hosting scene
  49822. * @returns the extruded shape mesh
  49823. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49825. */
  49826. static ExtrudeShape(name: string, options: {
  49827. shape: Vector3[];
  49828. path: Vector3[];
  49829. scale?: number;
  49830. rotation?: number;
  49831. cap?: number;
  49832. updatable?: boolean;
  49833. sideOrientation?: number;
  49834. frontUVs?: Vector4;
  49835. backUVs?: Vector4;
  49836. instance?: Mesh;
  49837. invertUV?: boolean;
  49838. }, scene?: Nullable<Scene>): Mesh;
  49839. /**
  49840. * Creates an custom extruded shape mesh.
  49841. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49842. * * 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.
  49843. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49844. * * 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
  49845. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49846. * * 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
  49847. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49848. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49849. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49850. * * 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
  49851. * * 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
  49852. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49854. * * 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
  49855. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49857. * @param name defines the name of the mesh
  49858. * @param options defines the options used to create the mesh
  49859. * @param scene defines the hosting scene
  49860. * @returns the custom extruded shape mesh
  49861. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49862. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49864. */
  49865. static ExtrudeShapeCustom(name: string, options: {
  49866. shape: Vector3[];
  49867. path: Vector3[];
  49868. scaleFunction?: any;
  49869. rotationFunction?: any;
  49870. ribbonCloseArray?: boolean;
  49871. ribbonClosePath?: boolean;
  49872. cap?: number;
  49873. updatable?: boolean;
  49874. sideOrientation?: number;
  49875. frontUVs?: Vector4;
  49876. backUVs?: Vector4;
  49877. instance?: Mesh;
  49878. invertUV?: boolean;
  49879. }, scene?: Nullable<Scene>): Mesh;
  49880. private static _ExtrudeShapeGeneric;
  49881. }
  49882. }
  49883. declare module BABYLON {
  49884. /**
  49885. * AmmoJS Physics plugin
  49886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49887. * @see https://github.com/kripken/ammo.js/
  49888. */
  49889. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49890. private _useDeltaForWorldStep;
  49891. /**
  49892. * Reference to the Ammo library
  49893. */
  49894. bjsAMMO: any;
  49895. /**
  49896. * Created ammoJS world which physics bodies are added to
  49897. */
  49898. world: any;
  49899. /**
  49900. * Name of the plugin
  49901. */
  49902. name: string;
  49903. private _timeStep;
  49904. private _fixedTimeStep;
  49905. private _maxSteps;
  49906. private _tmpQuaternion;
  49907. private _tmpAmmoTransform;
  49908. private _tmpAmmoQuaternion;
  49909. private _tmpAmmoConcreteContactResultCallback;
  49910. private _collisionConfiguration;
  49911. private _dispatcher;
  49912. private _overlappingPairCache;
  49913. private _solver;
  49914. private _softBodySolver;
  49915. private _tmpAmmoVectorA;
  49916. private _tmpAmmoVectorB;
  49917. private _tmpAmmoVectorC;
  49918. private _tmpAmmoVectorD;
  49919. private _tmpContactCallbackResult;
  49920. private _tmpAmmoVectorRCA;
  49921. private _tmpAmmoVectorRCB;
  49922. private _raycastResult;
  49923. private static readonly DISABLE_COLLISION_FLAG;
  49924. private static readonly KINEMATIC_FLAG;
  49925. private static readonly DISABLE_DEACTIVATION_FLAG;
  49926. /**
  49927. * Initializes the ammoJS plugin
  49928. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49929. * @param ammoInjection can be used to inject your own ammo reference
  49930. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49931. */
  49932. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49933. /**
  49934. * Sets the gravity of the physics world (m/(s^2))
  49935. * @param gravity Gravity to set
  49936. */
  49937. setGravity(gravity: Vector3): void;
  49938. /**
  49939. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49940. * @param timeStep timestep to use in seconds
  49941. */
  49942. setTimeStep(timeStep: number): void;
  49943. /**
  49944. * 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)
  49945. * @param fixedTimeStep fixedTimeStep to use in seconds
  49946. */
  49947. setFixedTimeStep(fixedTimeStep: number): void;
  49948. /**
  49949. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49950. * @param maxSteps the maximum number of steps by the physics engine per frame
  49951. */
  49952. setMaxSteps(maxSteps: number): void;
  49953. /**
  49954. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49955. * @returns the current timestep in seconds
  49956. */
  49957. getTimeStep(): number;
  49958. private _isImpostorInContact;
  49959. private _isImpostorPairInContact;
  49960. private _stepSimulation;
  49961. /**
  49962. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49963. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49964. * After the step the babylon meshes are set to the position of the physics imposters
  49965. * @param delta amount of time to step forward
  49966. * @param impostors array of imposters to update before/after the step
  49967. */
  49968. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49969. /**
  49970. * Update babylon mesh to match physics world object
  49971. * @param impostor imposter to match
  49972. */
  49973. private _afterSoftStep;
  49974. /**
  49975. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49976. * @param impostor imposter to match
  49977. */
  49978. private _ropeStep;
  49979. /**
  49980. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49981. * @param impostor imposter to match
  49982. */
  49983. private _softbodyOrClothStep;
  49984. private _tmpVector;
  49985. private _tmpMatrix;
  49986. /**
  49987. * Applies an impulse on the imposter
  49988. * @param impostor imposter to apply impulse to
  49989. * @param force amount of force to be applied to the imposter
  49990. * @param contactPoint the location to apply the impulse on the imposter
  49991. */
  49992. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49993. /**
  49994. * Applies a force on the imposter
  49995. * @param impostor imposter to apply force
  49996. * @param force amount of force to be applied to the imposter
  49997. * @param contactPoint the location to apply the force on the imposter
  49998. */
  49999. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50000. /**
  50001. * Creates a physics body using the plugin
  50002. * @param impostor the imposter to create the physics body on
  50003. */
  50004. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50005. /**
  50006. * Removes the physics body from the imposter and disposes of the body's memory
  50007. * @param impostor imposter to remove the physics body from
  50008. */
  50009. removePhysicsBody(impostor: PhysicsImpostor): void;
  50010. /**
  50011. * Generates a joint
  50012. * @param impostorJoint the imposter joint to create the joint with
  50013. */
  50014. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50015. /**
  50016. * Removes a joint
  50017. * @param impostorJoint the imposter joint to remove the joint from
  50018. */
  50019. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50020. private _addMeshVerts;
  50021. /**
  50022. * Initialise the soft body vertices to match its object's (mesh) vertices
  50023. * Softbody vertices (nodes) are in world space and to match this
  50024. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50025. * @param impostor to create the softbody for
  50026. */
  50027. private _softVertexData;
  50028. /**
  50029. * Create an impostor's soft body
  50030. * @param impostor to create the softbody for
  50031. */
  50032. private _createSoftbody;
  50033. /**
  50034. * Create cloth for an impostor
  50035. * @param impostor to create the softbody for
  50036. */
  50037. private _createCloth;
  50038. /**
  50039. * Create rope for an impostor
  50040. * @param impostor to create the softbody for
  50041. */
  50042. private _createRope;
  50043. private _addHullVerts;
  50044. private _createShape;
  50045. /**
  50046. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50047. * @param impostor imposter containing the physics body and babylon object
  50048. */
  50049. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50050. /**
  50051. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50052. * @param impostor imposter containing the physics body and babylon object
  50053. * @param newPosition new position
  50054. * @param newRotation new rotation
  50055. */
  50056. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50057. /**
  50058. * If this plugin is supported
  50059. * @returns true if its supported
  50060. */
  50061. isSupported(): boolean;
  50062. /**
  50063. * Sets the linear velocity of the physics body
  50064. * @param impostor imposter to set the velocity on
  50065. * @param velocity velocity to set
  50066. */
  50067. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50068. /**
  50069. * Sets the angular velocity of the physics body
  50070. * @param impostor imposter to set the velocity on
  50071. * @param velocity velocity to set
  50072. */
  50073. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50074. /**
  50075. * gets the linear velocity
  50076. * @param impostor imposter to get linear velocity from
  50077. * @returns linear velocity
  50078. */
  50079. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50080. /**
  50081. * gets the angular velocity
  50082. * @param impostor imposter to get angular velocity from
  50083. * @returns angular velocity
  50084. */
  50085. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50086. /**
  50087. * Sets the mass of physics body
  50088. * @param impostor imposter to set the mass on
  50089. * @param mass mass to set
  50090. */
  50091. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50092. /**
  50093. * Gets the mass of the physics body
  50094. * @param impostor imposter to get the mass from
  50095. * @returns mass
  50096. */
  50097. getBodyMass(impostor: PhysicsImpostor): number;
  50098. /**
  50099. * Gets friction of the impostor
  50100. * @param impostor impostor to get friction from
  50101. * @returns friction value
  50102. */
  50103. getBodyFriction(impostor: PhysicsImpostor): number;
  50104. /**
  50105. * Sets friction of the impostor
  50106. * @param impostor impostor to set friction on
  50107. * @param friction friction value
  50108. */
  50109. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50110. /**
  50111. * Gets restitution of the impostor
  50112. * @param impostor impostor to get restitution from
  50113. * @returns restitution value
  50114. */
  50115. getBodyRestitution(impostor: PhysicsImpostor): number;
  50116. /**
  50117. * Sets resitution of the impostor
  50118. * @param impostor impostor to set resitution on
  50119. * @param restitution resitution value
  50120. */
  50121. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50122. /**
  50123. * Gets pressure inside the impostor
  50124. * @param impostor impostor to get pressure from
  50125. * @returns pressure value
  50126. */
  50127. getBodyPressure(impostor: PhysicsImpostor): number;
  50128. /**
  50129. * Sets pressure inside a soft body impostor
  50130. * Cloth and rope must remain 0 pressure
  50131. * @param impostor impostor to set pressure on
  50132. * @param pressure pressure value
  50133. */
  50134. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50135. /**
  50136. * Gets stiffness of the impostor
  50137. * @param impostor impostor to get stiffness from
  50138. * @returns pressure value
  50139. */
  50140. getBodyStiffness(impostor: PhysicsImpostor): number;
  50141. /**
  50142. * Sets stiffness of the impostor
  50143. * @param impostor impostor to set stiffness on
  50144. * @param stiffness stiffness value from 0 to 1
  50145. */
  50146. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50147. /**
  50148. * Gets velocityIterations of the impostor
  50149. * @param impostor impostor to get velocity iterations from
  50150. * @returns velocityIterations value
  50151. */
  50152. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50153. /**
  50154. * Sets velocityIterations of the impostor
  50155. * @param impostor impostor to set velocity iterations on
  50156. * @param velocityIterations velocityIterations value
  50157. */
  50158. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50159. /**
  50160. * Gets positionIterations of the impostor
  50161. * @param impostor impostor to get position iterations from
  50162. * @returns positionIterations value
  50163. */
  50164. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50165. /**
  50166. * Sets positionIterations of the impostor
  50167. * @param impostor impostor to set position on
  50168. * @param positionIterations positionIterations value
  50169. */
  50170. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50171. /**
  50172. * Append an anchor to a cloth object
  50173. * @param impostor is the cloth impostor to add anchor to
  50174. * @param otherImpostor is the rigid impostor to anchor to
  50175. * @param width ratio across width from 0 to 1
  50176. * @param height ratio up height from 0 to 1
  50177. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50178. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50179. */
  50180. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50181. /**
  50182. * Append an hook to a rope object
  50183. * @param impostor is the rope impostor to add hook to
  50184. * @param otherImpostor is the rigid impostor to hook to
  50185. * @param length ratio along the rope from 0 to 1
  50186. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50187. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50188. */
  50189. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50190. /**
  50191. * Sleeps the physics body and stops it from being active
  50192. * @param impostor impostor to sleep
  50193. */
  50194. sleepBody(impostor: PhysicsImpostor): void;
  50195. /**
  50196. * Activates the physics body
  50197. * @param impostor impostor to activate
  50198. */
  50199. wakeUpBody(impostor: PhysicsImpostor): void;
  50200. /**
  50201. * Updates the distance parameters of the joint
  50202. * @param joint joint to update
  50203. * @param maxDistance maximum distance of the joint
  50204. * @param minDistance minimum distance of the joint
  50205. */
  50206. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50207. /**
  50208. * Sets a motor on the joint
  50209. * @param joint joint to set motor on
  50210. * @param speed speed of the motor
  50211. * @param maxForce maximum force of the motor
  50212. * @param motorIndex index of the motor
  50213. */
  50214. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50215. /**
  50216. * Sets the motors limit
  50217. * @param joint joint to set limit on
  50218. * @param upperLimit upper limit
  50219. * @param lowerLimit lower limit
  50220. */
  50221. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50222. /**
  50223. * Syncs the position and rotation of a mesh with the impostor
  50224. * @param mesh mesh to sync
  50225. * @param impostor impostor to update the mesh with
  50226. */
  50227. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50228. /**
  50229. * Gets the radius of the impostor
  50230. * @param impostor impostor to get radius from
  50231. * @returns the radius
  50232. */
  50233. getRadius(impostor: PhysicsImpostor): number;
  50234. /**
  50235. * Gets the box size of the impostor
  50236. * @param impostor impostor to get box size from
  50237. * @param result the resulting box size
  50238. */
  50239. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50240. /**
  50241. * Disposes of the impostor
  50242. */
  50243. dispose(): void;
  50244. /**
  50245. * Does a raycast in the physics world
  50246. * @param from when should the ray start?
  50247. * @param to when should the ray end?
  50248. * @returns PhysicsRaycastResult
  50249. */
  50250. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50251. }
  50252. }
  50253. declare module BABYLON {
  50254. interface AbstractScene {
  50255. /**
  50256. * The list of reflection probes added to the scene
  50257. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50258. */
  50259. reflectionProbes: Array<ReflectionProbe>;
  50260. /**
  50261. * Removes the given reflection probe from this scene.
  50262. * @param toRemove The reflection probe to remove
  50263. * @returns The index of the removed reflection probe
  50264. */
  50265. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50266. /**
  50267. * Adds the given reflection probe to this scene.
  50268. * @param newReflectionProbe The reflection probe to add
  50269. */
  50270. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50271. }
  50272. /**
  50273. * Class used to generate realtime reflection / refraction cube textures
  50274. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50275. */
  50276. export class ReflectionProbe {
  50277. /** defines the name of the probe */
  50278. name: string;
  50279. private _scene;
  50280. private _renderTargetTexture;
  50281. private _projectionMatrix;
  50282. private _viewMatrix;
  50283. private _target;
  50284. private _add;
  50285. private _attachedMesh;
  50286. private _invertYAxis;
  50287. /** Gets or sets probe position (center of the cube map) */
  50288. position: Vector3;
  50289. /**
  50290. * Creates a new reflection probe
  50291. * @param name defines the name of the probe
  50292. * @param size defines the texture resolution (for each face)
  50293. * @param scene defines the hosting scene
  50294. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50295. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50296. */
  50297. constructor(
  50298. /** defines the name of the probe */
  50299. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50300. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50301. samples: number;
  50302. /** Gets or sets the refresh rate to use (on every frame by default) */
  50303. refreshRate: number;
  50304. /**
  50305. * Gets the hosting scene
  50306. * @returns a Scene
  50307. */
  50308. getScene(): Scene;
  50309. /** Gets the internal CubeTexture used to render to */
  50310. readonly cubeTexture: RenderTargetTexture;
  50311. /** Gets the list of meshes to render */
  50312. readonly renderList: Nullable<AbstractMesh[]>;
  50313. /**
  50314. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50315. * @param mesh defines the mesh to attach to
  50316. */
  50317. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50318. /**
  50319. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50320. * @param renderingGroupId The rendering group id corresponding to its index
  50321. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50322. */
  50323. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50324. /**
  50325. * Clean all associated resources
  50326. */
  50327. dispose(): void;
  50328. /**
  50329. * Converts the reflection probe information to a readable string for debug purpose.
  50330. * @param fullDetails Supports for multiple levels of logging within scene loading
  50331. * @returns the human readable reflection probe info
  50332. */
  50333. toString(fullDetails?: boolean): string;
  50334. /**
  50335. * Get the class name of the relfection probe.
  50336. * @returns "ReflectionProbe"
  50337. */
  50338. getClassName(): string;
  50339. /**
  50340. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50341. * @returns The JSON representation of the texture
  50342. */
  50343. serialize(): any;
  50344. /**
  50345. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50346. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50347. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50348. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50349. * @returns The parsed reflection probe if successful
  50350. */
  50351. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50352. }
  50353. }
  50354. declare module BABYLON {
  50355. /** @hidden */
  50356. export var _BabylonLoaderRegistered: boolean;
  50357. }
  50358. declare module BABYLON {
  50359. /**
  50360. * The Physically based simple base material of BJS.
  50361. *
  50362. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50363. * It is used as the base class for both the specGloss and metalRough conventions.
  50364. */
  50365. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50366. /**
  50367. * Number of Simultaneous lights allowed on the material.
  50368. */
  50369. maxSimultaneousLights: number;
  50370. /**
  50371. * If sets to true, disables all the lights affecting the material.
  50372. */
  50373. disableLighting: boolean;
  50374. /**
  50375. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50376. */
  50377. environmentTexture: BaseTexture;
  50378. /**
  50379. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50380. */
  50381. invertNormalMapX: boolean;
  50382. /**
  50383. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50384. */
  50385. invertNormalMapY: boolean;
  50386. /**
  50387. * Normal map used in the model.
  50388. */
  50389. normalTexture: BaseTexture;
  50390. /**
  50391. * Emissivie color used to self-illuminate the model.
  50392. */
  50393. emissiveColor: Color3;
  50394. /**
  50395. * Emissivie texture used to self-illuminate the model.
  50396. */
  50397. emissiveTexture: BaseTexture;
  50398. /**
  50399. * Occlusion Channel Strenght.
  50400. */
  50401. occlusionStrength: number;
  50402. /**
  50403. * Occlusion Texture of the material (adding extra occlusion effects).
  50404. */
  50405. occlusionTexture: BaseTexture;
  50406. /**
  50407. * Defines the alpha limits in alpha test mode.
  50408. */
  50409. alphaCutOff: number;
  50410. /**
  50411. * Gets the current double sided mode.
  50412. */
  50413. /**
  50414. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50415. */
  50416. doubleSided: boolean;
  50417. /**
  50418. * Stores the pre-calculated light information of a mesh in a texture.
  50419. */
  50420. lightmapTexture: BaseTexture;
  50421. /**
  50422. * If true, the light map contains occlusion information instead of lighting info.
  50423. */
  50424. useLightmapAsShadowmap: boolean;
  50425. /**
  50426. * Instantiates a new PBRMaterial instance.
  50427. *
  50428. * @param name The material name
  50429. * @param scene The scene the material will be use in.
  50430. */
  50431. constructor(name: string, scene: Scene);
  50432. getClassName(): string;
  50433. }
  50434. }
  50435. declare module BABYLON {
  50436. /**
  50437. * The PBR material of BJS following the metal roughness convention.
  50438. *
  50439. * This fits to the PBR convention in the GLTF definition:
  50440. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50441. */
  50442. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50443. /**
  50444. * The base color has two different interpretations depending on the value of metalness.
  50445. * When the material is a metal, the base color is the specific measured reflectance value
  50446. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50447. * of the material.
  50448. */
  50449. baseColor: Color3;
  50450. /**
  50451. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50452. * well as opacity information in the alpha channel.
  50453. */
  50454. baseTexture: BaseTexture;
  50455. /**
  50456. * Specifies the metallic scalar value of the material.
  50457. * Can also be used to scale the metalness values of the metallic texture.
  50458. */
  50459. metallic: number;
  50460. /**
  50461. * Specifies the roughness scalar value of the material.
  50462. * Can also be used to scale the roughness values of the metallic texture.
  50463. */
  50464. roughness: number;
  50465. /**
  50466. * Texture containing both the metallic value in the B channel and the
  50467. * roughness value in the G channel to keep better precision.
  50468. */
  50469. metallicRoughnessTexture: BaseTexture;
  50470. /**
  50471. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50472. *
  50473. * @param name The material name
  50474. * @param scene The scene the material will be use in.
  50475. */
  50476. constructor(name: string, scene: Scene);
  50477. /**
  50478. * Return the currrent class name of the material.
  50479. */
  50480. getClassName(): string;
  50481. /**
  50482. * Makes a duplicate of the current material.
  50483. * @param name - name to use for the new material.
  50484. */
  50485. clone(name: string): PBRMetallicRoughnessMaterial;
  50486. /**
  50487. * Serialize the material to a parsable JSON object.
  50488. */
  50489. serialize(): any;
  50490. /**
  50491. * Parses a JSON object correponding to the serialize function.
  50492. */
  50493. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50494. }
  50495. }
  50496. declare module BABYLON {
  50497. /**
  50498. * The PBR material of BJS following the specular glossiness convention.
  50499. *
  50500. * This fits to the PBR convention in the GLTF definition:
  50501. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50502. */
  50503. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50504. /**
  50505. * Specifies the diffuse color of the material.
  50506. */
  50507. diffuseColor: Color3;
  50508. /**
  50509. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50510. * channel.
  50511. */
  50512. diffuseTexture: BaseTexture;
  50513. /**
  50514. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50515. */
  50516. specularColor: Color3;
  50517. /**
  50518. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50519. */
  50520. glossiness: number;
  50521. /**
  50522. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50523. */
  50524. specularGlossinessTexture: BaseTexture;
  50525. /**
  50526. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50527. *
  50528. * @param name The material name
  50529. * @param scene The scene the material will be use in.
  50530. */
  50531. constructor(name: string, scene: Scene);
  50532. /**
  50533. * Return the currrent class name of the material.
  50534. */
  50535. getClassName(): string;
  50536. /**
  50537. * Makes a duplicate of the current material.
  50538. * @param name - name to use for the new material.
  50539. */
  50540. clone(name: string): PBRSpecularGlossinessMaterial;
  50541. /**
  50542. * Serialize the material to a parsable JSON object.
  50543. */
  50544. serialize(): any;
  50545. /**
  50546. * Parses a JSON object correponding to the serialize function.
  50547. */
  50548. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50549. }
  50550. }
  50551. declare module BABYLON {
  50552. /**
  50553. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50554. * It can help converting any input color in a desired output one. This can then be used to create effects
  50555. * from sepia, black and white to sixties or futuristic rendering...
  50556. *
  50557. * The only supported format is currently 3dl.
  50558. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50559. */
  50560. export class ColorGradingTexture extends BaseTexture {
  50561. /**
  50562. * The current texture matrix. (will always be identity in color grading texture)
  50563. */
  50564. private _textureMatrix;
  50565. /**
  50566. * The texture URL.
  50567. */
  50568. url: string;
  50569. /**
  50570. * Empty line regex stored for GC.
  50571. */
  50572. private static _noneEmptyLineRegex;
  50573. private _engine;
  50574. /**
  50575. * Instantiates a ColorGradingTexture from the following parameters.
  50576. *
  50577. * @param url The location of the color gradind data (currently only supporting 3dl)
  50578. * @param scene The scene the texture will be used in
  50579. */
  50580. constructor(url: string, scene: Scene);
  50581. /**
  50582. * Returns the texture matrix used in most of the material.
  50583. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50584. */
  50585. getTextureMatrix(): Matrix;
  50586. /**
  50587. * Occurs when the file being loaded is a .3dl LUT file.
  50588. */
  50589. private load3dlTexture;
  50590. /**
  50591. * Starts the loading process of the texture.
  50592. */
  50593. private loadTexture;
  50594. /**
  50595. * Clones the color gradind texture.
  50596. */
  50597. clone(): ColorGradingTexture;
  50598. /**
  50599. * Called during delayed load for textures.
  50600. */
  50601. delayLoad(): void;
  50602. /**
  50603. * Parses a color grading texture serialized by Babylon.
  50604. * @param parsedTexture The texture information being parsedTexture
  50605. * @param scene The scene to load the texture in
  50606. * @param rootUrl The root url of the data assets to load
  50607. * @return A color gradind texture
  50608. */
  50609. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50610. /**
  50611. * Serializes the LUT texture to json format.
  50612. */
  50613. serialize(): any;
  50614. }
  50615. }
  50616. declare module BABYLON {
  50617. /**
  50618. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50619. */
  50620. export class EquiRectangularCubeTexture extends BaseTexture {
  50621. /** The six faces of the cube. */
  50622. private static _FacesMapping;
  50623. private _noMipmap;
  50624. private _onLoad;
  50625. private _onError;
  50626. /** The size of the cubemap. */
  50627. private _size;
  50628. /** The buffer of the image. */
  50629. private _buffer;
  50630. /** The width of the input image. */
  50631. private _width;
  50632. /** The height of the input image. */
  50633. private _height;
  50634. /** The URL to the image. */
  50635. url: string;
  50636. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50637. coordinatesMode: number;
  50638. /**
  50639. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50640. * @param url The location of the image
  50641. * @param scene The scene the texture will be used in
  50642. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50643. * @param noMipmap Forces to not generate the mipmap if true
  50644. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50645. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50646. * @param onLoad — defines a callback called when texture is loaded
  50647. * @param onError — defines a callback called if there is an error
  50648. */
  50649. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50650. /**
  50651. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50652. */
  50653. private loadImage;
  50654. /**
  50655. * Convert the image buffer into a cubemap and create a CubeTexture.
  50656. */
  50657. private loadTexture;
  50658. /**
  50659. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50660. * @param buffer The ArrayBuffer that should be converted.
  50661. * @returns The buffer as Float32Array.
  50662. */
  50663. private getFloat32ArrayFromArrayBuffer;
  50664. /**
  50665. * Get the current class name of the texture useful for serialization or dynamic coding.
  50666. * @returns "EquiRectangularCubeTexture"
  50667. */
  50668. getClassName(): string;
  50669. /**
  50670. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50671. * @returns A clone of the current EquiRectangularCubeTexture.
  50672. */
  50673. clone(): EquiRectangularCubeTexture;
  50674. }
  50675. }
  50676. declare module BABYLON {
  50677. /**
  50678. * Based on jsTGALoader - Javascript loader for TGA file
  50679. * By Vincent Thibault
  50680. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50681. */
  50682. export class TGATools {
  50683. private static _TYPE_INDEXED;
  50684. private static _TYPE_RGB;
  50685. private static _TYPE_GREY;
  50686. private static _TYPE_RLE_INDEXED;
  50687. private static _TYPE_RLE_RGB;
  50688. private static _TYPE_RLE_GREY;
  50689. private static _ORIGIN_MASK;
  50690. private static _ORIGIN_SHIFT;
  50691. private static _ORIGIN_BL;
  50692. private static _ORIGIN_BR;
  50693. private static _ORIGIN_UL;
  50694. private static _ORIGIN_UR;
  50695. /**
  50696. * Gets the header of a TGA file
  50697. * @param data defines the TGA data
  50698. * @returns the header
  50699. */
  50700. static GetTGAHeader(data: Uint8Array): any;
  50701. /**
  50702. * Uploads TGA content to a Babylon Texture
  50703. * @hidden
  50704. */
  50705. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50706. /** @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;
  50707. /** @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;
  50708. /** @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;
  50709. /** @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;
  50710. /** @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;
  50711. /** @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;
  50712. }
  50713. }
  50714. declare module BABYLON {
  50715. /**
  50716. * Implementation of the TGA Texture Loader.
  50717. * @hidden
  50718. */
  50719. export class _TGATextureLoader implements IInternalTextureLoader {
  50720. /**
  50721. * Defines wether the loader supports cascade loading the different faces.
  50722. */
  50723. readonly supportCascades: boolean;
  50724. /**
  50725. * This returns if the loader support the current file information.
  50726. * @param extension defines the file extension of the file being loaded
  50727. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50728. * @param fallback defines the fallback internal texture if any
  50729. * @param isBase64 defines whether the texture is encoded as a base64
  50730. * @param isBuffer defines whether the texture data are stored as a buffer
  50731. * @returns true if the loader can load the specified file
  50732. */
  50733. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50734. /**
  50735. * Transform the url before loading if required.
  50736. * @param rootUrl the url of the texture
  50737. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50738. * @returns the transformed texture
  50739. */
  50740. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50741. /**
  50742. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50743. * @param rootUrl the url of the texture
  50744. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50745. * @returns the fallback texture
  50746. */
  50747. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50748. /**
  50749. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50750. * @param data contains the texture data
  50751. * @param texture defines the BabylonJS internal texture
  50752. * @param createPolynomials will be true if polynomials have been requested
  50753. * @param onLoad defines the callback to trigger once the texture is ready
  50754. * @param onError defines the callback to trigger in case of error
  50755. */
  50756. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50757. /**
  50758. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50759. * @param data contains the texture data
  50760. * @param texture defines the BabylonJS internal texture
  50761. * @param callback defines the method to call once ready to upload
  50762. */
  50763. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50764. }
  50765. }
  50766. declare module BABYLON {
  50767. /**
  50768. * Info about the .basis files
  50769. */
  50770. class BasisFileInfo {
  50771. /**
  50772. * If the file has alpha
  50773. */
  50774. hasAlpha: boolean;
  50775. /**
  50776. * Info about each image of the basis file
  50777. */
  50778. images: Array<{
  50779. levels: Array<{
  50780. width: number;
  50781. height: number;
  50782. transcodedPixels: ArrayBufferView;
  50783. }>;
  50784. }>;
  50785. }
  50786. /**
  50787. * Result of transcoding a basis file
  50788. */
  50789. class TranscodeResult {
  50790. /**
  50791. * Info about the .basis file
  50792. */
  50793. fileInfo: BasisFileInfo;
  50794. /**
  50795. * Format to use when loading the file
  50796. */
  50797. format: number;
  50798. }
  50799. /**
  50800. * Configuration options for the Basis transcoder
  50801. */
  50802. export class BasisTranscodeConfiguration {
  50803. /**
  50804. * Supported compression formats used to determine the supported output format of the transcoder
  50805. */
  50806. supportedCompressionFormats?: {
  50807. /**
  50808. * etc1 compression format
  50809. */
  50810. etc1?: boolean;
  50811. /**
  50812. * s3tc compression format
  50813. */
  50814. s3tc?: boolean;
  50815. /**
  50816. * pvrtc compression format
  50817. */
  50818. pvrtc?: boolean;
  50819. /**
  50820. * etc2 compression format
  50821. */
  50822. etc2?: boolean;
  50823. };
  50824. /**
  50825. * If mipmap levels should be loaded for transcoded images (Default: true)
  50826. */
  50827. loadMipmapLevels?: boolean;
  50828. /**
  50829. * Index of a single image to load (Default: all images)
  50830. */
  50831. loadSingleImage?: number;
  50832. }
  50833. /**
  50834. * Used to load .Basis files
  50835. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50836. */
  50837. export class BasisTools {
  50838. private static _IgnoreSupportedFormats;
  50839. /**
  50840. * URL to use when loading the basis transcoder
  50841. */
  50842. static JSModuleURL: string;
  50843. /**
  50844. * URL to use when loading the wasm module for the transcoder
  50845. */
  50846. static WasmModuleURL: string;
  50847. /**
  50848. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50849. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50850. * @returns internal format corresponding to the Basis format
  50851. */
  50852. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50853. private static _WorkerPromise;
  50854. private static _Worker;
  50855. private static _actionId;
  50856. private static _CreateWorkerAsync;
  50857. /**
  50858. * Transcodes a loaded image file to compressed pixel data
  50859. * @param imageData image data to transcode
  50860. * @param config configuration options for the transcoding
  50861. * @returns a promise resulting in the transcoded image
  50862. */
  50863. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50864. /**
  50865. * Loads a texture from the transcode result
  50866. * @param texture texture load to
  50867. * @param transcodeResult the result of transcoding the basis file to load from
  50868. */
  50869. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50870. }
  50871. }
  50872. declare module BABYLON {
  50873. /**
  50874. * Loader for .basis file format
  50875. */
  50876. export class _BasisTextureLoader implements IInternalTextureLoader {
  50877. /**
  50878. * Defines whether the loader supports cascade loading the different faces.
  50879. */
  50880. readonly supportCascades: boolean;
  50881. /**
  50882. * This returns if the loader support the current file information.
  50883. * @param extension defines the file extension of the file being loaded
  50884. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50885. * @param fallback defines the fallback internal texture if any
  50886. * @param isBase64 defines whether the texture is encoded as a base64
  50887. * @param isBuffer defines whether the texture data are stored as a buffer
  50888. * @returns true if the loader can load the specified file
  50889. */
  50890. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50891. /**
  50892. * Transform the url before loading if required.
  50893. * @param rootUrl the url of the texture
  50894. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50895. * @returns the transformed texture
  50896. */
  50897. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50898. /**
  50899. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50900. * @param rootUrl the url of the texture
  50901. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50902. * @returns the fallback texture
  50903. */
  50904. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50905. /**
  50906. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50907. * @param data contains the texture data
  50908. * @param texture defines the BabylonJS internal texture
  50909. * @param createPolynomials will be true if polynomials have been requested
  50910. * @param onLoad defines the callback to trigger once the texture is ready
  50911. * @param onError defines the callback to trigger in case of error
  50912. */
  50913. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50914. /**
  50915. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50916. * @param data contains the texture data
  50917. * @param texture defines the BabylonJS internal texture
  50918. * @param callback defines the method to call once ready to upload
  50919. */
  50920. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50921. }
  50922. }
  50923. declare module BABYLON {
  50924. /**
  50925. * 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.
  50926. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50927. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50928. */
  50929. export class CustomProceduralTexture extends ProceduralTexture {
  50930. private _animate;
  50931. private _time;
  50932. private _config;
  50933. private _texturePath;
  50934. /**
  50935. * Instantiates a new Custom Procedural Texture.
  50936. * 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.
  50937. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50938. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50939. * @param name Define the name of the texture
  50940. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50941. * @param size Define the size of the texture to create
  50942. * @param scene Define the scene the texture belongs to
  50943. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50944. * @param generateMipMaps Define if the texture should creates mip maps or not
  50945. */
  50946. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50947. private _loadJson;
  50948. /**
  50949. * Is the texture ready to be used ? (rendered at least once)
  50950. * @returns true if ready, otherwise, false.
  50951. */
  50952. isReady(): boolean;
  50953. /**
  50954. * Render the texture to its associated render target.
  50955. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50956. */
  50957. render(useCameraPostProcess?: boolean): void;
  50958. /**
  50959. * Update the list of dependant textures samplers in the shader.
  50960. */
  50961. updateTextures(): void;
  50962. /**
  50963. * Update the uniform values of the procedural texture in the shader.
  50964. */
  50965. updateShaderUniforms(): void;
  50966. /**
  50967. * Define if the texture animates or not.
  50968. */
  50969. animate: boolean;
  50970. }
  50971. }
  50972. declare module BABYLON {
  50973. /** @hidden */
  50974. export var noisePixelShader: {
  50975. name: string;
  50976. shader: string;
  50977. };
  50978. }
  50979. declare module BABYLON {
  50980. /**
  50981. * Class used to generate noise procedural textures
  50982. */
  50983. export class NoiseProceduralTexture extends ProceduralTexture {
  50984. private _time;
  50985. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50986. brightness: number;
  50987. /** Defines the number of octaves to process */
  50988. octaves: number;
  50989. /** Defines the level of persistence (0.8 by default) */
  50990. persistence: number;
  50991. /** Gets or sets animation speed factor (default is 1) */
  50992. animationSpeedFactor: number;
  50993. /**
  50994. * Creates a new NoiseProceduralTexture
  50995. * @param name defines the name fo the texture
  50996. * @param size defines the size of the texture (default is 256)
  50997. * @param scene defines the hosting scene
  50998. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50999. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51000. */
  51001. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51002. private _updateShaderUniforms;
  51003. protected _getDefines(): string;
  51004. /** Generate the current state of the procedural texture */
  51005. render(useCameraPostProcess?: boolean): void;
  51006. /**
  51007. * Serializes this noise procedural texture
  51008. * @returns a serialized noise procedural texture object
  51009. */
  51010. serialize(): any;
  51011. /**
  51012. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51013. * @param parsedTexture defines parsed texture data
  51014. * @param scene defines the current scene
  51015. * @param rootUrl defines the root URL containing noise procedural texture information
  51016. * @returns a parsed NoiseProceduralTexture
  51017. */
  51018. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51019. }
  51020. }
  51021. declare module BABYLON {
  51022. /**
  51023. * Raw cube texture where the raw buffers are passed in
  51024. */
  51025. export class RawCubeTexture extends CubeTexture {
  51026. /**
  51027. * Creates a cube texture where the raw buffers are passed in.
  51028. * @param scene defines the scene the texture is attached to
  51029. * @param data defines the array of data to use to create each face
  51030. * @param size defines the size of the textures
  51031. * @param format defines the format of the data
  51032. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51033. * @param generateMipMaps defines if the engine should generate the mip levels
  51034. * @param invertY defines if data must be stored with Y axis inverted
  51035. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51036. * @param compression defines the compression used (null by default)
  51037. */
  51038. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51039. /**
  51040. * Updates the raw cube texture.
  51041. * @param data defines the data to store
  51042. * @param format defines the data format
  51043. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51044. * @param invertY defines if data must be stored with Y axis inverted
  51045. * @param compression defines the compression used (null by default)
  51046. * @param level defines which level of the texture to update
  51047. */
  51048. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51049. /**
  51050. * Updates a raw cube texture with RGBD encoded data.
  51051. * @param data defines the array of data [mipmap][face] to use to create each face
  51052. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51053. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51054. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51055. * @returns a promsie that resolves when the operation is complete
  51056. */
  51057. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51058. /**
  51059. * Clones the raw cube texture.
  51060. * @return a new cube texture
  51061. */
  51062. clone(): CubeTexture;
  51063. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51064. }
  51065. }
  51066. declare module BABYLON {
  51067. /**
  51068. * Class used to store 3D textures containing user data
  51069. */
  51070. export class RawTexture3D extends Texture {
  51071. /** Gets or sets the texture format to use */
  51072. format: number;
  51073. private _engine;
  51074. /**
  51075. * Create a new RawTexture3D
  51076. * @param data defines the data of the texture
  51077. * @param width defines the width of the texture
  51078. * @param height defines the height of the texture
  51079. * @param depth defines the depth of the texture
  51080. * @param format defines the texture format to use
  51081. * @param scene defines the hosting scene
  51082. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51083. * @param invertY defines if texture must be stored with Y axis inverted
  51084. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51085. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51086. */
  51087. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51088. /** Gets or sets the texture format to use */
  51089. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51090. /**
  51091. * Update the texture with new data
  51092. * @param data defines the data to store in the texture
  51093. */
  51094. update(data: ArrayBufferView): void;
  51095. }
  51096. }
  51097. declare module BABYLON {
  51098. /**
  51099. * Creates a refraction texture used by refraction channel of the standard material.
  51100. * It is like a mirror but to see through a material.
  51101. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51102. */
  51103. export class RefractionTexture extends RenderTargetTexture {
  51104. /**
  51105. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51106. * 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.
  51107. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51108. */
  51109. refractionPlane: Plane;
  51110. /**
  51111. * Define how deep under the surface we should see.
  51112. */
  51113. depth: number;
  51114. /**
  51115. * Creates a refraction texture used by refraction channel of the standard material.
  51116. * It is like a mirror but to see through a material.
  51117. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51118. * @param name Define the texture name
  51119. * @param size Define the size of the underlying texture
  51120. * @param scene Define the scene the refraction belongs to
  51121. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51122. */
  51123. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51124. /**
  51125. * Clone the refraction texture.
  51126. * @returns the cloned texture
  51127. */
  51128. clone(): RefractionTexture;
  51129. /**
  51130. * Serialize the texture to a JSON representation you could use in Parse later on
  51131. * @returns the serialized JSON representation
  51132. */
  51133. serialize(): any;
  51134. }
  51135. }
  51136. declare module BABYLON {
  51137. /**
  51138. * Defines the options related to the creation of an HtmlElementTexture
  51139. */
  51140. export interface IHtmlElementTextureOptions {
  51141. /**
  51142. * Defines wether mip maps should be created or not.
  51143. */
  51144. generateMipMaps?: boolean;
  51145. /**
  51146. * Defines the sampling mode of the texture.
  51147. */
  51148. samplingMode?: number;
  51149. /**
  51150. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51151. */
  51152. engine: Nullable<Engine>;
  51153. /**
  51154. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51155. */
  51156. scene: Nullable<Scene>;
  51157. }
  51158. /**
  51159. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51160. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51161. * is automatically managed.
  51162. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51163. * in your application.
  51164. *
  51165. * As the update is not automatic, you need to call them manually.
  51166. */
  51167. export class HtmlElementTexture extends BaseTexture {
  51168. /**
  51169. * The texture URL.
  51170. */
  51171. element: HTMLVideoElement | HTMLCanvasElement;
  51172. private static readonly DefaultOptions;
  51173. private _textureMatrix;
  51174. private _engine;
  51175. private _isVideo;
  51176. private _generateMipMaps;
  51177. private _samplingMode;
  51178. /**
  51179. * Instantiates a HtmlElementTexture from the following parameters.
  51180. *
  51181. * @param name Defines the name of the texture
  51182. * @param element Defines the video or canvas the texture is filled with
  51183. * @param options Defines the other none mandatory texture creation options
  51184. */
  51185. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51186. private _createInternalTexture;
  51187. /**
  51188. * Returns the texture matrix used in most of the material.
  51189. */
  51190. getTextureMatrix(): Matrix;
  51191. /**
  51192. * Updates the content of the texture.
  51193. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51194. */
  51195. update(invertY?: Nullable<boolean>): void;
  51196. }
  51197. }
  51198. declare module BABYLON {
  51199. /**
  51200. * Enum used to define the target of a block
  51201. */
  51202. export enum NodeMaterialBlockTargets {
  51203. /** Vertex shader */
  51204. Vertex = 1,
  51205. /** Fragment shader */
  51206. Fragment = 2,
  51207. /** Neutral */
  51208. Neutral = 4,
  51209. /** Vertex and Fragment */
  51210. VertexAndFragment = 3
  51211. }
  51212. }
  51213. declare module BABYLON {
  51214. /**
  51215. * Defines the kind of connection point for node based material
  51216. */
  51217. export enum NodeMaterialBlockConnectionPointTypes {
  51218. /** Float */
  51219. Float = 1,
  51220. /** Int */
  51221. Int = 2,
  51222. /** Vector2 */
  51223. Vector2 = 4,
  51224. /** Vector3 */
  51225. Vector3 = 8,
  51226. /** Vector4 */
  51227. Vector4 = 16,
  51228. /** Color3 */
  51229. Color3 = 32,
  51230. /** Color4 */
  51231. Color4 = 64,
  51232. /** Matrix */
  51233. Matrix = 128,
  51234. /** Detect type based on connection */
  51235. AutoDetect = 1024,
  51236. /** Output type that will be defined by input type */
  51237. BasedOnInput = 2048
  51238. }
  51239. }
  51240. declare module BABYLON {
  51241. /**
  51242. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51243. */
  51244. export enum NodeMaterialBlockConnectionPointMode {
  51245. /** Value is an uniform */
  51246. Uniform = 0,
  51247. /** Value is a mesh attribute */
  51248. Attribute = 1,
  51249. /** Value is a varying between vertex and fragment shaders */
  51250. Varying = 2,
  51251. /** Mode is undefined */
  51252. Undefined = 3
  51253. }
  51254. }
  51255. declare module BABYLON {
  51256. /**
  51257. * Enum used to define system values e.g. values automatically provided by the system
  51258. */
  51259. export enum NodeMaterialSystemValues {
  51260. /** World */
  51261. World = 1,
  51262. /** View */
  51263. View = 2,
  51264. /** Projection */
  51265. Projection = 3,
  51266. /** ViewProjection */
  51267. ViewProjection = 4,
  51268. /** WorldView */
  51269. WorldView = 5,
  51270. /** WorldViewProjection */
  51271. WorldViewProjection = 6,
  51272. /** CameraPosition */
  51273. CameraPosition = 7,
  51274. /** Fog Color */
  51275. FogColor = 8
  51276. }
  51277. }
  51278. declare module BABYLON {
  51279. /**
  51280. * Root class for all node material optimizers
  51281. */
  51282. export class NodeMaterialOptimizer {
  51283. /**
  51284. * Function used to optimize a NodeMaterial graph
  51285. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51286. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51287. */
  51288. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51289. }
  51290. }
  51291. declare module BABYLON {
  51292. /**
  51293. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51294. */
  51295. export class TransformBlock extends NodeMaterialBlock {
  51296. /**
  51297. * Defines the value to use to complement W value to transform it to a Vector4
  51298. */
  51299. complementW: number;
  51300. /**
  51301. * Defines the value to use to complement z value to transform it to a Vector4
  51302. */
  51303. complementZ: number;
  51304. /**
  51305. * Creates a new TransformBlock
  51306. * @param name defines the block name
  51307. */
  51308. constructor(name: string);
  51309. /**
  51310. * Gets the current class name
  51311. * @returns the class name
  51312. */
  51313. getClassName(): string;
  51314. /**
  51315. * Gets the vector input
  51316. */
  51317. readonly vector: NodeMaterialConnectionPoint;
  51318. /**
  51319. * Gets the output component
  51320. */
  51321. readonly output: NodeMaterialConnectionPoint;
  51322. /**
  51323. * Gets the matrix transform input
  51324. */
  51325. readonly transform: NodeMaterialConnectionPoint;
  51326. protected _buildBlock(state: NodeMaterialBuildState): this;
  51327. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51328. protected _dumpPropertiesCode(): string;
  51329. }
  51330. }
  51331. declare module BABYLON {
  51332. /**
  51333. * Block used to output the vertex position
  51334. */
  51335. export class VertexOutputBlock extends NodeMaterialBlock {
  51336. /**
  51337. * Creates a new VertexOutputBlock
  51338. * @param name defines the block name
  51339. */
  51340. constructor(name: string);
  51341. /**
  51342. * Gets the current class name
  51343. * @returns the class name
  51344. */
  51345. getClassName(): string;
  51346. /**
  51347. * Gets the vector input component
  51348. */
  51349. readonly vector: NodeMaterialConnectionPoint;
  51350. protected _buildBlock(state: NodeMaterialBuildState): this;
  51351. }
  51352. }
  51353. declare module BABYLON {
  51354. /**
  51355. * Block used to output the final color
  51356. */
  51357. export class FragmentOutputBlock extends NodeMaterialBlock {
  51358. /**
  51359. * Create a new FragmentOutputBlock
  51360. * @param name defines the block name
  51361. */
  51362. constructor(name: string);
  51363. /**
  51364. * Gets the current class name
  51365. * @returns the class name
  51366. */
  51367. getClassName(): string;
  51368. /**
  51369. * Gets the rgba input component
  51370. */
  51371. readonly rgba: NodeMaterialConnectionPoint;
  51372. /**
  51373. * Gets the rgb input component
  51374. */
  51375. readonly rgb: NodeMaterialConnectionPoint;
  51376. /**
  51377. * Gets the a input component
  51378. */
  51379. readonly a: NodeMaterialConnectionPoint;
  51380. protected _buildBlock(state: NodeMaterialBuildState): this;
  51381. }
  51382. }
  51383. declare module BABYLON {
  51384. /**
  51385. * Block used to read a reflection texture from a sampler
  51386. */
  51387. export class ReflectionTextureBlock extends NodeMaterialBlock {
  51388. private _define3DName;
  51389. private _defineCubicName;
  51390. private _defineExplicitName;
  51391. private _defineProjectionName;
  51392. private _defineLocalCubicName;
  51393. private _defineSphericalName;
  51394. private _definePlanarName;
  51395. private _defineEquirectangularName;
  51396. private _defineMirroredEquirectangularFixedName;
  51397. private _defineEquirectangularFixedName;
  51398. private _defineSkyboxName;
  51399. private _cubeSamplerName;
  51400. private _2DSamplerName;
  51401. private _positionUVWName;
  51402. private _directionWName;
  51403. private _reflectionCoordsName;
  51404. private _reflection2DCoordsName;
  51405. private _reflectionColorName;
  51406. private _reflectionMatrixName;
  51407. /**
  51408. * Gets or sets the texture associated with the node
  51409. */
  51410. texture: Nullable<BaseTexture>;
  51411. /**
  51412. * Create a new TextureBlock
  51413. * @param name defines the block name
  51414. */
  51415. constructor(name: string);
  51416. /**
  51417. * Gets the current class name
  51418. * @returns the class name
  51419. */
  51420. getClassName(): string;
  51421. /**
  51422. * Gets the world position input component
  51423. */
  51424. readonly position: NodeMaterialConnectionPoint;
  51425. /**
  51426. * Gets the world position input component
  51427. */
  51428. readonly worldPosition: NodeMaterialConnectionPoint;
  51429. /**
  51430. * Gets the world normal input component
  51431. */
  51432. readonly worldNormal: NodeMaterialConnectionPoint;
  51433. /**
  51434. * Gets the world input component
  51435. */
  51436. readonly world: NodeMaterialConnectionPoint;
  51437. /**
  51438. * Gets the camera (or eye) position component
  51439. */
  51440. readonly cameraPosition: NodeMaterialConnectionPoint;
  51441. /**
  51442. * Gets the view input component
  51443. */
  51444. readonly view: NodeMaterialConnectionPoint;
  51445. /**
  51446. * Gets the rgb output component
  51447. */
  51448. readonly rgb: NodeMaterialConnectionPoint;
  51449. /**
  51450. * Gets the r output component
  51451. */
  51452. readonly r: NodeMaterialConnectionPoint;
  51453. /**
  51454. * Gets the g output component
  51455. */
  51456. readonly g: NodeMaterialConnectionPoint;
  51457. /**
  51458. * Gets the b output component
  51459. */
  51460. readonly b: NodeMaterialConnectionPoint;
  51461. autoConfigure(material: NodeMaterial): void;
  51462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51463. isReady(): boolean;
  51464. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51465. private _injectVertexCode;
  51466. private _writeOutput;
  51467. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51468. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51469. }
  51470. }
  51471. declare module BABYLON {
  51472. /**
  51473. * Interface used to configure the node material editor
  51474. */
  51475. export interface INodeMaterialEditorOptions {
  51476. /** Define the URl to load node editor script */
  51477. editorURL?: string;
  51478. }
  51479. /** @hidden */
  51480. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51481. /** BONES */
  51482. NUM_BONE_INFLUENCERS: number;
  51483. BonesPerMesh: number;
  51484. BONETEXTURE: boolean;
  51485. /** MORPH TARGETS */
  51486. MORPHTARGETS: boolean;
  51487. MORPHTARGETS_NORMAL: boolean;
  51488. MORPHTARGETS_TANGENT: boolean;
  51489. MORPHTARGETS_UV: boolean;
  51490. NUM_MORPH_INFLUENCERS: number;
  51491. /** IMAGE PROCESSING */
  51492. IMAGEPROCESSING: boolean;
  51493. VIGNETTE: boolean;
  51494. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51495. VIGNETTEBLENDMODEOPAQUE: boolean;
  51496. TONEMAPPING: boolean;
  51497. TONEMAPPING_ACES: boolean;
  51498. CONTRAST: boolean;
  51499. EXPOSURE: boolean;
  51500. COLORCURVES: boolean;
  51501. COLORGRADING: boolean;
  51502. COLORGRADING3D: boolean;
  51503. SAMPLER3DGREENDEPTH: boolean;
  51504. SAMPLER3DBGRMAP: boolean;
  51505. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51506. /** MISC. */
  51507. BUMPDIRECTUV: number;
  51508. constructor();
  51509. setValue(name: string, value: boolean): void;
  51510. }
  51511. /**
  51512. * Class used to configure NodeMaterial
  51513. */
  51514. export interface INodeMaterialOptions {
  51515. /**
  51516. * Defines if blocks should emit comments
  51517. */
  51518. emitComments: boolean;
  51519. }
  51520. /**
  51521. * Class used to create a node based material built by assembling shader blocks
  51522. */
  51523. export class NodeMaterial extends PushMaterial {
  51524. private static _BuildIdGenerator;
  51525. private _options;
  51526. private _vertexCompilationState;
  51527. private _fragmentCompilationState;
  51528. private _sharedData;
  51529. private _buildId;
  51530. private _buildWasSuccessful;
  51531. private _cachedWorldViewMatrix;
  51532. private _cachedWorldViewProjectionMatrix;
  51533. private _optimizers;
  51534. private _animationFrame;
  51535. /** Define the URl to load node editor script */
  51536. static EditorURL: string;
  51537. private BJSNODEMATERIALEDITOR;
  51538. /** Get the inspector from bundle or global */
  51539. private _getGlobalNodeMaterialEditor;
  51540. /**
  51541. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  51542. */
  51543. ignoreAlpha: boolean;
  51544. /**
  51545. * Defines the maximum number of lights that can be used in the material
  51546. */
  51547. maxSimultaneousLights: number;
  51548. /**
  51549. * Observable raised when the material is built
  51550. */
  51551. onBuildObservable: Observable<NodeMaterial>;
  51552. /**
  51553. * Gets or sets the root nodes of the material vertex shader
  51554. */ private _vertexOutputNodes: NodeMaterialBlock[];
  51555. /**
  51556. * Gets or sets the root nodes of the material fragment (pixel) shader
  51557. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  51558. /** Gets or sets options to control the node material overall behavior */
  51559. options: INodeMaterialOptions;
  51560. /**
  51561. * Default configuration related to image processing available in the standard Material.
  51562. */
  51563. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51564. /**
  51565. * Gets the image processing configuration used either in this material.
  51566. */
  51567. /**
  51568. * Sets the Default image processing configuration used either in the this material.
  51569. *
  51570. * If sets to null, the scene one is in use.
  51571. */
  51572. imageProcessingConfiguration: ImageProcessingConfiguration;
  51573. /**
  51574. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51575. */
  51576. attachedBlocks: NodeMaterialBlock[];
  51577. /**
  51578. * Create a new node based material
  51579. * @param name defines the material name
  51580. * @param scene defines the hosting scene
  51581. * @param options defines creation option
  51582. */
  51583. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51584. /**
  51585. * Gets the current class name of the material e.g. "NodeMaterial"
  51586. * @returns the class name
  51587. */
  51588. getClassName(): string;
  51589. /**
  51590. * Keep track of the image processing observer to allow dispose and replace.
  51591. */
  51592. private _imageProcessingObserver;
  51593. /**
  51594. * Attaches a new image processing configuration to the Standard Material.
  51595. * @param configuration
  51596. */
  51597. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51598. /**
  51599. * Get a block by its name
  51600. * @param name defines the name of the block to retrieve
  51601. * @returns the required block or null if not found
  51602. */
  51603. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  51604. /**
  51605. * Get a block by its name
  51606. * @param predicate defines the predicate used to find the good candidate
  51607. * @returns the required block or null if not found
  51608. */
  51609. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  51610. /**
  51611. * Get an input block by its name
  51612. * @param predicate defines the predicate used to find the good candidate
  51613. * @returns the required input block or null if not found
  51614. */
  51615. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  51616. /**
  51617. * Gets the list of input blocks attached to this material
  51618. * @returns an array of InputBlocks
  51619. */
  51620. getInputBlocks(): InputBlock[];
  51621. /**
  51622. * Adds a new optimizer to the list of optimizers
  51623. * @param optimizer defines the optimizers to add
  51624. * @returns the current material
  51625. */
  51626. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51627. /**
  51628. * Remove an optimizer from the list of optimizers
  51629. * @param optimizer defines the optimizers to remove
  51630. * @returns the current material
  51631. */
  51632. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51633. /**
  51634. * Add a new block to the list of output nodes
  51635. * @param node defines the node to add
  51636. * @returns the current material
  51637. */
  51638. addOutputNode(node: NodeMaterialBlock): this;
  51639. /**
  51640. * Remove a block from the list of root nodes
  51641. * @param node defines the node to remove
  51642. * @returns the current material
  51643. */
  51644. removeOutputNode(node: NodeMaterialBlock): this;
  51645. private _addVertexOutputNode;
  51646. private _removeVertexOutputNode;
  51647. private _addFragmentOutputNode;
  51648. private _removeFragmentOutputNode;
  51649. /**
  51650. * Specifies if the material will require alpha blending
  51651. * @returns a boolean specifying if alpha blending is needed
  51652. */
  51653. needAlphaBlending(): boolean;
  51654. /**
  51655. * Specifies if this material should be rendered in alpha test mode
  51656. * @returns a boolean specifying if an alpha test is needed.
  51657. */
  51658. needAlphaTesting(): boolean;
  51659. private _initializeBlock;
  51660. private _resetDualBlocks;
  51661. /**
  51662. * Build the material and generates the inner effect
  51663. * @param verbose defines if the build should log activity
  51664. */
  51665. build(verbose?: boolean): void;
  51666. /**
  51667. * Runs an otpimization phase to try to improve the shader code
  51668. */
  51669. optimize(): void;
  51670. private _prepareDefinesForAttributes;
  51671. /**
  51672. * Get if the submesh is ready to be used and all its information available.
  51673. * Child classes can use it to update shaders
  51674. * @param mesh defines the mesh to check
  51675. * @param subMesh defines which submesh to check
  51676. * @param useInstances specifies that instances should be used
  51677. * @returns a boolean indicating that the submesh is ready or not
  51678. */
  51679. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51680. /**
  51681. * Get a string representing the shaders built by the current node graph
  51682. */
  51683. readonly compiledShaders: string;
  51684. /**
  51685. * Binds the world matrix to the material
  51686. * @param world defines the world transformation matrix
  51687. */
  51688. bindOnlyWorldMatrix(world: Matrix): void;
  51689. /**
  51690. * Binds the submesh to this material by preparing the effect and shader to draw
  51691. * @param world defines the world transformation matrix
  51692. * @param mesh defines the mesh containing the submesh
  51693. * @param subMesh defines the submesh to bind the material to
  51694. */
  51695. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51696. /**
  51697. * Gets the active textures from the material
  51698. * @returns an array of textures
  51699. */
  51700. getActiveTextures(): BaseTexture[];
  51701. /**
  51702. * Gets the list of texture blocks
  51703. * @returns an array of texture blocks
  51704. */
  51705. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  51706. /**
  51707. * Specifies if the material uses a texture
  51708. * @param texture defines the texture to check against the material
  51709. * @returns a boolean specifying if the material uses the texture
  51710. */
  51711. hasTexture(texture: BaseTexture): boolean;
  51712. /**
  51713. * Disposes the material
  51714. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51715. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51716. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51717. */
  51718. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51719. /** Creates the node editor window. */
  51720. private _createNodeEditor;
  51721. /**
  51722. * Launch the node material editor
  51723. * @param config Define the configuration of the editor
  51724. * @return a promise fulfilled when the node editor is visible
  51725. */
  51726. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51727. /**
  51728. * Clear the current material
  51729. */
  51730. clear(): void;
  51731. /**
  51732. * Clear the current material and set it to a default state
  51733. */
  51734. setToDefault(): void;
  51735. /**
  51736. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  51737. * @param url defines the url to load from
  51738. * @returns a promise that will fullfil when the material is fully loaded
  51739. */
  51740. loadAsync(url: string): Promise<unknown>;
  51741. private _gatherBlocks;
  51742. /**
  51743. * Generate a string containing the code declaration required to create an equivalent of this material
  51744. * @returns a string
  51745. */
  51746. generateCode(): string;
  51747. /**
  51748. * Serializes this material in a JSON representation
  51749. * @returns the serialized material object
  51750. */
  51751. serialize(): any;
  51752. private _restoreConnections;
  51753. /**
  51754. * Clear the current graph and load a new one from a serialization object
  51755. * @param source defines the JSON representation of the material
  51756. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51757. */
  51758. loadFromSerialization(source: any, rootUrl?: string): void;
  51759. /**
  51760. * Creates a node material from parsed material data
  51761. * @param source defines the JSON representation of the material
  51762. * @param scene defines the hosting scene
  51763. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51764. * @returns a new node material
  51765. */
  51766. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  51767. /**
  51768. * Creates a new node material set to default basic configuration
  51769. * @param name defines the name of the material
  51770. * @param scene defines the hosting scene
  51771. * @returns a new NodeMaterial
  51772. */
  51773. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  51774. }
  51775. }
  51776. declare module BABYLON {
  51777. /**
  51778. * Block used to read a texture from a sampler
  51779. */
  51780. export class TextureBlock extends NodeMaterialBlock {
  51781. private _defineName;
  51782. private _samplerName;
  51783. private _transformedUVName;
  51784. private _textureTransformName;
  51785. private _textureInfoName;
  51786. private _mainUVName;
  51787. private _mainUVDefineName;
  51788. /**
  51789. * Gets or sets the texture associated with the node
  51790. */
  51791. texture: Nullable<Texture>;
  51792. /**
  51793. * Create a new TextureBlock
  51794. * @param name defines the block name
  51795. */
  51796. constructor(name: string);
  51797. /**
  51798. * Gets the current class name
  51799. * @returns the class name
  51800. */
  51801. getClassName(): string;
  51802. /**
  51803. * Gets the uv input component
  51804. */
  51805. readonly uv: NodeMaterialConnectionPoint;
  51806. /**
  51807. * Gets the rgba output component
  51808. */
  51809. readonly rgba: NodeMaterialConnectionPoint;
  51810. /**
  51811. * Gets the rgb output component
  51812. */
  51813. readonly rgb: NodeMaterialConnectionPoint;
  51814. /**
  51815. * Gets the r output component
  51816. */
  51817. readonly r: NodeMaterialConnectionPoint;
  51818. /**
  51819. * Gets the g output component
  51820. */
  51821. readonly g: NodeMaterialConnectionPoint;
  51822. /**
  51823. * Gets the b output component
  51824. */
  51825. readonly b: NodeMaterialConnectionPoint;
  51826. /**
  51827. * Gets the a output component
  51828. */
  51829. readonly a: NodeMaterialConnectionPoint;
  51830. readonly target: NodeMaterialBlockTargets;
  51831. autoConfigure(material: NodeMaterial): void;
  51832. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51834. isReady(): boolean;
  51835. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51836. private readonly _isMixed;
  51837. private _injectVertexCode;
  51838. private _writeOutput;
  51839. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51840. protected _dumpPropertiesCode(): string;
  51841. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51842. }
  51843. }
  51844. declare module BABYLON {
  51845. /**
  51846. * Class used to store shared data between 2 NodeMaterialBuildState
  51847. */
  51848. export class NodeMaterialBuildStateSharedData {
  51849. /**
  51850. * Gets the list of emitted varyings
  51851. */
  51852. temps: string[];
  51853. /**
  51854. * Gets the list of emitted varyings
  51855. */
  51856. varyings: string[];
  51857. /**
  51858. * Gets the varying declaration string
  51859. */
  51860. varyingDeclaration: string;
  51861. /**
  51862. * Input blocks
  51863. */
  51864. inputBlocks: InputBlock[];
  51865. /**
  51866. * Input blocks
  51867. */
  51868. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  51869. /**
  51870. * Bindable blocks (Blocks that need to set data to the effect)
  51871. */
  51872. bindableBlocks: NodeMaterialBlock[];
  51873. /**
  51874. * List of blocks that can provide a compilation fallback
  51875. */
  51876. blocksWithFallbacks: NodeMaterialBlock[];
  51877. /**
  51878. * List of blocks that can provide a define update
  51879. */
  51880. blocksWithDefines: NodeMaterialBlock[];
  51881. /**
  51882. * List of blocks that can provide a repeatable content
  51883. */
  51884. repeatableContentBlocks: NodeMaterialBlock[];
  51885. /**
  51886. * List of blocks that can provide a dynamic list of uniforms
  51887. */
  51888. dynamicUniformBlocks: NodeMaterialBlock[];
  51889. /**
  51890. * List of blocks that can block the isReady function for the material
  51891. */
  51892. blockingBlocks: NodeMaterialBlock[];
  51893. /**
  51894. * Gets the list of animated inputs
  51895. */
  51896. animatedInputs: InputBlock[];
  51897. /**
  51898. * Build Id used to avoid multiple recompilations
  51899. */
  51900. buildId: number;
  51901. /** List of emitted variables */
  51902. variableNames: {
  51903. [key: string]: number;
  51904. };
  51905. /** List of emitted defines */
  51906. defineNames: {
  51907. [key: string]: number;
  51908. };
  51909. /** Should emit comments? */
  51910. emitComments: boolean;
  51911. /** Emit build activity */
  51912. verbose: boolean;
  51913. /** Gets or sets the hosting scene */
  51914. scene: Scene;
  51915. /**
  51916. * Gets the compilation hints emitted at compilation time
  51917. */
  51918. hints: {
  51919. needWorldViewMatrix: boolean;
  51920. needWorldViewProjectionMatrix: boolean;
  51921. needAlphaBlending: boolean;
  51922. needAlphaTesting: boolean;
  51923. };
  51924. /**
  51925. * List of compilation checks
  51926. */
  51927. checks: {
  51928. emitVertex: boolean;
  51929. emitFragment: boolean;
  51930. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  51931. };
  51932. /** Creates a new shared data */
  51933. constructor();
  51934. /**
  51935. * Emits console errors and exceptions if there is a failing check
  51936. */
  51937. emitErrors(): void;
  51938. }
  51939. }
  51940. declare module BABYLON {
  51941. /**
  51942. * Class used to store node based material build state
  51943. */
  51944. export class NodeMaterialBuildState {
  51945. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  51946. supportUniformBuffers: boolean;
  51947. /**
  51948. * Gets the list of emitted attributes
  51949. */
  51950. attributes: string[];
  51951. /**
  51952. * Gets the list of emitted uniforms
  51953. */
  51954. uniforms: string[];
  51955. /**
  51956. * Gets the list of emitted constants
  51957. */
  51958. constants: string[];
  51959. /**
  51960. * Gets the list of emitted uniform buffers
  51961. */
  51962. uniformBuffers: string[];
  51963. /**
  51964. * Gets the list of emitted samplers
  51965. */
  51966. samplers: string[];
  51967. /**
  51968. * Gets the list of emitted functions
  51969. */
  51970. functions: {
  51971. [key: string]: string;
  51972. };
  51973. /**
  51974. * Gets the list of emitted extensions
  51975. */
  51976. extensions: {
  51977. [key: string]: string;
  51978. };
  51979. /**
  51980. * Gets the target of the compilation state
  51981. */
  51982. target: NodeMaterialBlockTargets;
  51983. /**
  51984. * Gets the list of emitted counters
  51985. */
  51986. counters: {
  51987. [key: string]: number;
  51988. };
  51989. /**
  51990. * Shared data between multiple NodeMaterialBuildState instances
  51991. */
  51992. sharedData: NodeMaterialBuildStateSharedData;
  51993. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  51994. /** @hidden */ private _attributeDeclaration: string;
  51995. /** @hidden */ private _uniformDeclaration: string;
  51996. /** @hidden */ private _constantDeclaration: string;
  51997. /** @hidden */ private _samplerDeclaration: string;
  51998. /** @hidden */ private _varyingTransfer: string;
  51999. private _repeatableContentAnchorIndex;
  52000. /** @hidden */ private _builtCompilationString: string;
  52001. /**
  52002. * Gets the emitted compilation strings
  52003. */
  52004. compilationString: string;
  52005. /**
  52006. * Finalize the compilation strings
  52007. * @param state defines the current compilation state
  52008. */
  52009. finalize(state: NodeMaterialBuildState): void;
  52010. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  52011. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  52012. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  52013. /** @hidden */ private _excludeVariableName(name: string): void;
  52014. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52015. /** @hidden */ private _emitExtension(name: string, extension: string): void;
  52016. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  52017. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52018. replaceStrings?: {
  52019. search: RegExp;
  52020. replace: string;
  52021. }[];
  52022. repeatKey?: string;
  52023. }): string;
  52024. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52025. repeatKey?: string;
  52026. removeAttributes?: boolean;
  52027. removeUniforms?: boolean;
  52028. removeVaryings?: boolean;
  52029. removeIfDef?: boolean;
  52030. replaceStrings?: {
  52031. search: RegExp;
  52032. replace: string;
  52033. }[];
  52034. }, storeKey?: string): void;
  52035. /** @hidden */ private _registerTempVariable(name: string): boolean;
  52036. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52037. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52038. }
  52039. }
  52040. declare module BABYLON {
  52041. /**
  52042. * Defines a block that can be used inside a node based material
  52043. */
  52044. export class NodeMaterialBlock {
  52045. private _buildId;
  52046. private _buildTarget;
  52047. private _target;
  52048. private _isFinalMerger;
  52049. private _isInput;
  52050. /** @hidden */ private _codeVariableName: string;
  52051. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  52052. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  52053. /** @hidden */ private _preparationId: number;
  52054. /**
  52055. * Gets or sets the name of the block
  52056. */
  52057. name: string;
  52058. /**
  52059. * Gets or sets the unique id of the node
  52060. */
  52061. uniqueId: number;
  52062. /**
  52063. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52064. */
  52065. readonly isFinalMerger: boolean;
  52066. /**
  52067. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52068. */
  52069. readonly isInput: boolean;
  52070. /**
  52071. * Gets or sets the build Id
  52072. */
  52073. buildId: number;
  52074. /**
  52075. * Gets or sets the target of the block
  52076. */
  52077. target: NodeMaterialBlockTargets;
  52078. /**
  52079. * Gets the list of input points
  52080. */
  52081. readonly inputs: NodeMaterialConnectionPoint[];
  52082. /** Gets the list of output points */
  52083. readonly outputs: NodeMaterialConnectionPoint[];
  52084. /**
  52085. * Find an input by its name
  52086. * @param name defines the name of the input to look for
  52087. * @returns the input or null if not found
  52088. */
  52089. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52090. /**
  52091. * Find an output by its name
  52092. * @param name defines the name of the outputto look for
  52093. * @returns the output or null if not found
  52094. */
  52095. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52096. /**
  52097. * Creates a new NodeMaterialBlock
  52098. * @param name defines the block name
  52099. * @param target defines the target of that block (Vertex by default)
  52100. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52101. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52102. */
  52103. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52104. /**
  52105. * Initialize the block and prepare the context for build
  52106. * @param state defines the state that will be used for the build
  52107. */
  52108. initialize(state: NodeMaterialBuildState): void;
  52109. /**
  52110. * Bind data to effect. Will only be called for blocks with isBindable === true
  52111. * @param effect defines the effect to bind data to
  52112. * @param nodeMaterial defines the hosting NodeMaterial
  52113. * @param mesh defines the mesh that will be rendered
  52114. */
  52115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52116. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52117. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52118. protected _writeFloat(value: number): string;
  52119. /**
  52120. * Gets the current class name e.g. "NodeMaterialBlock"
  52121. * @returns the class name
  52122. */
  52123. getClassName(): string;
  52124. /**
  52125. * Register a new input. Must be called inside a block constructor
  52126. * @param name defines the connection point name
  52127. * @param type defines the connection point type
  52128. * @param isOptional defines a boolean indicating that this input can be omitted
  52129. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52130. * @returns the current block
  52131. */
  52132. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52133. /**
  52134. * Register a new output. Must be called inside a block constructor
  52135. * @param name defines the connection point name
  52136. * @param type defines the connection point type
  52137. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52138. * @returns the current block
  52139. */
  52140. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52141. /**
  52142. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52143. * @param forOutput defines an optional connection point to check compatibility with
  52144. * @returns the first available input or null
  52145. */
  52146. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52147. /**
  52148. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52149. * @param forBlock defines an optional block to check compatibility with
  52150. * @returns the first available input or null
  52151. */
  52152. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52153. /**
  52154. * Gets the sibling of the given output
  52155. * @param current defines the current output
  52156. * @returns the next output in the list or null
  52157. */
  52158. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52159. /**
  52160. * Connect current block with another block
  52161. * @param other defines the block to connect with
  52162. * @param options define the various options to help pick the right connections
  52163. * @returns the current block
  52164. */
  52165. connectTo(other: NodeMaterialBlock, options?: {
  52166. input?: string;
  52167. output?: string;
  52168. outputSwizzle?: string;
  52169. }): this | undefined;
  52170. protected _buildBlock(state: NodeMaterialBuildState): void;
  52171. /**
  52172. * Add uniforms, samplers and uniform buffers at compilation time
  52173. * @param state defines the state to update
  52174. * @param nodeMaterial defines the node material requesting the update
  52175. * @param defines defines the material defines to update
  52176. */
  52177. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52178. /**
  52179. * Add potential fallbacks if shader compilation fails
  52180. * @param mesh defines the mesh to be rendered
  52181. * @param fallbacks defines the current prioritized list of fallbacks
  52182. */
  52183. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52184. /**
  52185. * Initialize defines for shader compilation
  52186. * @param mesh defines the mesh to be rendered
  52187. * @param nodeMaterial defines the node material requesting the update
  52188. * @param defines defines the material defines to update
  52189. * @param useInstances specifies that instances should be used
  52190. */
  52191. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52192. /**
  52193. * Update defines for shader compilation
  52194. * @param mesh defines the mesh to be rendered
  52195. * @param nodeMaterial defines the node material requesting the update
  52196. * @param defines defines the material defines to update
  52197. * @param useInstances specifies that instances should be used
  52198. */
  52199. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52200. /**
  52201. * Lets the block try to connect some inputs automatically
  52202. * @param material defines the hosting NodeMaterial
  52203. */
  52204. autoConfigure(material: NodeMaterial): void;
  52205. /**
  52206. * Function called when a block is declared as repeatable content generator
  52207. * @param vertexShaderState defines the current compilation state for the vertex shader
  52208. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52209. * @param mesh defines the mesh to be rendered
  52210. * @param defines defines the material defines to update
  52211. */
  52212. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52213. /**
  52214. * Checks if the block is ready
  52215. * @param mesh defines the mesh to be rendered
  52216. * @param nodeMaterial defines the node material requesting the update
  52217. * @param defines defines the material defines to update
  52218. * @param useInstances specifies that instances should be used
  52219. * @returns true if the block is ready
  52220. */
  52221. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52222. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52223. private _processBuild;
  52224. /**
  52225. * Compile the current node and generate the shader code
  52226. * @param state defines the current compilation state (uniforms, samplers, current string)
  52227. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52228. * @returns true if already built
  52229. */
  52230. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52231. protected _inputRename(name: string): string;
  52232. protected _outputRename(name: string): string;
  52233. protected _dumpPropertiesCode(): string;
  52234. /** @hidden */ private _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52235. /**
  52236. * Clone the current block to a new identical block
  52237. * @param scene defines the hosting scene
  52238. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52239. * @returns a copy of the current block
  52240. */
  52241. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52242. /**
  52243. * Serializes this block in a JSON representation
  52244. * @returns the serialized block object
  52245. */
  52246. serialize(): any;
  52247. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52248. }
  52249. }
  52250. declare module BABYLON {
  52251. /**
  52252. * Enum defining the type of animations supported by InputBlock
  52253. */
  52254. export enum AnimatedInputBlockTypes {
  52255. /** No animation */
  52256. None = 0,
  52257. /** Time based animation. Will only work for floats */
  52258. Time = 1
  52259. }
  52260. }
  52261. declare module BABYLON {
  52262. /**
  52263. * Block used to expose an input value
  52264. */
  52265. export class InputBlock extends NodeMaterialBlock {
  52266. private _mode;
  52267. private _associatedVariableName;
  52268. private _storedValue;
  52269. private _valueCallback;
  52270. private _type;
  52271. private _animationType;
  52272. /** Gets or set a value used to limit the range of float values */
  52273. min: number;
  52274. /** Gets or set a value used to limit the range of float values */
  52275. max: number;
  52276. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  52277. matrixMode: number;
  52278. /** @hidden */ private _systemValue: Nullable<NodeMaterialSystemValues>;
  52279. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  52280. visibleInInspector: boolean;
  52281. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  52282. isConstant: boolean;
  52283. /**
  52284. * Gets or sets the connection point type (default is float)
  52285. */
  52286. readonly type: NodeMaterialBlockConnectionPointTypes;
  52287. /**
  52288. * Creates a new InputBlock
  52289. * @param name defines the block name
  52290. * @param target defines the target of that block (Vertex by default)
  52291. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52292. */
  52293. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52294. /**
  52295. * Gets the output component
  52296. */
  52297. readonly output: NodeMaterialConnectionPoint;
  52298. /**
  52299. * Set the source of this connection point to a vertex attribute
  52300. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52301. * @returns the current connection point
  52302. */
  52303. setAsAttribute(attributeName?: string): InputBlock;
  52304. /**
  52305. * Set the source of this connection point to a system value
  52306. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  52307. * @returns the current connection point
  52308. */
  52309. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  52310. /**
  52311. * Gets or sets the value of that point.
  52312. * Please note that this value will be ignored if valueCallback is defined
  52313. */
  52314. value: any;
  52315. /**
  52316. * Gets or sets a callback used to get the value of that point.
  52317. * Please note that setting this value will force the connection point to ignore the value property
  52318. */
  52319. valueCallback: () => any;
  52320. /**
  52321. * Gets or sets the associated variable name in the shader
  52322. */
  52323. associatedVariableName: string;
  52324. /** Gets or sets the type of animation applied to the input */
  52325. animationType: AnimatedInputBlockTypes;
  52326. /**
  52327. * Gets a boolean indicating that this connection point not defined yet
  52328. */
  52329. readonly isUndefined: boolean;
  52330. /**
  52331. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52332. * In this case the connection point name must be the name of the uniform to use.
  52333. * Can only be set on inputs
  52334. */
  52335. isUniform: boolean;
  52336. /**
  52337. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52338. * In this case the connection point name must be the name of the attribute to use
  52339. * Can only be set on inputs
  52340. */
  52341. isAttribute: boolean;
  52342. /**
  52343. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52344. * Can only be set on exit points
  52345. */
  52346. isVarying: boolean;
  52347. /**
  52348. * Gets a boolean indicating that the current connection point is a system value
  52349. */
  52350. readonly isSystemValue: boolean;
  52351. /**
  52352. * Gets or sets the current well known value or null if not defined as a system value
  52353. */
  52354. systemValue: Nullable<NodeMaterialSystemValues>;
  52355. /**
  52356. * Gets the current class name
  52357. * @returns the class name
  52358. */
  52359. getClassName(): string;
  52360. /**
  52361. * Animate the input if animationType !== None
  52362. * @param scene defines the rendering scene
  52363. */
  52364. animate(scene: Scene): void;
  52365. private _emitDefine;
  52366. initialize(state: NodeMaterialBuildState): void;
  52367. /**
  52368. * Set the input block to its default value (based on its type)
  52369. */
  52370. setDefaultValue(): void;
  52371. protected _dumpPropertiesCode(): string;
  52372. private _emitConstant;
  52373. private _emit;
  52374. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52375. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  52376. protected _buildBlock(state: NodeMaterialBuildState): void;
  52377. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52378. }
  52379. }
  52380. declare module BABYLON {
  52381. /**
  52382. * Defines a connection point for a block
  52383. */
  52384. export class NodeMaterialConnectionPoint {
  52385. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  52386. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52387. private _endpoints;
  52388. private _associatedVariableName;
  52389. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52390. /** @hidden */ private _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52391. private _type;
  52392. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  52393. /**
  52394. * Gets or sets the additional types supported byt this connection point
  52395. */
  52396. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52397. /**
  52398. * Gets or sets the associated variable name in the shader
  52399. */
  52400. associatedVariableName: string;
  52401. /**
  52402. * Gets or sets the connection point type (default is float)
  52403. */
  52404. type: NodeMaterialBlockConnectionPointTypes;
  52405. /**
  52406. * Gets or sets the connection point name
  52407. */
  52408. name: string;
  52409. /**
  52410. * Gets or sets a boolean indicating that this connection point can be omitted
  52411. */
  52412. isOptional: boolean;
  52413. /**
  52414. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52415. */
  52416. define: string;
  52417. /** Gets or sets the target of that connection point */
  52418. target: NodeMaterialBlockTargets;
  52419. /**
  52420. * Gets a boolean indicating that the current point is connected
  52421. */
  52422. readonly isConnected: boolean;
  52423. /**
  52424. * Gets a boolean indicating that the current point is connected to an input block
  52425. */
  52426. readonly isConnectedToInputBlock: boolean;
  52427. /**
  52428. * Gets a the connected input block (if any)
  52429. */
  52430. readonly connectInputBlock: Nullable<InputBlock>;
  52431. /** Get the other side of the connection (if any) */
  52432. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52433. /** Get the block that owns this connection point */
  52434. readonly ownerBlock: NodeMaterialBlock;
  52435. /** Get the block connected on the other side of this connection (if any) */
  52436. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52437. /** Get the block connected on the endpoints of this connection (if any) */
  52438. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52439. /** Gets the list of connected endpoints */
  52440. readonly endpoints: NodeMaterialConnectionPoint[];
  52441. /** Gets a boolean indicating if that output point is connected to at least one input */
  52442. readonly hasEndpoints: boolean;
  52443. /**
  52444. * Creates a new connection point
  52445. * @param name defines the connection point name
  52446. * @param ownerBlock defines the block hosting this connection point
  52447. */
  52448. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52449. /**
  52450. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52451. * @returns the class name
  52452. */
  52453. getClassName(): string;
  52454. /**
  52455. * Gets an boolean indicating if the current point can be connected to another point
  52456. * @param connectionPoint defines the other connection point
  52457. * @returns true if the connection is possible
  52458. */
  52459. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52460. /**
  52461. * Connect this point to another connection point
  52462. * @param connectionPoint defines the other connection point
  52463. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  52464. * @returns the current connection point
  52465. */
  52466. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  52467. /**
  52468. * Disconnect this point from one of his endpoint
  52469. * @param endpoint defines the other connection point
  52470. * @returns the current connection point
  52471. */
  52472. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52473. /**
  52474. * Serializes this point in a JSON representation
  52475. * @returns the serialized point object
  52476. */
  52477. serialize(): any;
  52478. }
  52479. }
  52480. declare module BABYLON {
  52481. /**
  52482. * Block used to add support for vertex skinning (bones)
  52483. */
  52484. export class BonesBlock extends NodeMaterialBlock {
  52485. /**
  52486. * Creates a new BonesBlock
  52487. * @param name defines the block name
  52488. */
  52489. constructor(name: string);
  52490. /**
  52491. * Initialize the block and prepare the context for build
  52492. * @param state defines the state that will be used for the build
  52493. */
  52494. initialize(state: NodeMaterialBuildState): void;
  52495. /**
  52496. * Gets the current class name
  52497. * @returns the class name
  52498. */
  52499. getClassName(): string;
  52500. /**
  52501. * Gets the matrix indices input component
  52502. */
  52503. readonly matricesIndices: NodeMaterialConnectionPoint;
  52504. /**
  52505. * Gets the matrix weights input component
  52506. */
  52507. readonly matricesWeights: NodeMaterialConnectionPoint;
  52508. /**
  52509. * Gets the extra matrix indices input component
  52510. */
  52511. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52512. /**
  52513. * Gets the extra matrix weights input component
  52514. */
  52515. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52516. /**
  52517. * Gets the world input component
  52518. */
  52519. readonly world: NodeMaterialConnectionPoint;
  52520. /**
  52521. * Gets the output component
  52522. */
  52523. readonly output: NodeMaterialConnectionPoint;
  52524. autoConfigure(material: NodeMaterial): void;
  52525. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52528. protected _buildBlock(state: NodeMaterialBuildState): this;
  52529. }
  52530. }
  52531. declare module BABYLON {
  52532. /**
  52533. * Block used to add support for instances
  52534. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52535. */
  52536. export class InstancesBlock extends NodeMaterialBlock {
  52537. /**
  52538. * Creates a new InstancesBlock
  52539. * @param name defines the block name
  52540. */
  52541. constructor(name: string);
  52542. /**
  52543. * Gets the current class name
  52544. * @returns the class name
  52545. */
  52546. getClassName(): string;
  52547. /**
  52548. * Gets the first world row input component
  52549. */
  52550. readonly world0: NodeMaterialConnectionPoint;
  52551. /**
  52552. * Gets the second world row input component
  52553. */
  52554. readonly world1: NodeMaterialConnectionPoint;
  52555. /**
  52556. * Gets the third world row input component
  52557. */
  52558. readonly world2: NodeMaterialConnectionPoint;
  52559. /**
  52560. * Gets the forth world row input component
  52561. */
  52562. readonly world3: NodeMaterialConnectionPoint;
  52563. /**
  52564. * Gets the world input component
  52565. */
  52566. readonly world: NodeMaterialConnectionPoint;
  52567. /**
  52568. * Gets the output component
  52569. */
  52570. readonly output: NodeMaterialConnectionPoint;
  52571. autoConfigure(material: NodeMaterial): void;
  52572. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52573. protected _buildBlock(state: NodeMaterialBuildState): this;
  52574. }
  52575. }
  52576. declare module BABYLON {
  52577. /**
  52578. * Block used to add morph targets support to vertex shader
  52579. */
  52580. export class MorphTargetsBlock extends NodeMaterialBlock {
  52581. private _repeatableContentAnchor;
  52582. private _repeatebleContentGenerated;
  52583. /**
  52584. * Create a new MorphTargetsBlock
  52585. * @param name defines the block name
  52586. */
  52587. constructor(name: string);
  52588. /**
  52589. * Gets the current class name
  52590. * @returns the class name
  52591. */
  52592. getClassName(): string;
  52593. /**
  52594. * Gets the position input component
  52595. */
  52596. readonly position: NodeMaterialConnectionPoint;
  52597. /**
  52598. * Gets the normal input component
  52599. */
  52600. readonly normal: NodeMaterialConnectionPoint;
  52601. /**
  52602. * Gets the tangent input component
  52603. */
  52604. readonly tangent: NodeMaterialConnectionPoint;
  52605. /**
  52606. * Gets the tangent input component
  52607. */
  52608. readonly uv: NodeMaterialConnectionPoint;
  52609. /**
  52610. * Gets the position output component
  52611. */
  52612. readonly positionOutput: NodeMaterialConnectionPoint;
  52613. /**
  52614. * Gets the normal output component
  52615. */
  52616. readonly normalOutput: NodeMaterialConnectionPoint;
  52617. /**
  52618. * Gets the tangent output component
  52619. */
  52620. readonly tangentOutput: NodeMaterialConnectionPoint;
  52621. /**
  52622. * Gets the tangent output component
  52623. */
  52624. readonly uvOutput: NodeMaterialConnectionPoint;
  52625. initialize(state: NodeMaterialBuildState): void;
  52626. autoConfigure(material: NodeMaterial): void;
  52627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52628. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52629. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52630. protected _buildBlock(state: NodeMaterialBuildState): this;
  52631. }
  52632. }
  52633. declare module BABYLON {
  52634. /**
  52635. * Block used to get data information from a light
  52636. */
  52637. export class LightInformationBlock extends NodeMaterialBlock {
  52638. private _lightDataUniformName;
  52639. private _lightColorUniformName;
  52640. private _lightTypeDefineName;
  52641. /**
  52642. * Gets or sets the light associated with this block
  52643. */
  52644. light: Nullable<Light>;
  52645. /**
  52646. * Creates a new LightInformationBlock
  52647. * @param name defines the block name
  52648. */
  52649. constructor(name: string);
  52650. /**
  52651. * Gets the current class name
  52652. * @returns the class name
  52653. */
  52654. getClassName(): string;
  52655. /**
  52656. * Gets the world position input component
  52657. */
  52658. readonly worldPosition: NodeMaterialConnectionPoint;
  52659. /**
  52660. * Gets the direction output component
  52661. */
  52662. readonly direction: NodeMaterialConnectionPoint;
  52663. /**
  52664. * Gets the direction output component
  52665. */
  52666. readonly color: NodeMaterialConnectionPoint;
  52667. /**
  52668. * Gets the direction output component
  52669. */
  52670. readonly intensity: NodeMaterialConnectionPoint;
  52671. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52672. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52673. protected _buildBlock(state: NodeMaterialBuildState): this;
  52674. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52675. }
  52676. }
  52677. declare module BABYLON {
  52678. /**
  52679. * Block used to add image processing support to fragment shader
  52680. */
  52681. export class ImageProcessingBlock extends NodeMaterialBlock {
  52682. /**
  52683. * Create a new ImageProcessingBlock
  52684. * @param name defines the block name
  52685. */
  52686. constructor(name: string);
  52687. /**
  52688. * Gets the current class name
  52689. * @returns the class name
  52690. */
  52691. getClassName(): string;
  52692. /**
  52693. * Gets the color input component
  52694. */
  52695. readonly color: NodeMaterialConnectionPoint;
  52696. /**
  52697. * Gets the output component
  52698. */
  52699. readonly output: NodeMaterialConnectionPoint;
  52700. /**
  52701. * Initialize the block and prepare the context for build
  52702. * @param state defines the state that will be used for the build
  52703. */
  52704. initialize(state: NodeMaterialBuildState): void;
  52705. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52707. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52708. protected _buildBlock(state: NodeMaterialBuildState): this;
  52709. }
  52710. }
  52711. declare module BABYLON {
  52712. /**
  52713. * Block used to pertub normals based on a normal map
  52714. */
  52715. export class PerturbNormalBlock extends NodeMaterialBlock {
  52716. private _tangentSpaceParameterName;
  52717. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  52718. invertX: boolean;
  52719. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  52720. invertY: boolean;
  52721. /**
  52722. * Create a new PerturbNormalBlock
  52723. * @param name defines the block name
  52724. */
  52725. constructor(name: string);
  52726. /**
  52727. * Gets the current class name
  52728. * @returns the class name
  52729. */
  52730. getClassName(): string;
  52731. /**
  52732. * Gets the world position input component
  52733. */
  52734. readonly worldPosition: NodeMaterialConnectionPoint;
  52735. /**
  52736. * Gets the world normal input component
  52737. */
  52738. readonly worldNormal: NodeMaterialConnectionPoint;
  52739. /**
  52740. * Gets the uv input component
  52741. */
  52742. readonly uv: NodeMaterialConnectionPoint;
  52743. /**
  52744. * Gets the normal map color input component
  52745. */
  52746. readonly normalMapColor: NodeMaterialConnectionPoint;
  52747. /**
  52748. * Gets the strength input component
  52749. */
  52750. readonly strength: NodeMaterialConnectionPoint;
  52751. /**
  52752. * Gets the output component
  52753. */
  52754. readonly output: NodeMaterialConnectionPoint;
  52755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52756. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52757. autoConfigure(material: NodeMaterial): void;
  52758. protected _buildBlock(state: NodeMaterialBuildState): this;
  52759. protected _dumpPropertiesCode(): string;
  52760. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52761. }
  52762. }
  52763. declare module BABYLON {
  52764. /**
  52765. * Block used to discard a pixel if a value is smaller than a cutoff
  52766. */
  52767. export class DiscardBlock extends NodeMaterialBlock {
  52768. /**
  52769. * Create a new DiscardBlock
  52770. * @param name defines the block name
  52771. */
  52772. constructor(name: string);
  52773. /**
  52774. * Gets the current class name
  52775. * @returns the class name
  52776. */
  52777. getClassName(): string;
  52778. /**
  52779. * Gets the color input component
  52780. */
  52781. readonly value: NodeMaterialConnectionPoint;
  52782. /**
  52783. * Gets the cutoff input component
  52784. */
  52785. readonly cutoff: NodeMaterialConnectionPoint;
  52786. protected _buildBlock(state: NodeMaterialBuildState): this;
  52787. }
  52788. }
  52789. declare module BABYLON {
  52790. /**
  52791. * Block used to add support for scene fog
  52792. */
  52793. export class FogBlock extends NodeMaterialBlock {
  52794. private _fogDistanceName;
  52795. private _fogParameters;
  52796. /**
  52797. * Create a new FogBlock
  52798. * @param name defines the block name
  52799. */
  52800. constructor(name: string);
  52801. /**
  52802. * Gets the current class name
  52803. * @returns the class name
  52804. */
  52805. getClassName(): string;
  52806. /**
  52807. * Gets the world position input component
  52808. */
  52809. readonly worldPosition: NodeMaterialConnectionPoint;
  52810. /**
  52811. * Gets the view input component
  52812. */
  52813. readonly view: NodeMaterialConnectionPoint;
  52814. /**
  52815. * Gets the color input component
  52816. */
  52817. readonly input: NodeMaterialConnectionPoint;
  52818. /**
  52819. * Gets the fog color input component
  52820. */
  52821. readonly fogColor: NodeMaterialConnectionPoint;
  52822. /**
  52823. * Gets the output component
  52824. */
  52825. readonly output: NodeMaterialConnectionPoint;
  52826. autoConfigure(material: NodeMaterial): void;
  52827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52828. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52829. protected _buildBlock(state: NodeMaterialBuildState): this;
  52830. }
  52831. }
  52832. declare module BABYLON {
  52833. /**
  52834. * Block used to add light in the fragment shader
  52835. */
  52836. export class LightBlock extends NodeMaterialBlock {
  52837. private _lightId;
  52838. /**
  52839. * Gets or sets the light associated with this block
  52840. */
  52841. light: Nullable<Light>;
  52842. /**
  52843. * Create a new LightBlock
  52844. * @param name defines the block name
  52845. */
  52846. constructor(name: string);
  52847. /**
  52848. * Gets the current class name
  52849. * @returns the class name
  52850. */
  52851. getClassName(): string;
  52852. /**
  52853. * Gets the world position input component
  52854. */
  52855. readonly worldPosition: NodeMaterialConnectionPoint;
  52856. /**
  52857. * Gets the world normal input component
  52858. */
  52859. readonly worldNormal: NodeMaterialConnectionPoint;
  52860. /**
  52861. * Gets the camera (or eye) position component
  52862. */
  52863. readonly cameraPosition: NodeMaterialConnectionPoint;
  52864. /**
  52865. * Gets the diffuse output component
  52866. */
  52867. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52868. /**
  52869. * Gets the specular output component
  52870. */
  52871. readonly specularOutput: NodeMaterialConnectionPoint;
  52872. autoConfigure(material: NodeMaterial): void;
  52873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52874. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52876. private _injectVertexCode;
  52877. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52878. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52879. }
  52880. }
  52881. declare module BABYLON {
  52882. /**
  52883. * Block used to multiply 2 values
  52884. */
  52885. export class MultiplyBlock extends NodeMaterialBlock {
  52886. /**
  52887. * Creates a new MultiplyBlock
  52888. * @param name defines the block name
  52889. */
  52890. constructor(name: string);
  52891. /**
  52892. * Gets the current class name
  52893. * @returns the class name
  52894. */
  52895. getClassName(): string;
  52896. /**
  52897. * Gets the left operand input component
  52898. */
  52899. readonly left: NodeMaterialConnectionPoint;
  52900. /**
  52901. * Gets the right operand input component
  52902. */
  52903. readonly right: NodeMaterialConnectionPoint;
  52904. /**
  52905. * Gets the output component
  52906. */
  52907. readonly output: NodeMaterialConnectionPoint;
  52908. protected _buildBlock(state: NodeMaterialBuildState): this;
  52909. }
  52910. }
  52911. declare module BABYLON {
  52912. /**
  52913. * Block used to add 2 vectors
  52914. */
  52915. export class AddBlock extends NodeMaterialBlock {
  52916. /**
  52917. * Creates a new AddBlock
  52918. * @param name defines the block name
  52919. */
  52920. constructor(name: string);
  52921. /**
  52922. * Gets the current class name
  52923. * @returns the class name
  52924. */
  52925. getClassName(): string;
  52926. /**
  52927. * Gets the left operand input component
  52928. */
  52929. readonly left: NodeMaterialConnectionPoint;
  52930. /**
  52931. * Gets the right operand input component
  52932. */
  52933. readonly right: NodeMaterialConnectionPoint;
  52934. /**
  52935. * Gets the output component
  52936. */
  52937. readonly output: NodeMaterialConnectionPoint;
  52938. protected _buildBlock(state: NodeMaterialBuildState): this;
  52939. }
  52940. }
  52941. declare module BABYLON {
  52942. /**
  52943. * Block used to scale a vector by a float
  52944. */
  52945. export class ScaleBlock extends NodeMaterialBlock {
  52946. /**
  52947. * Creates a new ScaleBlock
  52948. * @param name defines the block name
  52949. */
  52950. constructor(name: string);
  52951. /**
  52952. * Gets the current class name
  52953. * @returns the class name
  52954. */
  52955. getClassName(): string;
  52956. /**
  52957. * Gets the input component
  52958. */
  52959. readonly input: NodeMaterialConnectionPoint;
  52960. /**
  52961. * Gets the factor input component
  52962. */
  52963. readonly factor: NodeMaterialConnectionPoint;
  52964. /**
  52965. * Gets the output component
  52966. */
  52967. readonly output: NodeMaterialConnectionPoint;
  52968. protected _buildBlock(state: NodeMaterialBuildState): this;
  52969. }
  52970. }
  52971. declare module BABYLON {
  52972. /**
  52973. * Block used to clamp a float
  52974. */
  52975. export class ClampBlock extends NodeMaterialBlock {
  52976. /** Gets or sets the minimum range */
  52977. minimum: number;
  52978. /** Gets or sets the maximum range */
  52979. maximum: number;
  52980. /**
  52981. * Creates a new ClampBlock
  52982. * @param name defines the block name
  52983. */
  52984. constructor(name: string);
  52985. /**
  52986. * Gets the current class name
  52987. * @returns the class name
  52988. */
  52989. getClassName(): string;
  52990. /**
  52991. * Gets the value input component
  52992. */
  52993. readonly value: NodeMaterialConnectionPoint;
  52994. /**
  52995. * Gets the output component
  52996. */
  52997. readonly output: NodeMaterialConnectionPoint;
  52998. protected _buildBlock(state: NodeMaterialBuildState): this;
  52999. protected _dumpPropertiesCode(): string;
  53000. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53001. }
  53002. }
  53003. declare module BABYLON {
  53004. /**
  53005. * Block used to apply a cross product between 2 vectors
  53006. */
  53007. export class CrossBlock extends NodeMaterialBlock {
  53008. /**
  53009. * Creates a new CrossBlock
  53010. * @param name defines the block name
  53011. */
  53012. constructor(name: string);
  53013. /**
  53014. * Gets the current class name
  53015. * @returns the class name
  53016. */
  53017. getClassName(): string;
  53018. /**
  53019. * Gets the left operand input component
  53020. */
  53021. readonly left: NodeMaterialConnectionPoint;
  53022. /**
  53023. * Gets the right operand input component
  53024. */
  53025. readonly right: NodeMaterialConnectionPoint;
  53026. /**
  53027. * Gets the output component
  53028. */
  53029. readonly output: NodeMaterialConnectionPoint;
  53030. protected _buildBlock(state: NodeMaterialBuildState): this;
  53031. }
  53032. }
  53033. declare module BABYLON {
  53034. /**
  53035. * Block used to apply a dot product between 2 vectors
  53036. */
  53037. export class DotBlock extends NodeMaterialBlock {
  53038. /**
  53039. * Creates a new DotBlock
  53040. * @param name defines the block name
  53041. */
  53042. constructor(name: string);
  53043. /**
  53044. * Gets the current class name
  53045. * @returns the class name
  53046. */
  53047. getClassName(): string;
  53048. /**
  53049. * Gets the left operand input component
  53050. */
  53051. readonly left: NodeMaterialConnectionPoint;
  53052. /**
  53053. * Gets the right operand input component
  53054. */
  53055. readonly right: NodeMaterialConnectionPoint;
  53056. /**
  53057. * Gets the output component
  53058. */
  53059. readonly output: NodeMaterialConnectionPoint;
  53060. protected _buildBlock(state: NodeMaterialBuildState): this;
  53061. }
  53062. }
  53063. declare module BABYLON {
  53064. /**
  53065. * Block used to remap a float from a range to a new one
  53066. */
  53067. export class RemapBlock extends NodeMaterialBlock {
  53068. /**
  53069. * Gets or sets the source range
  53070. */
  53071. sourceRange: Vector2;
  53072. /**
  53073. * Gets or sets the target range
  53074. */
  53075. targetRange: Vector2;
  53076. /**
  53077. * Creates a new RemapBlock
  53078. * @param name defines the block name
  53079. */
  53080. constructor(name: string);
  53081. /**
  53082. * Gets the current class name
  53083. * @returns the class name
  53084. */
  53085. getClassName(): string;
  53086. /**
  53087. * Gets the input component
  53088. */
  53089. readonly input: NodeMaterialConnectionPoint;
  53090. /**
  53091. * Gets the source min input component
  53092. */
  53093. readonly sourceMin: NodeMaterialConnectionPoint;
  53094. /**
  53095. * Gets the source max input component
  53096. */
  53097. readonly sourceMax: NodeMaterialConnectionPoint;
  53098. /**
  53099. * Gets the target min input component
  53100. */
  53101. readonly targetMin: NodeMaterialConnectionPoint;
  53102. /**
  53103. * Gets the target max input component
  53104. */
  53105. readonly targetMax: NodeMaterialConnectionPoint;
  53106. /**
  53107. * Gets the output component
  53108. */
  53109. readonly output: NodeMaterialConnectionPoint;
  53110. protected _buildBlock(state: NodeMaterialBuildState): this;
  53111. protected _dumpPropertiesCode(): string;
  53112. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53113. }
  53114. }
  53115. declare module BABYLON {
  53116. /**
  53117. * Block used to normalize a vector
  53118. */
  53119. export class NormalizeBlock extends NodeMaterialBlock {
  53120. /**
  53121. * Creates a new NormalizeBlock
  53122. * @param name defines the block name
  53123. */
  53124. constructor(name: string);
  53125. /**
  53126. * Gets the current class name
  53127. * @returns the class name
  53128. */
  53129. getClassName(): string;
  53130. /**
  53131. * Gets the input component
  53132. */
  53133. readonly input: NodeMaterialConnectionPoint;
  53134. /**
  53135. * Gets the output component
  53136. */
  53137. readonly output: NodeMaterialConnectionPoint;
  53138. protected _buildBlock(state: NodeMaterialBuildState): this;
  53139. }
  53140. }
  53141. declare module BABYLON {
  53142. /**
  53143. * Operations supported by the Trigonometry block
  53144. */
  53145. export enum TrigonometryBlockOperations {
  53146. /** Cos */
  53147. Cos = 0,
  53148. /** Sin */
  53149. Sin = 1,
  53150. /** Abs */
  53151. Abs = 2,
  53152. /** Exp */
  53153. Exp = 3,
  53154. /** Exp2 */
  53155. Exp2 = 4,
  53156. /** Round */
  53157. Round = 5,
  53158. /** Floor */
  53159. Floor = 6,
  53160. /** Ceiling */
  53161. Ceiling = 7,
  53162. /** Square root */
  53163. Sqrt = 8
  53164. }
  53165. /**
  53166. * Block used to apply trigonometry operation to floats
  53167. */
  53168. export class TrigonometryBlock extends NodeMaterialBlock {
  53169. /**
  53170. * Gets or sets the operation applied by the block
  53171. */
  53172. operation: TrigonometryBlockOperations;
  53173. /**
  53174. * Creates a new TrigonometryBlock
  53175. * @param name defines the block name
  53176. */
  53177. constructor(name: string);
  53178. /**
  53179. * Gets the current class name
  53180. * @returns the class name
  53181. */
  53182. getClassName(): string;
  53183. /**
  53184. * Gets the input component
  53185. */
  53186. readonly input: NodeMaterialConnectionPoint;
  53187. /**
  53188. * Gets the output component
  53189. */
  53190. readonly output: NodeMaterialConnectionPoint;
  53191. protected _buildBlock(state: NodeMaterialBuildState): this;
  53192. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53193. }
  53194. }
  53195. declare module BABYLON {
  53196. /**
  53197. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53198. */
  53199. export class ColorMergerBlock extends NodeMaterialBlock {
  53200. /**
  53201. * Create a new ColorMergerBlock
  53202. * @param name defines the block name
  53203. */
  53204. constructor(name: string);
  53205. /**
  53206. * Gets the current class name
  53207. * @returns the class name
  53208. */
  53209. getClassName(): string;
  53210. /**
  53211. * Gets the r component (input)
  53212. */
  53213. readonly r: NodeMaterialConnectionPoint;
  53214. /**
  53215. * Gets the g component (input)
  53216. */
  53217. readonly g: NodeMaterialConnectionPoint;
  53218. /**
  53219. * Gets the b component (input)
  53220. */
  53221. readonly b: NodeMaterialConnectionPoint;
  53222. /**
  53223. * Gets the a component (input)
  53224. */
  53225. readonly a: NodeMaterialConnectionPoint;
  53226. /**
  53227. * Gets the rgba component (output)
  53228. */
  53229. readonly rgba: NodeMaterialConnectionPoint;
  53230. /**
  53231. * Gets the rgb component (output)
  53232. */
  53233. readonly rgb: NodeMaterialConnectionPoint;
  53234. protected _buildBlock(state: NodeMaterialBuildState): this;
  53235. }
  53236. }
  53237. declare module BABYLON {
  53238. /**
  53239. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53240. */
  53241. export class VectorMergerBlock extends NodeMaterialBlock {
  53242. /**
  53243. * Create a new VectorMergerBlock
  53244. * @param name defines the block name
  53245. */
  53246. constructor(name: string);
  53247. /**
  53248. * Gets the current class name
  53249. * @returns the class name
  53250. */
  53251. getClassName(): string;
  53252. /**
  53253. * Gets the x component (input)
  53254. */
  53255. readonly x: NodeMaterialConnectionPoint;
  53256. /**
  53257. * Gets the y component (input)
  53258. */
  53259. readonly y: NodeMaterialConnectionPoint;
  53260. /**
  53261. * Gets the z component (input)
  53262. */
  53263. readonly z: NodeMaterialConnectionPoint;
  53264. /**
  53265. * Gets the w component (input)
  53266. */
  53267. readonly w: NodeMaterialConnectionPoint;
  53268. /**
  53269. * Gets the xyzw component (output)
  53270. */
  53271. readonly xyzw: NodeMaterialConnectionPoint;
  53272. /**
  53273. * Gets the xyz component (output)
  53274. */
  53275. readonly xyz: NodeMaterialConnectionPoint;
  53276. /**
  53277. * Gets the xy component (output)
  53278. */
  53279. readonly xy: NodeMaterialConnectionPoint;
  53280. protected _buildBlock(state: NodeMaterialBuildState): this;
  53281. }
  53282. }
  53283. declare module BABYLON {
  53284. /**
  53285. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53286. */
  53287. export class ColorSplitterBlock extends NodeMaterialBlock {
  53288. /**
  53289. * Create a new ColorSplitterBlock
  53290. * @param name defines the block name
  53291. */
  53292. constructor(name: string);
  53293. /**
  53294. * Gets the current class name
  53295. * @returns the class name
  53296. */
  53297. getClassName(): string;
  53298. /**
  53299. * Gets the rgba component (input)
  53300. */
  53301. readonly rgba: NodeMaterialConnectionPoint;
  53302. /**
  53303. * Gets the rgb component (input)
  53304. */
  53305. readonly rgbIn: NodeMaterialConnectionPoint;
  53306. /**
  53307. * Gets the rgb component (output)
  53308. */
  53309. readonly rgbOut: NodeMaterialConnectionPoint;
  53310. /**
  53311. * Gets the r component (output)
  53312. */
  53313. readonly r: NodeMaterialConnectionPoint;
  53314. /**
  53315. * Gets the g component (output)
  53316. */
  53317. readonly g: NodeMaterialConnectionPoint;
  53318. /**
  53319. * Gets the b component (output)
  53320. */
  53321. readonly b: NodeMaterialConnectionPoint;
  53322. /**
  53323. * Gets the a component (output)
  53324. */
  53325. readonly a: NodeMaterialConnectionPoint;
  53326. protected _inputRename(name: string): string;
  53327. protected _outputRename(name: string): string;
  53328. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53329. }
  53330. }
  53331. declare module BABYLON {
  53332. /**
  53333. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53334. */
  53335. export class VectorSplitterBlock extends NodeMaterialBlock {
  53336. /**
  53337. * Create a new VectorSplitterBlock
  53338. * @param name defines the block name
  53339. */
  53340. constructor(name: string);
  53341. /**
  53342. * Gets the current class name
  53343. * @returns the class name
  53344. */
  53345. getClassName(): string;
  53346. /**
  53347. * Gets the xyzw component (input)
  53348. */
  53349. readonly xyzw: NodeMaterialConnectionPoint;
  53350. /**
  53351. * Gets the xyz component (input)
  53352. */
  53353. readonly xyzIn: NodeMaterialConnectionPoint;
  53354. /**
  53355. * Gets the xy component (input)
  53356. */
  53357. readonly xyIn: NodeMaterialConnectionPoint;
  53358. /**
  53359. * Gets the xyz component (output)
  53360. */
  53361. readonly xyzOut: NodeMaterialConnectionPoint;
  53362. /**
  53363. * Gets the xy component (output)
  53364. */
  53365. readonly xyOut: NodeMaterialConnectionPoint;
  53366. /**
  53367. * Gets the x component (output)
  53368. */
  53369. readonly x: NodeMaterialConnectionPoint;
  53370. /**
  53371. * Gets the y component (output)
  53372. */
  53373. readonly y: NodeMaterialConnectionPoint;
  53374. /**
  53375. * Gets the z component (output)
  53376. */
  53377. readonly z: NodeMaterialConnectionPoint;
  53378. /**
  53379. * Gets the w component (output)
  53380. */
  53381. readonly w: NodeMaterialConnectionPoint;
  53382. protected _inputRename(name: string): string;
  53383. protected _outputRename(name: string): string;
  53384. protected _buildBlock(state: NodeMaterialBuildState): this;
  53385. }
  53386. }
  53387. declare module BABYLON {
  53388. /**
  53389. * Block used to lerp 2 values
  53390. */
  53391. export class LerpBlock extends NodeMaterialBlock {
  53392. /**
  53393. * Creates a new LerpBlock
  53394. * @param name defines the block name
  53395. */
  53396. constructor(name: string);
  53397. /**
  53398. * Gets the current class name
  53399. * @returns the class name
  53400. */
  53401. getClassName(): string;
  53402. /**
  53403. * Gets the left operand input component
  53404. */
  53405. readonly left: NodeMaterialConnectionPoint;
  53406. /**
  53407. * Gets the right operand input component
  53408. */
  53409. readonly right: NodeMaterialConnectionPoint;
  53410. /**
  53411. * Gets the gradient operand input component
  53412. */
  53413. readonly gradient: NodeMaterialConnectionPoint;
  53414. /**
  53415. * Gets the output component
  53416. */
  53417. readonly output: NodeMaterialConnectionPoint;
  53418. protected _buildBlock(state: NodeMaterialBuildState): this;
  53419. }
  53420. }
  53421. declare module BABYLON {
  53422. /**
  53423. * Block used to divide 2 vectors
  53424. */
  53425. export class DivideBlock extends NodeMaterialBlock {
  53426. /**
  53427. * Creates a new DivideBlock
  53428. * @param name defines the block name
  53429. */
  53430. constructor(name: string);
  53431. /**
  53432. * Gets the current class name
  53433. * @returns the class name
  53434. */
  53435. getClassName(): string;
  53436. /**
  53437. * Gets the left operand input component
  53438. */
  53439. readonly left: NodeMaterialConnectionPoint;
  53440. /**
  53441. * Gets the right operand input component
  53442. */
  53443. readonly right: NodeMaterialConnectionPoint;
  53444. /**
  53445. * Gets the output component
  53446. */
  53447. readonly output: NodeMaterialConnectionPoint;
  53448. protected _buildBlock(state: NodeMaterialBuildState): this;
  53449. }
  53450. }
  53451. declare module BABYLON {
  53452. /**
  53453. * Block used to subtract 2 vectors
  53454. */
  53455. export class SubtractBlock extends NodeMaterialBlock {
  53456. /**
  53457. * Creates a new SubtractBlock
  53458. * @param name defines the block name
  53459. */
  53460. constructor(name: string);
  53461. /**
  53462. * Gets the current class name
  53463. * @returns the class name
  53464. */
  53465. getClassName(): string;
  53466. /**
  53467. * Gets the left operand input component
  53468. */
  53469. readonly left: NodeMaterialConnectionPoint;
  53470. /**
  53471. * Gets the right operand input component
  53472. */
  53473. readonly right: NodeMaterialConnectionPoint;
  53474. /**
  53475. * Gets the output component
  53476. */
  53477. readonly output: NodeMaterialConnectionPoint;
  53478. protected _buildBlock(state: NodeMaterialBuildState): this;
  53479. }
  53480. }
  53481. declare module BABYLON {
  53482. /**
  53483. * Block used to step a value
  53484. */
  53485. export class StepBlock extends NodeMaterialBlock {
  53486. /**
  53487. * Creates a new AddBlock
  53488. * @param name defines the block name
  53489. */
  53490. constructor(name: string);
  53491. /**
  53492. * Gets the current class name
  53493. * @returns the class name
  53494. */
  53495. getClassName(): string;
  53496. /**
  53497. * Gets the value operand input component
  53498. */
  53499. readonly value: NodeMaterialConnectionPoint;
  53500. /**
  53501. * Gets the edge operand input component
  53502. */
  53503. readonly edge: NodeMaterialConnectionPoint;
  53504. /**
  53505. * Gets the output component
  53506. */
  53507. readonly output: NodeMaterialConnectionPoint;
  53508. protected _buildBlock(state: NodeMaterialBuildState): this;
  53509. }
  53510. }
  53511. declare module BABYLON {
  53512. /**
  53513. * Block used to get the opposite (1 - x) of a value
  53514. */
  53515. export class OneMinusBlock extends NodeMaterialBlock {
  53516. /**
  53517. * Creates a new OneMinusBlock
  53518. * @param name defines the block name
  53519. */
  53520. constructor(name: string);
  53521. /**
  53522. * Gets the current class name
  53523. * @returns the class name
  53524. */
  53525. getClassName(): string;
  53526. /**
  53527. * Gets the input component
  53528. */
  53529. readonly input: NodeMaterialConnectionPoint;
  53530. /**
  53531. * Gets the output component
  53532. */
  53533. readonly output: NodeMaterialConnectionPoint;
  53534. protected _buildBlock(state: NodeMaterialBuildState): this;
  53535. }
  53536. }
  53537. declare module BABYLON {
  53538. /**
  53539. * Block used to get the view direction
  53540. */
  53541. export class ViewDirectionBlock extends NodeMaterialBlock {
  53542. /**
  53543. * Creates a new ViewDirectionBlock
  53544. * @param name defines the block name
  53545. */
  53546. constructor(name: string);
  53547. /**
  53548. * Gets the current class name
  53549. * @returns the class name
  53550. */
  53551. getClassName(): string;
  53552. /**
  53553. * Gets the world position component
  53554. */
  53555. readonly worldPosition: NodeMaterialConnectionPoint;
  53556. /**
  53557. * Gets the camera position component
  53558. */
  53559. readonly cameraPosition: NodeMaterialConnectionPoint;
  53560. /**
  53561. * Gets the output component
  53562. */
  53563. readonly output: NodeMaterialConnectionPoint;
  53564. autoConfigure(material: NodeMaterial): void;
  53565. protected _buildBlock(state: NodeMaterialBuildState): this;
  53566. }
  53567. }
  53568. declare module BABYLON {
  53569. /**
  53570. * Block used to compute fresnel value
  53571. */
  53572. export class FresnelBlock extends NodeMaterialBlock {
  53573. /**
  53574. * Create a new FresnelBlock
  53575. * @param name defines the block name
  53576. */
  53577. constructor(name: string);
  53578. /**
  53579. * Gets the current class name
  53580. * @returns the class name
  53581. */
  53582. getClassName(): string;
  53583. /**
  53584. * Gets the world normal input component
  53585. */
  53586. readonly worldNormal: NodeMaterialConnectionPoint;
  53587. /**
  53588. * Gets the view direction input component
  53589. */
  53590. readonly viewDirection: NodeMaterialConnectionPoint;
  53591. /**
  53592. * Gets the bias input component
  53593. */
  53594. readonly bias: NodeMaterialConnectionPoint;
  53595. /**
  53596. * Gets the camera (or eye) position component
  53597. */
  53598. readonly power: NodeMaterialConnectionPoint;
  53599. /**
  53600. * Gets the fresnel output component
  53601. */
  53602. readonly fresnel: NodeMaterialConnectionPoint;
  53603. autoConfigure(material: NodeMaterial): void;
  53604. protected _buildBlock(state: NodeMaterialBuildState): this;
  53605. }
  53606. }
  53607. declare module BABYLON {
  53608. /**
  53609. * Block used to get the max of 2 values
  53610. */
  53611. export class MaxBlock extends NodeMaterialBlock {
  53612. /**
  53613. * Creates a new MaxBlock
  53614. * @param name defines the block name
  53615. */
  53616. constructor(name: string);
  53617. /**
  53618. * Gets the current class name
  53619. * @returns the class name
  53620. */
  53621. getClassName(): string;
  53622. /**
  53623. * Gets the left operand input component
  53624. */
  53625. readonly left: NodeMaterialConnectionPoint;
  53626. /**
  53627. * Gets the right operand input component
  53628. */
  53629. readonly right: NodeMaterialConnectionPoint;
  53630. /**
  53631. * Gets the output component
  53632. */
  53633. readonly output: NodeMaterialConnectionPoint;
  53634. protected _buildBlock(state: NodeMaterialBuildState): this;
  53635. }
  53636. }
  53637. declare module BABYLON {
  53638. /**
  53639. * Block used to get the min of 2 values
  53640. */
  53641. export class MinBlock extends NodeMaterialBlock {
  53642. /**
  53643. * Creates a new MinBlock
  53644. * @param name defines the block name
  53645. */
  53646. constructor(name: string);
  53647. /**
  53648. * Gets the current class name
  53649. * @returns the class name
  53650. */
  53651. getClassName(): string;
  53652. /**
  53653. * Gets the left operand input component
  53654. */
  53655. readonly left: NodeMaterialConnectionPoint;
  53656. /**
  53657. * Gets the right operand input component
  53658. */
  53659. readonly right: NodeMaterialConnectionPoint;
  53660. /**
  53661. * Gets the output component
  53662. */
  53663. readonly output: NodeMaterialConnectionPoint;
  53664. protected _buildBlock(state: NodeMaterialBuildState): this;
  53665. }
  53666. }
  53667. declare module BABYLON {
  53668. /**
  53669. * Block used to get the distance between 2 values
  53670. */
  53671. export class DistanceBlock extends NodeMaterialBlock {
  53672. /**
  53673. * Creates a new DistanceBlock
  53674. * @param name defines the block name
  53675. */
  53676. constructor(name: string);
  53677. /**
  53678. * Gets the current class name
  53679. * @returns the class name
  53680. */
  53681. getClassName(): string;
  53682. /**
  53683. * Gets the left operand input component
  53684. */
  53685. readonly left: NodeMaterialConnectionPoint;
  53686. /**
  53687. * Gets the right operand input component
  53688. */
  53689. readonly right: NodeMaterialConnectionPoint;
  53690. /**
  53691. * Gets the output component
  53692. */
  53693. readonly output: NodeMaterialConnectionPoint;
  53694. protected _buildBlock(state: NodeMaterialBuildState): this;
  53695. }
  53696. }
  53697. declare module BABYLON {
  53698. /**
  53699. * Block used to get the length of a vector
  53700. */
  53701. export class LengthBlock extends NodeMaterialBlock {
  53702. /**
  53703. * Creates a new LengthBlock
  53704. * @param name defines the block name
  53705. */
  53706. constructor(name: string);
  53707. /**
  53708. * Gets the current class name
  53709. * @returns the class name
  53710. */
  53711. getClassName(): string;
  53712. /**
  53713. * Gets the value input component
  53714. */
  53715. readonly value: NodeMaterialConnectionPoint;
  53716. /**
  53717. * Gets the output component
  53718. */
  53719. readonly output: NodeMaterialConnectionPoint;
  53720. protected _buildBlock(state: NodeMaterialBuildState): this;
  53721. }
  53722. }
  53723. declare module BABYLON {
  53724. /**
  53725. * Block used to get negative version of a value (i.e. x * -1)
  53726. */
  53727. export class NegateBlock extends NodeMaterialBlock {
  53728. /**
  53729. * Creates a new NegateBlock
  53730. * @param name defines the block name
  53731. */
  53732. constructor(name: string);
  53733. /**
  53734. * Gets the current class name
  53735. * @returns the class name
  53736. */
  53737. getClassName(): string;
  53738. /**
  53739. * Gets the value input component
  53740. */
  53741. readonly value: NodeMaterialConnectionPoint;
  53742. /**
  53743. * Gets the output component
  53744. */
  53745. readonly output: NodeMaterialConnectionPoint;
  53746. protected _buildBlock(state: NodeMaterialBuildState): this;
  53747. }
  53748. }
  53749. declare module BABYLON {
  53750. /**
  53751. * Block used to get the value of the first parameter raised to the power of the second
  53752. */
  53753. export class PowBlock extends NodeMaterialBlock {
  53754. /**
  53755. * Creates a new PowBlock
  53756. * @param name defines the block name
  53757. */
  53758. constructor(name: string);
  53759. /**
  53760. * Gets the current class name
  53761. * @returns the class name
  53762. */
  53763. getClassName(): string;
  53764. /**
  53765. * Gets the value operand input component
  53766. */
  53767. readonly value: NodeMaterialConnectionPoint;
  53768. /**
  53769. * Gets the power operand input component
  53770. */
  53771. readonly power: NodeMaterialConnectionPoint;
  53772. /**
  53773. * Gets the output component
  53774. */
  53775. readonly output: NodeMaterialConnectionPoint;
  53776. protected _buildBlock(state: NodeMaterialBuildState): this;
  53777. }
  53778. }
  53779. declare module BABYLON {
  53780. /**
  53781. * Effect Render Options
  53782. */
  53783. export interface IEffectRendererOptions {
  53784. /**
  53785. * Defines the vertices positions.
  53786. */
  53787. positions?: number[];
  53788. /**
  53789. * Defines the indices.
  53790. */
  53791. indices?: number[];
  53792. }
  53793. /**
  53794. * Helper class to render one or more effects
  53795. */
  53796. export class EffectRenderer {
  53797. private engine;
  53798. private static _DefaultOptions;
  53799. private _vertexBuffers;
  53800. private _indexBuffer;
  53801. private _ringBufferIndex;
  53802. private _ringScreenBuffer;
  53803. private _fullscreenViewport;
  53804. private _getNextFrameBuffer;
  53805. /**
  53806. * Creates an effect renderer
  53807. * @param engine the engine to use for rendering
  53808. * @param options defines the options of the effect renderer
  53809. */
  53810. constructor(engine: Engine, options?: IEffectRendererOptions);
  53811. /**
  53812. * Sets the current viewport in normalized coordinates 0-1
  53813. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  53814. */
  53815. setViewport(viewport?: Viewport): void;
  53816. /**
  53817. * Binds the embedded attributes buffer to the effect.
  53818. * @param effect Defines the effect to bind the attributes for
  53819. */
  53820. bindBuffers(effect: Effect): void;
  53821. /**
  53822. * Sets the current effect wrapper to use during draw.
  53823. * The effect needs to be ready before calling this api.
  53824. * This also sets the default full screen position attribute.
  53825. * @param effectWrapper Defines the effect to draw with
  53826. */
  53827. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  53828. /**
  53829. * Draws a full screen quad.
  53830. */
  53831. draw(): void;
  53832. /**
  53833. * renders one or more effects to a specified texture
  53834. * @param effectWrappers list of effects to renderer
  53835. * @param outputTexture texture to draw to, if null it will render to the screen
  53836. */
  53837. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  53838. /**
  53839. * Disposes of the effect renderer
  53840. */
  53841. dispose(): void;
  53842. }
  53843. /**
  53844. * Options to create an EffectWrapper
  53845. */
  53846. interface EffectWrapperCreationOptions {
  53847. /**
  53848. * Engine to use to create the effect
  53849. */
  53850. engine: Engine;
  53851. /**
  53852. * Fragment shader for the effect
  53853. */
  53854. fragmentShader: string;
  53855. /**
  53856. * Vertex shader for the effect
  53857. */
  53858. vertexShader?: string;
  53859. /**
  53860. * Attributes to use in the shader
  53861. */
  53862. attributeNames?: Array<string>;
  53863. /**
  53864. * Uniforms to use in the shader
  53865. */
  53866. uniformNames?: Array<string>;
  53867. /**
  53868. * Texture sampler names to use in the shader
  53869. */
  53870. samplerNames?: Array<string>;
  53871. /**
  53872. * The friendly name of the effect displayed in Spector.
  53873. */
  53874. name?: string;
  53875. }
  53876. /**
  53877. * Wraps an effect to be used for rendering
  53878. */
  53879. export class EffectWrapper {
  53880. /**
  53881. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  53882. */
  53883. onApplyObservable: Observable<{}>;
  53884. /**
  53885. * The underlying effect
  53886. */
  53887. effect: Effect;
  53888. /**
  53889. * Creates an effect to be renderer
  53890. * @param creationOptions options to create the effect
  53891. */
  53892. constructor(creationOptions: EffectWrapperCreationOptions);
  53893. /**
  53894. * Disposes of the effect wrapper
  53895. */
  53896. dispose(): void;
  53897. }
  53898. }
  53899. declare module BABYLON {
  53900. /**
  53901. * Helper class to push actions to a pool of workers.
  53902. */
  53903. export class WorkerPool implements IDisposable {
  53904. private _workerInfos;
  53905. private _pendingActions;
  53906. /**
  53907. * Constructor
  53908. * @param workers Array of workers to use for actions
  53909. */
  53910. constructor(workers: Array<Worker>);
  53911. /**
  53912. * Terminates all workers and clears any pending actions.
  53913. */
  53914. dispose(): void;
  53915. /**
  53916. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53917. * pended until a worker has completed its action.
  53918. * @param action The action to perform. Call onComplete when the action is complete.
  53919. */
  53920. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53921. private _execute;
  53922. }
  53923. }
  53924. declare module BABYLON {
  53925. /**
  53926. * Configuration for Draco compression
  53927. */
  53928. export interface IDracoCompressionConfiguration {
  53929. /**
  53930. * Configuration for the decoder.
  53931. */
  53932. decoder: {
  53933. /**
  53934. * The url to the WebAssembly module.
  53935. */
  53936. wasmUrl?: string;
  53937. /**
  53938. * The url to the WebAssembly binary.
  53939. */
  53940. wasmBinaryUrl?: string;
  53941. /**
  53942. * The url to the fallback JavaScript module.
  53943. */
  53944. fallbackUrl?: string;
  53945. };
  53946. }
  53947. /**
  53948. * Draco compression (https://google.github.io/draco/)
  53949. *
  53950. * This class wraps the Draco module.
  53951. *
  53952. * **Encoder**
  53953. *
  53954. * The encoder is not currently implemented.
  53955. *
  53956. * **Decoder**
  53957. *
  53958. * 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.
  53959. *
  53960. * To update the configuration, use the following code:
  53961. * ```javascript
  53962. * DracoCompression.Configuration = {
  53963. * decoder: {
  53964. * wasmUrl: "<url to the WebAssembly library>",
  53965. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53966. * fallbackUrl: "<url to the fallback JavaScript library>",
  53967. * }
  53968. * };
  53969. * ```
  53970. *
  53971. * 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.
  53972. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53973. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53974. *
  53975. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53976. * ```javascript
  53977. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53978. * ```
  53979. *
  53980. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53981. */
  53982. export class DracoCompression implements IDisposable {
  53983. private _workerPoolPromise?;
  53984. private _decoderModulePromise?;
  53985. /**
  53986. * The configuration. Defaults to the following urls:
  53987. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  53988. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  53989. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  53990. */
  53991. static Configuration: IDracoCompressionConfiguration;
  53992. /**
  53993. * Returns true if the decoder configuration is available.
  53994. */
  53995. static readonly DecoderAvailable: boolean;
  53996. /**
  53997. * Default number of workers to create when creating the draco compression object.
  53998. */
  53999. static DefaultNumWorkers: number;
  54000. private static GetDefaultNumWorkers;
  54001. private static _Default;
  54002. /**
  54003. * Default instance for the draco compression object.
  54004. */
  54005. static readonly Default: DracoCompression;
  54006. /**
  54007. * Constructor
  54008. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54009. */
  54010. constructor(numWorkers?: number);
  54011. /**
  54012. * Stop all async operations and release resources.
  54013. */
  54014. dispose(): void;
  54015. /**
  54016. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54017. * @returns a promise that resolves when ready
  54018. */
  54019. whenReadyAsync(): Promise<void>;
  54020. /**
  54021. * Decode Draco compressed mesh data to vertex data.
  54022. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54023. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54024. * @returns A promise that resolves with the decoded vertex data
  54025. */
  54026. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54027. [kind: string]: number;
  54028. }): Promise<VertexData>;
  54029. }
  54030. }
  54031. declare module BABYLON {
  54032. /**
  54033. * Class for building Constructive Solid Geometry
  54034. */
  54035. export class CSG {
  54036. private polygons;
  54037. /**
  54038. * The world matrix
  54039. */
  54040. matrix: Matrix;
  54041. /**
  54042. * Stores the position
  54043. */
  54044. position: Vector3;
  54045. /**
  54046. * Stores the rotation
  54047. */
  54048. rotation: Vector3;
  54049. /**
  54050. * Stores the rotation quaternion
  54051. */
  54052. rotationQuaternion: Nullable<Quaternion>;
  54053. /**
  54054. * Stores the scaling vector
  54055. */
  54056. scaling: Vector3;
  54057. /**
  54058. * Convert the Mesh to CSG
  54059. * @param mesh The Mesh to convert to CSG
  54060. * @returns A new CSG from the Mesh
  54061. */
  54062. static FromMesh(mesh: Mesh): CSG;
  54063. /**
  54064. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54065. * @param polygons Polygons used to construct a CSG solid
  54066. */
  54067. private static FromPolygons;
  54068. /**
  54069. * Clones, or makes a deep copy, of the CSG
  54070. * @returns A new CSG
  54071. */
  54072. clone(): CSG;
  54073. /**
  54074. * Unions this CSG with another CSG
  54075. * @param csg The CSG to union against this CSG
  54076. * @returns The unioned CSG
  54077. */
  54078. union(csg: CSG): CSG;
  54079. /**
  54080. * Unions this CSG with another CSG in place
  54081. * @param csg The CSG to union against this CSG
  54082. */
  54083. unionInPlace(csg: CSG): void;
  54084. /**
  54085. * Subtracts this CSG with another CSG
  54086. * @param csg The CSG to subtract against this CSG
  54087. * @returns A new CSG
  54088. */
  54089. subtract(csg: CSG): CSG;
  54090. /**
  54091. * Subtracts this CSG with another CSG in place
  54092. * @param csg The CSG to subtact against this CSG
  54093. */
  54094. subtractInPlace(csg: CSG): void;
  54095. /**
  54096. * Intersect this CSG with another CSG
  54097. * @param csg The CSG to intersect against this CSG
  54098. * @returns A new CSG
  54099. */
  54100. intersect(csg: CSG): CSG;
  54101. /**
  54102. * Intersects this CSG with another CSG in place
  54103. * @param csg The CSG to intersect against this CSG
  54104. */
  54105. intersectInPlace(csg: CSG): void;
  54106. /**
  54107. * Return a new CSG solid with solid and empty space switched. This solid is
  54108. * not modified.
  54109. * @returns A new CSG solid with solid and empty space switched
  54110. */
  54111. inverse(): CSG;
  54112. /**
  54113. * Inverses the CSG in place
  54114. */
  54115. inverseInPlace(): void;
  54116. /**
  54117. * This is used to keep meshes transformations so they can be restored
  54118. * when we build back a Babylon Mesh
  54119. * NB : All CSG operations are performed in world coordinates
  54120. * @param csg The CSG to copy the transform attributes from
  54121. * @returns This CSG
  54122. */
  54123. copyTransformAttributes(csg: CSG): CSG;
  54124. /**
  54125. * Build Raw mesh from CSG
  54126. * Coordinates here are in world space
  54127. * @param name The name of the mesh geometry
  54128. * @param scene The Scene
  54129. * @param keepSubMeshes Specifies if the submeshes should be kept
  54130. * @returns A new Mesh
  54131. */
  54132. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54133. /**
  54134. * Build Mesh from CSG taking material and transforms into account
  54135. * @param name The name of the Mesh
  54136. * @param material The material of the Mesh
  54137. * @param scene The Scene
  54138. * @param keepSubMeshes Specifies if submeshes should be kept
  54139. * @returns The new Mesh
  54140. */
  54141. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54142. }
  54143. }
  54144. declare module BABYLON {
  54145. /**
  54146. * Class used to create a trail following a mesh
  54147. */
  54148. export class TrailMesh extends Mesh {
  54149. private _generator;
  54150. private _autoStart;
  54151. private _running;
  54152. private _diameter;
  54153. private _length;
  54154. private _sectionPolygonPointsCount;
  54155. private _sectionVectors;
  54156. private _sectionNormalVectors;
  54157. private _beforeRenderObserver;
  54158. /**
  54159. * @constructor
  54160. * @param name The value used by scene.getMeshByName() to do a lookup.
  54161. * @param generator The mesh to generate a trail.
  54162. * @param scene The scene to add this mesh to.
  54163. * @param diameter Diameter of trailing mesh. Default is 1.
  54164. * @param length Length of trailing mesh. Default is 60.
  54165. * @param autoStart Automatically start trailing mesh. Default true.
  54166. */
  54167. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54168. /**
  54169. * "TrailMesh"
  54170. * @returns "TrailMesh"
  54171. */
  54172. getClassName(): string;
  54173. private _createMesh;
  54174. /**
  54175. * Start trailing mesh.
  54176. */
  54177. start(): void;
  54178. /**
  54179. * Stop trailing mesh.
  54180. */
  54181. stop(): void;
  54182. /**
  54183. * Update trailing mesh geometry.
  54184. */
  54185. update(): void;
  54186. /**
  54187. * Returns a new TrailMesh object.
  54188. * @param name is a string, the name given to the new mesh
  54189. * @param newGenerator use new generator object for cloned trail mesh
  54190. * @returns a new mesh
  54191. */
  54192. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54193. /**
  54194. * Serializes this trail mesh
  54195. * @param serializationObject object to write serialization to
  54196. */
  54197. serialize(serializationObject: any): void;
  54198. /**
  54199. * Parses a serialized trail mesh
  54200. * @param parsedMesh the serialized mesh
  54201. * @param scene the scene to create the trail mesh in
  54202. * @returns the created trail mesh
  54203. */
  54204. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54205. }
  54206. }
  54207. declare module BABYLON {
  54208. /**
  54209. * Class containing static functions to help procedurally build meshes
  54210. */
  54211. export class TiledBoxBuilder {
  54212. /**
  54213. * Creates a box mesh
  54214. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  54215. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54217. * * 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
  54218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54219. * @param name defines the name of the mesh
  54220. * @param options defines the options used to create the mesh
  54221. * @param scene defines the hosting scene
  54222. * @returns the box mesh
  54223. */
  54224. static CreateTiledBox(name: string, options: {
  54225. pattern?: number;
  54226. width?: number;
  54227. height?: number;
  54228. depth?: number;
  54229. tileSize?: number;
  54230. tileWidth?: number;
  54231. tileHeight?: number;
  54232. alignHorizontal?: number;
  54233. alignVertical?: number;
  54234. faceUV?: Vector4[];
  54235. faceColors?: Color4[];
  54236. sideOrientation?: number;
  54237. updatable?: boolean;
  54238. }, scene?: Nullable<Scene>): Mesh;
  54239. }
  54240. }
  54241. declare module BABYLON {
  54242. /**
  54243. * Class containing static functions to help procedurally build meshes
  54244. */
  54245. export class TorusKnotBuilder {
  54246. /**
  54247. * Creates a torus knot mesh
  54248. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54249. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54250. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54251. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54253. * * 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
  54254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54255. * @param name defines the name of the mesh
  54256. * @param options defines the options used to create the mesh
  54257. * @param scene defines the hosting scene
  54258. * @returns the torus knot mesh
  54259. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54260. */
  54261. static CreateTorusKnot(name: string, options: {
  54262. radius?: number;
  54263. tube?: number;
  54264. radialSegments?: number;
  54265. tubularSegments?: number;
  54266. p?: number;
  54267. q?: number;
  54268. updatable?: boolean;
  54269. sideOrientation?: number;
  54270. frontUVs?: Vector4;
  54271. backUVs?: Vector4;
  54272. }, scene: any): Mesh;
  54273. }
  54274. }
  54275. declare module BABYLON {
  54276. /**
  54277. * Polygon
  54278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54279. */
  54280. export class Polygon {
  54281. /**
  54282. * Creates a rectangle
  54283. * @param xmin bottom X coord
  54284. * @param ymin bottom Y coord
  54285. * @param xmax top X coord
  54286. * @param ymax top Y coord
  54287. * @returns points that make the resulting rectation
  54288. */
  54289. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54290. /**
  54291. * Creates a circle
  54292. * @param radius radius of circle
  54293. * @param cx scale in x
  54294. * @param cy scale in y
  54295. * @param numberOfSides number of sides that make up the circle
  54296. * @returns points that make the resulting circle
  54297. */
  54298. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54299. /**
  54300. * Creates a polygon from input string
  54301. * @param input Input polygon data
  54302. * @returns the parsed points
  54303. */
  54304. static Parse(input: string): Vector2[];
  54305. /**
  54306. * Starts building a polygon from x and y coordinates
  54307. * @param x x coordinate
  54308. * @param y y coordinate
  54309. * @returns the started path2
  54310. */
  54311. static StartingAt(x: number, y: number): Path2;
  54312. }
  54313. /**
  54314. * Builds a polygon
  54315. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54316. */
  54317. export class PolygonMeshBuilder {
  54318. private _points;
  54319. private _outlinepoints;
  54320. private _holes;
  54321. private _name;
  54322. private _scene;
  54323. private _epoints;
  54324. private _eholes;
  54325. private _addToepoint;
  54326. /**
  54327. * Babylon reference to the earcut plugin.
  54328. */
  54329. bjsEarcut: any;
  54330. /**
  54331. * Creates a PolygonMeshBuilder
  54332. * @param name name of the builder
  54333. * @param contours Path of the polygon
  54334. * @param scene scene to add to when creating the mesh
  54335. * @param earcutInjection can be used to inject your own earcut reference
  54336. */
  54337. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54338. /**
  54339. * Adds a whole within the polygon
  54340. * @param hole Array of points defining the hole
  54341. * @returns this
  54342. */
  54343. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54344. /**
  54345. * Creates the polygon
  54346. * @param updatable If the mesh should be updatable
  54347. * @param depth The depth of the mesh created
  54348. * @returns the created mesh
  54349. */
  54350. build(updatable?: boolean, depth?: number): Mesh;
  54351. /**
  54352. * Creates the polygon
  54353. * @param depth The depth of the mesh created
  54354. * @returns the created VertexData
  54355. */
  54356. buildVertexData(depth?: number): VertexData;
  54357. /**
  54358. * Adds a side to the polygon
  54359. * @param positions points that make the polygon
  54360. * @param normals normals of the polygon
  54361. * @param uvs uvs of the polygon
  54362. * @param indices indices of the polygon
  54363. * @param bounds bounds of the polygon
  54364. * @param points points of the polygon
  54365. * @param depth depth of the polygon
  54366. * @param flip flip of the polygon
  54367. */
  54368. private addSide;
  54369. }
  54370. }
  54371. declare module BABYLON {
  54372. /**
  54373. * Class containing static functions to help procedurally build meshes
  54374. */
  54375. export class PolygonBuilder {
  54376. /**
  54377. * Creates a polygon mesh
  54378. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54379. * * 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
  54380. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54382. * * 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)
  54383. * * Remember you can only change the shape positions, not their number when updating a polygon
  54384. * @param name defines the name of the mesh
  54385. * @param options defines the options used to create the mesh
  54386. * @param scene defines the hosting scene
  54387. * @param earcutInjection can be used to inject your own earcut reference
  54388. * @returns the polygon mesh
  54389. */
  54390. static CreatePolygon(name: string, options: {
  54391. shape: Vector3[];
  54392. holes?: Vector3[][];
  54393. depth?: number;
  54394. faceUV?: Vector4[];
  54395. faceColors?: Color4[];
  54396. updatable?: boolean;
  54397. sideOrientation?: number;
  54398. frontUVs?: Vector4;
  54399. backUVs?: Vector4;
  54400. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54401. /**
  54402. * Creates an extruded polygon mesh, with depth in the Y direction.
  54403. * * 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)
  54404. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54405. * @param name defines the name of the mesh
  54406. * @param options defines the options used to create the mesh
  54407. * @param scene defines the hosting scene
  54408. * @param earcutInjection can be used to inject your own earcut reference
  54409. * @returns the polygon mesh
  54410. */
  54411. static ExtrudePolygon(name: string, options: {
  54412. shape: Vector3[];
  54413. holes?: Vector3[][];
  54414. depth?: number;
  54415. faceUV?: Vector4[];
  54416. faceColors?: Color4[];
  54417. updatable?: boolean;
  54418. sideOrientation?: number;
  54419. frontUVs?: Vector4;
  54420. backUVs?: Vector4;
  54421. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54422. }
  54423. }
  54424. declare module BABYLON {
  54425. /**
  54426. * Class containing static functions to help procedurally build meshes
  54427. */
  54428. export class LatheBuilder {
  54429. /**
  54430. * Creates lathe mesh.
  54431. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54432. * * 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
  54433. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54434. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54435. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54436. * * 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
  54437. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54438. * * 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
  54439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54440. * * 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
  54441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54443. * @param name defines the name of the mesh
  54444. * @param options defines the options used to create the mesh
  54445. * @param scene defines the hosting scene
  54446. * @returns the lathe mesh
  54447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54448. */
  54449. static CreateLathe(name: string, options: {
  54450. shape: Vector3[];
  54451. radius?: number;
  54452. tessellation?: number;
  54453. clip?: number;
  54454. arc?: number;
  54455. closed?: boolean;
  54456. updatable?: boolean;
  54457. sideOrientation?: number;
  54458. frontUVs?: Vector4;
  54459. backUVs?: Vector4;
  54460. cap?: number;
  54461. invertUV?: boolean;
  54462. }, scene?: Nullable<Scene>): Mesh;
  54463. }
  54464. }
  54465. declare module BABYLON {
  54466. /**
  54467. * Class containing static functions to help procedurally build meshes
  54468. */
  54469. export class TiledPlaneBuilder {
  54470. /**
  54471. * Creates a tiled plane mesh
  54472. * * The parameter `pattern` will, depending on value, do nothing or
  54473. * * * flip (reflect about central vertical) alternate tiles across and up
  54474. * * * flip every tile on alternate rows
  54475. * * * rotate (180 degs) alternate tiles across and up
  54476. * * * rotate every tile on alternate rows
  54477. * * * flip and rotate alternate tiles across and up
  54478. * * * flip and rotate every tile on alternate rows
  54479. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54480. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54481. * * 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
  54482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54483. * * 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)
  54484. * * 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)
  54485. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54486. * @param name defines the name of the mesh
  54487. * @param options defines the options used to create the mesh
  54488. * @param scene defines the hosting scene
  54489. * @returns the box mesh
  54490. */
  54491. static CreateTiledPlane(name: string, options: {
  54492. pattern?: number;
  54493. tileSize?: number;
  54494. tileWidth?: number;
  54495. tileHeight?: number;
  54496. size?: number;
  54497. width?: number;
  54498. height?: number;
  54499. alignHorizontal?: number;
  54500. alignVertical?: number;
  54501. sideOrientation?: number;
  54502. frontUVs?: Vector4;
  54503. backUVs?: Vector4;
  54504. updatable?: boolean;
  54505. }, scene?: Nullable<Scene>): Mesh;
  54506. }
  54507. }
  54508. declare module BABYLON {
  54509. /**
  54510. * Class containing static functions to help procedurally build meshes
  54511. */
  54512. export class TubeBuilder {
  54513. /**
  54514. * Creates a tube mesh.
  54515. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54516. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54517. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54518. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54519. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54520. * * 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)
  54521. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54522. * * 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
  54523. * * 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
  54524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54525. * * 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
  54526. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54528. * @param name defines the name of the mesh
  54529. * @param options defines the options used to create the mesh
  54530. * @param scene defines the hosting scene
  54531. * @returns the tube mesh
  54532. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54533. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54534. */
  54535. static CreateTube(name: string, options: {
  54536. path: Vector3[];
  54537. radius?: number;
  54538. tessellation?: number;
  54539. radiusFunction?: {
  54540. (i: number, distance: number): number;
  54541. };
  54542. cap?: number;
  54543. arc?: number;
  54544. updatable?: boolean;
  54545. sideOrientation?: number;
  54546. frontUVs?: Vector4;
  54547. backUVs?: Vector4;
  54548. instance?: Mesh;
  54549. invertUV?: boolean;
  54550. }, scene?: Nullable<Scene>): Mesh;
  54551. }
  54552. }
  54553. declare module BABYLON {
  54554. /**
  54555. * Class containing static functions to help procedurally build meshes
  54556. */
  54557. export class IcoSphereBuilder {
  54558. /**
  54559. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54560. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54561. * * 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`)
  54562. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54563. * * 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
  54564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54565. * * 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
  54566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54567. * @param name defines the name of the mesh
  54568. * @param options defines the options used to create the mesh
  54569. * @param scene defines the hosting scene
  54570. * @returns the icosahedron mesh
  54571. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54572. */
  54573. static CreateIcoSphere(name: string, options: {
  54574. radius?: number;
  54575. radiusX?: number;
  54576. radiusY?: number;
  54577. radiusZ?: number;
  54578. flat?: boolean;
  54579. subdivisions?: number;
  54580. sideOrientation?: number;
  54581. frontUVs?: Vector4;
  54582. backUVs?: Vector4;
  54583. updatable?: boolean;
  54584. }, scene?: Nullable<Scene>): Mesh;
  54585. }
  54586. }
  54587. declare module BABYLON {
  54588. /**
  54589. * Class containing static functions to help procedurally build meshes
  54590. */
  54591. export class DecalBuilder {
  54592. /**
  54593. * Creates a decal mesh.
  54594. * 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
  54595. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54596. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54597. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54598. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54599. * @param name defines the name of the mesh
  54600. * @param sourceMesh defines the mesh where the decal must be applied
  54601. * @param options defines the options used to create the mesh
  54602. * @param scene defines the hosting scene
  54603. * @returns the decal mesh
  54604. * @see https://doc.babylonjs.com/how_to/decals
  54605. */
  54606. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54607. position?: Vector3;
  54608. normal?: Vector3;
  54609. size?: Vector3;
  54610. angle?: number;
  54611. }): Mesh;
  54612. }
  54613. }
  54614. declare module BABYLON {
  54615. /**
  54616. * Class containing static functions to help procedurally build meshes
  54617. */
  54618. export class MeshBuilder {
  54619. /**
  54620. * Creates a box mesh
  54621. * * The parameter `size` sets the size (float) of each box side (default 1)
  54622. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54623. * * 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)
  54624. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54626. * * 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
  54627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54628. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54629. * @param name defines the name of the mesh
  54630. * @param options defines the options used to create the mesh
  54631. * @param scene defines the hosting scene
  54632. * @returns the box mesh
  54633. */
  54634. static CreateBox(name: string, options: {
  54635. size?: number;
  54636. width?: number;
  54637. height?: number;
  54638. depth?: number;
  54639. faceUV?: Vector4[];
  54640. faceColors?: Color4[];
  54641. sideOrientation?: number;
  54642. frontUVs?: Vector4;
  54643. backUVs?: Vector4;
  54644. updatable?: boolean;
  54645. }, scene?: Nullable<Scene>): Mesh;
  54646. /**
  54647. * Creates a tiled box mesh
  54648. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54650. * @param name defines the name of the mesh
  54651. * @param options defines the options used to create the mesh
  54652. * @param scene defines the hosting scene
  54653. * @returns the tiled box mesh
  54654. */
  54655. static CreateTiledBox(name: string, options: {
  54656. pattern?: number;
  54657. size?: number;
  54658. width?: number;
  54659. height?: number;
  54660. depth: number;
  54661. tileSize?: number;
  54662. tileWidth?: number;
  54663. tileHeight?: number;
  54664. faceUV?: Vector4[];
  54665. faceColors?: Color4[];
  54666. alignHorizontal?: number;
  54667. alignVertical?: number;
  54668. sideOrientation?: number;
  54669. updatable?: boolean;
  54670. }, scene?: Nullable<Scene>): Mesh;
  54671. /**
  54672. * Creates a sphere mesh
  54673. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54674. * * 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`)
  54675. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54676. * * 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
  54677. * * 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)
  54678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54679. * * 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
  54680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54681. * @param name defines the name of the mesh
  54682. * @param options defines the options used to create the mesh
  54683. * @param scene defines the hosting scene
  54684. * @returns the sphere mesh
  54685. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54686. */
  54687. static CreateSphere(name: string, options: {
  54688. segments?: number;
  54689. diameter?: number;
  54690. diameterX?: number;
  54691. diameterY?: number;
  54692. diameterZ?: number;
  54693. arc?: number;
  54694. slice?: number;
  54695. sideOrientation?: number;
  54696. frontUVs?: Vector4;
  54697. backUVs?: Vector4;
  54698. updatable?: boolean;
  54699. }, scene?: Nullable<Scene>): Mesh;
  54700. /**
  54701. * Creates a plane polygonal mesh. By default, this is a disc
  54702. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54703. * * 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
  54704. * * 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
  54705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54706. * * 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
  54707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54708. * @param name defines the name of the mesh
  54709. * @param options defines the options used to create the mesh
  54710. * @param scene defines the hosting scene
  54711. * @returns the plane polygonal mesh
  54712. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54713. */
  54714. static CreateDisc(name: string, options: {
  54715. radius?: number;
  54716. tessellation?: number;
  54717. arc?: number;
  54718. updatable?: boolean;
  54719. sideOrientation?: number;
  54720. frontUVs?: Vector4;
  54721. backUVs?: Vector4;
  54722. }, scene?: Nullable<Scene>): Mesh;
  54723. /**
  54724. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54725. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54726. * * 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`)
  54727. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54728. * * 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
  54729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54730. * * 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
  54731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54732. * @param name defines the name of the mesh
  54733. * @param options defines the options used to create the mesh
  54734. * @param scene defines the hosting scene
  54735. * @returns the icosahedron mesh
  54736. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54737. */
  54738. static CreateIcoSphere(name: string, options: {
  54739. radius?: number;
  54740. radiusX?: number;
  54741. radiusY?: number;
  54742. radiusZ?: number;
  54743. flat?: boolean;
  54744. subdivisions?: number;
  54745. sideOrientation?: number;
  54746. frontUVs?: Vector4;
  54747. backUVs?: Vector4;
  54748. updatable?: boolean;
  54749. }, scene?: Nullable<Scene>): Mesh;
  54750. /**
  54751. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54752. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54753. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54754. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54755. * * 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
  54756. * * 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
  54757. * * 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
  54758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54759. * * 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
  54760. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54761. * * 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
  54762. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54763. * * 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
  54764. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54766. * @param name defines the name of the mesh
  54767. * @param options defines the options used to create the mesh
  54768. * @param scene defines the hosting scene
  54769. * @returns the ribbon mesh
  54770. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54771. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54772. */
  54773. static CreateRibbon(name: string, options: {
  54774. pathArray: Vector3[][];
  54775. closeArray?: boolean;
  54776. closePath?: boolean;
  54777. offset?: number;
  54778. updatable?: boolean;
  54779. sideOrientation?: number;
  54780. frontUVs?: Vector4;
  54781. backUVs?: Vector4;
  54782. instance?: Mesh;
  54783. invertUV?: boolean;
  54784. uvs?: Vector2[];
  54785. colors?: Color4[];
  54786. }, scene?: Nullable<Scene>): Mesh;
  54787. /**
  54788. * Creates a cylinder or a cone mesh
  54789. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54790. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54791. * * 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.
  54792. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54793. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54794. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54795. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54796. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  54797. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54798. * * 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).
  54799. * * 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
  54800. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54801. * * 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
  54802. * * 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.
  54803. * * If `enclose` is false, a ring surface is one element.
  54804. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54805. * * 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
  54806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54807. * * 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
  54808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54809. * @param name defines the name of the mesh
  54810. * @param options defines the options used to create the mesh
  54811. * @param scene defines the hosting scene
  54812. * @returns the cylinder mesh
  54813. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54814. */
  54815. static CreateCylinder(name: string, options: {
  54816. height?: number;
  54817. diameterTop?: number;
  54818. diameterBottom?: number;
  54819. diameter?: number;
  54820. tessellation?: number;
  54821. subdivisions?: number;
  54822. arc?: number;
  54823. faceColors?: Color4[];
  54824. faceUV?: Vector4[];
  54825. updatable?: boolean;
  54826. hasRings?: boolean;
  54827. enclose?: boolean;
  54828. cap?: number;
  54829. sideOrientation?: number;
  54830. frontUVs?: Vector4;
  54831. backUVs?: Vector4;
  54832. }, scene?: Nullable<Scene>): Mesh;
  54833. /**
  54834. * Creates a torus mesh
  54835. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54836. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54837. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54839. * * 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
  54840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54841. * @param name defines the name of the mesh
  54842. * @param options defines the options used to create the mesh
  54843. * @param scene defines the hosting scene
  54844. * @returns the torus mesh
  54845. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54846. */
  54847. static CreateTorus(name: string, options: {
  54848. diameter?: number;
  54849. thickness?: number;
  54850. tessellation?: number;
  54851. updatable?: boolean;
  54852. sideOrientation?: number;
  54853. frontUVs?: Vector4;
  54854. backUVs?: Vector4;
  54855. }, scene?: Nullable<Scene>): Mesh;
  54856. /**
  54857. * Creates a torus knot mesh
  54858. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54859. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54860. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54861. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54863. * * 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
  54864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54865. * @param name defines the name of the mesh
  54866. * @param options defines the options used to create the mesh
  54867. * @param scene defines the hosting scene
  54868. * @returns the torus knot mesh
  54869. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54870. */
  54871. static CreateTorusKnot(name: string, options: {
  54872. radius?: number;
  54873. tube?: number;
  54874. radialSegments?: number;
  54875. tubularSegments?: number;
  54876. p?: number;
  54877. q?: number;
  54878. updatable?: boolean;
  54879. sideOrientation?: number;
  54880. frontUVs?: Vector4;
  54881. backUVs?: Vector4;
  54882. }, scene?: Nullable<Scene>): Mesh;
  54883. /**
  54884. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54885. * * 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
  54886. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54887. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54888. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54889. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54890. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54891. * * 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
  54892. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54895. * @param name defines the name of the new line system
  54896. * @param options defines the options used to create the line system
  54897. * @param scene defines the hosting scene
  54898. * @returns a new line system mesh
  54899. */
  54900. static CreateLineSystem(name: string, options: {
  54901. lines: Vector3[][];
  54902. updatable?: boolean;
  54903. instance?: Nullable<LinesMesh>;
  54904. colors?: Nullable<Color4[][]>;
  54905. useVertexAlpha?: boolean;
  54906. }, scene: Nullable<Scene>): LinesMesh;
  54907. /**
  54908. * Creates a line mesh
  54909. * 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
  54910. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54911. * * The parameter `points` is an array successive Vector3
  54912. * * 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
  54913. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54914. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54915. * * When updating an instance, remember that only point positions can change, not the number of points
  54916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54918. * @param name defines the name of the new line system
  54919. * @param options defines the options used to create the line system
  54920. * @param scene defines the hosting scene
  54921. * @returns a new line mesh
  54922. */
  54923. static CreateLines(name: string, options: {
  54924. points: Vector3[];
  54925. updatable?: boolean;
  54926. instance?: Nullable<LinesMesh>;
  54927. colors?: Color4[];
  54928. useVertexAlpha?: boolean;
  54929. }, scene?: Nullable<Scene>): LinesMesh;
  54930. /**
  54931. * Creates a dashed line mesh
  54932. * * 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
  54933. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54934. * * The parameter `points` is an array successive Vector3
  54935. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54936. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54937. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54938. * * 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
  54939. * * When updating an instance, remember that only point positions can change, not the number of points
  54940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54941. * @param name defines the name of the mesh
  54942. * @param options defines the options used to create the mesh
  54943. * @param scene defines the hosting scene
  54944. * @returns the dashed line mesh
  54945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54946. */
  54947. static CreateDashedLines(name: string, options: {
  54948. points: Vector3[];
  54949. dashSize?: number;
  54950. gapSize?: number;
  54951. dashNb?: number;
  54952. updatable?: boolean;
  54953. instance?: LinesMesh;
  54954. }, scene?: Nullable<Scene>): LinesMesh;
  54955. /**
  54956. * 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.
  54957. * * 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.
  54958. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54959. * * 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.
  54960. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54961. * * 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
  54962. * * 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
  54963. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54965. * * 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
  54966. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54968. * @param name defines the name of the mesh
  54969. * @param options defines the options used to create the mesh
  54970. * @param scene defines the hosting scene
  54971. * @returns the extruded shape mesh
  54972. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54974. */
  54975. static ExtrudeShape(name: string, options: {
  54976. shape: Vector3[];
  54977. path: Vector3[];
  54978. scale?: number;
  54979. rotation?: number;
  54980. cap?: number;
  54981. updatable?: boolean;
  54982. sideOrientation?: number;
  54983. frontUVs?: Vector4;
  54984. backUVs?: Vector4;
  54985. instance?: Mesh;
  54986. invertUV?: boolean;
  54987. }, scene?: Nullable<Scene>): Mesh;
  54988. /**
  54989. * Creates an custom extruded shape mesh.
  54990. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54991. * * 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.
  54992. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54993. * * 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
  54994. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54995. * * 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
  54996. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54997. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54998. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54999. * * 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
  55000. * * 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
  55001. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55003. * * 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
  55004. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55006. * @param name defines the name of the mesh
  55007. * @param options defines the options used to create the mesh
  55008. * @param scene defines the hosting scene
  55009. * @returns the custom extruded shape mesh
  55010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55011. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55013. */
  55014. static ExtrudeShapeCustom(name: string, options: {
  55015. shape: Vector3[];
  55016. path: Vector3[];
  55017. scaleFunction?: any;
  55018. rotationFunction?: any;
  55019. ribbonCloseArray?: boolean;
  55020. ribbonClosePath?: boolean;
  55021. cap?: number;
  55022. updatable?: boolean;
  55023. sideOrientation?: number;
  55024. frontUVs?: Vector4;
  55025. backUVs?: Vector4;
  55026. instance?: Mesh;
  55027. invertUV?: boolean;
  55028. }, scene?: Nullable<Scene>): Mesh;
  55029. /**
  55030. * Creates lathe mesh.
  55031. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55032. * * 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
  55033. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55034. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55035. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55036. * * 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
  55037. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55038. * * 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
  55039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55040. * * 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
  55041. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55043. * @param name defines the name of the mesh
  55044. * @param options defines the options used to create the mesh
  55045. * @param scene defines the hosting scene
  55046. * @returns the lathe mesh
  55047. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55048. */
  55049. static CreateLathe(name: string, options: {
  55050. shape: Vector3[];
  55051. radius?: number;
  55052. tessellation?: number;
  55053. clip?: number;
  55054. arc?: number;
  55055. closed?: boolean;
  55056. updatable?: boolean;
  55057. sideOrientation?: number;
  55058. frontUVs?: Vector4;
  55059. backUVs?: Vector4;
  55060. cap?: number;
  55061. invertUV?: boolean;
  55062. }, scene?: Nullable<Scene>): Mesh;
  55063. /**
  55064. * Creates a tiled plane mesh
  55065. * * You can set a limited pattern arrangement with the tiles
  55066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55067. * * 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
  55068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55069. * @param name defines the name of the mesh
  55070. * @param options defines the options used to create the mesh
  55071. * @param scene defines the hosting scene
  55072. * @returns the plane mesh
  55073. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55074. */
  55075. static CreateTiledPlane(name: string, options: {
  55076. pattern?: number;
  55077. tileSize?: number;
  55078. tileWidth?: number;
  55079. tileHeight?: number;
  55080. size?: number;
  55081. width?: number;
  55082. height?: number;
  55083. alignHorizontal?: number;
  55084. alignVertical?: number;
  55085. sideOrientation?: number;
  55086. frontUVs?: Vector4;
  55087. backUVs?: Vector4;
  55088. updatable?: boolean;
  55089. }, scene?: Nullable<Scene>): Mesh;
  55090. /**
  55091. * Creates a plane mesh
  55092. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55093. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55094. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55096. * * 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
  55097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55098. * @param name defines the name of the mesh
  55099. * @param options defines the options used to create the mesh
  55100. * @param scene defines the hosting scene
  55101. * @returns the plane mesh
  55102. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55103. */
  55104. static CreatePlane(name: string, options: {
  55105. size?: number;
  55106. width?: number;
  55107. height?: number;
  55108. sideOrientation?: number;
  55109. frontUVs?: Vector4;
  55110. backUVs?: Vector4;
  55111. updatable?: boolean;
  55112. sourcePlane?: Plane;
  55113. }, scene?: Nullable<Scene>): Mesh;
  55114. /**
  55115. * Creates a ground mesh
  55116. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55117. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55119. * @param name defines the name of the mesh
  55120. * @param options defines the options used to create the mesh
  55121. * @param scene defines the hosting scene
  55122. * @returns the ground mesh
  55123. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55124. */
  55125. static CreateGround(name: string, options: {
  55126. width?: number;
  55127. height?: number;
  55128. subdivisions?: number;
  55129. subdivisionsX?: number;
  55130. subdivisionsY?: number;
  55131. updatable?: boolean;
  55132. }, scene?: Nullable<Scene>): Mesh;
  55133. /**
  55134. * Creates a tiled ground mesh
  55135. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55136. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55137. * * 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
  55138. * * 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
  55139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55140. * @param name defines the name of the mesh
  55141. * @param options defines the options used to create the mesh
  55142. * @param scene defines the hosting scene
  55143. * @returns the tiled ground mesh
  55144. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55145. */
  55146. static CreateTiledGround(name: string, options: {
  55147. xmin: number;
  55148. zmin: number;
  55149. xmax: number;
  55150. zmax: number;
  55151. subdivisions?: {
  55152. w: number;
  55153. h: number;
  55154. };
  55155. precision?: {
  55156. w: number;
  55157. h: number;
  55158. };
  55159. updatable?: boolean;
  55160. }, scene?: Nullable<Scene>): Mesh;
  55161. /**
  55162. * Creates a ground mesh from a height map
  55163. * * The parameter `url` sets the URL of the height map image resource.
  55164. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55165. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55166. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55167. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55168. * * 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.
  55169. * * 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).
  55170. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55172. * @param name defines the name of the mesh
  55173. * @param url defines the url to the height map
  55174. * @param options defines the options used to create the mesh
  55175. * @param scene defines the hosting scene
  55176. * @returns the ground mesh
  55177. * @see https://doc.babylonjs.com/babylon101/height_map
  55178. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55179. */
  55180. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55181. width?: number;
  55182. height?: number;
  55183. subdivisions?: number;
  55184. minHeight?: number;
  55185. maxHeight?: number;
  55186. colorFilter?: Color3;
  55187. alphaFilter?: number;
  55188. updatable?: boolean;
  55189. onReady?: (mesh: GroundMesh) => void;
  55190. }, scene?: Nullable<Scene>): GroundMesh;
  55191. /**
  55192. * Creates a polygon mesh
  55193. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55194. * * 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
  55195. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55197. * * 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)
  55198. * * Remember you can only change the shape positions, not their number when updating a polygon
  55199. * @param name defines the name of the mesh
  55200. * @param options defines the options used to create the mesh
  55201. * @param scene defines the hosting scene
  55202. * @param earcutInjection can be used to inject your own earcut reference
  55203. * @returns the polygon mesh
  55204. */
  55205. static CreatePolygon(name: string, options: {
  55206. shape: Vector3[];
  55207. holes?: Vector3[][];
  55208. depth?: number;
  55209. faceUV?: Vector4[];
  55210. faceColors?: Color4[];
  55211. updatable?: boolean;
  55212. sideOrientation?: number;
  55213. frontUVs?: Vector4;
  55214. backUVs?: Vector4;
  55215. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55216. /**
  55217. * Creates an extruded polygon mesh, with depth in the Y direction.
  55218. * * 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)
  55219. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55220. * @param name defines the name of the mesh
  55221. * @param options defines the options used to create the mesh
  55222. * @param scene defines the hosting scene
  55223. * @param earcutInjection can be used to inject your own earcut reference
  55224. * @returns the polygon mesh
  55225. */
  55226. static ExtrudePolygon(name: string, options: {
  55227. shape: Vector3[];
  55228. holes?: Vector3[][];
  55229. depth?: number;
  55230. faceUV?: Vector4[];
  55231. faceColors?: Color4[];
  55232. updatable?: boolean;
  55233. sideOrientation?: number;
  55234. frontUVs?: Vector4;
  55235. backUVs?: Vector4;
  55236. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55237. /**
  55238. * Creates a tube mesh.
  55239. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55240. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55241. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55242. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55243. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55244. * * 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)
  55245. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55246. * * 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
  55247. * * 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
  55248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55249. * * 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
  55250. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55252. * @param name defines the name of the mesh
  55253. * @param options defines the options used to create the mesh
  55254. * @param scene defines the hosting scene
  55255. * @returns the tube mesh
  55256. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55257. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55258. */
  55259. static CreateTube(name: string, options: {
  55260. path: Vector3[];
  55261. radius?: number;
  55262. tessellation?: number;
  55263. radiusFunction?: {
  55264. (i: number, distance: number): number;
  55265. };
  55266. cap?: number;
  55267. arc?: number;
  55268. updatable?: boolean;
  55269. sideOrientation?: number;
  55270. frontUVs?: Vector4;
  55271. backUVs?: Vector4;
  55272. instance?: Mesh;
  55273. invertUV?: boolean;
  55274. }, scene?: Nullable<Scene>): Mesh;
  55275. /**
  55276. * Creates a polyhedron mesh
  55277. * * 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
  55278. * * The parameter `size` (positive float, default 1) sets the polygon size
  55279. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55280. * * 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`
  55281. * * 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
  55282. * * 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)`)
  55283. * * 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
  55284. * * 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
  55285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55286. * * 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
  55287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55288. * @param name defines the name of the mesh
  55289. * @param options defines the options used to create the mesh
  55290. * @param scene defines the hosting scene
  55291. * @returns the polyhedron mesh
  55292. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55293. */
  55294. static CreatePolyhedron(name: string, options: {
  55295. type?: number;
  55296. size?: number;
  55297. sizeX?: number;
  55298. sizeY?: number;
  55299. sizeZ?: number;
  55300. custom?: any;
  55301. faceUV?: Vector4[];
  55302. faceColors?: Color4[];
  55303. flat?: boolean;
  55304. updatable?: boolean;
  55305. sideOrientation?: number;
  55306. frontUVs?: Vector4;
  55307. backUVs?: Vector4;
  55308. }, scene?: Nullable<Scene>): Mesh;
  55309. /**
  55310. * Creates a decal mesh.
  55311. * 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
  55312. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55313. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55314. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55315. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55316. * @param name defines the name of the mesh
  55317. * @param sourceMesh defines the mesh where the decal must be applied
  55318. * @param options defines the options used to create the mesh
  55319. * @param scene defines the hosting scene
  55320. * @returns the decal mesh
  55321. * @see https://doc.babylonjs.com/how_to/decals
  55322. */
  55323. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55324. position?: Vector3;
  55325. normal?: Vector3;
  55326. size?: Vector3;
  55327. angle?: number;
  55328. }): Mesh;
  55329. }
  55330. }
  55331. declare module BABYLON {
  55332. /**
  55333. * A simplifier interface for future simplification implementations
  55334. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55335. */
  55336. export interface ISimplifier {
  55337. /**
  55338. * Simplification of a given mesh according to the given settings.
  55339. * Since this requires computation, it is assumed that the function runs async.
  55340. * @param settings The settings of the simplification, including quality and distance
  55341. * @param successCallback A callback that will be called after the mesh was simplified.
  55342. * @param errorCallback in case of an error, this callback will be called. optional.
  55343. */
  55344. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55345. }
  55346. /**
  55347. * Expected simplification settings.
  55348. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55349. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55350. */
  55351. export interface ISimplificationSettings {
  55352. /**
  55353. * Gets or sets the expected quality
  55354. */
  55355. quality: number;
  55356. /**
  55357. * Gets or sets the distance when this optimized version should be used
  55358. */
  55359. distance: number;
  55360. /**
  55361. * Gets an already optimized mesh
  55362. */
  55363. optimizeMesh?: boolean;
  55364. }
  55365. /**
  55366. * Class used to specify simplification options
  55367. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55368. */
  55369. export class SimplificationSettings implements ISimplificationSettings {
  55370. /** expected quality */
  55371. quality: number;
  55372. /** distance when this optimized version should be used */
  55373. distance: number;
  55374. /** already optimized mesh */
  55375. optimizeMesh?: boolean | undefined;
  55376. /**
  55377. * Creates a SimplificationSettings
  55378. * @param quality expected quality
  55379. * @param distance distance when this optimized version should be used
  55380. * @param optimizeMesh already optimized mesh
  55381. */
  55382. constructor(
  55383. /** expected quality */
  55384. quality: number,
  55385. /** distance when this optimized version should be used */
  55386. distance: number,
  55387. /** already optimized mesh */
  55388. optimizeMesh?: boolean | undefined);
  55389. }
  55390. /**
  55391. * Interface used to define a simplification task
  55392. */
  55393. export interface ISimplificationTask {
  55394. /**
  55395. * Array of settings
  55396. */
  55397. settings: Array<ISimplificationSettings>;
  55398. /**
  55399. * Simplification type
  55400. */
  55401. simplificationType: SimplificationType;
  55402. /**
  55403. * Mesh to simplify
  55404. */
  55405. mesh: Mesh;
  55406. /**
  55407. * Callback called on success
  55408. */
  55409. successCallback?: () => void;
  55410. /**
  55411. * Defines if parallel processing can be used
  55412. */
  55413. parallelProcessing: boolean;
  55414. }
  55415. /**
  55416. * Queue used to order the simplification tasks
  55417. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55418. */
  55419. export class SimplificationQueue {
  55420. private _simplificationArray;
  55421. /**
  55422. * Gets a boolean indicating that the process is still running
  55423. */
  55424. running: boolean;
  55425. /**
  55426. * Creates a new queue
  55427. */
  55428. constructor();
  55429. /**
  55430. * Adds a new simplification task
  55431. * @param task defines a task to add
  55432. */
  55433. addTask(task: ISimplificationTask): void;
  55434. /**
  55435. * Execute next task
  55436. */
  55437. executeNext(): void;
  55438. /**
  55439. * Execute a simplification task
  55440. * @param task defines the task to run
  55441. */
  55442. runSimplification(task: ISimplificationTask): void;
  55443. private getSimplifier;
  55444. }
  55445. /**
  55446. * The implemented types of simplification
  55447. * At the moment only Quadratic Error Decimation is implemented
  55448. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55449. */
  55450. export enum SimplificationType {
  55451. /** Quadratic error decimation */
  55452. QUADRATIC = 0
  55453. }
  55454. }
  55455. declare module BABYLON {
  55456. interface Scene {
  55457. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  55458. /**
  55459. * Gets or sets the simplification queue attached to the scene
  55460. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55461. */
  55462. simplificationQueue: SimplificationQueue;
  55463. }
  55464. interface Mesh {
  55465. /**
  55466. * Simplify the mesh according to the given array of settings.
  55467. * Function will return immediately and will simplify async
  55468. * @param settings a collection of simplification settings
  55469. * @param parallelProcessing should all levels calculate parallel or one after the other
  55470. * @param simplificationType the type of simplification to run
  55471. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55472. * @returns the current mesh
  55473. */
  55474. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55475. }
  55476. /**
  55477. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55478. * created in a scene
  55479. */
  55480. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55481. /**
  55482. * The component name helpfull to identify the component in the list of scene components.
  55483. */
  55484. readonly name: string;
  55485. /**
  55486. * The scene the component belongs to.
  55487. */
  55488. scene: Scene;
  55489. /**
  55490. * Creates a new instance of the component for the given scene
  55491. * @param scene Defines the scene to register the component in
  55492. */
  55493. constructor(scene: Scene);
  55494. /**
  55495. * Registers the component in a given scene
  55496. */
  55497. register(): void;
  55498. /**
  55499. * Rebuilds the elements related to this component in case of
  55500. * context lost for instance.
  55501. */
  55502. rebuild(): void;
  55503. /**
  55504. * Disposes the component and the associated ressources
  55505. */
  55506. dispose(): void;
  55507. private _beforeCameraUpdate;
  55508. }
  55509. }
  55510. declare module BABYLON {
  55511. /**
  55512. * Navigation plugin interface to add navigation constrained by a navigation mesh
  55513. */
  55514. export interface INavigationEnginePlugin {
  55515. /**
  55516. * plugin name
  55517. */
  55518. name: string;
  55519. /**
  55520. * Creates a navigation mesh
  55521. * @param meshes array of all the geometry used to compute the navigatio mesh
  55522. * @param parameters bunch of parameters used to filter geometry
  55523. */
  55524. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55525. /**
  55526. * Create a navigation mesh debug mesh
  55527. * @param scene is where the mesh will be added
  55528. * @returns debug display mesh
  55529. */
  55530. createDebugNavMesh(scene: Scene): Mesh;
  55531. /**
  55532. * Get a navigation mesh constrained position, closest to the parameter position
  55533. * @param position world position
  55534. * @returns the closest point to position constrained by the navigation mesh
  55535. */
  55536. getClosestPoint(position: Vector3): Vector3;
  55537. /**
  55538. * Get a navigation mesh constrained position, within a particular radius
  55539. * @param position world position
  55540. * @param maxRadius the maximum distance to the constrained world position
  55541. * @returns the closest point to position constrained by the navigation mesh
  55542. */
  55543. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55544. /**
  55545. * Compute the final position from a segment made of destination-position
  55546. * @param position world position
  55547. * @param destination world position
  55548. * @returns the resulting point along the navmesh
  55549. */
  55550. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55551. /**
  55552. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55553. * @param start world position
  55554. * @param end world position
  55555. * @returns array containing world position composing the path
  55556. */
  55557. computePath(start: Vector3, end: Vector3): Vector3[];
  55558. /**
  55559. * If this plugin is supported
  55560. * @returns true if plugin is supported
  55561. */
  55562. isSupported(): boolean;
  55563. /**
  55564. * Create a new Crowd so you can add agents
  55565. * @param maxAgents the maximum agent count in the crowd
  55566. * @param maxAgentRadius the maximum radius an agent can have
  55567. * @param scene to attach the crowd to
  55568. * @returns the crowd you can add agents to
  55569. */
  55570. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55571. /**
  55572. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55573. * The queries will try to find a solution within those bounds
  55574. * default is (1,1,1)
  55575. * @param extent x,y,z value that define the extent around the queries point of reference
  55576. */
  55577. setDefaultQueryExtent(extent: Vector3): void;
  55578. /**
  55579. * Get the Bounding box extent specified by setDefaultQueryExtent
  55580. * @returns the box extent values
  55581. */
  55582. getDefaultQueryExtent(): Vector3;
  55583. /**
  55584. * Release all resources
  55585. */
  55586. dispose(): void;
  55587. }
  55588. /**
  55589. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  55590. */
  55591. export interface ICrowd {
  55592. /**
  55593. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55594. * You can attach anything to that node. The node position is updated in the scene update tick.
  55595. * @param pos world position that will be constrained by the navigation mesh
  55596. * @param parameters agent parameters
  55597. * @param transform hooked to the agent that will be update by the scene
  55598. * @returns agent index
  55599. */
  55600. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55601. /**
  55602. * Returns the agent position in world space
  55603. * @param index agent index returned by addAgent
  55604. * @returns world space position
  55605. */
  55606. getAgentPosition(index: number): Vector3;
  55607. /**
  55608. * Gets the agent velocity in world space
  55609. * @param index agent index returned by addAgent
  55610. * @returns world space velocity
  55611. */
  55612. getAgentVelocity(index: number): Vector3;
  55613. /**
  55614. * remove a particular agent previously created
  55615. * @param index agent index returned by addAgent
  55616. */
  55617. removeAgent(index: number): void;
  55618. /**
  55619. * get the list of all agents attached to this crowd
  55620. * @returns list of agent indices
  55621. */
  55622. getAgents(): number[];
  55623. /**
  55624. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55625. * @param deltaTime in seconds
  55626. */
  55627. update(deltaTime: number): void;
  55628. /**
  55629. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55630. * @param index agent index returned by addAgent
  55631. * @param destination targeted world position
  55632. */
  55633. agentGoto(index: number, destination: Vector3): void;
  55634. /**
  55635. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55636. * The queries will try to find a solution within those bounds
  55637. * default is (1,1,1)
  55638. * @param extent x,y,z value that define the extent around the queries point of reference
  55639. */
  55640. setDefaultQueryExtent(extent: Vector3): void;
  55641. /**
  55642. * Get the Bounding box extent specified by setDefaultQueryExtent
  55643. * @returns the box extent values
  55644. */
  55645. getDefaultQueryExtent(): Vector3;
  55646. /**
  55647. * Release all resources
  55648. */
  55649. dispose(): void;
  55650. }
  55651. /**
  55652. * Configures an agent
  55653. */
  55654. export interface IAgentParameters {
  55655. /**
  55656. * Agent radius. [Limit: >= 0]
  55657. */
  55658. radius: number;
  55659. /**
  55660. * Agent height. [Limit: > 0]
  55661. */
  55662. height: number;
  55663. /**
  55664. * Maximum allowed acceleration. [Limit: >= 0]
  55665. */
  55666. maxAcceleration: number;
  55667. /**
  55668. * Maximum allowed speed. [Limit: >= 0]
  55669. */
  55670. maxSpeed: number;
  55671. /**
  55672. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  55673. */
  55674. collisionQueryRange: number;
  55675. /**
  55676. * The path visibility optimization range. [Limit: > 0]
  55677. */
  55678. pathOptimizationRange: number;
  55679. /**
  55680. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  55681. */
  55682. separationWeight: number;
  55683. }
  55684. /**
  55685. * Configures the navigation mesh creation
  55686. */
  55687. export interface INavMeshParameters {
  55688. /**
  55689. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  55690. */
  55691. cs: number;
  55692. /**
  55693. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  55694. */
  55695. ch: number;
  55696. /**
  55697. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  55698. */
  55699. walkableSlopeAngle: number;
  55700. /**
  55701. * Minimum floor to 'ceiling' height that will still allow the floor area to
  55702. * be considered walkable. [Limit: >= 3] [Units: vx]
  55703. */
  55704. walkableHeight: number;
  55705. /**
  55706. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  55707. */
  55708. walkableClimb: number;
  55709. /**
  55710. * The distance to erode/shrink the walkable area of the heightfield away from
  55711. * obstructions. [Limit: >=0] [Units: vx]
  55712. */
  55713. walkableRadius: number;
  55714. /**
  55715. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  55716. */
  55717. maxEdgeLen: number;
  55718. /**
  55719. * The maximum distance a simplfied contour's border edges should deviate
  55720. * the original raw contour. [Limit: >=0] [Units: vx]
  55721. */
  55722. maxSimplificationError: number;
  55723. /**
  55724. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  55725. */
  55726. minRegionArea: number;
  55727. /**
  55728. * Any regions with a span count smaller than this value will, if possible,
  55729. * be merged with larger regions. [Limit: >=0] [Units: vx]
  55730. */
  55731. mergeRegionArea: number;
  55732. /**
  55733. * The maximum number of vertices allowed for polygons generated during the
  55734. * contour to polygon conversion process. [Limit: >= 3]
  55735. */
  55736. maxVertsPerPoly: number;
  55737. /**
  55738. * Sets the sampling distance to use when generating the detail mesh.
  55739. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  55740. */
  55741. detailSampleDist: number;
  55742. /**
  55743. * The maximum distance the detail mesh surface should deviate from heightfield
  55744. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  55745. */
  55746. detailSampleMaxError: number;
  55747. }
  55748. }
  55749. declare module BABYLON {
  55750. /**
  55751. * RecastJS navigation plugin
  55752. */
  55753. export class RecastJSPlugin implements INavigationEnginePlugin {
  55754. /**
  55755. * Reference to the Recast library
  55756. */
  55757. bjsRECAST: any;
  55758. /**
  55759. * plugin name
  55760. */
  55761. name: string;
  55762. /**
  55763. * the first navmesh created. We might extend this to support multiple navmeshes
  55764. */
  55765. navMesh: any;
  55766. /**
  55767. * Initializes the recastJS plugin
  55768. * @param recastInjection can be used to inject your own recast reference
  55769. */
  55770. constructor(recastInjection?: any);
  55771. /**
  55772. * Creates a navigation mesh
  55773. * @param meshes array of all the geometry used to compute the navigatio mesh
  55774. * @param parameters bunch of parameters used to filter geometry
  55775. */
  55776. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55777. /**
  55778. * Create a navigation mesh debug mesh
  55779. * @param scene is where the mesh will be added
  55780. * @returns debug display mesh
  55781. */
  55782. createDebugNavMesh(scene: Scene): Mesh;
  55783. /**
  55784. * Get a navigation mesh constrained position, closest to the parameter position
  55785. * @param position world position
  55786. * @returns the closest point to position constrained by the navigation mesh
  55787. */
  55788. getClosestPoint(position: Vector3): Vector3;
  55789. /**
  55790. * Get a navigation mesh constrained position, within a particular radius
  55791. * @param position world position
  55792. * @param maxRadius the maximum distance to the constrained world position
  55793. * @returns the closest point to position constrained by the navigation mesh
  55794. */
  55795. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55796. /**
  55797. * Compute the final position from a segment made of destination-position
  55798. * @param position world position
  55799. * @param destination world position
  55800. * @returns the resulting point along the navmesh
  55801. */
  55802. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55803. /**
  55804. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55805. * @param start world position
  55806. * @param end world position
  55807. * @returns array containing world position composing the path
  55808. */
  55809. computePath(start: Vector3, end: Vector3): Vector3[];
  55810. /**
  55811. * Create a new Crowd so you can add agents
  55812. * @param maxAgents the maximum agent count in the crowd
  55813. * @param maxAgentRadius the maximum radius an agent can have
  55814. * @param scene to attach the crowd to
  55815. * @returns the crowd you can add agents to
  55816. */
  55817. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55818. /**
  55819. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55820. * The queries will try to find a solution within those bounds
  55821. * default is (1,1,1)
  55822. * @param extent x,y,z value that define the extent around the queries point of reference
  55823. */
  55824. setDefaultQueryExtent(extent: Vector3): void;
  55825. /**
  55826. * Get the Bounding box extent specified by setDefaultQueryExtent
  55827. * @returns the box extent values
  55828. */
  55829. getDefaultQueryExtent(): Vector3;
  55830. /**
  55831. * Disposes
  55832. */
  55833. dispose(): void;
  55834. /**
  55835. * If this plugin is supported
  55836. * @returns true if plugin is supported
  55837. */
  55838. isSupported(): boolean;
  55839. }
  55840. /**
  55841. * Recast detour crowd implementation
  55842. */
  55843. export class RecastJSCrowd implements ICrowd {
  55844. /**
  55845. * Recast/detour plugin
  55846. */
  55847. bjsRECASTPlugin: RecastJSPlugin;
  55848. /**
  55849. * Link to the detour crowd
  55850. */
  55851. recastCrowd: any;
  55852. /**
  55853. * One transform per agent
  55854. */
  55855. transforms: TransformNode[];
  55856. /**
  55857. * All agents created
  55858. */
  55859. agents: number[];
  55860. /**
  55861. * Link to the scene is kept to unregister the crowd from the scene
  55862. */
  55863. private _scene;
  55864. /**
  55865. * Observer for crowd updates
  55866. */
  55867. private _onBeforeAnimationsObserver;
  55868. /**
  55869. * Constructor
  55870. * @param plugin recastJS plugin
  55871. * @param maxAgents the maximum agent count in the crowd
  55872. * @param maxAgentRadius the maximum radius an agent can have
  55873. * @param scene to attach the crowd to
  55874. * @returns the crowd you can add agents to
  55875. */
  55876. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  55877. /**
  55878. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55879. * You can attach anything to that node. The node position is updated in the scene update tick.
  55880. * @param pos world position that will be constrained by the navigation mesh
  55881. * @param parameters agent parameters
  55882. * @param transform hooked to the agent that will be update by the scene
  55883. * @returns agent index
  55884. */
  55885. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55886. /**
  55887. * Returns the agent position in world space
  55888. * @param index agent index returned by addAgent
  55889. * @returns world space position
  55890. */
  55891. getAgentPosition(index: number): Vector3;
  55892. /**
  55893. * Returns the agent velocity in world space
  55894. * @param index agent index returned by addAgent
  55895. * @returns world space velocity
  55896. */
  55897. getAgentVelocity(index: number): Vector3;
  55898. /**
  55899. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55900. * @param index agent index returned by addAgent
  55901. * @param destination targeted world position
  55902. */
  55903. agentGoto(index: number, destination: Vector3): void;
  55904. /**
  55905. * remove a particular agent previously created
  55906. * @param index agent index returned by addAgent
  55907. */
  55908. removeAgent(index: number): void;
  55909. /**
  55910. * get the list of all agents attached to this crowd
  55911. * @returns list of agent indices
  55912. */
  55913. getAgents(): number[];
  55914. /**
  55915. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55916. * @param deltaTime in seconds
  55917. */
  55918. update(deltaTime: number): void;
  55919. /**
  55920. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55921. * The queries will try to find a solution within those bounds
  55922. * default is (1,1,1)
  55923. * @param extent x,y,z value that define the extent around the queries point of reference
  55924. */
  55925. setDefaultQueryExtent(extent: Vector3): void;
  55926. /**
  55927. * Get the Bounding box extent specified by setDefaultQueryExtent
  55928. * @returns the box extent values
  55929. */
  55930. getDefaultQueryExtent(): Vector3;
  55931. /**
  55932. * Release all resources
  55933. */
  55934. dispose(): void;
  55935. }
  55936. }
  55937. declare module BABYLON {
  55938. /**
  55939. * Class used to enable access to IndexedDB
  55940. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55941. */
  55942. export class Database implements IOfflineProvider {
  55943. private _callbackManifestChecked;
  55944. private _currentSceneUrl;
  55945. private _db;
  55946. private _enableSceneOffline;
  55947. private _enableTexturesOffline;
  55948. private _manifestVersionFound;
  55949. private _mustUpdateRessources;
  55950. private _hasReachedQuota;
  55951. private _isSupported;
  55952. private _idbFactory;
  55953. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55954. private static IsUASupportingBlobStorage;
  55955. /**
  55956. * Gets a boolean indicating if Database storate is enabled (off by default)
  55957. */
  55958. static IDBStorageEnabled: boolean;
  55959. /**
  55960. * Gets a boolean indicating if scene must be saved in the database
  55961. */
  55962. readonly enableSceneOffline: boolean;
  55963. /**
  55964. * Gets a boolean indicating if textures must be saved in the database
  55965. */
  55966. readonly enableTexturesOffline: boolean;
  55967. /**
  55968. * Creates a new Database
  55969. * @param urlToScene defines the url to load the scene
  55970. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55971. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55972. */
  55973. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55974. private static _ParseURL;
  55975. private static _ReturnFullUrlLocation;
  55976. private _checkManifestFile;
  55977. /**
  55978. * Open the database and make it available
  55979. * @param successCallback defines the callback to call on success
  55980. * @param errorCallback defines the callback to call on error
  55981. */
  55982. open(successCallback: () => void, errorCallback: () => void): void;
  55983. /**
  55984. * Loads an image from the database
  55985. * @param url defines the url to load from
  55986. * @param image defines the target DOM image
  55987. */
  55988. loadImage(url: string, image: HTMLImageElement): void;
  55989. private _loadImageFromDBAsync;
  55990. private _saveImageIntoDBAsync;
  55991. private _checkVersionFromDB;
  55992. private _loadVersionFromDBAsync;
  55993. private _saveVersionIntoDBAsync;
  55994. /**
  55995. * Loads a file from database
  55996. * @param url defines the URL to load from
  55997. * @param sceneLoaded defines a callback to call on success
  55998. * @param progressCallBack defines a callback to call when progress changed
  55999. * @param errorCallback defines a callback to call on error
  56000. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56001. */
  56002. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56003. private _loadFileAsync;
  56004. private _saveFileAsync;
  56005. /**
  56006. * Validates if xhr data is correct
  56007. * @param xhr defines the request to validate
  56008. * @param dataType defines the expected data type
  56009. * @returns true if data is correct
  56010. */
  56011. private static _ValidateXHRData;
  56012. }
  56013. }
  56014. declare module BABYLON {
  56015. /** @hidden */
  56016. export var gpuUpdateParticlesPixelShader: {
  56017. name: string;
  56018. shader: string;
  56019. };
  56020. }
  56021. declare module BABYLON {
  56022. /** @hidden */
  56023. export var gpuUpdateParticlesVertexShader: {
  56024. name: string;
  56025. shader: string;
  56026. };
  56027. }
  56028. declare module BABYLON {
  56029. /** @hidden */
  56030. export var clipPlaneFragmentDeclaration2: {
  56031. name: string;
  56032. shader: string;
  56033. };
  56034. }
  56035. declare module BABYLON {
  56036. /** @hidden */
  56037. export var gpuRenderParticlesPixelShader: {
  56038. name: string;
  56039. shader: string;
  56040. };
  56041. }
  56042. declare module BABYLON {
  56043. /** @hidden */
  56044. export var clipPlaneVertexDeclaration2: {
  56045. name: string;
  56046. shader: string;
  56047. };
  56048. }
  56049. declare module BABYLON {
  56050. /** @hidden */
  56051. export var gpuRenderParticlesVertexShader: {
  56052. name: string;
  56053. shader: string;
  56054. };
  56055. }
  56056. declare module BABYLON {
  56057. /**
  56058. * This represents a GPU particle system in Babylon
  56059. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56060. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56061. */
  56062. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56063. /**
  56064. * The layer mask we are rendering the particles through.
  56065. */
  56066. layerMask: number;
  56067. private _capacity;
  56068. private _activeCount;
  56069. private _currentActiveCount;
  56070. private _accumulatedCount;
  56071. private _renderEffect;
  56072. private _updateEffect;
  56073. private _buffer0;
  56074. private _buffer1;
  56075. private _spriteBuffer;
  56076. private _updateVAO;
  56077. private _renderVAO;
  56078. private _targetIndex;
  56079. private _sourceBuffer;
  56080. private _targetBuffer;
  56081. private _engine;
  56082. private _currentRenderId;
  56083. private _started;
  56084. private _stopped;
  56085. private _timeDelta;
  56086. private _randomTexture;
  56087. private _randomTexture2;
  56088. private _attributesStrideSize;
  56089. private _updateEffectOptions;
  56090. private _randomTextureSize;
  56091. private _actualFrame;
  56092. private readonly _rawTextureWidth;
  56093. /**
  56094. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56095. */
  56096. static readonly IsSupported: boolean;
  56097. /**
  56098. * An event triggered when the system is disposed.
  56099. */
  56100. onDisposeObservable: Observable<GPUParticleSystem>;
  56101. /**
  56102. * Gets the maximum number of particles active at the same time.
  56103. * @returns The max number of active particles.
  56104. */
  56105. getCapacity(): number;
  56106. /**
  56107. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56108. * to override the particles.
  56109. */
  56110. forceDepthWrite: boolean;
  56111. /**
  56112. * Gets or set the number of active particles
  56113. */
  56114. activeParticleCount: number;
  56115. private _preWarmDone;
  56116. /**
  56117. * Is this system ready to be used/rendered
  56118. * @return true if the system is ready
  56119. */
  56120. isReady(): boolean;
  56121. /**
  56122. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56123. * @returns True if it has been started, otherwise false.
  56124. */
  56125. isStarted(): boolean;
  56126. /**
  56127. * Starts the particle system and begins to emit
  56128. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56129. */
  56130. start(delay?: number): void;
  56131. /**
  56132. * Stops the particle system.
  56133. */
  56134. stop(): void;
  56135. /**
  56136. * Remove all active particles
  56137. */
  56138. reset(): void;
  56139. /**
  56140. * Returns the string "GPUParticleSystem"
  56141. * @returns a string containing the class name
  56142. */
  56143. getClassName(): string;
  56144. private _colorGradientsTexture;
  56145. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56146. /**
  56147. * Adds a new color gradient
  56148. * @param gradient defines the gradient to use (between 0 and 1)
  56149. * @param color1 defines the color to affect to the specified gradient
  56150. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56151. * @returns the current particle system
  56152. */
  56153. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56154. /**
  56155. * Remove a specific color gradient
  56156. * @param gradient defines the gradient to remove
  56157. * @returns the current particle system
  56158. */
  56159. removeColorGradient(gradient: number): GPUParticleSystem;
  56160. private _angularSpeedGradientsTexture;
  56161. private _sizeGradientsTexture;
  56162. private _velocityGradientsTexture;
  56163. private _limitVelocityGradientsTexture;
  56164. private _dragGradientsTexture;
  56165. private _addFactorGradient;
  56166. /**
  56167. * Adds a new size gradient
  56168. * @param gradient defines the gradient to use (between 0 and 1)
  56169. * @param factor defines the size factor to affect to the specified gradient
  56170. * @returns the current particle system
  56171. */
  56172. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56173. /**
  56174. * Remove a specific size gradient
  56175. * @param gradient defines the gradient to remove
  56176. * @returns the current particle system
  56177. */
  56178. removeSizeGradient(gradient: number): GPUParticleSystem;
  56179. /**
  56180. * Adds a new angular speed gradient
  56181. * @param gradient defines the gradient to use (between 0 and 1)
  56182. * @param factor defines the angular speed to affect to the specified gradient
  56183. * @returns the current particle system
  56184. */
  56185. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56186. /**
  56187. * Remove a specific angular speed gradient
  56188. * @param gradient defines the gradient to remove
  56189. * @returns the current particle system
  56190. */
  56191. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56192. /**
  56193. * Adds a new velocity gradient
  56194. * @param gradient defines the gradient to use (between 0 and 1)
  56195. * @param factor defines the velocity to affect to the specified gradient
  56196. * @returns the current particle system
  56197. */
  56198. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56199. /**
  56200. * Remove a specific velocity gradient
  56201. * @param gradient defines the gradient to remove
  56202. * @returns the current particle system
  56203. */
  56204. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56205. /**
  56206. * Adds a new limit velocity gradient
  56207. * @param gradient defines the gradient to use (between 0 and 1)
  56208. * @param factor defines the limit velocity value to affect to the specified gradient
  56209. * @returns the current particle system
  56210. */
  56211. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56212. /**
  56213. * Remove a specific limit velocity gradient
  56214. * @param gradient defines the gradient to remove
  56215. * @returns the current particle system
  56216. */
  56217. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56218. /**
  56219. * Adds a new drag gradient
  56220. * @param gradient defines the gradient to use (between 0 and 1)
  56221. * @param factor defines the drag value to affect to the specified gradient
  56222. * @returns the current particle system
  56223. */
  56224. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56225. /**
  56226. * Remove a specific drag gradient
  56227. * @param gradient defines the gradient to remove
  56228. * @returns the current particle system
  56229. */
  56230. removeDragGradient(gradient: number): GPUParticleSystem;
  56231. /**
  56232. * Not supported by GPUParticleSystem
  56233. * @param gradient defines the gradient to use (between 0 and 1)
  56234. * @param factor defines the emit rate value to affect to the specified gradient
  56235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56236. * @returns the current particle system
  56237. */
  56238. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56239. /**
  56240. * Not supported by GPUParticleSystem
  56241. * @param gradient defines the gradient to remove
  56242. * @returns the current particle system
  56243. */
  56244. removeEmitRateGradient(gradient: number): IParticleSystem;
  56245. /**
  56246. * Not supported by GPUParticleSystem
  56247. * @param gradient defines the gradient to use (between 0 and 1)
  56248. * @param factor defines the start size value to affect to the specified gradient
  56249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56250. * @returns the current particle system
  56251. */
  56252. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56253. /**
  56254. * Not supported by GPUParticleSystem
  56255. * @param gradient defines the gradient to remove
  56256. * @returns the current particle system
  56257. */
  56258. removeStartSizeGradient(gradient: number): IParticleSystem;
  56259. /**
  56260. * Not supported by GPUParticleSystem
  56261. * @param gradient defines the gradient to use (between 0 and 1)
  56262. * @param min defines the color remap minimal range
  56263. * @param max defines the color remap maximal range
  56264. * @returns the current particle system
  56265. */
  56266. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56267. /**
  56268. * Not supported by GPUParticleSystem
  56269. * @param gradient defines the gradient to remove
  56270. * @returns the current particle system
  56271. */
  56272. removeColorRemapGradient(): IParticleSystem;
  56273. /**
  56274. * Not supported by GPUParticleSystem
  56275. * @param gradient defines the gradient to use (between 0 and 1)
  56276. * @param min defines the alpha remap minimal range
  56277. * @param max defines the alpha remap maximal range
  56278. * @returns the current particle system
  56279. */
  56280. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56281. /**
  56282. * Not supported by GPUParticleSystem
  56283. * @param gradient defines the gradient to remove
  56284. * @returns the current particle system
  56285. */
  56286. removeAlphaRemapGradient(): IParticleSystem;
  56287. /**
  56288. * Not supported by GPUParticleSystem
  56289. * @param gradient defines the gradient to use (between 0 and 1)
  56290. * @param color defines the color to affect to the specified gradient
  56291. * @returns the current particle system
  56292. */
  56293. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56294. /**
  56295. * Not supported by GPUParticleSystem
  56296. * @param gradient defines the gradient to remove
  56297. * @returns the current particle system
  56298. */
  56299. removeRampGradient(): IParticleSystem;
  56300. /**
  56301. * Not supported by GPUParticleSystem
  56302. * @returns the list of ramp gradients
  56303. */
  56304. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56305. /**
  56306. * Not supported by GPUParticleSystem
  56307. * Gets or sets a boolean indicating that ramp gradients must be used
  56308. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56309. */
  56310. useRampGradients: boolean;
  56311. /**
  56312. * Not supported by GPUParticleSystem
  56313. * @param gradient defines the gradient to use (between 0 and 1)
  56314. * @param factor defines the life time factor to affect to the specified gradient
  56315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56316. * @returns the current particle system
  56317. */
  56318. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56319. /**
  56320. * Not supported by GPUParticleSystem
  56321. * @param gradient defines the gradient to remove
  56322. * @returns the current particle system
  56323. */
  56324. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56325. /**
  56326. * Instantiates a GPU particle system.
  56327. * 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.
  56328. * @param name The name of the particle system
  56329. * @param options The options used to create the system
  56330. * @param scene The scene the particle system belongs to
  56331. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56332. */
  56333. constructor(name: string, options: Partial<{
  56334. capacity: number;
  56335. randomTextureSize: number;
  56336. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56337. protected _reset(): void;
  56338. private _createUpdateVAO;
  56339. private _createRenderVAO;
  56340. private _initialize;
  56341. /** @hidden */ private _recreateUpdateEffect(): void;
  56342. /** @hidden */ private _recreateRenderEffect(): void;
  56343. /**
  56344. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56345. * @param preWarm defines if we are in the pre-warmimg phase
  56346. */
  56347. animate(preWarm?: boolean): void;
  56348. private _createFactorGradientTexture;
  56349. private _createSizeGradientTexture;
  56350. private _createAngularSpeedGradientTexture;
  56351. private _createVelocityGradientTexture;
  56352. private _createLimitVelocityGradientTexture;
  56353. private _createDragGradientTexture;
  56354. private _createColorGradientTexture;
  56355. /**
  56356. * Renders the particle system in its current state
  56357. * @param preWarm defines if the system should only update the particles but not render them
  56358. * @returns the current number of particles
  56359. */
  56360. render(preWarm?: boolean): number;
  56361. /**
  56362. * Rebuilds the particle system
  56363. */
  56364. rebuild(): void;
  56365. private _releaseBuffers;
  56366. private _releaseVAOs;
  56367. /**
  56368. * Disposes the particle system and free the associated resources
  56369. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56370. */
  56371. dispose(disposeTexture?: boolean): void;
  56372. /**
  56373. * Clones the particle system.
  56374. * @param name The name of the cloned object
  56375. * @param newEmitter The new emitter to use
  56376. * @returns the cloned particle system
  56377. */
  56378. clone(name: string, newEmitter: any): GPUParticleSystem;
  56379. /**
  56380. * Serializes the particle system to a JSON object.
  56381. * @returns the JSON object
  56382. */
  56383. serialize(): any;
  56384. /**
  56385. * Parses a JSON object to create a GPU particle system.
  56386. * @param parsedParticleSystem The JSON object to parse
  56387. * @param scene The scene to create the particle system in
  56388. * @param rootUrl The root url to use to load external dependencies like texture
  56389. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56390. * @returns the parsed GPU particle system
  56391. */
  56392. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56393. }
  56394. }
  56395. declare module BABYLON {
  56396. /**
  56397. * Represents a set of particle systems working together to create a specific effect
  56398. */
  56399. export class ParticleSystemSet implements IDisposable {
  56400. private _emitterCreationOptions;
  56401. private _emitterNode;
  56402. /**
  56403. * Gets the particle system list
  56404. */
  56405. systems: IParticleSystem[];
  56406. /**
  56407. * Gets the emitter node used with this set
  56408. */
  56409. readonly emitterNode: Nullable<TransformNode>;
  56410. /**
  56411. * Creates a new emitter mesh as a sphere
  56412. * @param options defines the options used to create the sphere
  56413. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56414. * @param scene defines the hosting scene
  56415. */
  56416. setEmitterAsSphere(options: {
  56417. diameter: number;
  56418. segments: number;
  56419. color: Color3;
  56420. }, renderingGroupId: number, scene: Scene): void;
  56421. /**
  56422. * Starts all particle systems of the set
  56423. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56424. */
  56425. start(emitter?: AbstractMesh): void;
  56426. /**
  56427. * Release all associated resources
  56428. */
  56429. dispose(): void;
  56430. /**
  56431. * Serialize the set into a JSON compatible object
  56432. * @returns a JSON compatible representation of the set
  56433. */
  56434. serialize(): any;
  56435. /**
  56436. * Parse a new ParticleSystemSet from a serialized source
  56437. * @param data defines a JSON compatible representation of the set
  56438. * @param scene defines the hosting scene
  56439. * @param gpu defines if we want GPU particles or CPU particles
  56440. * @returns a new ParticleSystemSet
  56441. */
  56442. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56443. }
  56444. }
  56445. declare module BABYLON {
  56446. /**
  56447. * This class is made for on one-liner static method to help creating particle system set.
  56448. */
  56449. export class ParticleHelper {
  56450. /**
  56451. * Gets or sets base Assets URL
  56452. */
  56453. static BaseAssetsUrl: string;
  56454. /**
  56455. * Create a default particle system that you can tweak
  56456. * @param emitter defines the emitter to use
  56457. * @param capacity defines the system capacity (default is 500 particles)
  56458. * @param scene defines the hosting scene
  56459. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56460. * @returns the new Particle system
  56461. */
  56462. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56463. /**
  56464. * This is the main static method (one-liner) of this helper to create different particle systems
  56465. * @param type This string represents the type to the particle system to create
  56466. * @param scene The scene where the particle system should live
  56467. * @param gpu If the system will use gpu
  56468. * @returns the ParticleSystemSet created
  56469. */
  56470. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56471. /**
  56472. * Static function used to export a particle system to a ParticleSystemSet variable.
  56473. * Please note that the emitter shape is not exported
  56474. * @param systems defines the particle systems to export
  56475. * @returns the created particle system set
  56476. */
  56477. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56478. }
  56479. }
  56480. declare module BABYLON {
  56481. interface Engine {
  56482. /**
  56483. * Create an effect to use with particle systems.
  56484. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56485. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56486. * @param uniformsNames defines a list of attribute names
  56487. * @param samplers defines an array of string used to represent textures
  56488. * @param defines defines the string containing the defines to use to compile the shaders
  56489. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56490. * @param onCompiled defines a function to call when the effect creation is successful
  56491. * @param onError defines a function to call when the effect creation has failed
  56492. * @returns the new Effect
  56493. */
  56494. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56495. }
  56496. interface Mesh {
  56497. /**
  56498. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56499. * @returns an array of IParticleSystem
  56500. */
  56501. getEmittedParticleSystems(): IParticleSystem[];
  56502. /**
  56503. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56504. * @returns an array of IParticleSystem
  56505. */
  56506. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56507. }
  56508. /**
  56509. * @hidden
  56510. */
  56511. export var _IDoNeedToBeInTheBuild: number;
  56512. }
  56513. declare module BABYLON {
  56514. interface Scene {
  56515. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  56516. /**
  56517. * Gets the current physics engine
  56518. * @returns a IPhysicsEngine or null if none attached
  56519. */
  56520. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56521. /**
  56522. * Enables physics to the current scene
  56523. * @param gravity defines the scene's gravity for the physics engine
  56524. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56525. * @return a boolean indicating if the physics engine was initialized
  56526. */
  56527. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56528. /**
  56529. * Disables and disposes the physics engine associated with the scene
  56530. */
  56531. disablePhysicsEngine(): void;
  56532. /**
  56533. * Gets a boolean indicating if there is an active physics engine
  56534. * @returns a boolean indicating if there is an active physics engine
  56535. */
  56536. isPhysicsEnabled(): boolean;
  56537. /**
  56538. * Deletes a physics compound impostor
  56539. * @param compound defines the compound to delete
  56540. */
  56541. deleteCompoundImpostor(compound: any): void;
  56542. /**
  56543. * An event triggered when physic simulation is about to be run
  56544. */
  56545. onBeforePhysicsObservable: Observable<Scene>;
  56546. /**
  56547. * An event triggered when physic simulation has been done
  56548. */
  56549. onAfterPhysicsObservable: Observable<Scene>;
  56550. }
  56551. interface AbstractMesh {
  56552. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  56553. /**
  56554. * Gets or sets impostor used for physic simulation
  56555. * @see http://doc.babylonjs.com/features/physics_engine
  56556. */
  56557. physicsImpostor: Nullable<PhysicsImpostor>;
  56558. /**
  56559. * Gets the current physics impostor
  56560. * @see http://doc.babylonjs.com/features/physics_engine
  56561. * @returns a physics impostor or null
  56562. */
  56563. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56564. /** Apply a physic impulse to the mesh
  56565. * @param force defines the force to apply
  56566. * @param contactPoint defines where to apply the force
  56567. * @returns the current mesh
  56568. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56569. */
  56570. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56571. /**
  56572. * Creates a physic joint between two meshes
  56573. * @param otherMesh defines the other mesh to use
  56574. * @param pivot1 defines the pivot to use on this mesh
  56575. * @param pivot2 defines the pivot to use on the other mesh
  56576. * @param options defines additional options (can be plugin dependent)
  56577. * @returns the current mesh
  56578. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56579. */
  56580. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56581. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  56582. }
  56583. /**
  56584. * Defines the physics engine scene component responsible to manage a physics engine
  56585. */
  56586. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56587. /**
  56588. * The component name helpful to identify the component in the list of scene components.
  56589. */
  56590. readonly name: string;
  56591. /**
  56592. * The scene the component belongs to.
  56593. */
  56594. scene: Scene;
  56595. /**
  56596. * Creates a new instance of the component for the given scene
  56597. * @param scene Defines the scene to register the component in
  56598. */
  56599. constructor(scene: Scene);
  56600. /**
  56601. * Registers the component in a given scene
  56602. */
  56603. register(): void;
  56604. /**
  56605. * Rebuilds the elements related to this component in case of
  56606. * context lost for instance.
  56607. */
  56608. rebuild(): void;
  56609. /**
  56610. * Disposes the component and the associated ressources
  56611. */
  56612. dispose(): void;
  56613. }
  56614. }
  56615. declare module BABYLON {
  56616. /**
  56617. * A helper for physics simulations
  56618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56619. */
  56620. export class PhysicsHelper {
  56621. private _scene;
  56622. private _physicsEngine;
  56623. /**
  56624. * Initializes the Physics helper
  56625. * @param scene Babylon.js scene
  56626. */
  56627. constructor(scene: Scene);
  56628. /**
  56629. * Applies a radial explosion impulse
  56630. * @param origin the origin of the explosion
  56631. * @param radiusOrEventOptions the radius or the options of radial explosion
  56632. * @param strength the explosion strength
  56633. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56634. * @returns A physics radial explosion event, or null
  56635. */
  56636. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56637. /**
  56638. * Applies a radial explosion force
  56639. * @param origin the origin of the explosion
  56640. * @param radiusOrEventOptions the radius or the options of radial explosion
  56641. * @param strength the explosion strength
  56642. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56643. * @returns A physics radial explosion event, or null
  56644. */
  56645. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56646. /**
  56647. * Creates a gravitational field
  56648. * @param origin the origin of the explosion
  56649. * @param radiusOrEventOptions the radius or the options of radial explosion
  56650. * @param strength the explosion strength
  56651. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56652. * @returns A physics gravitational field event, or null
  56653. */
  56654. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56655. /**
  56656. * Creates a physics updraft event
  56657. * @param origin the origin of the updraft
  56658. * @param radiusOrEventOptions the radius or the options of the updraft
  56659. * @param strength the strength of the updraft
  56660. * @param height the height of the updraft
  56661. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56662. * @returns A physics updraft event, or null
  56663. */
  56664. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56665. /**
  56666. * Creates a physics vortex event
  56667. * @param origin the of the vortex
  56668. * @param radiusOrEventOptions the radius or the options of the vortex
  56669. * @param strength the strength of the vortex
  56670. * @param height the height of the vortex
  56671. * @returns a Physics vortex event, or null
  56672. * A physics vortex event or null
  56673. */
  56674. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56675. }
  56676. /**
  56677. * Represents a physics radial explosion event
  56678. */
  56679. class PhysicsRadialExplosionEvent {
  56680. private _scene;
  56681. private _options;
  56682. private _sphere;
  56683. private _dataFetched;
  56684. /**
  56685. * Initializes a radial explosioin event
  56686. * @param _scene BabylonJS scene
  56687. * @param _options The options for the vortex event
  56688. */
  56689. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56690. /**
  56691. * Returns the data related to the radial explosion event (sphere).
  56692. * @returns The radial explosion event data
  56693. */
  56694. getData(): PhysicsRadialExplosionEventData;
  56695. /**
  56696. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56697. * @param impostor A physics imposter
  56698. * @param origin the origin of the explosion
  56699. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56700. */
  56701. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56702. /**
  56703. * Triggers affecterd impostors callbacks
  56704. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56705. */
  56706. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56707. /**
  56708. * Disposes the sphere.
  56709. * @param force Specifies if the sphere should be disposed by force
  56710. */
  56711. dispose(force?: boolean): void;
  56712. /*** Helpers ***/
  56713. private _prepareSphere;
  56714. private _intersectsWithSphere;
  56715. }
  56716. /**
  56717. * Represents a gravitational field event
  56718. */
  56719. class PhysicsGravitationalFieldEvent {
  56720. private _physicsHelper;
  56721. private _scene;
  56722. private _origin;
  56723. private _options;
  56724. private _tickCallback;
  56725. private _sphere;
  56726. private _dataFetched;
  56727. /**
  56728. * Initializes the physics gravitational field event
  56729. * @param _physicsHelper A physics helper
  56730. * @param _scene BabylonJS scene
  56731. * @param _origin The origin position of the gravitational field event
  56732. * @param _options The options for the vortex event
  56733. */
  56734. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56735. /**
  56736. * Returns the data related to the gravitational field event (sphere).
  56737. * @returns A gravitational field event
  56738. */
  56739. getData(): PhysicsGravitationalFieldEventData;
  56740. /**
  56741. * Enables the gravitational field.
  56742. */
  56743. enable(): void;
  56744. /**
  56745. * Disables the gravitational field.
  56746. */
  56747. disable(): void;
  56748. /**
  56749. * Disposes the sphere.
  56750. * @param force The force to dispose from the gravitational field event
  56751. */
  56752. dispose(force?: boolean): void;
  56753. private _tick;
  56754. }
  56755. /**
  56756. * Represents a physics updraft event
  56757. */
  56758. class PhysicsUpdraftEvent {
  56759. private _scene;
  56760. private _origin;
  56761. private _options;
  56762. private _physicsEngine;
  56763. private _originTop;
  56764. private _originDirection;
  56765. private _tickCallback;
  56766. private _cylinder;
  56767. private _cylinderPosition;
  56768. private _dataFetched;
  56769. /**
  56770. * Initializes the physics updraft event
  56771. * @param _scene BabylonJS scene
  56772. * @param _origin The origin position of the updraft
  56773. * @param _options The options for the updraft event
  56774. */
  56775. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56776. /**
  56777. * Returns the data related to the updraft event (cylinder).
  56778. * @returns A physics updraft event
  56779. */
  56780. getData(): PhysicsUpdraftEventData;
  56781. /**
  56782. * Enables the updraft.
  56783. */
  56784. enable(): void;
  56785. /**
  56786. * Disables the updraft.
  56787. */
  56788. disable(): void;
  56789. /**
  56790. * Disposes the cylinder.
  56791. * @param force Specifies if the updraft should be disposed by force
  56792. */
  56793. dispose(force?: boolean): void;
  56794. private getImpostorHitData;
  56795. private _tick;
  56796. /*** Helpers ***/
  56797. private _prepareCylinder;
  56798. private _intersectsWithCylinder;
  56799. }
  56800. /**
  56801. * Represents a physics vortex event
  56802. */
  56803. class PhysicsVortexEvent {
  56804. private _scene;
  56805. private _origin;
  56806. private _options;
  56807. private _physicsEngine;
  56808. private _originTop;
  56809. private _tickCallback;
  56810. private _cylinder;
  56811. private _cylinderPosition;
  56812. private _dataFetched;
  56813. /**
  56814. * Initializes the physics vortex event
  56815. * @param _scene The BabylonJS scene
  56816. * @param _origin The origin position of the vortex
  56817. * @param _options The options for the vortex event
  56818. */
  56819. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56820. /**
  56821. * Returns the data related to the vortex event (cylinder).
  56822. * @returns The physics vortex event data
  56823. */
  56824. getData(): PhysicsVortexEventData;
  56825. /**
  56826. * Enables the vortex.
  56827. */
  56828. enable(): void;
  56829. /**
  56830. * Disables the cortex.
  56831. */
  56832. disable(): void;
  56833. /**
  56834. * Disposes the sphere.
  56835. * @param force
  56836. */
  56837. dispose(force?: boolean): void;
  56838. private getImpostorHitData;
  56839. private _tick;
  56840. /*** Helpers ***/
  56841. private _prepareCylinder;
  56842. private _intersectsWithCylinder;
  56843. }
  56844. /**
  56845. * Options fot the radial explosion event
  56846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56847. */
  56848. export class PhysicsRadialExplosionEventOptions {
  56849. /**
  56850. * The radius of the sphere for the radial explosion.
  56851. */
  56852. radius: number;
  56853. /**
  56854. * The strenth of the explosion.
  56855. */
  56856. strength: number;
  56857. /**
  56858. * The strenght of the force in correspondence to the distance of the affected object
  56859. */
  56860. falloff: PhysicsRadialImpulseFalloff;
  56861. /**
  56862. * Sphere options for the radial explosion.
  56863. */
  56864. sphere: {
  56865. segments: number;
  56866. diameter: number;
  56867. };
  56868. /**
  56869. * Sphere options for the radial explosion.
  56870. */
  56871. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56872. }
  56873. /**
  56874. * Options fot the updraft event
  56875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56876. */
  56877. export class PhysicsUpdraftEventOptions {
  56878. /**
  56879. * The radius of the cylinder for the vortex
  56880. */
  56881. radius: number;
  56882. /**
  56883. * The strenth of the updraft.
  56884. */
  56885. strength: number;
  56886. /**
  56887. * The height of the cylinder for the updraft.
  56888. */
  56889. height: number;
  56890. /**
  56891. * The mode for the the updraft.
  56892. */
  56893. updraftMode: PhysicsUpdraftMode;
  56894. }
  56895. /**
  56896. * Options fot the vortex event
  56897. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56898. */
  56899. export class PhysicsVortexEventOptions {
  56900. /**
  56901. * The radius of the cylinder for the vortex
  56902. */
  56903. radius: number;
  56904. /**
  56905. * The strenth of the vortex.
  56906. */
  56907. strength: number;
  56908. /**
  56909. * The height of the cylinder for the vortex.
  56910. */
  56911. height: number;
  56912. /**
  56913. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56914. */
  56915. centripetalForceThreshold: number;
  56916. /**
  56917. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56918. */
  56919. centripetalForceMultiplier: number;
  56920. /**
  56921. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56922. */
  56923. centrifugalForceMultiplier: number;
  56924. /**
  56925. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56926. */
  56927. updraftForceMultiplier: number;
  56928. }
  56929. /**
  56930. * The strenght of the force in correspondence to the distance of the affected object
  56931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56932. */
  56933. export enum PhysicsRadialImpulseFalloff {
  56934. /** Defines that impulse is constant in strength across it's whole radius */
  56935. Constant = 0,
  56936. /** Defines that impulse gets weaker if it's further from the origin */
  56937. Linear = 1
  56938. }
  56939. /**
  56940. * The strength of the force in correspondence to the distance of the affected object
  56941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56942. */
  56943. export enum PhysicsUpdraftMode {
  56944. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56945. Center = 0,
  56946. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56947. Perpendicular = 1
  56948. }
  56949. /**
  56950. * Interface for a physics hit data
  56951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56952. */
  56953. export interface PhysicsHitData {
  56954. /**
  56955. * The force applied at the contact point
  56956. */
  56957. force: Vector3;
  56958. /**
  56959. * The contact point
  56960. */
  56961. contactPoint: Vector3;
  56962. /**
  56963. * The distance from the origin to the contact point
  56964. */
  56965. distanceFromOrigin: number;
  56966. }
  56967. /**
  56968. * Interface for radial explosion event data
  56969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56970. */
  56971. export interface PhysicsRadialExplosionEventData {
  56972. /**
  56973. * A sphere used for the radial explosion event
  56974. */
  56975. sphere: Mesh;
  56976. }
  56977. /**
  56978. * Interface for gravitational field event data
  56979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56980. */
  56981. export interface PhysicsGravitationalFieldEventData {
  56982. /**
  56983. * A sphere mesh used for the gravitational field event
  56984. */
  56985. sphere: Mesh;
  56986. }
  56987. /**
  56988. * Interface for updraft event data
  56989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56990. */
  56991. export interface PhysicsUpdraftEventData {
  56992. /**
  56993. * A cylinder used for the updraft event
  56994. */
  56995. cylinder: Mesh;
  56996. }
  56997. /**
  56998. * Interface for vortex event data
  56999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57000. */
  57001. export interface PhysicsVortexEventData {
  57002. /**
  57003. * A cylinder used for the vortex event
  57004. */
  57005. cylinder: Mesh;
  57006. }
  57007. /**
  57008. * Interface for an affected physics impostor
  57009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57010. */
  57011. export interface PhysicsAffectedImpostorWithData {
  57012. /**
  57013. * The impostor affected by the effect
  57014. */
  57015. impostor: PhysicsImpostor;
  57016. /**
  57017. * The data about the hit/horce from the explosion
  57018. */
  57019. hitData: PhysicsHitData;
  57020. }
  57021. }
  57022. declare module BABYLON {
  57023. /** @hidden */
  57024. export var blackAndWhitePixelShader: {
  57025. name: string;
  57026. shader: string;
  57027. };
  57028. }
  57029. declare module BABYLON {
  57030. /**
  57031. * Post process used to render in black and white
  57032. */
  57033. export class BlackAndWhitePostProcess extends PostProcess {
  57034. /**
  57035. * Linear about to convert he result to black and white (default: 1)
  57036. */
  57037. degree: number;
  57038. /**
  57039. * Creates a black and white post process
  57040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57041. * @param name The name of the effect.
  57042. * @param options The required width/height ratio to downsize to before computing the render pass.
  57043. * @param camera The camera to apply the render pass to.
  57044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57045. * @param engine The engine which the post process will be applied. (default: current engine)
  57046. * @param reusable If the post process can be reused on the same frame. (default: false)
  57047. */
  57048. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57049. }
  57050. }
  57051. declare module BABYLON {
  57052. /**
  57053. * This represents a set of one or more post processes in Babylon.
  57054. * A post process can be used to apply a shader to a texture after it is rendered.
  57055. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57056. */
  57057. export class PostProcessRenderEffect {
  57058. private _postProcesses;
  57059. private _getPostProcesses;
  57060. private _singleInstance;
  57061. private _cameras;
  57062. private _indicesForCamera;
  57063. /**
  57064. * Name of the effect
  57065. * @hidden
  57066. */ private _name: string;
  57067. /**
  57068. * Instantiates a post process render effect.
  57069. * A post process can be used to apply a shader to a texture after it is rendered.
  57070. * @param engine The engine the effect is tied to
  57071. * @param name The name of the effect
  57072. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57073. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57074. */
  57075. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57076. /**
  57077. * Checks if all the post processes in the effect are supported.
  57078. */
  57079. readonly isSupported: boolean;
  57080. /**
  57081. * Updates the current state of the effect
  57082. * @hidden
  57083. */ private _update(): void;
  57084. /**
  57085. * Attaches the effect on cameras
  57086. * @param cameras The camera to attach to.
  57087. * @hidden
  57088. */ private _attachCameras(cameras: Camera): void;
  57089. /**
  57090. * Attaches the effect on cameras
  57091. * @param cameras The camera to attach to.
  57092. * @hidden
  57093. */ private _attachCameras(cameras: Camera[]): void;
  57094. /**
  57095. * Detaches the effect on cameras
  57096. * @param cameras The camera to detatch from.
  57097. * @hidden
  57098. */ private _detachCameras(cameras: Camera): void;
  57099. /**
  57100. * Detatches the effect on cameras
  57101. * @param cameras The camera to detatch from.
  57102. * @hidden
  57103. */ private _detachCameras(cameras: Camera[]): void;
  57104. /**
  57105. * Enables the effect on given cameras
  57106. * @param cameras The camera to enable.
  57107. * @hidden
  57108. */ private _enable(cameras: Camera): void;
  57109. /**
  57110. * Enables the effect on given cameras
  57111. * @param cameras The camera to enable.
  57112. * @hidden
  57113. */ private _enable(cameras: Nullable<Camera[]>): void;
  57114. /**
  57115. * Disables the effect on the given cameras
  57116. * @param cameras The camera to disable.
  57117. * @hidden
  57118. */ private _disable(cameras: Camera): void;
  57119. /**
  57120. * Disables the effect on the given cameras
  57121. * @param cameras The camera to disable.
  57122. * @hidden
  57123. */ private _disable(cameras: Nullable<Camera[]>): void;
  57124. /**
  57125. * Gets a list of the post processes contained in the effect.
  57126. * @param camera The camera to get the post processes on.
  57127. * @returns The list of the post processes in the effect.
  57128. */
  57129. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57130. }
  57131. }
  57132. declare module BABYLON {
  57133. /** @hidden */
  57134. export var extractHighlightsPixelShader: {
  57135. name: string;
  57136. shader: string;
  57137. };
  57138. }
  57139. declare module BABYLON {
  57140. /**
  57141. * 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.
  57142. */
  57143. export class ExtractHighlightsPostProcess extends PostProcess {
  57144. /**
  57145. * The luminance threshold, pixels below this value will be set to black.
  57146. */
  57147. threshold: number;
  57148. /** @hidden */ private _exposure: number;
  57149. /**
  57150. * Post process which has the input texture to be used when performing highlight extraction
  57151. * @hidden
  57152. */ private _inputPostProcess: Nullable<PostProcess>;
  57153. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57154. }
  57155. }
  57156. declare module BABYLON {
  57157. /** @hidden */
  57158. export var bloomMergePixelShader: {
  57159. name: string;
  57160. shader: string;
  57161. };
  57162. }
  57163. declare module BABYLON {
  57164. /**
  57165. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57166. */
  57167. export class BloomMergePostProcess extends PostProcess {
  57168. /** Weight of the bloom to be added to the original input. */
  57169. weight: number;
  57170. /**
  57171. * Creates a new instance of @see BloomMergePostProcess
  57172. * @param name The name of the effect.
  57173. * @param originalFromInput Post process which's input will be used for the merge.
  57174. * @param blurred Blurred highlights post process which's output will be used.
  57175. * @param weight Weight of the bloom to be added to the original input.
  57176. * @param options The required width/height ratio to downsize to before computing the render pass.
  57177. * @param camera The camera to apply the render pass to.
  57178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57179. * @param engine The engine which the post process will be applied. (default: current engine)
  57180. * @param reusable If the post process can be reused on the same frame. (default: false)
  57181. * @param textureType Type of textures used when performing the post process. (default: 0)
  57182. * @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)
  57183. */
  57184. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57185. /** Weight of the bloom to be added to the original input. */
  57186. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57187. }
  57188. }
  57189. declare module BABYLON {
  57190. /**
  57191. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57192. */
  57193. export class BloomEffect extends PostProcessRenderEffect {
  57194. private bloomScale;
  57195. /**
  57196. * @hidden Internal
  57197. */ private _effects: Array<PostProcess>;
  57198. /**
  57199. * @hidden Internal
  57200. */ private _downscale: ExtractHighlightsPostProcess;
  57201. private _blurX;
  57202. private _blurY;
  57203. private _merge;
  57204. /**
  57205. * The luminance threshold to find bright areas of the image to bloom.
  57206. */
  57207. threshold: number;
  57208. /**
  57209. * The strength of the bloom.
  57210. */
  57211. weight: number;
  57212. /**
  57213. * Specifies the size of the bloom blur kernel, relative to the final output size
  57214. */
  57215. kernel: number;
  57216. /**
  57217. * Creates a new instance of @see BloomEffect
  57218. * @param scene The scene the effect belongs to.
  57219. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57220. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57221. * @param bloomWeight The the strength of bloom.
  57222. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57223. * @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)
  57224. */
  57225. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57226. /**
  57227. * Disposes each of the internal effects for a given camera.
  57228. * @param camera The camera to dispose the effect on.
  57229. */
  57230. disposeEffects(camera: Camera): void;
  57231. /**
  57232. * @hidden Internal
  57233. */ private _updateEffects(): void;
  57234. /**
  57235. * Internal
  57236. * @returns if all the contained post processes are ready.
  57237. * @hidden
  57238. */ private _isReady(): boolean;
  57239. }
  57240. }
  57241. declare module BABYLON {
  57242. /** @hidden */
  57243. export var chromaticAberrationPixelShader: {
  57244. name: string;
  57245. shader: string;
  57246. };
  57247. }
  57248. declare module BABYLON {
  57249. /**
  57250. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57251. */
  57252. export class ChromaticAberrationPostProcess extends PostProcess {
  57253. /**
  57254. * The amount of seperation of rgb channels (default: 30)
  57255. */
  57256. aberrationAmount: number;
  57257. /**
  57258. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57259. */
  57260. radialIntensity: number;
  57261. /**
  57262. * 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))
  57263. */
  57264. direction: Vector2;
  57265. /**
  57266. * 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))
  57267. */
  57268. centerPosition: Vector2;
  57269. /**
  57270. * Creates a new instance ChromaticAberrationPostProcess
  57271. * @param name The name of the effect.
  57272. * @param screenWidth The width of the screen to apply the effect on.
  57273. * @param screenHeight The height of the screen to apply the effect on.
  57274. * @param options The required width/height ratio to downsize to before computing the render pass.
  57275. * @param camera The camera to apply the render pass to.
  57276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57277. * @param engine The engine which the post process will be applied. (default: current engine)
  57278. * @param reusable If the post process can be reused on the same frame. (default: false)
  57279. * @param textureType Type of textures used when performing the post process. (default: 0)
  57280. * @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)
  57281. */
  57282. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57283. }
  57284. }
  57285. declare module BABYLON {
  57286. /** @hidden */
  57287. export var circleOfConfusionPixelShader: {
  57288. name: string;
  57289. shader: string;
  57290. };
  57291. }
  57292. declare module BABYLON {
  57293. /**
  57294. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57295. */
  57296. export class CircleOfConfusionPostProcess extends PostProcess {
  57297. /**
  57298. * 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.
  57299. */
  57300. lensSize: number;
  57301. /**
  57302. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57303. */
  57304. fStop: number;
  57305. /**
  57306. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57307. */
  57308. focusDistance: number;
  57309. /**
  57310. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57311. */
  57312. focalLength: number;
  57313. private _depthTexture;
  57314. /**
  57315. * Creates a new instance CircleOfConfusionPostProcess
  57316. * @param name The name of the effect.
  57317. * @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.
  57318. * @param options The required width/height ratio to downsize to before computing the render pass.
  57319. * @param camera The camera to apply the render pass to.
  57320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57321. * @param engine The engine which the post process will be applied. (default: current engine)
  57322. * @param reusable If the post process can be reused on the same frame. (default: false)
  57323. * @param textureType Type of textures used when performing the post process. (default: 0)
  57324. * @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)
  57325. */
  57326. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57327. /**
  57328. * 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.
  57329. */
  57330. depthTexture: RenderTargetTexture;
  57331. }
  57332. }
  57333. declare module BABYLON {
  57334. /** @hidden */
  57335. export var colorCorrectionPixelShader: {
  57336. name: string;
  57337. shader: string;
  57338. };
  57339. }
  57340. declare module BABYLON {
  57341. /**
  57342. *
  57343. * This post-process allows the modification of rendered colors by using
  57344. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57345. *
  57346. * The object needs to be provided an url to a texture containing the color
  57347. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57348. * Use an image editing software to tweak the LUT to match your needs.
  57349. *
  57350. * For an example of a color LUT, see here:
  57351. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57352. * For explanations on color grading, see here:
  57353. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57354. *
  57355. */
  57356. export class ColorCorrectionPostProcess extends PostProcess {
  57357. private _colorTableTexture;
  57358. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57359. }
  57360. }
  57361. declare module BABYLON {
  57362. /** @hidden */
  57363. export var convolutionPixelShader: {
  57364. name: string;
  57365. shader: string;
  57366. };
  57367. }
  57368. declare module BABYLON {
  57369. /**
  57370. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57371. * input texture to perform effects such as edge detection or sharpening
  57372. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57373. */
  57374. export class ConvolutionPostProcess extends PostProcess {
  57375. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57376. kernel: number[];
  57377. /**
  57378. * Creates a new instance ConvolutionPostProcess
  57379. * @param name The name of the effect.
  57380. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57381. * @param options The required width/height ratio to downsize to before computing the render pass.
  57382. * @param camera The camera to apply the render pass to.
  57383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57384. * @param engine The engine which the post process will be applied. (default: current engine)
  57385. * @param reusable If the post process can be reused on the same frame. (default: false)
  57386. * @param textureType Type of textures used when performing the post process. (default: 0)
  57387. */
  57388. constructor(name: string,
  57389. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57390. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57391. /**
  57392. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57393. */
  57394. static EdgeDetect0Kernel: number[];
  57395. /**
  57396. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57397. */
  57398. static EdgeDetect1Kernel: number[];
  57399. /**
  57400. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57401. */
  57402. static EdgeDetect2Kernel: number[];
  57403. /**
  57404. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57405. */
  57406. static SharpenKernel: number[];
  57407. /**
  57408. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57409. */
  57410. static EmbossKernel: number[];
  57411. /**
  57412. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57413. */
  57414. static GaussianKernel: number[];
  57415. }
  57416. }
  57417. declare module BABYLON {
  57418. /**
  57419. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57420. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57421. * based on samples that have a large difference in distance than the center pixel.
  57422. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57423. */
  57424. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57425. direction: Vector2;
  57426. /**
  57427. * Creates a new instance CircleOfConfusionPostProcess
  57428. * @param name The name of the effect.
  57429. * @param scene The scene the effect belongs to.
  57430. * @param direction The direction the blur should be applied.
  57431. * @param kernel The size of the kernel used to blur.
  57432. * @param options The required width/height ratio to downsize to before computing the render pass.
  57433. * @param camera The camera to apply the render pass to.
  57434. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57435. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57437. * @param engine The engine which the post process will be applied. (default: current engine)
  57438. * @param reusable If the post process can be reused on the same frame. (default: false)
  57439. * @param textureType Type of textures used when performing the post process. (default: 0)
  57440. * @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)
  57441. */
  57442. 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);
  57443. }
  57444. }
  57445. declare module BABYLON {
  57446. /** @hidden */
  57447. export var depthOfFieldMergePixelShader: {
  57448. name: string;
  57449. shader: string;
  57450. };
  57451. }
  57452. declare module BABYLON {
  57453. /**
  57454. * Options to be set when merging outputs from the default pipeline.
  57455. */
  57456. export class DepthOfFieldMergePostProcessOptions {
  57457. /**
  57458. * The original image to merge on top of
  57459. */
  57460. originalFromInput: PostProcess;
  57461. /**
  57462. * Parameters to perform the merge of the depth of field effect
  57463. */
  57464. depthOfField?: {
  57465. circleOfConfusion: PostProcess;
  57466. blurSteps: Array<PostProcess>;
  57467. };
  57468. /**
  57469. * Parameters to perform the merge of bloom effect
  57470. */
  57471. bloom?: {
  57472. blurred: PostProcess;
  57473. weight: number;
  57474. };
  57475. }
  57476. /**
  57477. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57478. */
  57479. export class DepthOfFieldMergePostProcess extends PostProcess {
  57480. private blurSteps;
  57481. /**
  57482. * Creates a new instance of DepthOfFieldMergePostProcess
  57483. * @param name The name of the effect.
  57484. * @param originalFromInput Post process which's input will be used for the merge.
  57485. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57486. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57487. * @param options The required width/height ratio to downsize to before computing the render pass.
  57488. * @param camera The camera to apply the render pass to.
  57489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57490. * @param engine The engine which the post process will be applied. (default: current engine)
  57491. * @param reusable If the post process can be reused on the same frame. (default: false)
  57492. * @param textureType Type of textures used when performing the post process. (default: 0)
  57493. * @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)
  57494. */
  57495. 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);
  57496. /**
  57497. * Updates the effect with the current post process compile time values and recompiles the shader.
  57498. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57499. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57500. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57501. * @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
  57502. * @param onCompiled Called when the shader has been compiled.
  57503. * @param onError Called if there is an error when compiling a shader.
  57504. */
  57505. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57506. }
  57507. }
  57508. declare module BABYLON {
  57509. /**
  57510. * Specifies the level of max blur that should be applied when using the depth of field effect
  57511. */
  57512. export enum DepthOfFieldEffectBlurLevel {
  57513. /**
  57514. * Subtle blur
  57515. */
  57516. Low = 0,
  57517. /**
  57518. * Medium blur
  57519. */
  57520. Medium = 1,
  57521. /**
  57522. * Large blur
  57523. */
  57524. High = 2
  57525. }
  57526. /**
  57527. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57528. */
  57529. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57530. private _circleOfConfusion;
  57531. /**
  57532. * @hidden Internal, blurs from high to low
  57533. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57534. private _depthOfFieldBlurY;
  57535. private _dofMerge;
  57536. /**
  57537. * @hidden Internal post processes in depth of field effect
  57538. */ private _effects: Array<PostProcess>;
  57539. /**
  57540. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57541. */
  57542. focalLength: number;
  57543. /**
  57544. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57545. */
  57546. fStop: number;
  57547. /**
  57548. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57549. */
  57550. focusDistance: number;
  57551. /**
  57552. * 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.
  57553. */
  57554. lensSize: number;
  57555. /**
  57556. * Creates a new instance DepthOfFieldEffect
  57557. * @param scene The scene the effect belongs to.
  57558. * @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.
  57559. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57560. * @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)
  57561. */
  57562. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57563. /**
  57564. * Get the current class name of the current effet
  57565. * @returns "DepthOfFieldEffect"
  57566. */
  57567. getClassName(): string;
  57568. /**
  57569. * 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.
  57570. */
  57571. depthTexture: RenderTargetTexture;
  57572. /**
  57573. * Disposes each of the internal effects for a given camera.
  57574. * @param camera The camera to dispose the effect on.
  57575. */
  57576. disposeEffects(camera: Camera): void;
  57577. /**
  57578. * @hidden Internal
  57579. */ private _updateEffects(): void;
  57580. /**
  57581. * Internal
  57582. * @returns if all the contained post processes are ready.
  57583. * @hidden
  57584. */ private _isReady(): boolean;
  57585. }
  57586. }
  57587. declare module BABYLON {
  57588. /** @hidden */
  57589. export var displayPassPixelShader: {
  57590. name: string;
  57591. shader: string;
  57592. };
  57593. }
  57594. declare module BABYLON {
  57595. /**
  57596. * DisplayPassPostProcess which produces an output the same as it's input
  57597. */
  57598. export class DisplayPassPostProcess extends PostProcess {
  57599. /**
  57600. * Creates the DisplayPassPostProcess
  57601. * @param name The name of the effect.
  57602. * @param options The required width/height ratio to downsize to before computing the render pass.
  57603. * @param camera The camera to apply the render pass to.
  57604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57605. * @param engine The engine which the post process will be applied. (default: current engine)
  57606. * @param reusable If the post process can be reused on the same frame. (default: false)
  57607. */
  57608. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57609. }
  57610. }
  57611. declare module BABYLON {
  57612. /** @hidden */
  57613. export var filterPixelShader: {
  57614. name: string;
  57615. shader: string;
  57616. };
  57617. }
  57618. declare module BABYLON {
  57619. /**
  57620. * Applies a kernel filter to the image
  57621. */
  57622. export class FilterPostProcess extends PostProcess {
  57623. /** The matrix to be applied to the image */
  57624. kernelMatrix: Matrix;
  57625. /**
  57626. *
  57627. * @param name The name of the effect.
  57628. * @param kernelMatrix The matrix to be applied to the image
  57629. * @param options The required width/height ratio to downsize to before computing the render pass.
  57630. * @param camera The camera to apply the render pass to.
  57631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57632. * @param engine The engine which the post process will be applied. (default: current engine)
  57633. * @param reusable If the post process can be reused on the same frame. (default: false)
  57634. */
  57635. constructor(name: string,
  57636. /** The matrix to be applied to the image */
  57637. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57638. }
  57639. }
  57640. declare module BABYLON {
  57641. /** @hidden */
  57642. export var fxaaPixelShader: {
  57643. name: string;
  57644. shader: string;
  57645. };
  57646. }
  57647. declare module BABYLON {
  57648. /** @hidden */
  57649. export var fxaaVertexShader: {
  57650. name: string;
  57651. shader: string;
  57652. };
  57653. }
  57654. declare module BABYLON {
  57655. /**
  57656. * Fxaa post process
  57657. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57658. */
  57659. export class FxaaPostProcess extends PostProcess {
  57660. /** @hidden */
  57661. texelWidth: number;
  57662. /** @hidden */
  57663. texelHeight: number;
  57664. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57665. private _getDefines;
  57666. }
  57667. }
  57668. declare module BABYLON {
  57669. /** @hidden */
  57670. export var grainPixelShader: {
  57671. name: string;
  57672. shader: string;
  57673. };
  57674. }
  57675. declare module BABYLON {
  57676. /**
  57677. * The GrainPostProcess adds noise to the image at mid luminance levels
  57678. */
  57679. export class GrainPostProcess extends PostProcess {
  57680. /**
  57681. * The intensity of the grain added (default: 30)
  57682. */
  57683. intensity: number;
  57684. /**
  57685. * If the grain should be randomized on every frame
  57686. */
  57687. animated: boolean;
  57688. /**
  57689. * Creates a new instance of @see GrainPostProcess
  57690. * @param name The name of the effect.
  57691. * @param options The required width/height ratio to downsize to before computing the render pass.
  57692. * @param camera The camera to apply the render pass to.
  57693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57694. * @param engine The engine which the post process will be applied. (default: current engine)
  57695. * @param reusable If the post process can be reused on the same frame. (default: false)
  57696. * @param textureType Type of textures used when performing the post process. (default: 0)
  57697. * @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)
  57698. */
  57699. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57700. }
  57701. }
  57702. declare module BABYLON {
  57703. /** @hidden */
  57704. export var highlightsPixelShader: {
  57705. name: string;
  57706. shader: string;
  57707. };
  57708. }
  57709. declare module BABYLON {
  57710. /**
  57711. * Extracts highlights from the image
  57712. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57713. */
  57714. export class HighlightsPostProcess extends PostProcess {
  57715. /**
  57716. * Extracts highlights from the image
  57717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57718. * @param name The name of the effect.
  57719. * @param options The required width/height ratio to downsize to before computing the render pass.
  57720. * @param camera The camera to apply the render pass to.
  57721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57722. * @param engine The engine which the post process will be applied. (default: current engine)
  57723. * @param reusable If the post process can be reused on the same frame. (default: false)
  57724. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57725. */
  57726. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57727. }
  57728. }
  57729. declare module BABYLON {
  57730. /** @hidden */
  57731. export var mrtFragmentDeclaration: {
  57732. name: string;
  57733. shader: string;
  57734. };
  57735. }
  57736. declare module BABYLON {
  57737. /** @hidden */
  57738. export var geometryPixelShader: {
  57739. name: string;
  57740. shader: string;
  57741. };
  57742. }
  57743. declare module BABYLON {
  57744. /** @hidden */
  57745. export var geometryVertexShader: {
  57746. name: string;
  57747. shader: string;
  57748. };
  57749. }
  57750. declare module BABYLON {
  57751. /** @hidden */
  57752. interface ISavedTransformationMatrix {
  57753. world: Matrix;
  57754. viewProjection: Matrix;
  57755. }
  57756. /**
  57757. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57758. */
  57759. export class GeometryBufferRenderer {
  57760. /**
  57761. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57762. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57763. */
  57764. static readonly POSITION_TEXTURE_TYPE: number;
  57765. /**
  57766. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57767. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57768. */
  57769. static readonly VELOCITY_TEXTURE_TYPE: number;
  57770. /**
  57771. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57772. * in order to compute objects velocities when enableVelocity is set to "true"
  57773. * @hidden
  57774. */ private _previousTransformationMatrices: {
  57775. [index: number]: ISavedTransformationMatrix;
  57776. };
  57777. /**
  57778. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57779. * in order to compute objects velocities when enableVelocity is set to "true"
  57780. * @hidden
  57781. */ private _previousBonesTransformationMatrices: {
  57782. [index: number]: Float32Array;
  57783. };
  57784. /**
  57785. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57786. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57787. */
  57788. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57789. private _scene;
  57790. private _multiRenderTarget;
  57791. private _ratio;
  57792. private _enablePosition;
  57793. private _enableVelocity;
  57794. private _positionIndex;
  57795. private _velocityIndex;
  57796. protected _effect: Effect;
  57797. protected _cachedDefines: string;
  57798. /**
  57799. * Set the render list (meshes to be rendered) used in the G buffer.
  57800. */
  57801. renderList: Mesh[];
  57802. /**
  57803. * Gets wether or not G buffer are supported by the running hardware.
  57804. * This requires draw buffer supports
  57805. */
  57806. readonly isSupported: boolean;
  57807. /**
  57808. * Returns the index of the given texture type in the G-Buffer textures array
  57809. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57810. * @returns the index of the given texture type in the G-Buffer textures array
  57811. */
  57812. getTextureIndex(textureType: number): number;
  57813. /**
  57814. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57815. */
  57816. /**
  57817. * Sets whether or not objects positions are enabled for the G buffer.
  57818. */
  57819. enablePosition: boolean;
  57820. /**
  57821. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57822. */
  57823. /**
  57824. * Sets wether or not objects velocities are enabled for the G buffer.
  57825. */
  57826. enableVelocity: boolean;
  57827. /**
  57828. * Gets the scene associated with the buffer.
  57829. */
  57830. readonly scene: Scene;
  57831. /**
  57832. * Gets the ratio used by the buffer during its creation.
  57833. * How big is the buffer related to the main canvas.
  57834. */
  57835. readonly ratio: number;
  57836. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  57837. /**
  57838. * Creates a new G Buffer for the scene
  57839. * @param scene The scene the buffer belongs to
  57840. * @param ratio How big is the buffer related to the main canvas.
  57841. */
  57842. constructor(scene: Scene, ratio?: number);
  57843. /**
  57844. * Checks wether everything is ready to render a submesh to the G buffer.
  57845. * @param subMesh the submesh to check readiness for
  57846. * @param useInstances is the mesh drawn using instance or not
  57847. * @returns true if ready otherwise false
  57848. */
  57849. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57850. /**
  57851. * Gets the current underlying G Buffer.
  57852. * @returns the buffer
  57853. */
  57854. getGBuffer(): MultiRenderTarget;
  57855. /**
  57856. * Gets the number of samples used to render the buffer (anti aliasing).
  57857. */
  57858. /**
  57859. * Sets the number of samples used to render the buffer (anti aliasing).
  57860. */
  57861. samples: number;
  57862. /**
  57863. * Disposes the renderer and frees up associated resources.
  57864. */
  57865. dispose(): void;
  57866. protected _createRenderTargets(): void;
  57867. private _copyBonesTransformationMatrices;
  57868. }
  57869. }
  57870. declare module BABYLON {
  57871. interface Scene {
  57872. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57873. /**
  57874. * Gets or Sets the current geometry buffer associated to the scene.
  57875. */
  57876. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57877. /**
  57878. * Enables a GeometryBufferRender and associates it with the scene
  57879. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  57880. * @returns the GeometryBufferRenderer
  57881. */
  57882. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  57883. /**
  57884. * Disables the GeometryBufferRender associated with the scene
  57885. */
  57886. disableGeometryBufferRenderer(): void;
  57887. }
  57888. /**
  57889. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  57890. * in several rendering techniques.
  57891. */
  57892. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  57893. /**
  57894. * The component name helpful to identify the component in the list of scene components.
  57895. */
  57896. readonly name: string;
  57897. /**
  57898. * The scene the component belongs to.
  57899. */
  57900. scene: Scene;
  57901. /**
  57902. * Creates a new instance of the component for the given scene
  57903. * @param scene Defines the scene to register the component in
  57904. */
  57905. constructor(scene: Scene);
  57906. /**
  57907. * Registers the component in a given scene
  57908. */
  57909. register(): void;
  57910. /**
  57911. * Rebuilds the elements related to this component in case of
  57912. * context lost for instance.
  57913. */
  57914. rebuild(): void;
  57915. /**
  57916. * Disposes the component and the associated ressources
  57917. */
  57918. dispose(): void;
  57919. private _gatherRenderTargets;
  57920. }
  57921. }
  57922. declare module BABYLON {
  57923. /** @hidden */
  57924. export var motionBlurPixelShader: {
  57925. name: string;
  57926. shader: string;
  57927. };
  57928. }
  57929. declare module BABYLON {
  57930. /**
  57931. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  57932. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  57933. * As an example, all you have to do is to create the post-process:
  57934. * var mb = new BABYLON.MotionBlurPostProcess(
  57935. * 'mb', // The name of the effect.
  57936. * scene, // The scene containing the objects to blur according to their velocity.
  57937. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  57938. * camera // The camera to apply the render pass to.
  57939. * );
  57940. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  57941. */
  57942. export class MotionBlurPostProcess extends PostProcess {
  57943. /**
  57944. * Defines how much the image is blurred by the movement. Default value is equal to 1
  57945. */
  57946. motionStrength: number;
  57947. /**
  57948. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  57949. */
  57950. /**
  57951. * Sets the number of iterations to be used for motion blur quality
  57952. */
  57953. motionBlurSamples: number;
  57954. private _motionBlurSamples;
  57955. private _geometryBufferRenderer;
  57956. /**
  57957. * Creates a new instance MotionBlurPostProcess
  57958. * @param name The name of the effect.
  57959. * @param scene The scene containing the objects to blur according to their velocity.
  57960. * @param options The required width/height ratio to downsize to before computing the render pass.
  57961. * @param camera The camera to apply the render pass to.
  57962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57963. * @param engine The engine which the post process will be applied. (default: current engine)
  57964. * @param reusable If the post process can be reused on the same frame. (default: false)
  57965. * @param textureType Type of textures used when performing the post process. (default: 0)
  57966. * @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)
  57967. */
  57968. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57969. /**
  57970. * Excludes the given skinned mesh from computing bones velocities.
  57971. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  57972. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  57973. */
  57974. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57975. /**
  57976. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  57977. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  57978. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  57979. */
  57980. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57981. /**
  57982. * Disposes the post process.
  57983. * @param camera The camera to dispose the post process on.
  57984. */
  57985. dispose(camera?: Camera): void;
  57986. }
  57987. }
  57988. declare module BABYLON {
  57989. /** @hidden */
  57990. export var refractionPixelShader: {
  57991. name: string;
  57992. shader: string;
  57993. };
  57994. }
  57995. declare module BABYLON {
  57996. /**
  57997. * Post process which applies a refractin texture
  57998. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57999. */
  58000. export class RefractionPostProcess extends PostProcess {
  58001. /** the base color of the refraction (used to taint the rendering) */
  58002. color: Color3;
  58003. /** simulated refraction depth */
  58004. depth: number;
  58005. /** the coefficient of the base color (0 to remove base color tainting) */
  58006. colorLevel: number;
  58007. private _refTexture;
  58008. private _ownRefractionTexture;
  58009. /**
  58010. * Gets or sets the refraction texture
  58011. * Please note that you are responsible for disposing the texture if you set it manually
  58012. */
  58013. refractionTexture: Texture;
  58014. /**
  58015. * Initializes the RefractionPostProcess
  58016. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58017. * @param name The name of the effect.
  58018. * @param refractionTextureUrl Url of the refraction texture to use
  58019. * @param color the base color of the refraction (used to taint the rendering)
  58020. * @param depth simulated refraction depth
  58021. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58022. * @param camera The camera to apply the render pass to.
  58023. * @param options The required width/height ratio to downsize to before computing the render pass.
  58024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58025. * @param engine The engine which the post process will be applied. (default: current engine)
  58026. * @param reusable If the post process can be reused on the same frame. (default: false)
  58027. */
  58028. constructor(name: string, refractionTextureUrl: string,
  58029. /** the base color of the refraction (used to taint the rendering) */
  58030. color: Color3,
  58031. /** simulated refraction depth */
  58032. depth: number,
  58033. /** the coefficient of the base color (0 to remove base color tainting) */
  58034. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58035. /**
  58036. * Disposes of the post process
  58037. * @param camera Camera to dispose post process on
  58038. */
  58039. dispose(camera: Camera): void;
  58040. }
  58041. }
  58042. declare module BABYLON {
  58043. /** @hidden */
  58044. export var sharpenPixelShader: {
  58045. name: string;
  58046. shader: string;
  58047. };
  58048. }
  58049. declare module BABYLON {
  58050. /**
  58051. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58052. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58053. */
  58054. export class SharpenPostProcess extends PostProcess {
  58055. /**
  58056. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58057. */
  58058. colorAmount: number;
  58059. /**
  58060. * How much sharpness should be applied (default: 0.3)
  58061. */
  58062. edgeAmount: number;
  58063. /**
  58064. * Creates a new instance ConvolutionPostProcess
  58065. * @param name The name of the effect.
  58066. * @param options The required width/height ratio to downsize to before computing the render pass.
  58067. * @param camera The camera to apply the render pass to.
  58068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58069. * @param engine The engine which the post process will be applied. (default: current engine)
  58070. * @param reusable If the post process can be reused on the same frame. (default: false)
  58071. * @param textureType Type of textures used when performing the post process. (default: 0)
  58072. * @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)
  58073. */
  58074. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58075. }
  58076. }
  58077. declare module BABYLON {
  58078. /**
  58079. * PostProcessRenderPipeline
  58080. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58081. */
  58082. export class PostProcessRenderPipeline {
  58083. private engine;
  58084. private _renderEffects;
  58085. private _renderEffectsForIsolatedPass;
  58086. /**
  58087. * List of inspectable custom properties (used by the Inspector)
  58088. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58089. */
  58090. inspectableCustomProperties: IInspectable[];
  58091. /**
  58092. * @hidden
  58093. */
  58094. protected _cameras: Camera[];
  58095. /** @hidden */ private _name: string;
  58096. /**
  58097. * Gets pipeline name
  58098. */
  58099. readonly name: string;
  58100. /**
  58101. * Initializes a PostProcessRenderPipeline
  58102. * @param engine engine to add the pipeline to
  58103. * @param name name of the pipeline
  58104. */
  58105. constructor(engine: Engine, name: string);
  58106. /**
  58107. * Gets the class name
  58108. * @returns "PostProcessRenderPipeline"
  58109. */
  58110. getClassName(): string;
  58111. /**
  58112. * If all the render effects in the pipeline are supported
  58113. */
  58114. readonly isSupported: boolean;
  58115. /**
  58116. * Adds an effect to the pipeline
  58117. * @param renderEffect the effect to add
  58118. */
  58119. addEffect(renderEffect: PostProcessRenderEffect): void;
  58120. /** @hidden */ private _rebuild(): void;
  58121. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  58122. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58123. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58124. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58125. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  58126. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  58127. /** @hidden */ private _detachCameras(cameras: Camera): void;
  58128. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  58129. /** @hidden */ private _update(): void;
  58130. /** @hidden */ private _reset(): void;
  58131. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58132. /**
  58133. * Disposes of the pipeline
  58134. */
  58135. dispose(): void;
  58136. }
  58137. }
  58138. declare module BABYLON {
  58139. /**
  58140. * PostProcessRenderPipelineManager class
  58141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58142. */
  58143. export class PostProcessRenderPipelineManager {
  58144. private _renderPipelines;
  58145. /**
  58146. * Initializes a PostProcessRenderPipelineManager
  58147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58148. */
  58149. constructor();
  58150. /**
  58151. * Gets the list of supported render pipelines
  58152. */
  58153. readonly supportedPipelines: PostProcessRenderPipeline[];
  58154. /**
  58155. * Adds a pipeline to the manager
  58156. * @param renderPipeline The pipeline to add
  58157. */
  58158. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58159. /**
  58160. * Attaches a camera to the pipeline
  58161. * @param renderPipelineName The name of the pipeline to attach to
  58162. * @param cameras the camera to attach
  58163. * @param unique if the camera can be attached multiple times to the pipeline
  58164. */
  58165. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58166. /**
  58167. * Detaches a camera from the pipeline
  58168. * @param renderPipelineName The name of the pipeline to detach from
  58169. * @param cameras the camera to detach
  58170. */
  58171. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58172. /**
  58173. * Enables an effect by name on a pipeline
  58174. * @param renderPipelineName the name of the pipeline to enable the effect in
  58175. * @param renderEffectName the name of the effect to enable
  58176. * @param cameras the cameras that the effect should be enabled on
  58177. */
  58178. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58179. /**
  58180. * Disables an effect by name on a pipeline
  58181. * @param renderPipelineName the name of the pipeline to disable the effect in
  58182. * @param renderEffectName the name of the effect to disable
  58183. * @param cameras the cameras that the effect should be disabled on
  58184. */
  58185. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58186. /**
  58187. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58188. */
  58189. update(): void;
  58190. /** @hidden */ private _rebuild(): void;
  58191. /**
  58192. * Disposes of the manager and pipelines
  58193. */
  58194. dispose(): void;
  58195. }
  58196. }
  58197. declare module BABYLON {
  58198. interface Scene {
  58199. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58200. /**
  58201. * Gets the postprocess render pipeline manager
  58202. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58203. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58204. */
  58205. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58206. }
  58207. /**
  58208. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58209. */
  58210. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58211. /**
  58212. * The component name helpfull to identify the component in the list of scene components.
  58213. */
  58214. readonly name: string;
  58215. /**
  58216. * The scene the component belongs to.
  58217. */
  58218. scene: Scene;
  58219. /**
  58220. * Creates a new instance of the component for the given scene
  58221. * @param scene Defines the scene to register the component in
  58222. */
  58223. constructor(scene: Scene);
  58224. /**
  58225. * Registers the component in a given scene
  58226. */
  58227. register(): void;
  58228. /**
  58229. * Rebuilds the elements related to this component in case of
  58230. * context lost for instance.
  58231. */
  58232. rebuild(): void;
  58233. /**
  58234. * Disposes the component and the associated ressources
  58235. */
  58236. dispose(): void;
  58237. private _gatherRenderTargets;
  58238. }
  58239. }
  58240. declare module BABYLON {
  58241. /**
  58242. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58243. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58244. */
  58245. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58246. private _scene;
  58247. private _camerasToBeAttached;
  58248. /**
  58249. * ID of the sharpen post process,
  58250. */
  58251. private readonly SharpenPostProcessId;
  58252. /**
  58253. * @ignore
  58254. * ID of the image processing post process;
  58255. */
  58256. readonly ImageProcessingPostProcessId: string;
  58257. /**
  58258. * @ignore
  58259. * ID of the Fast Approximate Anti-Aliasing post process;
  58260. */
  58261. readonly FxaaPostProcessId: string;
  58262. /**
  58263. * ID of the chromatic aberration post process,
  58264. */
  58265. private readonly ChromaticAberrationPostProcessId;
  58266. /**
  58267. * ID of the grain post process
  58268. */
  58269. private readonly GrainPostProcessId;
  58270. /**
  58271. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58272. */
  58273. sharpen: SharpenPostProcess;
  58274. private _sharpenEffect;
  58275. private bloom;
  58276. /**
  58277. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58278. */
  58279. depthOfField: DepthOfFieldEffect;
  58280. /**
  58281. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58282. */
  58283. fxaa: FxaaPostProcess;
  58284. /**
  58285. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58286. */
  58287. imageProcessing: ImageProcessingPostProcess;
  58288. /**
  58289. * Chromatic aberration post process which will shift rgb colors in the image
  58290. */
  58291. chromaticAberration: ChromaticAberrationPostProcess;
  58292. private _chromaticAberrationEffect;
  58293. /**
  58294. * Grain post process which add noise to the image
  58295. */
  58296. grain: GrainPostProcess;
  58297. private _grainEffect;
  58298. /**
  58299. * Glow post process which adds a glow to emissive areas of the image
  58300. */
  58301. private _glowLayer;
  58302. /**
  58303. * Animations which can be used to tweak settings over a period of time
  58304. */
  58305. animations: Animation[];
  58306. private _imageProcessingConfigurationObserver;
  58307. private _sharpenEnabled;
  58308. private _bloomEnabled;
  58309. private _depthOfFieldEnabled;
  58310. private _depthOfFieldBlurLevel;
  58311. private _fxaaEnabled;
  58312. private _imageProcessingEnabled;
  58313. private _defaultPipelineTextureType;
  58314. private _bloomScale;
  58315. private _chromaticAberrationEnabled;
  58316. private _grainEnabled;
  58317. private _buildAllowed;
  58318. /**
  58319. * Gets active scene
  58320. */
  58321. readonly scene: Scene;
  58322. /**
  58323. * Enable or disable the sharpen process from the pipeline
  58324. */
  58325. sharpenEnabled: boolean;
  58326. private _resizeObserver;
  58327. private _hardwareScaleLevel;
  58328. private _bloomKernel;
  58329. /**
  58330. * Specifies the size of the bloom blur kernel, relative to the final output size
  58331. */
  58332. bloomKernel: number;
  58333. /**
  58334. * Specifies the weight of the bloom in the final rendering
  58335. */
  58336. private _bloomWeight;
  58337. /**
  58338. * Specifies the luma threshold for the area that will be blurred by the bloom
  58339. */
  58340. private _bloomThreshold;
  58341. private _hdr;
  58342. /**
  58343. * The strength of the bloom.
  58344. */
  58345. bloomWeight: number;
  58346. /**
  58347. * The strength of the bloom.
  58348. */
  58349. bloomThreshold: number;
  58350. /**
  58351. * The scale of the bloom, lower value will provide better performance.
  58352. */
  58353. bloomScale: number;
  58354. /**
  58355. * Enable or disable the bloom from the pipeline
  58356. */
  58357. bloomEnabled: boolean;
  58358. private _rebuildBloom;
  58359. /**
  58360. * If the depth of field is enabled.
  58361. */
  58362. depthOfFieldEnabled: boolean;
  58363. /**
  58364. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58365. */
  58366. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58367. /**
  58368. * If the anti aliasing is enabled.
  58369. */
  58370. fxaaEnabled: boolean;
  58371. private _samples;
  58372. /**
  58373. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58374. */
  58375. samples: number;
  58376. /**
  58377. * If image processing is enabled.
  58378. */
  58379. imageProcessingEnabled: boolean;
  58380. /**
  58381. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58382. */
  58383. glowLayerEnabled: boolean;
  58384. /**
  58385. * Gets the glow layer (or null if not defined)
  58386. */
  58387. readonly glowLayer: Nullable<GlowLayer>;
  58388. /**
  58389. * Enable or disable the chromaticAberration process from the pipeline
  58390. */
  58391. chromaticAberrationEnabled: boolean;
  58392. /**
  58393. * Enable or disable the grain process from the pipeline
  58394. */
  58395. grainEnabled: boolean;
  58396. /**
  58397. * @constructor
  58398. * @param name - The rendering pipeline name (default: "")
  58399. * @param hdr - If high dynamic range textures should be used (default: true)
  58400. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58401. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58402. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58403. */
  58404. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58405. /**
  58406. * Get the class name
  58407. * @returns "DefaultRenderingPipeline"
  58408. */
  58409. getClassName(): string;
  58410. /**
  58411. * Force the compilation of the entire pipeline.
  58412. */
  58413. prepare(): void;
  58414. private _hasCleared;
  58415. private _prevPostProcess;
  58416. private _prevPrevPostProcess;
  58417. private _setAutoClearAndTextureSharing;
  58418. private _depthOfFieldSceneObserver;
  58419. private _buildPipeline;
  58420. private _disposePostProcesses;
  58421. /**
  58422. * Adds a camera to the pipeline
  58423. * @param camera the camera to be added
  58424. */
  58425. addCamera(camera: Camera): void;
  58426. /**
  58427. * Removes a camera from the pipeline
  58428. * @param camera the camera to remove
  58429. */
  58430. removeCamera(camera: Camera): void;
  58431. /**
  58432. * Dispose of the pipeline and stop all post processes
  58433. */
  58434. dispose(): void;
  58435. /**
  58436. * Serialize the rendering pipeline (Used when exporting)
  58437. * @returns the serialized object
  58438. */
  58439. serialize(): any;
  58440. /**
  58441. * Parse the serialized pipeline
  58442. * @param source Source pipeline.
  58443. * @param scene The scene to load the pipeline to.
  58444. * @param rootUrl The URL of the serialized pipeline.
  58445. * @returns An instantiated pipeline from the serialized object.
  58446. */
  58447. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58448. }
  58449. }
  58450. declare module BABYLON {
  58451. /** @hidden */
  58452. export var lensHighlightsPixelShader: {
  58453. name: string;
  58454. shader: string;
  58455. };
  58456. }
  58457. declare module BABYLON {
  58458. /** @hidden */
  58459. export var depthOfFieldPixelShader: {
  58460. name: string;
  58461. shader: string;
  58462. };
  58463. }
  58464. declare module BABYLON {
  58465. /**
  58466. * BABYLON.JS Chromatic Aberration GLSL Shader
  58467. * Author: Olivier Guyot
  58468. * Separates very slightly R, G and B colors on the edges of the screen
  58469. * Inspired by Francois Tarlier & Martins Upitis
  58470. */
  58471. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58472. /**
  58473. * @ignore
  58474. * The chromatic aberration PostProcess id in the pipeline
  58475. */
  58476. LensChromaticAberrationEffect: string;
  58477. /**
  58478. * @ignore
  58479. * The highlights enhancing PostProcess id in the pipeline
  58480. */
  58481. HighlightsEnhancingEffect: string;
  58482. /**
  58483. * @ignore
  58484. * The depth-of-field PostProcess id in the pipeline
  58485. */
  58486. LensDepthOfFieldEffect: string;
  58487. private _scene;
  58488. private _depthTexture;
  58489. private _grainTexture;
  58490. private _chromaticAberrationPostProcess;
  58491. private _highlightsPostProcess;
  58492. private _depthOfFieldPostProcess;
  58493. private _edgeBlur;
  58494. private _grainAmount;
  58495. private _chromaticAberration;
  58496. private _distortion;
  58497. private _highlightsGain;
  58498. private _highlightsThreshold;
  58499. private _dofDistance;
  58500. private _dofAperture;
  58501. private _dofDarken;
  58502. private _dofPentagon;
  58503. private _blurNoise;
  58504. /**
  58505. * @constructor
  58506. *
  58507. * Effect parameters are as follow:
  58508. * {
  58509. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58510. * edge_blur: number; // from 0 to x (1 for realism)
  58511. * distortion: number; // from 0 to x (1 for realism)
  58512. * grain_amount: number; // from 0 to 1
  58513. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58514. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58515. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58516. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58517. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58518. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58519. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58520. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58521. * }
  58522. * Note: if an effect parameter is unset, effect is disabled
  58523. *
  58524. * @param name The rendering pipeline name
  58525. * @param parameters - An object containing all parameters (see above)
  58526. * @param scene The scene linked to this pipeline
  58527. * @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)
  58528. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58529. */
  58530. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58531. /**
  58532. * Get the class name
  58533. * @returns "LensRenderingPipeline"
  58534. */
  58535. getClassName(): string;
  58536. /**
  58537. * Gets associated scene
  58538. */
  58539. readonly scene: Scene;
  58540. /**
  58541. * Gets or sets the edge blur
  58542. */
  58543. edgeBlur: number;
  58544. /**
  58545. * Gets or sets the grain amount
  58546. */
  58547. grainAmount: number;
  58548. /**
  58549. * Gets or sets the chromatic aberration amount
  58550. */
  58551. chromaticAberration: number;
  58552. /**
  58553. * Gets or sets the depth of field aperture
  58554. */
  58555. dofAperture: number;
  58556. /**
  58557. * Gets or sets the edge distortion
  58558. */
  58559. edgeDistortion: number;
  58560. /**
  58561. * Gets or sets the depth of field distortion
  58562. */
  58563. dofDistortion: number;
  58564. /**
  58565. * Gets or sets the darken out of focus amount
  58566. */
  58567. darkenOutOfFocus: number;
  58568. /**
  58569. * Gets or sets a boolean indicating if blur noise is enabled
  58570. */
  58571. blurNoise: boolean;
  58572. /**
  58573. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58574. */
  58575. pentagonBokeh: boolean;
  58576. /**
  58577. * Gets or sets the highlight grain amount
  58578. */
  58579. highlightsGain: number;
  58580. /**
  58581. * Gets or sets the highlight threshold
  58582. */
  58583. highlightsThreshold: number;
  58584. /**
  58585. * Sets the amount of blur at the edges
  58586. * @param amount blur amount
  58587. */
  58588. setEdgeBlur(amount: number): void;
  58589. /**
  58590. * Sets edge blur to 0
  58591. */
  58592. disableEdgeBlur(): void;
  58593. /**
  58594. * Sets the amout of grain
  58595. * @param amount Amount of grain
  58596. */
  58597. setGrainAmount(amount: number): void;
  58598. /**
  58599. * Set grain amount to 0
  58600. */
  58601. disableGrain(): void;
  58602. /**
  58603. * Sets the chromatic aberration amount
  58604. * @param amount amount of chromatic aberration
  58605. */
  58606. setChromaticAberration(amount: number): void;
  58607. /**
  58608. * Sets chromatic aberration amount to 0
  58609. */
  58610. disableChromaticAberration(): void;
  58611. /**
  58612. * Sets the EdgeDistortion amount
  58613. * @param amount amount of EdgeDistortion
  58614. */
  58615. setEdgeDistortion(amount: number): void;
  58616. /**
  58617. * Sets edge distortion to 0
  58618. */
  58619. disableEdgeDistortion(): void;
  58620. /**
  58621. * Sets the FocusDistance amount
  58622. * @param amount amount of FocusDistance
  58623. */
  58624. setFocusDistance(amount: number): void;
  58625. /**
  58626. * Disables depth of field
  58627. */
  58628. disableDepthOfField(): void;
  58629. /**
  58630. * Sets the Aperture amount
  58631. * @param amount amount of Aperture
  58632. */
  58633. setAperture(amount: number): void;
  58634. /**
  58635. * Sets the DarkenOutOfFocus amount
  58636. * @param amount amount of DarkenOutOfFocus
  58637. */
  58638. setDarkenOutOfFocus(amount: number): void;
  58639. private _pentagonBokehIsEnabled;
  58640. /**
  58641. * Creates a pentagon bokeh effect
  58642. */
  58643. enablePentagonBokeh(): void;
  58644. /**
  58645. * Disables the pentagon bokeh effect
  58646. */
  58647. disablePentagonBokeh(): void;
  58648. /**
  58649. * Enables noise blur
  58650. */
  58651. enableNoiseBlur(): void;
  58652. /**
  58653. * Disables noise blur
  58654. */
  58655. disableNoiseBlur(): void;
  58656. /**
  58657. * Sets the HighlightsGain amount
  58658. * @param amount amount of HighlightsGain
  58659. */
  58660. setHighlightsGain(amount: number): void;
  58661. /**
  58662. * Sets the HighlightsThreshold amount
  58663. * @param amount amount of HighlightsThreshold
  58664. */
  58665. setHighlightsThreshold(amount: number): void;
  58666. /**
  58667. * Disables highlights
  58668. */
  58669. disableHighlights(): void;
  58670. /**
  58671. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58672. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58673. */
  58674. dispose(disableDepthRender?: boolean): void;
  58675. private _createChromaticAberrationPostProcess;
  58676. private _createHighlightsPostProcess;
  58677. private _createDepthOfFieldPostProcess;
  58678. private _createGrainTexture;
  58679. }
  58680. }
  58681. declare module BABYLON {
  58682. /** @hidden */
  58683. export var ssao2PixelShader: {
  58684. name: string;
  58685. shader: string;
  58686. };
  58687. }
  58688. declare module BABYLON {
  58689. /** @hidden */
  58690. export var ssaoCombinePixelShader: {
  58691. name: string;
  58692. shader: string;
  58693. };
  58694. }
  58695. declare module BABYLON {
  58696. /**
  58697. * Render pipeline to produce ssao effect
  58698. */
  58699. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58700. /**
  58701. * @ignore
  58702. * The PassPostProcess id in the pipeline that contains the original scene color
  58703. */
  58704. SSAOOriginalSceneColorEffect: string;
  58705. /**
  58706. * @ignore
  58707. * The SSAO PostProcess id in the pipeline
  58708. */
  58709. SSAORenderEffect: string;
  58710. /**
  58711. * @ignore
  58712. * The horizontal blur PostProcess id in the pipeline
  58713. */
  58714. SSAOBlurHRenderEffect: string;
  58715. /**
  58716. * @ignore
  58717. * The vertical blur PostProcess id in the pipeline
  58718. */
  58719. SSAOBlurVRenderEffect: string;
  58720. /**
  58721. * @ignore
  58722. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58723. */
  58724. SSAOCombineRenderEffect: string;
  58725. /**
  58726. * The output strength of the SSAO post-process. Default value is 1.0.
  58727. */
  58728. totalStrength: number;
  58729. /**
  58730. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58731. */
  58732. maxZ: number;
  58733. /**
  58734. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58735. */
  58736. minZAspect: number;
  58737. private _samples;
  58738. /**
  58739. * Number of samples used for the SSAO calculations. Default value is 8
  58740. */
  58741. samples: number;
  58742. private _textureSamples;
  58743. /**
  58744. * Number of samples to use for antialiasing
  58745. */
  58746. textureSamples: number;
  58747. /**
  58748. * Ratio object used for SSAO ratio and blur ratio
  58749. */
  58750. private _ratio;
  58751. /**
  58752. * Dynamically generated sphere sampler.
  58753. */
  58754. private _sampleSphere;
  58755. /**
  58756. * Blur filter offsets
  58757. */
  58758. private _samplerOffsets;
  58759. private _expensiveBlur;
  58760. /**
  58761. * If bilateral blur should be used
  58762. */
  58763. expensiveBlur: boolean;
  58764. /**
  58765. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58766. */
  58767. radius: number;
  58768. /**
  58769. * The base color of the SSAO post-process
  58770. * The final result is "base + ssao" between [0, 1]
  58771. */
  58772. base: number;
  58773. /**
  58774. * Support test.
  58775. */
  58776. static readonly IsSupported: boolean;
  58777. private _scene;
  58778. private _depthTexture;
  58779. private _normalTexture;
  58780. private _randomTexture;
  58781. private _originalColorPostProcess;
  58782. private _ssaoPostProcess;
  58783. private _blurHPostProcess;
  58784. private _blurVPostProcess;
  58785. private _ssaoCombinePostProcess;
  58786. private _firstUpdate;
  58787. /**
  58788. * Gets active scene
  58789. */
  58790. readonly scene: Scene;
  58791. /**
  58792. * @constructor
  58793. * @param name The rendering pipeline name
  58794. * @param scene The scene linked to this pipeline
  58795. * @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 }
  58796. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58797. */
  58798. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58799. /**
  58800. * Get the class name
  58801. * @returns "SSAO2RenderingPipeline"
  58802. */
  58803. getClassName(): string;
  58804. /**
  58805. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58806. */
  58807. dispose(disableGeometryBufferRenderer?: boolean): void;
  58808. private _createBlurPostProcess;
  58809. /** @hidden */ private _rebuild(): void;
  58810. private _bits;
  58811. private _radicalInverse_VdC;
  58812. private _hammersley;
  58813. private _hemisphereSample_uniform;
  58814. private _generateHemisphere;
  58815. private _createSSAOPostProcess;
  58816. private _createSSAOCombinePostProcess;
  58817. private _createRandomTexture;
  58818. /**
  58819. * Serialize the rendering pipeline (Used when exporting)
  58820. * @returns the serialized object
  58821. */
  58822. serialize(): any;
  58823. /**
  58824. * Parse the serialized pipeline
  58825. * @param source Source pipeline.
  58826. * @param scene The scene to load the pipeline to.
  58827. * @param rootUrl The URL of the serialized pipeline.
  58828. * @returns An instantiated pipeline from the serialized object.
  58829. */
  58830. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58831. }
  58832. }
  58833. declare module BABYLON {
  58834. /** @hidden */
  58835. export var ssaoPixelShader: {
  58836. name: string;
  58837. shader: string;
  58838. };
  58839. }
  58840. declare module BABYLON {
  58841. /**
  58842. * Render pipeline to produce ssao effect
  58843. */
  58844. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58845. /**
  58846. * @ignore
  58847. * The PassPostProcess id in the pipeline that contains the original scene color
  58848. */
  58849. SSAOOriginalSceneColorEffect: string;
  58850. /**
  58851. * @ignore
  58852. * The SSAO PostProcess id in the pipeline
  58853. */
  58854. SSAORenderEffect: string;
  58855. /**
  58856. * @ignore
  58857. * The horizontal blur PostProcess id in the pipeline
  58858. */
  58859. SSAOBlurHRenderEffect: string;
  58860. /**
  58861. * @ignore
  58862. * The vertical blur PostProcess id in the pipeline
  58863. */
  58864. SSAOBlurVRenderEffect: string;
  58865. /**
  58866. * @ignore
  58867. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58868. */
  58869. SSAOCombineRenderEffect: string;
  58870. /**
  58871. * The output strength of the SSAO post-process. Default value is 1.0.
  58872. */
  58873. totalStrength: number;
  58874. /**
  58875. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  58876. */
  58877. radius: number;
  58878. /**
  58879. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  58880. * Must not be equal to fallOff and superior to fallOff.
  58881. * Default value is 0.0075
  58882. */
  58883. area: number;
  58884. /**
  58885. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  58886. * Must not be equal to area and inferior to area.
  58887. * Default value is 0.000001
  58888. */
  58889. fallOff: number;
  58890. /**
  58891. * The base color of the SSAO post-process
  58892. * The final result is "base + ssao" between [0, 1]
  58893. */
  58894. base: number;
  58895. private _scene;
  58896. private _depthTexture;
  58897. private _randomTexture;
  58898. private _originalColorPostProcess;
  58899. private _ssaoPostProcess;
  58900. private _blurHPostProcess;
  58901. private _blurVPostProcess;
  58902. private _ssaoCombinePostProcess;
  58903. private _firstUpdate;
  58904. /**
  58905. * Gets active scene
  58906. */
  58907. readonly scene: Scene;
  58908. /**
  58909. * @constructor
  58910. * @param name - The rendering pipeline name
  58911. * @param scene - The scene linked to this pipeline
  58912. * @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 }
  58913. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  58914. */
  58915. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58916. /**
  58917. * Get the class name
  58918. * @returns "SSAORenderingPipeline"
  58919. */
  58920. getClassName(): string;
  58921. /**
  58922. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58923. */
  58924. dispose(disableDepthRender?: boolean): void;
  58925. private _createBlurPostProcess;
  58926. /** @hidden */ private _rebuild(): void;
  58927. private _createSSAOPostProcess;
  58928. private _createSSAOCombinePostProcess;
  58929. private _createRandomTexture;
  58930. }
  58931. }
  58932. declare module BABYLON {
  58933. /** @hidden */
  58934. export var standardPixelShader: {
  58935. name: string;
  58936. shader: string;
  58937. };
  58938. }
  58939. declare module BABYLON {
  58940. /**
  58941. * Standard rendering pipeline
  58942. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58943. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  58944. */
  58945. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58946. /**
  58947. * Public members
  58948. */
  58949. /**
  58950. * Post-process which contains the original scene color before the pipeline applies all the effects
  58951. */
  58952. originalPostProcess: Nullable<PostProcess>;
  58953. /**
  58954. * Post-process used to down scale an image x4
  58955. */
  58956. downSampleX4PostProcess: Nullable<PostProcess>;
  58957. /**
  58958. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  58959. */
  58960. brightPassPostProcess: Nullable<PostProcess>;
  58961. /**
  58962. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  58963. */
  58964. blurHPostProcesses: PostProcess[];
  58965. /**
  58966. * Post-process array storing all the vertical blur post-processes used by the pipeline
  58967. */
  58968. blurVPostProcesses: PostProcess[];
  58969. /**
  58970. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  58971. */
  58972. textureAdderPostProcess: Nullable<PostProcess>;
  58973. /**
  58974. * Post-process used to create volumetric lighting effect
  58975. */
  58976. volumetricLightPostProcess: Nullable<PostProcess>;
  58977. /**
  58978. * Post-process used to smooth the previous volumetric light post-process on the X axis
  58979. */
  58980. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  58981. /**
  58982. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  58983. */
  58984. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  58985. /**
  58986. * Post-process used to merge the volumetric light effect and the real scene color
  58987. */
  58988. volumetricLightMergePostProces: Nullable<PostProcess>;
  58989. /**
  58990. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  58991. */
  58992. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  58993. /**
  58994. * Base post-process used to calculate the average luminance of the final image for HDR
  58995. */
  58996. luminancePostProcess: Nullable<PostProcess>;
  58997. /**
  58998. * Post-processes used to create down sample post-processes in order to get
  58999. * the average luminance of the final image for HDR
  59000. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59001. */
  59002. luminanceDownSamplePostProcesses: PostProcess[];
  59003. /**
  59004. * Post-process used to create a HDR effect (light adaptation)
  59005. */
  59006. hdrPostProcess: Nullable<PostProcess>;
  59007. /**
  59008. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59009. */
  59010. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59011. /**
  59012. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59013. */
  59014. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59015. /**
  59016. * Post-process used to merge the final HDR post-process and the real scene color
  59017. */
  59018. hdrFinalPostProcess: Nullable<PostProcess>;
  59019. /**
  59020. * Post-process used to create a lens flare effect
  59021. */
  59022. lensFlarePostProcess: Nullable<PostProcess>;
  59023. /**
  59024. * Post-process that merges the result of the lens flare post-process and the real scene color
  59025. */
  59026. lensFlareComposePostProcess: Nullable<PostProcess>;
  59027. /**
  59028. * Post-process used to create a motion blur effect
  59029. */
  59030. motionBlurPostProcess: Nullable<PostProcess>;
  59031. /**
  59032. * Post-process used to create a depth of field effect
  59033. */
  59034. depthOfFieldPostProcess: Nullable<PostProcess>;
  59035. /**
  59036. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59037. */
  59038. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59039. /**
  59040. * Represents the brightness threshold in order to configure the illuminated surfaces
  59041. */
  59042. brightThreshold: number;
  59043. /**
  59044. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59045. */
  59046. blurWidth: number;
  59047. /**
  59048. * Sets if the blur for highlighted surfaces must be only horizontal
  59049. */
  59050. horizontalBlur: boolean;
  59051. /**
  59052. * Gets the overall exposure used by the pipeline
  59053. */
  59054. /**
  59055. * Sets the overall exposure used by the pipeline
  59056. */
  59057. exposure: number;
  59058. /**
  59059. * Texture used typically to simulate "dirty" on camera lens
  59060. */
  59061. lensTexture: Nullable<Texture>;
  59062. /**
  59063. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59064. */
  59065. volumetricLightCoefficient: number;
  59066. /**
  59067. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59068. */
  59069. volumetricLightPower: number;
  59070. /**
  59071. * Used the set the blur intensity to smooth the volumetric lights
  59072. */
  59073. volumetricLightBlurScale: number;
  59074. /**
  59075. * Light (spot or directional) used to generate the volumetric lights rays
  59076. * The source light must have a shadow generate so the pipeline can get its
  59077. * depth map
  59078. */
  59079. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59080. /**
  59081. * For eye adaptation, represents the minimum luminance the eye can see
  59082. */
  59083. hdrMinimumLuminance: number;
  59084. /**
  59085. * For eye adaptation, represents the decrease luminance speed
  59086. */
  59087. hdrDecreaseRate: number;
  59088. /**
  59089. * For eye adaptation, represents the increase luminance speed
  59090. */
  59091. hdrIncreaseRate: number;
  59092. /**
  59093. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59094. */
  59095. /**
  59096. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59097. */
  59098. hdrAutoExposure: boolean;
  59099. /**
  59100. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59101. */
  59102. lensColorTexture: Nullable<Texture>;
  59103. /**
  59104. * The overall strengh for the lens flare effect
  59105. */
  59106. lensFlareStrength: number;
  59107. /**
  59108. * Dispersion coefficient for lens flare ghosts
  59109. */
  59110. lensFlareGhostDispersal: number;
  59111. /**
  59112. * Main lens flare halo width
  59113. */
  59114. lensFlareHaloWidth: number;
  59115. /**
  59116. * Based on the lens distortion effect, defines how much the lens flare result
  59117. * is distorted
  59118. */
  59119. lensFlareDistortionStrength: number;
  59120. /**
  59121. * Configures the blur intensity used for for lens flare (halo)
  59122. */
  59123. lensFlareBlurWidth: number;
  59124. /**
  59125. * Lens star texture must be used to simulate rays on the flares and is available
  59126. * in the documentation
  59127. */
  59128. lensStarTexture: Nullable<Texture>;
  59129. /**
  59130. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59131. * flare effect by taking account of the dirt texture
  59132. */
  59133. lensFlareDirtTexture: Nullable<Texture>;
  59134. /**
  59135. * Represents the focal length for the depth of field effect
  59136. */
  59137. depthOfFieldDistance: number;
  59138. /**
  59139. * Represents the blur intensity for the blurred part of the depth of field effect
  59140. */
  59141. depthOfFieldBlurWidth: number;
  59142. /**
  59143. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59144. */
  59145. /**
  59146. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59147. */
  59148. motionStrength: number;
  59149. /**
  59150. * Gets wether or not the motion blur post-process is object based or screen based.
  59151. */
  59152. /**
  59153. * Sets wether or not the motion blur post-process should be object based or screen based
  59154. */
  59155. objectBasedMotionBlur: boolean;
  59156. /**
  59157. * List of animations for the pipeline (IAnimatable implementation)
  59158. */
  59159. animations: Animation[];
  59160. /**
  59161. * Private members
  59162. */
  59163. private _scene;
  59164. private _currentDepthOfFieldSource;
  59165. private _basePostProcess;
  59166. private _fixedExposure;
  59167. private _currentExposure;
  59168. private _hdrAutoExposure;
  59169. private _hdrCurrentLuminance;
  59170. private _motionStrength;
  59171. private _isObjectBasedMotionBlur;
  59172. private _floatTextureType;
  59173. private _camerasToBeAttached;
  59174. private _ratio;
  59175. private _bloomEnabled;
  59176. private _depthOfFieldEnabled;
  59177. private _vlsEnabled;
  59178. private _lensFlareEnabled;
  59179. private _hdrEnabled;
  59180. private _motionBlurEnabled;
  59181. private _fxaaEnabled;
  59182. private _motionBlurSamples;
  59183. private _volumetricLightStepsCount;
  59184. private _samples;
  59185. /**
  59186. * @ignore
  59187. * Specifies if the bloom pipeline is enabled
  59188. */
  59189. BloomEnabled: boolean;
  59190. /**
  59191. * @ignore
  59192. * Specifies if the depth of field pipeline is enabed
  59193. */
  59194. DepthOfFieldEnabled: boolean;
  59195. /**
  59196. * @ignore
  59197. * Specifies if the lens flare pipeline is enabed
  59198. */
  59199. LensFlareEnabled: boolean;
  59200. /**
  59201. * @ignore
  59202. * Specifies if the HDR pipeline is enabled
  59203. */
  59204. HDREnabled: boolean;
  59205. /**
  59206. * @ignore
  59207. * Specifies if the volumetric lights scattering effect is enabled
  59208. */
  59209. VLSEnabled: boolean;
  59210. /**
  59211. * @ignore
  59212. * Specifies if the motion blur effect is enabled
  59213. */
  59214. MotionBlurEnabled: boolean;
  59215. /**
  59216. * Specifies if anti-aliasing is enabled
  59217. */
  59218. fxaaEnabled: boolean;
  59219. /**
  59220. * Specifies the number of steps used to calculate the volumetric lights
  59221. * Typically in interval [50, 200]
  59222. */
  59223. volumetricLightStepsCount: number;
  59224. /**
  59225. * Specifies the number of samples used for the motion blur effect
  59226. * Typically in interval [16, 64]
  59227. */
  59228. motionBlurSamples: number;
  59229. /**
  59230. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59231. */
  59232. samples: number;
  59233. /**
  59234. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59235. * @constructor
  59236. * @param name The rendering pipeline name
  59237. * @param scene The scene linked to this pipeline
  59238. * @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)
  59239. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59240. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59241. */
  59242. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59243. private _buildPipeline;
  59244. private _createDownSampleX4PostProcess;
  59245. private _createBrightPassPostProcess;
  59246. private _createBlurPostProcesses;
  59247. private _createTextureAdderPostProcess;
  59248. private _createVolumetricLightPostProcess;
  59249. private _createLuminancePostProcesses;
  59250. private _createHdrPostProcess;
  59251. private _createLensFlarePostProcess;
  59252. private _createDepthOfFieldPostProcess;
  59253. private _createMotionBlurPostProcess;
  59254. private _getDepthTexture;
  59255. private _disposePostProcesses;
  59256. /**
  59257. * Dispose of the pipeline and stop all post processes
  59258. */
  59259. dispose(): void;
  59260. /**
  59261. * Serialize the rendering pipeline (Used when exporting)
  59262. * @returns the serialized object
  59263. */
  59264. serialize(): any;
  59265. /**
  59266. * Parse the serialized pipeline
  59267. * @param source Source pipeline.
  59268. * @param scene The scene to load the pipeline to.
  59269. * @param rootUrl The URL of the serialized pipeline.
  59270. * @returns An instantiated pipeline from the serialized object.
  59271. */
  59272. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59273. /**
  59274. * Luminance steps
  59275. */
  59276. static LuminanceSteps: number;
  59277. }
  59278. }
  59279. declare module BABYLON {
  59280. /** @hidden */
  59281. export var tonemapPixelShader: {
  59282. name: string;
  59283. shader: string;
  59284. };
  59285. }
  59286. declare module BABYLON {
  59287. /** Defines operator used for tonemapping */
  59288. export enum TonemappingOperator {
  59289. /** Hable */
  59290. Hable = 0,
  59291. /** Reinhard */
  59292. Reinhard = 1,
  59293. /** HejiDawson */
  59294. HejiDawson = 2,
  59295. /** Photographic */
  59296. Photographic = 3
  59297. }
  59298. /**
  59299. * Defines a post process to apply tone mapping
  59300. */
  59301. export class TonemapPostProcess extends PostProcess {
  59302. private _operator;
  59303. /** Defines the required exposure adjustement */
  59304. exposureAdjustment: number;
  59305. /**
  59306. * Creates a new TonemapPostProcess
  59307. * @param name defines the name of the postprocess
  59308. * @param _operator defines the operator to use
  59309. * @param exposureAdjustment defines the required exposure adjustement
  59310. * @param camera defines the camera to use (can be null)
  59311. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59312. * @param engine defines the hosting engine (can be ignore if camera is set)
  59313. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59314. */
  59315. constructor(name: string, _operator: TonemappingOperator,
  59316. /** Defines the required exposure adjustement */
  59317. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59318. }
  59319. }
  59320. declare module BABYLON {
  59321. /** @hidden */
  59322. export var depthVertexShader: {
  59323. name: string;
  59324. shader: string;
  59325. };
  59326. }
  59327. declare module BABYLON {
  59328. /** @hidden */
  59329. export var volumetricLightScatteringPixelShader: {
  59330. name: string;
  59331. shader: string;
  59332. };
  59333. }
  59334. declare module BABYLON {
  59335. /** @hidden */
  59336. export var volumetricLightScatteringPassVertexShader: {
  59337. name: string;
  59338. shader: string;
  59339. };
  59340. }
  59341. declare module BABYLON {
  59342. /** @hidden */
  59343. export var volumetricLightScatteringPassPixelShader: {
  59344. name: string;
  59345. shader: string;
  59346. };
  59347. }
  59348. declare module BABYLON {
  59349. /**
  59350. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59351. */
  59352. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59353. private _volumetricLightScatteringPass;
  59354. private _volumetricLightScatteringRTT;
  59355. private _viewPort;
  59356. private _screenCoordinates;
  59357. private _cachedDefines;
  59358. /**
  59359. * If not undefined, the mesh position is computed from the attached node position
  59360. */
  59361. attachedNode: {
  59362. position: Vector3;
  59363. };
  59364. /**
  59365. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59366. */
  59367. customMeshPosition: Vector3;
  59368. /**
  59369. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59370. */
  59371. useCustomMeshPosition: boolean;
  59372. /**
  59373. * If the post-process should inverse the light scattering direction
  59374. */
  59375. invert: boolean;
  59376. /**
  59377. * The internal mesh used by the post-process
  59378. */
  59379. mesh: Mesh;
  59380. /**
  59381. * @hidden
  59382. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59383. */
  59384. useDiffuseColor: boolean;
  59385. /**
  59386. * Array containing the excluded meshes not rendered in the internal pass
  59387. */
  59388. excludedMeshes: AbstractMesh[];
  59389. /**
  59390. * Controls the overall intensity of the post-process
  59391. */
  59392. exposure: number;
  59393. /**
  59394. * Dissipates each sample's contribution in range [0, 1]
  59395. */
  59396. decay: number;
  59397. /**
  59398. * Controls the overall intensity of each sample
  59399. */
  59400. weight: number;
  59401. /**
  59402. * Controls the density of each sample
  59403. */
  59404. density: number;
  59405. /**
  59406. * @constructor
  59407. * @param name The post-process name
  59408. * @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)
  59409. * @param camera The camera that the post-process will be attached to
  59410. * @param mesh The mesh used to create the light scattering
  59411. * @param samples The post-process quality, default 100
  59412. * @param samplingModeThe post-process filtering mode
  59413. * @param engine The babylon engine
  59414. * @param reusable If the post-process is reusable
  59415. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59416. */
  59417. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59418. /**
  59419. * Returns the string "VolumetricLightScatteringPostProcess"
  59420. * @returns "VolumetricLightScatteringPostProcess"
  59421. */
  59422. getClassName(): string;
  59423. private _isReady;
  59424. /**
  59425. * Sets the new light position for light scattering effect
  59426. * @param position The new custom light position
  59427. */
  59428. setCustomMeshPosition(position: Vector3): void;
  59429. /**
  59430. * Returns the light position for light scattering effect
  59431. * @return Vector3 The custom light position
  59432. */
  59433. getCustomMeshPosition(): Vector3;
  59434. /**
  59435. * Disposes the internal assets and detaches the post-process from the camera
  59436. */
  59437. dispose(camera: Camera): void;
  59438. /**
  59439. * Returns the render target texture used by the post-process
  59440. * @return the render target texture used by the post-process
  59441. */
  59442. getPass(): RenderTargetTexture;
  59443. private _meshExcluded;
  59444. private _createPass;
  59445. private _updateMeshScreenCoordinates;
  59446. /**
  59447. * Creates a default mesh for the Volumeric Light Scattering post-process
  59448. * @param name The mesh name
  59449. * @param scene The scene where to create the mesh
  59450. * @return the default mesh
  59451. */
  59452. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59453. }
  59454. }
  59455. declare module BABYLON {
  59456. interface Scene {
  59457. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  59458. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  59459. /**
  59460. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59461. */
  59462. forceShowBoundingBoxes: boolean;
  59463. /**
  59464. * Gets the bounding box renderer associated with the scene
  59465. * @returns a BoundingBoxRenderer
  59466. */
  59467. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59468. }
  59469. interface AbstractMesh {
  59470. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  59471. /**
  59472. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59473. */
  59474. showBoundingBox: boolean;
  59475. }
  59476. /**
  59477. * Component responsible of rendering the bounding box of the meshes in a scene.
  59478. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59479. */
  59480. export class BoundingBoxRenderer implements ISceneComponent {
  59481. /**
  59482. * The component name helpfull to identify the component in the list of scene components.
  59483. */
  59484. readonly name: string;
  59485. /**
  59486. * The scene the component belongs to.
  59487. */
  59488. scene: Scene;
  59489. /**
  59490. * Color of the bounding box lines placed in front of an object
  59491. */
  59492. frontColor: Color3;
  59493. /**
  59494. * Color of the bounding box lines placed behind an object
  59495. */
  59496. backColor: Color3;
  59497. /**
  59498. * Defines if the renderer should show the back lines or not
  59499. */
  59500. showBackLines: boolean;
  59501. /**
  59502. * @hidden
  59503. */
  59504. renderList: SmartArray<BoundingBox>;
  59505. private _colorShader;
  59506. private _vertexBuffers;
  59507. private _indexBuffer;
  59508. private _fillIndexBuffer;
  59509. private _fillIndexData;
  59510. /**
  59511. * Instantiates a new bounding box renderer in a scene.
  59512. * @param scene the scene the renderer renders in
  59513. */
  59514. constructor(scene: Scene);
  59515. /**
  59516. * Registers the component in a given scene
  59517. */
  59518. register(): void;
  59519. private _evaluateSubMesh;
  59520. private _activeMesh;
  59521. private _prepareRessources;
  59522. private _createIndexBuffer;
  59523. /**
  59524. * Rebuilds the elements related to this component in case of
  59525. * context lost for instance.
  59526. */
  59527. rebuild(): void;
  59528. /**
  59529. * @hidden
  59530. */
  59531. reset(): void;
  59532. /**
  59533. * Render the bounding boxes of a specific rendering group
  59534. * @param renderingGroupId defines the rendering group to render
  59535. */
  59536. render(renderingGroupId: number): void;
  59537. /**
  59538. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59539. * @param mesh Define the mesh to render the occlusion bounding box for
  59540. */
  59541. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59542. /**
  59543. * Dispose and release the resources attached to this renderer.
  59544. */
  59545. dispose(): void;
  59546. }
  59547. }
  59548. declare module BABYLON {
  59549. /** @hidden */
  59550. export var depthPixelShader: {
  59551. name: string;
  59552. shader: string;
  59553. };
  59554. }
  59555. declare module BABYLON {
  59556. /**
  59557. * This represents a depth renderer in Babylon.
  59558. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59559. */
  59560. export class DepthRenderer {
  59561. private _scene;
  59562. private _depthMap;
  59563. private _effect;
  59564. private readonly _storeNonLinearDepth;
  59565. private readonly _clearColor;
  59566. /** Get if the depth renderer is using packed depth or not */
  59567. readonly isPacked: boolean;
  59568. private _cachedDefines;
  59569. private _camera;
  59570. /**
  59571. * Specifiess that the depth renderer will only be used within
  59572. * the camera it is created for.
  59573. * This can help forcing its rendering during the camera processing.
  59574. */
  59575. useOnlyInActiveCamera: boolean;
  59576. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  59577. /**
  59578. * Instantiates a depth renderer
  59579. * @param scene The scene the renderer belongs to
  59580. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59581. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59582. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59583. */
  59584. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59585. /**
  59586. * Creates the depth rendering effect and checks if the effect is ready.
  59587. * @param subMesh The submesh to be used to render the depth map of
  59588. * @param useInstances If multiple world instances should be used
  59589. * @returns if the depth renderer is ready to render the depth map
  59590. */
  59591. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59592. /**
  59593. * Gets the texture which the depth map will be written to.
  59594. * @returns The depth map texture
  59595. */
  59596. getDepthMap(): RenderTargetTexture;
  59597. /**
  59598. * Disposes of the depth renderer.
  59599. */
  59600. dispose(): void;
  59601. }
  59602. }
  59603. declare module BABYLON {
  59604. interface Scene {
  59605. /** @hidden (Backing field) */ private _depthRenderer: {
  59606. [id: string]: DepthRenderer;
  59607. };
  59608. /**
  59609. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59610. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59611. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59612. * @returns the created depth renderer
  59613. */
  59614. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  59615. /**
  59616. * Disables a depth renderer for a given camera
  59617. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59618. */
  59619. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59620. }
  59621. /**
  59622. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59623. * in several rendering techniques.
  59624. */
  59625. export class DepthRendererSceneComponent implements ISceneComponent {
  59626. /**
  59627. * The component name helpfull to identify the component in the list of scene components.
  59628. */
  59629. readonly name: string;
  59630. /**
  59631. * The scene the component belongs to.
  59632. */
  59633. scene: Scene;
  59634. /**
  59635. * Creates a new instance of the component for the given scene
  59636. * @param scene Defines the scene to register the component in
  59637. */
  59638. constructor(scene: Scene);
  59639. /**
  59640. * Registers the component in a given scene
  59641. */
  59642. register(): void;
  59643. /**
  59644. * Rebuilds the elements related to this component in case of
  59645. * context lost for instance.
  59646. */
  59647. rebuild(): void;
  59648. /**
  59649. * Disposes the component and the associated ressources
  59650. */
  59651. dispose(): void;
  59652. private _gatherRenderTargets;
  59653. private _gatherActiveCameraRenderTargets;
  59654. }
  59655. }
  59656. declare module BABYLON {
  59657. /** @hidden */
  59658. export var outlinePixelShader: {
  59659. name: string;
  59660. shader: string;
  59661. };
  59662. }
  59663. declare module BABYLON {
  59664. /** @hidden */
  59665. export var outlineVertexShader: {
  59666. name: string;
  59667. shader: string;
  59668. };
  59669. }
  59670. declare module BABYLON {
  59671. interface Scene {
  59672. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  59673. /**
  59674. * Gets the outline renderer associated with the scene
  59675. * @returns a OutlineRenderer
  59676. */
  59677. getOutlineRenderer(): OutlineRenderer;
  59678. }
  59679. interface AbstractMesh {
  59680. /** @hidden (Backing field) */ private _renderOutline: boolean;
  59681. /**
  59682. * Gets or sets a boolean indicating if the outline must be rendered as well
  59683. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59684. */
  59685. renderOutline: boolean;
  59686. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  59687. /**
  59688. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59689. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59690. */
  59691. renderOverlay: boolean;
  59692. }
  59693. /**
  59694. * This class is responsible to draw bothe outline/overlay of meshes.
  59695. * It should not be used directly but through the available method on mesh.
  59696. */
  59697. export class OutlineRenderer implements ISceneComponent {
  59698. /**
  59699. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59700. */
  59701. private static _StencilReference;
  59702. /**
  59703. * The name of the component. Each component must have a unique name.
  59704. */
  59705. name: string;
  59706. /**
  59707. * The scene the component belongs to.
  59708. */
  59709. scene: Scene;
  59710. /**
  59711. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59712. */
  59713. zOffset: number;
  59714. private _engine;
  59715. private _effect;
  59716. private _cachedDefines;
  59717. private _savedDepthWrite;
  59718. /**
  59719. * Instantiates a new outline renderer. (There could be only one per scene).
  59720. * @param scene Defines the scene it belongs to
  59721. */
  59722. constructor(scene: Scene);
  59723. /**
  59724. * Register the component to one instance of a scene.
  59725. */
  59726. register(): void;
  59727. /**
  59728. * Rebuilds the elements related to this component in case of
  59729. * context lost for instance.
  59730. */
  59731. rebuild(): void;
  59732. /**
  59733. * Disposes the component and the associated ressources.
  59734. */
  59735. dispose(): void;
  59736. /**
  59737. * Renders the outline in the canvas.
  59738. * @param subMesh Defines the sumesh to render
  59739. * @param batch Defines the batch of meshes in case of instances
  59740. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59741. */
  59742. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59743. /**
  59744. * Returns whether or not the outline renderer is ready for a given submesh.
  59745. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59746. * @param subMesh Defines the submesh to check readyness for
  59747. * @param useInstances Defines wheter wee are trying to render instances or not
  59748. * @returns true if ready otherwise false
  59749. */
  59750. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59751. private _beforeRenderingMesh;
  59752. private _afterRenderingMesh;
  59753. }
  59754. }
  59755. declare module BABYLON {
  59756. /**
  59757. * Class used to manage multiple sprites of different sizes on the same spritesheet
  59758. * @see http://doc.babylonjs.com/babylon101/sprites
  59759. */
  59760. export class SpritePackedManager extends SpriteManager {
  59761. /** defines the packed manager's name */
  59762. name: string;
  59763. /**
  59764. * Creates a new sprite manager from a packed sprite sheet
  59765. * @param name defines the manager's name
  59766. * @param imgUrl defines the sprite sheet url
  59767. * @param capacity defines the maximum allowed number of sprites
  59768. * @param scene defines the hosting scene
  59769. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  59770. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  59771. * @param samplingMode defines the smapling mode to use with spritesheet
  59772. * @param fromPacked set to true; do not alter
  59773. */
  59774. constructor(
  59775. /** defines the packed manager's name */
  59776. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  59777. }
  59778. }
  59779. declare module BABYLON {
  59780. /**
  59781. * Defines the list of states available for a task inside a AssetsManager
  59782. */
  59783. export enum AssetTaskState {
  59784. /**
  59785. * Initialization
  59786. */
  59787. INIT = 0,
  59788. /**
  59789. * Running
  59790. */
  59791. RUNNING = 1,
  59792. /**
  59793. * Done
  59794. */
  59795. DONE = 2,
  59796. /**
  59797. * Error
  59798. */
  59799. ERROR = 3
  59800. }
  59801. /**
  59802. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  59803. */
  59804. export abstract class AbstractAssetTask {
  59805. /**
  59806. * Task name
  59807. */ name: string;
  59808. /**
  59809. * Callback called when the task is successful
  59810. */
  59811. onSuccess: (task: any) => void;
  59812. /**
  59813. * Callback called when the task is not successful
  59814. */
  59815. onError: (task: any, message?: string, exception?: any) => void;
  59816. /**
  59817. * Creates a new AssetsManager
  59818. * @param name defines the name of the task
  59819. */
  59820. constructor(
  59821. /**
  59822. * Task name
  59823. */ name: string);
  59824. private _isCompleted;
  59825. private _taskState;
  59826. private _errorObject;
  59827. /**
  59828. * Get if the task is completed
  59829. */
  59830. readonly isCompleted: boolean;
  59831. /**
  59832. * Gets the current state of the task
  59833. */
  59834. readonly taskState: AssetTaskState;
  59835. /**
  59836. * Gets the current error object (if task is in error)
  59837. */
  59838. readonly errorObject: {
  59839. message?: string;
  59840. exception?: any;
  59841. };
  59842. /**
  59843. * Internal only
  59844. * @hidden
  59845. */ private _setErrorObject(message?: string, exception?: any): void;
  59846. /**
  59847. * Execute the current task
  59848. * @param scene defines the scene where you want your assets to be loaded
  59849. * @param onSuccess is a callback called when the task is successfully executed
  59850. * @param onError is a callback called if an error occurs
  59851. */
  59852. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59853. /**
  59854. * Execute the current task
  59855. * @param scene defines the scene where you want your assets to be loaded
  59856. * @param onSuccess is a callback called when the task is successfully executed
  59857. * @param onError is a callback called if an error occurs
  59858. */
  59859. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59860. /**
  59861. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  59862. * This can be used with failed tasks that have the reason for failure fixed.
  59863. */
  59864. reset(): void;
  59865. private onErrorCallback;
  59866. private onDoneCallback;
  59867. }
  59868. /**
  59869. * Define the interface used by progress events raised during assets loading
  59870. */
  59871. export interface IAssetsProgressEvent {
  59872. /**
  59873. * Defines the number of remaining tasks to process
  59874. */
  59875. remainingCount: number;
  59876. /**
  59877. * Defines the total number of tasks
  59878. */
  59879. totalCount: number;
  59880. /**
  59881. * Defines the task that was just processed
  59882. */
  59883. task: AbstractAssetTask;
  59884. }
  59885. /**
  59886. * Class used to share progress information about assets loading
  59887. */
  59888. export class AssetsProgressEvent implements IAssetsProgressEvent {
  59889. /**
  59890. * Defines the number of remaining tasks to process
  59891. */
  59892. remainingCount: number;
  59893. /**
  59894. * Defines the total number of tasks
  59895. */
  59896. totalCount: number;
  59897. /**
  59898. * Defines the task that was just processed
  59899. */
  59900. task: AbstractAssetTask;
  59901. /**
  59902. * Creates a AssetsProgressEvent
  59903. * @param remainingCount defines the number of remaining tasks to process
  59904. * @param totalCount defines the total number of tasks
  59905. * @param task defines the task that was just processed
  59906. */
  59907. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  59908. }
  59909. /**
  59910. * Define a task used by AssetsManager to load meshes
  59911. */
  59912. export class MeshAssetTask extends AbstractAssetTask {
  59913. /**
  59914. * Defines the name of the task
  59915. */
  59916. name: string;
  59917. /**
  59918. * Defines the list of mesh's names you want to load
  59919. */
  59920. meshesNames: any;
  59921. /**
  59922. * Defines the root url to use as a base to load your meshes and associated resources
  59923. */
  59924. rootUrl: string;
  59925. /**
  59926. * Defines the filename of the scene to load from
  59927. */
  59928. sceneFilename: string;
  59929. /**
  59930. * Gets the list of loaded meshes
  59931. */
  59932. loadedMeshes: Array<AbstractMesh>;
  59933. /**
  59934. * Gets the list of loaded particle systems
  59935. */
  59936. loadedParticleSystems: Array<IParticleSystem>;
  59937. /**
  59938. * Gets the list of loaded skeletons
  59939. */
  59940. loadedSkeletons: Array<Skeleton>;
  59941. /**
  59942. * Gets the list of loaded animation groups
  59943. */
  59944. loadedAnimationGroups: Array<AnimationGroup>;
  59945. /**
  59946. * Callback called when the task is successful
  59947. */
  59948. onSuccess: (task: MeshAssetTask) => void;
  59949. /**
  59950. * Callback called when the task is successful
  59951. */
  59952. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  59953. /**
  59954. * Creates a new MeshAssetTask
  59955. * @param name defines the name of the task
  59956. * @param meshesNames defines the list of mesh's names you want to load
  59957. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  59958. * @param sceneFilename defines the filename of the scene to load from
  59959. */
  59960. constructor(
  59961. /**
  59962. * Defines the name of the task
  59963. */
  59964. name: string,
  59965. /**
  59966. * Defines the list of mesh's names you want to load
  59967. */
  59968. meshesNames: any,
  59969. /**
  59970. * Defines the root url to use as a base to load your meshes and associated resources
  59971. */
  59972. rootUrl: string,
  59973. /**
  59974. * Defines the filename of the scene to load from
  59975. */
  59976. sceneFilename: string);
  59977. /**
  59978. * Execute the current task
  59979. * @param scene defines the scene where you want your assets to be loaded
  59980. * @param onSuccess is a callback called when the task is successfully executed
  59981. * @param onError is a callback called if an error occurs
  59982. */
  59983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59984. }
  59985. /**
  59986. * Define a task used by AssetsManager to load text content
  59987. */
  59988. export class TextFileAssetTask extends AbstractAssetTask {
  59989. /**
  59990. * Defines the name of the task
  59991. */
  59992. name: string;
  59993. /**
  59994. * Defines the location of the file to load
  59995. */
  59996. url: string;
  59997. /**
  59998. * Gets the loaded text string
  59999. */
  60000. text: string;
  60001. /**
  60002. * Callback called when the task is successful
  60003. */
  60004. onSuccess: (task: TextFileAssetTask) => void;
  60005. /**
  60006. * Callback called when the task is successful
  60007. */
  60008. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60009. /**
  60010. * Creates a new TextFileAssetTask object
  60011. * @param name defines the name of the task
  60012. * @param url defines the location of the file to load
  60013. */
  60014. constructor(
  60015. /**
  60016. * Defines the name of the task
  60017. */
  60018. name: string,
  60019. /**
  60020. * Defines the location of the file to load
  60021. */
  60022. url: string);
  60023. /**
  60024. * Execute the current task
  60025. * @param scene defines the scene where you want your assets to be loaded
  60026. * @param onSuccess is a callback called when the task is successfully executed
  60027. * @param onError is a callback called if an error occurs
  60028. */
  60029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60030. }
  60031. /**
  60032. * Define a task used by AssetsManager to load binary data
  60033. */
  60034. export class BinaryFileAssetTask extends AbstractAssetTask {
  60035. /**
  60036. * Defines the name of the task
  60037. */
  60038. name: string;
  60039. /**
  60040. * Defines the location of the file to load
  60041. */
  60042. url: string;
  60043. /**
  60044. * Gets the lodaded data (as an array buffer)
  60045. */
  60046. data: ArrayBuffer;
  60047. /**
  60048. * Callback called when the task is successful
  60049. */
  60050. onSuccess: (task: BinaryFileAssetTask) => void;
  60051. /**
  60052. * Callback called when the task is successful
  60053. */
  60054. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60055. /**
  60056. * Creates a new BinaryFileAssetTask object
  60057. * @param name defines the name of the new task
  60058. * @param url defines the location of the file to load
  60059. */
  60060. constructor(
  60061. /**
  60062. * Defines the name of the task
  60063. */
  60064. name: string,
  60065. /**
  60066. * Defines the location of the file to load
  60067. */
  60068. url: string);
  60069. /**
  60070. * Execute the current task
  60071. * @param scene defines the scene where you want your assets to be loaded
  60072. * @param onSuccess is a callback called when the task is successfully executed
  60073. * @param onError is a callback called if an error occurs
  60074. */
  60075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60076. }
  60077. /**
  60078. * Define a task used by AssetsManager to load images
  60079. */
  60080. export class ImageAssetTask extends AbstractAssetTask {
  60081. /**
  60082. * Defines the name of the task
  60083. */
  60084. name: string;
  60085. /**
  60086. * Defines the location of the image to load
  60087. */
  60088. url: string;
  60089. /**
  60090. * Gets the loaded images
  60091. */
  60092. image: HTMLImageElement;
  60093. /**
  60094. * Callback called when the task is successful
  60095. */
  60096. onSuccess: (task: ImageAssetTask) => void;
  60097. /**
  60098. * Callback called when the task is successful
  60099. */
  60100. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60101. /**
  60102. * Creates a new ImageAssetTask
  60103. * @param name defines the name of the task
  60104. * @param url defines the location of the image to load
  60105. */
  60106. constructor(
  60107. /**
  60108. * Defines the name of the task
  60109. */
  60110. name: string,
  60111. /**
  60112. * Defines the location of the image to load
  60113. */
  60114. url: string);
  60115. /**
  60116. * Execute the current task
  60117. * @param scene defines the scene where you want your assets to be loaded
  60118. * @param onSuccess is a callback called when the task is successfully executed
  60119. * @param onError is a callback called if an error occurs
  60120. */
  60121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60122. }
  60123. /**
  60124. * Defines the interface used by texture loading tasks
  60125. */
  60126. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60127. /**
  60128. * Gets the loaded texture
  60129. */
  60130. texture: TEX;
  60131. }
  60132. /**
  60133. * Define a task used by AssetsManager to load 2D textures
  60134. */
  60135. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60136. /**
  60137. * Defines the name of the task
  60138. */
  60139. name: string;
  60140. /**
  60141. * Defines the location of the file to load
  60142. */
  60143. url: string;
  60144. /**
  60145. * Defines if mipmap should not be generated (default is false)
  60146. */
  60147. noMipmap?: boolean | undefined;
  60148. /**
  60149. * Defines if texture must be inverted on Y axis (default is false)
  60150. */
  60151. invertY?: boolean | undefined;
  60152. /**
  60153. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60154. */
  60155. samplingMode: number;
  60156. /**
  60157. * Gets the loaded texture
  60158. */
  60159. texture: Texture;
  60160. /**
  60161. * Callback called when the task is successful
  60162. */
  60163. onSuccess: (task: TextureAssetTask) => void;
  60164. /**
  60165. * Callback called when the task is successful
  60166. */
  60167. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60168. /**
  60169. * Creates a new TextureAssetTask object
  60170. * @param name defines the name of the task
  60171. * @param url defines the location of the file to load
  60172. * @param noMipmap defines if mipmap should not be generated (default is false)
  60173. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60174. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60175. */
  60176. constructor(
  60177. /**
  60178. * Defines the name of the task
  60179. */
  60180. name: string,
  60181. /**
  60182. * Defines the location of the file to load
  60183. */
  60184. url: string,
  60185. /**
  60186. * Defines if mipmap should not be generated (default is false)
  60187. */
  60188. noMipmap?: boolean | undefined,
  60189. /**
  60190. * Defines if texture must be inverted on Y axis (default is false)
  60191. */
  60192. invertY?: boolean | undefined,
  60193. /**
  60194. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60195. */
  60196. samplingMode?: number);
  60197. /**
  60198. * Execute the current task
  60199. * @param scene defines the scene where you want your assets to be loaded
  60200. * @param onSuccess is a callback called when the task is successfully executed
  60201. * @param onError is a callback called if an error occurs
  60202. */
  60203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60204. }
  60205. /**
  60206. * Define a task used by AssetsManager to load cube textures
  60207. */
  60208. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60209. /**
  60210. * Defines the name of the task
  60211. */
  60212. name: string;
  60213. /**
  60214. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60215. */
  60216. url: string;
  60217. /**
  60218. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60219. */
  60220. extensions?: string[] | undefined;
  60221. /**
  60222. * Defines if mipmaps should not be generated (default is false)
  60223. */
  60224. noMipmap?: boolean | undefined;
  60225. /**
  60226. * Defines the explicit list of files (undefined by default)
  60227. */
  60228. files?: string[] | undefined;
  60229. /**
  60230. * Gets the loaded texture
  60231. */
  60232. texture: CubeTexture;
  60233. /**
  60234. * Callback called when the task is successful
  60235. */
  60236. onSuccess: (task: CubeTextureAssetTask) => void;
  60237. /**
  60238. * Callback called when the task is successful
  60239. */
  60240. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60241. /**
  60242. * Creates a new CubeTextureAssetTask
  60243. * @param name defines the name of the task
  60244. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60245. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60246. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60247. * @param files defines the explicit list of files (undefined by default)
  60248. */
  60249. constructor(
  60250. /**
  60251. * Defines the name of the task
  60252. */
  60253. name: string,
  60254. /**
  60255. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60256. */
  60257. url: string,
  60258. /**
  60259. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60260. */
  60261. extensions?: string[] | undefined,
  60262. /**
  60263. * Defines if mipmaps should not be generated (default is false)
  60264. */
  60265. noMipmap?: boolean | undefined,
  60266. /**
  60267. * Defines the explicit list of files (undefined by default)
  60268. */
  60269. files?: string[] | undefined);
  60270. /**
  60271. * Execute the current task
  60272. * @param scene defines the scene where you want your assets to be loaded
  60273. * @param onSuccess is a callback called when the task is successfully executed
  60274. * @param onError is a callback called if an error occurs
  60275. */
  60276. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60277. }
  60278. /**
  60279. * Define a task used by AssetsManager to load HDR cube textures
  60280. */
  60281. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60282. /**
  60283. * Defines the name of the task
  60284. */
  60285. name: string;
  60286. /**
  60287. * Defines the location of the file to load
  60288. */
  60289. url: string;
  60290. /**
  60291. * Defines the desired size (the more it increases the longer the generation will be)
  60292. */
  60293. size: number;
  60294. /**
  60295. * Defines if mipmaps should not be generated (default is false)
  60296. */
  60297. noMipmap: boolean;
  60298. /**
  60299. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60300. */
  60301. generateHarmonics: boolean;
  60302. /**
  60303. * 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)
  60304. */
  60305. gammaSpace: boolean;
  60306. /**
  60307. * Internal Use Only
  60308. */
  60309. reserved: boolean;
  60310. /**
  60311. * Gets the loaded texture
  60312. */
  60313. texture: HDRCubeTexture;
  60314. /**
  60315. * Callback called when the task is successful
  60316. */
  60317. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60318. /**
  60319. * Callback called when the task is successful
  60320. */
  60321. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60322. /**
  60323. * Creates a new HDRCubeTextureAssetTask object
  60324. * @param name defines the name of the task
  60325. * @param url defines the location of the file to load
  60326. * @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.
  60327. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60328. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60329. * @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)
  60330. * @param reserved Internal use only
  60331. */
  60332. constructor(
  60333. /**
  60334. * Defines the name of the task
  60335. */
  60336. name: string,
  60337. /**
  60338. * Defines the location of the file to load
  60339. */
  60340. url: string,
  60341. /**
  60342. * Defines the desired size (the more it increases the longer the generation will be)
  60343. */
  60344. size: number,
  60345. /**
  60346. * Defines if mipmaps should not be generated (default is false)
  60347. */
  60348. noMipmap?: boolean,
  60349. /**
  60350. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60351. */
  60352. generateHarmonics?: boolean,
  60353. /**
  60354. * 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)
  60355. */
  60356. gammaSpace?: boolean,
  60357. /**
  60358. * Internal Use Only
  60359. */
  60360. reserved?: boolean);
  60361. /**
  60362. * Execute the current task
  60363. * @param scene defines the scene where you want your assets to be loaded
  60364. * @param onSuccess is a callback called when the task is successfully executed
  60365. * @param onError is a callback called if an error occurs
  60366. */
  60367. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60368. }
  60369. /**
  60370. * Define a task used by AssetsManager to load Equirectangular cube textures
  60371. */
  60372. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60373. /**
  60374. * Defines the name of the task
  60375. */
  60376. name: string;
  60377. /**
  60378. * Defines the location of the file to load
  60379. */
  60380. url: string;
  60381. /**
  60382. * Defines the desired size (the more it increases the longer the generation will be)
  60383. */
  60384. size: number;
  60385. /**
  60386. * Defines if mipmaps should not be generated (default is false)
  60387. */
  60388. noMipmap: boolean;
  60389. /**
  60390. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60391. * but the standard material would require them in Gamma space) (default is true)
  60392. */
  60393. gammaSpace: boolean;
  60394. /**
  60395. * Gets the loaded texture
  60396. */
  60397. texture: EquiRectangularCubeTexture;
  60398. /**
  60399. * Callback called when the task is successful
  60400. */
  60401. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60402. /**
  60403. * Callback called when the task is successful
  60404. */
  60405. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60406. /**
  60407. * Creates a new EquiRectangularCubeTextureAssetTask object
  60408. * @param name defines the name of the task
  60409. * @param url defines the location of the file to load
  60410. * @param size defines the desired size (the more it increases the longer the generation will be)
  60411. * If the size is omitted this implies you are using a preprocessed cubemap.
  60412. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60413. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60414. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60415. * (default is true)
  60416. */
  60417. constructor(
  60418. /**
  60419. * Defines the name of the task
  60420. */
  60421. name: string,
  60422. /**
  60423. * Defines the location of the file to load
  60424. */
  60425. url: string,
  60426. /**
  60427. * Defines the desired size (the more it increases the longer the generation will be)
  60428. */
  60429. size: number,
  60430. /**
  60431. * Defines if mipmaps should not be generated (default is false)
  60432. */
  60433. noMipmap?: boolean,
  60434. /**
  60435. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60436. * but the standard material would require them in Gamma space) (default is true)
  60437. */
  60438. gammaSpace?: boolean);
  60439. /**
  60440. * Execute the current task
  60441. * @param scene defines the scene where you want your assets to be loaded
  60442. * @param onSuccess is a callback called when the task is successfully executed
  60443. * @param onError is a callback called if an error occurs
  60444. */
  60445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60446. }
  60447. /**
  60448. * This class can be used to easily import assets into a scene
  60449. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60450. */
  60451. export class AssetsManager {
  60452. private _scene;
  60453. private _isLoading;
  60454. protected _tasks: AbstractAssetTask[];
  60455. protected _waitingTasksCount: number;
  60456. protected _totalTasksCount: number;
  60457. /**
  60458. * Callback called when all tasks are processed
  60459. */
  60460. onFinish: (tasks: AbstractAssetTask[]) => void;
  60461. /**
  60462. * Callback called when a task is successful
  60463. */
  60464. onTaskSuccess: (task: AbstractAssetTask) => void;
  60465. /**
  60466. * Callback called when a task had an error
  60467. */
  60468. onTaskError: (task: AbstractAssetTask) => void;
  60469. /**
  60470. * Callback called when a task is done (whatever the result is)
  60471. */
  60472. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60473. /**
  60474. * Observable called when all tasks are processed
  60475. */
  60476. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60477. /**
  60478. * Observable called when a task had an error
  60479. */
  60480. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60481. /**
  60482. * Observable called when all tasks were executed
  60483. */
  60484. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60485. /**
  60486. * Observable called when a task is done (whatever the result is)
  60487. */
  60488. onProgressObservable: Observable<IAssetsProgressEvent>;
  60489. /**
  60490. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60491. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60492. */
  60493. useDefaultLoadingScreen: boolean;
  60494. /**
  60495. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  60496. * when all assets have been downloaded.
  60497. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  60498. */
  60499. autoHideLoadingUI: boolean;
  60500. /**
  60501. * Creates a new AssetsManager
  60502. * @param scene defines the scene to work on
  60503. */
  60504. constructor(scene: Scene);
  60505. /**
  60506. * Add a MeshAssetTask to the list of active tasks
  60507. * @param taskName defines the name of the new task
  60508. * @param meshesNames defines the name of meshes to load
  60509. * @param rootUrl defines the root url to use to locate files
  60510. * @param sceneFilename defines the filename of the scene file
  60511. * @returns a new MeshAssetTask object
  60512. */
  60513. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60514. /**
  60515. * Add a TextFileAssetTask to the list of active tasks
  60516. * @param taskName defines the name of the new task
  60517. * @param url defines the url of the file to load
  60518. * @returns a new TextFileAssetTask object
  60519. */
  60520. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60521. /**
  60522. * Add a BinaryFileAssetTask to the list of active tasks
  60523. * @param taskName defines the name of the new task
  60524. * @param url defines the url of the file to load
  60525. * @returns a new BinaryFileAssetTask object
  60526. */
  60527. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60528. /**
  60529. * Add a ImageAssetTask to the list of active tasks
  60530. * @param taskName defines the name of the new task
  60531. * @param url defines the url of the file to load
  60532. * @returns a new ImageAssetTask object
  60533. */
  60534. addImageTask(taskName: string, url: string): ImageAssetTask;
  60535. /**
  60536. * Add a TextureAssetTask to the list of active tasks
  60537. * @param taskName defines the name of the new task
  60538. * @param url defines the url of the file to load
  60539. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60540. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60541. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60542. * @returns a new TextureAssetTask object
  60543. */
  60544. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60545. /**
  60546. * Add a CubeTextureAssetTask to the list of active tasks
  60547. * @param taskName defines the name of the new task
  60548. * @param url defines the url of the file to load
  60549. * @param extensions defines the extension to use to load the cube map (can be null)
  60550. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60551. * @param files defines the list of files to load (can be null)
  60552. * @returns a new CubeTextureAssetTask object
  60553. */
  60554. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60555. /**
  60556. *
  60557. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60558. * @param taskName defines the name of the new task
  60559. * @param url defines the url of the file to load
  60560. * @param size defines the size you want for the cubemap (can be null)
  60561. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60562. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60563. * @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)
  60564. * @param reserved Internal use only
  60565. * @returns a new HDRCubeTextureAssetTask object
  60566. */
  60567. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60568. /**
  60569. *
  60570. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60571. * @param taskName defines the name of the new task
  60572. * @param url defines the url of the file to load
  60573. * @param size defines the size you want for the cubemap (can be null)
  60574. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60575. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60576. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60577. * @returns a new EquiRectangularCubeTextureAssetTask object
  60578. */
  60579. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60580. /**
  60581. * Remove a task from the assets manager.
  60582. * @param task the task to remove
  60583. */
  60584. removeTask(task: AbstractAssetTask): void;
  60585. private _decreaseWaitingTasksCount;
  60586. private _runTask;
  60587. /**
  60588. * Reset the AssetsManager and remove all tasks
  60589. * @return the current instance of the AssetsManager
  60590. */
  60591. reset(): AssetsManager;
  60592. /**
  60593. * Start the loading process
  60594. * @return the current instance of the AssetsManager
  60595. */
  60596. load(): AssetsManager;
  60597. /**
  60598. * Start the loading process as an async operation
  60599. * @return a promise returning the list of failed tasks
  60600. */
  60601. loadAsync(): Promise<void>;
  60602. }
  60603. }
  60604. declare module BABYLON {
  60605. /**
  60606. * Wrapper class for promise with external resolve and reject.
  60607. */
  60608. export class Deferred<T> {
  60609. /**
  60610. * The promise associated with this deferred object.
  60611. */
  60612. readonly promise: Promise<T>;
  60613. private _resolve;
  60614. private _reject;
  60615. /**
  60616. * The resolve method of the promise associated with this deferred object.
  60617. */
  60618. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60619. /**
  60620. * The reject method of the promise associated with this deferred object.
  60621. */
  60622. readonly reject: (reason?: any) => void;
  60623. /**
  60624. * Constructor for this deferred object.
  60625. */
  60626. constructor();
  60627. }
  60628. }
  60629. declare module BABYLON {
  60630. /**
  60631. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60632. */
  60633. export class MeshExploder {
  60634. private _centerMesh;
  60635. private _meshes;
  60636. private _meshesOrigins;
  60637. private _toCenterVectors;
  60638. private _scaledDirection;
  60639. private _newPosition;
  60640. private _centerPosition;
  60641. /**
  60642. * Explodes meshes from a center mesh.
  60643. * @param meshes The meshes to explode.
  60644. * @param centerMesh The mesh to be center of explosion.
  60645. */
  60646. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60647. private _setCenterMesh;
  60648. /**
  60649. * Get class name
  60650. * @returns "MeshExploder"
  60651. */
  60652. getClassName(): string;
  60653. /**
  60654. * "Exploded meshes"
  60655. * @returns Array of meshes with the centerMesh at index 0.
  60656. */
  60657. getMeshes(): Array<Mesh>;
  60658. /**
  60659. * Explodes meshes giving a specific direction
  60660. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60661. */
  60662. explode(direction?: number): void;
  60663. }
  60664. }
  60665. declare module BABYLON {
  60666. /**
  60667. * Class used to help managing file picking and drag'n'drop
  60668. */
  60669. export class FilesInput {
  60670. /**
  60671. * List of files ready to be loaded
  60672. */
  60673. static readonly FilesToLoad: {
  60674. [key: string]: File;
  60675. };
  60676. /**
  60677. * Callback called when a file is processed
  60678. */
  60679. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60680. private _engine;
  60681. private _currentScene;
  60682. private _sceneLoadedCallback;
  60683. private _progressCallback;
  60684. private _additionalRenderLoopLogicCallback;
  60685. private _textureLoadingCallback;
  60686. private _startingProcessingFilesCallback;
  60687. private _onReloadCallback;
  60688. private _errorCallback;
  60689. private _elementToMonitor;
  60690. private _sceneFileToLoad;
  60691. private _filesToLoad;
  60692. /**
  60693. * Creates a new FilesInput
  60694. * @param engine defines the rendering engine
  60695. * @param scene defines the hosting scene
  60696. * @param sceneLoadedCallback callback called when scene is loaded
  60697. * @param progressCallback callback called to track progress
  60698. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60699. * @param textureLoadingCallback callback called when a texture is loading
  60700. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60701. * @param onReloadCallback callback called when a reload is requested
  60702. * @param errorCallback callback call if an error occurs
  60703. */
  60704. 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);
  60705. private _dragEnterHandler;
  60706. private _dragOverHandler;
  60707. private _dropHandler;
  60708. /**
  60709. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60710. * @param elementToMonitor defines the DOM element to track
  60711. */
  60712. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60713. /**
  60714. * Release all associated resources
  60715. */
  60716. dispose(): void;
  60717. private renderFunction;
  60718. private drag;
  60719. private drop;
  60720. private _traverseFolder;
  60721. private _processFiles;
  60722. /**
  60723. * Load files from a drop event
  60724. * @param event defines the drop event to use as source
  60725. */
  60726. loadFiles(event: any): void;
  60727. private _processReload;
  60728. /**
  60729. * Reload the current scene from the loaded files
  60730. */
  60731. reload(): void;
  60732. }
  60733. }
  60734. declare module BABYLON {
  60735. /**
  60736. * Defines the root class used to create scene optimization to use with SceneOptimizer
  60737. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60738. */
  60739. export class SceneOptimization {
  60740. /**
  60741. * Defines the priority of this optimization (0 by default which means first in the list)
  60742. */
  60743. priority: number;
  60744. /**
  60745. * Gets a string describing the action executed by the current optimization
  60746. * @returns description string
  60747. */
  60748. getDescription(): string;
  60749. /**
  60750. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60751. * @param scene defines the current scene where to apply this optimization
  60752. * @param optimizer defines the current optimizer
  60753. * @returns true if everything that can be done was applied
  60754. */
  60755. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60756. /**
  60757. * Creates the SceneOptimization object
  60758. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60759. * @param desc defines the description associated with the optimization
  60760. */
  60761. constructor(
  60762. /**
  60763. * Defines the priority of this optimization (0 by default which means first in the list)
  60764. */
  60765. priority?: number);
  60766. }
  60767. /**
  60768. * Defines an optimization used to reduce the size of render target textures
  60769. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60770. */
  60771. export class TextureOptimization extends SceneOptimization {
  60772. /**
  60773. * Defines the priority of this optimization (0 by default which means first in the list)
  60774. */
  60775. priority: number;
  60776. /**
  60777. * 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
  60778. */
  60779. maximumSize: number;
  60780. /**
  60781. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60782. */
  60783. step: number;
  60784. /**
  60785. * Gets a string describing the action executed by the current optimization
  60786. * @returns description string
  60787. */
  60788. getDescription(): string;
  60789. /**
  60790. * Creates the TextureOptimization object
  60791. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60792. * @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
  60793. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60794. */
  60795. constructor(
  60796. /**
  60797. * Defines the priority of this optimization (0 by default which means first in the list)
  60798. */
  60799. priority?: number,
  60800. /**
  60801. * 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
  60802. */
  60803. maximumSize?: number,
  60804. /**
  60805. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60806. */
  60807. step?: number);
  60808. /**
  60809. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60810. * @param scene defines the current scene where to apply this optimization
  60811. * @param optimizer defines the current optimizer
  60812. * @returns true if everything that can be done was applied
  60813. */
  60814. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60815. }
  60816. /**
  60817. * Defines an optimization used to increase or decrease the rendering resolution
  60818. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60819. */
  60820. export class HardwareScalingOptimization extends SceneOptimization {
  60821. /**
  60822. * Defines the priority of this optimization (0 by default which means first in the list)
  60823. */
  60824. priority: number;
  60825. /**
  60826. * Defines the maximum scale to use (2 by default)
  60827. */
  60828. maximumScale: number;
  60829. /**
  60830. * Defines the step to use between two passes (0.5 by default)
  60831. */
  60832. step: number;
  60833. private _currentScale;
  60834. private _directionOffset;
  60835. /**
  60836. * Gets a string describing the action executed by the current optimization
  60837. * @return description string
  60838. */
  60839. getDescription(): string;
  60840. /**
  60841. * Creates the HardwareScalingOptimization object
  60842. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60843. * @param maximumScale defines the maximum scale to use (2 by default)
  60844. * @param step defines the step to use between two passes (0.5 by default)
  60845. */
  60846. constructor(
  60847. /**
  60848. * Defines the priority of this optimization (0 by default which means first in the list)
  60849. */
  60850. priority?: number,
  60851. /**
  60852. * Defines the maximum scale to use (2 by default)
  60853. */
  60854. maximumScale?: number,
  60855. /**
  60856. * Defines the step to use between two passes (0.5 by default)
  60857. */
  60858. step?: number);
  60859. /**
  60860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60861. * @param scene defines the current scene where to apply this optimization
  60862. * @param optimizer defines the current optimizer
  60863. * @returns true if everything that can be done was applied
  60864. */
  60865. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60866. }
  60867. /**
  60868. * Defines an optimization used to remove shadows
  60869. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60870. */
  60871. export class ShadowsOptimization extends SceneOptimization {
  60872. /**
  60873. * Gets a string describing the action executed by the current optimization
  60874. * @return description string
  60875. */
  60876. getDescription(): string;
  60877. /**
  60878. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60879. * @param scene defines the current scene where to apply this optimization
  60880. * @param optimizer defines the current optimizer
  60881. * @returns true if everything that can be done was applied
  60882. */
  60883. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60884. }
  60885. /**
  60886. * Defines an optimization used to turn post-processes off
  60887. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60888. */
  60889. export class PostProcessesOptimization extends SceneOptimization {
  60890. /**
  60891. * Gets a string describing the action executed by the current optimization
  60892. * @return description string
  60893. */
  60894. getDescription(): string;
  60895. /**
  60896. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60897. * @param scene defines the current scene where to apply this optimization
  60898. * @param optimizer defines the current optimizer
  60899. * @returns true if everything that can be done was applied
  60900. */
  60901. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60902. }
  60903. /**
  60904. * Defines an optimization used to turn lens flares off
  60905. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60906. */
  60907. export class LensFlaresOptimization extends SceneOptimization {
  60908. /**
  60909. * Gets a string describing the action executed by the current optimization
  60910. * @return description string
  60911. */
  60912. getDescription(): string;
  60913. /**
  60914. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60915. * @param scene defines the current scene where to apply this optimization
  60916. * @param optimizer defines the current optimizer
  60917. * @returns true if everything that can be done was applied
  60918. */
  60919. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60920. }
  60921. /**
  60922. * Defines an optimization based on user defined callback.
  60923. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60924. */
  60925. export class CustomOptimization extends SceneOptimization {
  60926. /**
  60927. * Callback called to apply the custom optimization.
  60928. */
  60929. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  60930. /**
  60931. * Callback called to get custom description
  60932. */
  60933. onGetDescription: () => string;
  60934. /**
  60935. * Gets a string describing the action executed by the current optimization
  60936. * @returns description string
  60937. */
  60938. getDescription(): string;
  60939. /**
  60940. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60941. * @param scene defines the current scene where to apply this optimization
  60942. * @param optimizer defines the current optimizer
  60943. * @returns true if everything that can be done was applied
  60944. */
  60945. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60946. }
  60947. /**
  60948. * Defines an optimization used to turn particles off
  60949. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60950. */
  60951. export class ParticlesOptimization extends SceneOptimization {
  60952. /**
  60953. * Gets a string describing the action executed by the current optimization
  60954. * @return description string
  60955. */
  60956. getDescription(): string;
  60957. /**
  60958. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60959. * @param scene defines the current scene where to apply this optimization
  60960. * @param optimizer defines the current optimizer
  60961. * @returns true if everything that can be done was applied
  60962. */
  60963. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60964. }
  60965. /**
  60966. * Defines an optimization used to turn render targets off
  60967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60968. */
  60969. export class RenderTargetsOptimization extends SceneOptimization {
  60970. /**
  60971. * Gets a string describing the action executed by the current optimization
  60972. * @return description string
  60973. */
  60974. getDescription(): string;
  60975. /**
  60976. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60977. * @param scene defines the current scene where to apply this optimization
  60978. * @param optimizer defines the current optimizer
  60979. * @returns true if everything that can be done was applied
  60980. */
  60981. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60982. }
  60983. /**
  60984. * Defines an optimization used to merge meshes with compatible materials
  60985. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60986. */
  60987. export class MergeMeshesOptimization extends SceneOptimization {
  60988. private static _UpdateSelectionTree;
  60989. /**
  60990. * Gets or sets a boolean which defines if optimization octree has to be updated
  60991. */
  60992. /**
  60993. * Gets or sets a boolean which defines if optimization octree has to be updated
  60994. */
  60995. static UpdateSelectionTree: boolean;
  60996. /**
  60997. * Gets a string describing the action executed by the current optimization
  60998. * @return description string
  60999. */
  61000. getDescription(): string;
  61001. private _canBeMerged;
  61002. /**
  61003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61004. * @param scene defines the current scene where to apply this optimization
  61005. * @param optimizer defines the current optimizer
  61006. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61007. * @returns true if everything that can be done was applied
  61008. */
  61009. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61010. }
  61011. /**
  61012. * Defines a list of options used by SceneOptimizer
  61013. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61014. */
  61015. export class SceneOptimizerOptions {
  61016. /**
  61017. * Defines the target frame rate to reach (60 by default)
  61018. */
  61019. targetFrameRate: number;
  61020. /**
  61021. * Defines the interval between two checkes (2000ms by default)
  61022. */
  61023. trackerDuration: number;
  61024. /**
  61025. * Gets the list of optimizations to apply
  61026. */
  61027. optimizations: SceneOptimization[];
  61028. /**
  61029. * Creates a new list of options used by SceneOptimizer
  61030. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61031. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61032. */
  61033. constructor(
  61034. /**
  61035. * Defines the target frame rate to reach (60 by default)
  61036. */
  61037. targetFrameRate?: number,
  61038. /**
  61039. * Defines the interval between two checkes (2000ms by default)
  61040. */
  61041. trackerDuration?: number);
  61042. /**
  61043. * Add a new optimization
  61044. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61045. * @returns the current SceneOptimizerOptions
  61046. */
  61047. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61048. /**
  61049. * Add a new custom optimization
  61050. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61051. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61052. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61053. * @returns the current SceneOptimizerOptions
  61054. */
  61055. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61056. /**
  61057. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61058. * @param targetFrameRate defines the target frame rate (60 by default)
  61059. * @returns a SceneOptimizerOptions object
  61060. */
  61061. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61062. /**
  61063. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61064. * @param targetFrameRate defines the target frame rate (60 by default)
  61065. * @returns a SceneOptimizerOptions object
  61066. */
  61067. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61068. /**
  61069. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61070. * @param targetFrameRate defines the target frame rate (60 by default)
  61071. * @returns a SceneOptimizerOptions object
  61072. */
  61073. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61074. }
  61075. /**
  61076. * Class used to run optimizations in order to reach a target frame rate
  61077. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61078. */
  61079. export class SceneOptimizer implements IDisposable {
  61080. private _isRunning;
  61081. private _options;
  61082. private _scene;
  61083. private _currentPriorityLevel;
  61084. private _targetFrameRate;
  61085. private _trackerDuration;
  61086. private _currentFrameRate;
  61087. private _sceneDisposeObserver;
  61088. private _improvementMode;
  61089. /**
  61090. * Defines an observable called when the optimizer reaches the target frame rate
  61091. */
  61092. onSuccessObservable: Observable<SceneOptimizer>;
  61093. /**
  61094. * Defines an observable called when the optimizer enables an optimization
  61095. */
  61096. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61097. /**
  61098. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61099. */
  61100. onFailureObservable: Observable<SceneOptimizer>;
  61101. /**
  61102. * Gets a boolean indicating if the optimizer is in improvement mode
  61103. */
  61104. readonly isInImprovementMode: boolean;
  61105. /**
  61106. * Gets the current priority level (0 at start)
  61107. */
  61108. readonly currentPriorityLevel: number;
  61109. /**
  61110. * Gets the current frame rate checked by the SceneOptimizer
  61111. */
  61112. readonly currentFrameRate: number;
  61113. /**
  61114. * Gets or sets the current target frame rate (60 by default)
  61115. */
  61116. /**
  61117. * Gets or sets the current target frame rate (60 by default)
  61118. */
  61119. targetFrameRate: number;
  61120. /**
  61121. * Gets or sets the current interval between two checks (every 2000ms by default)
  61122. */
  61123. /**
  61124. * Gets or sets the current interval between two checks (every 2000ms by default)
  61125. */
  61126. trackerDuration: number;
  61127. /**
  61128. * Gets the list of active optimizations
  61129. */
  61130. readonly optimizations: SceneOptimization[];
  61131. /**
  61132. * Creates a new SceneOptimizer
  61133. * @param scene defines the scene to work on
  61134. * @param options defines the options to use with the SceneOptimizer
  61135. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61136. * @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)
  61137. */
  61138. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61139. /**
  61140. * Stops the current optimizer
  61141. */
  61142. stop(): void;
  61143. /**
  61144. * Reset the optimizer to initial step (current priority level = 0)
  61145. */
  61146. reset(): void;
  61147. /**
  61148. * Start the optimizer. By default it will try to reach a specific framerate
  61149. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61150. */
  61151. start(): void;
  61152. private _checkCurrentState;
  61153. /**
  61154. * Release all resources
  61155. */
  61156. dispose(): void;
  61157. /**
  61158. * Helper function to create a SceneOptimizer with one single line of code
  61159. * @param scene defines the scene to work on
  61160. * @param options defines the options to use with the SceneOptimizer
  61161. * @param onSuccess defines a callback to call on success
  61162. * @param onFailure defines a callback to call on failure
  61163. * @returns the new SceneOptimizer object
  61164. */
  61165. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61166. }
  61167. }
  61168. declare module BABYLON {
  61169. /**
  61170. * Class used to serialize a scene into a string
  61171. */
  61172. export class SceneSerializer {
  61173. /**
  61174. * Clear cache used by a previous serialization
  61175. */
  61176. static ClearCache(): void;
  61177. /**
  61178. * Serialize a scene into a JSON compatible object
  61179. * @param scene defines the scene to serialize
  61180. * @returns a JSON compatible object
  61181. */
  61182. static Serialize(scene: Scene): any;
  61183. /**
  61184. * Serialize a mesh into a JSON compatible object
  61185. * @param toSerialize defines the mesh to serialize
  61186. * @param withParents defines if parents must be serialized as well
  61187. * @param withChildren defines if children must be serialized as well
  61188. * @returns a JSON compatible object
  61189. */
  61190. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61191. }
  61192. }
  61193. declare module BABYLON {
  61194. /**
  61195. * Class used to host texture specific utilities
  61196. */
  61197. export class TextureTools {
  61198. /**
  61199. * Uses the GPU to create a copy texture rescaled at a given size
  61200. * @param texture Texture to copy from
  61201. * @param width defines the desired width
  61202. * @param height defines the desired height
  61203. * @param useBilinearMode defines if bilinear mode has to be used
  61204. * @return the generated texture
  61205. */
  61206. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61207. }
  61208. }
  61209. declare module BABYLON {
  61210. /**
  61211. * This represents the different options available for the video capture.
  61212. */
  61213. export interface VideoRecorderOptions {
  61214. /** Defines the mime type of the video. */
  61215. mimeType: string;
  61216. /** Defines the FPS the video should be recorded at. */
  61217. fps: number;
  61218. /** Defines the chunk size for the recording data. */
  61219. recordChunckSize: number;
  61220. /** The audio tracks to attach to the recording. */
  61221. audioTracks?: MediaStreamTrack[];
  61222. }
  61223. /**
  61224. * This can help with recording videos from BabylonJS.
  61225. * This is based on the available WebRTC functionalities of the browser.
  61226. *
  61227. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61228. */
  61229. export class VideoRecorder {
  61230. private static readonly _defaultOptions;
  61231. /**
  61232. * Returns whether or not the VideoRecorder is available in your browser.
  61233. * @param engine Defines the Babylon Engine.
  61234. * @returns true if supported otherwise false.
  61235. */
  61236. static IsSupported(engine: Engine): boolean;
  61237. private readonly _options;
  61238. private _canvas;
  61239. private _mediaRecorder;
  61240. private _recordedChunks;
  61241. private _fileName;
  61242. private _resolve;
  61243. private _reject;
  61244. /**
  61245. * True when a recording is already in progress.
  61246. */
  61247. readonly isRecording: boolean;
  61248. /**
  61249. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61250. * @param engine Defines the BabylonJS Engine you wish to record.
  61251. * @param options Defines options that can be used to customize the capture.
  61252. */
  61253. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61254. /**
  61255. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61256. */
  61257. stopRecording(): void;
  61258. /**
  61259. * Starts recording the canvas for a max duration specified in parameters.
  61260. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61261. * If null no automatic download will start and you can rely on the promise to get the data back.
  61262. * @param maxDuration Defines the maximum recording time in seconds.
  61263. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61264. * @return A promise callback at the end of the recording with the video data in Blob.
  61265. */
  61266. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61267. /**
  61268. * Releases internal resources used during the recording.
  61269. */
  61270. dispose(): void;
  61271. private _handleDataAvailable;
  61272. private _handleError;
  61273. private _handleStop;
  61274. }
  61275. }
  61276. declare module BABYLON {
  61277. /**
  61278. * Class containing a set of static utilities functions for screenshots
  61279. */
  61280. export class ScreenshotTools {
  61281. /**
  61282. * Captures a screenshot of the current rendering
  61283. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61284. * @param engine defines the rendering engine
  61285. * @param camera defines the source camera
  61286. * @param size This parameter can be set to a single number or to an object with the
  61287. * following (optional) properties: precision, width, height. If a single number is passed,
  61288. * it will be used for both width and height. If an object is passed, the screenshot size
  61289. * will be derived from the parameters. The precision property is a multiplier allowing
  61290. * rendering at a higher or lower resolution
  61291. * @param successCallback defines the callback receives a single parameter which contains the
  61292. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61293. * src parameter of an <img> to display it
  61294. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61295. * Check your browser for supported MIME types
  61296. */
  61297. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61298. /**
  61299. * Captures a screenshot of the current rendering
  61300. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61301. * @param engine defines the rendering engine
  61302. * @param camera defines the source camera
  61303. * @param size This parameter can be set to a single number or to an object with the
  61304. * following (optional) properties: precision, width, height. If a single number is passed,
  61305. * it will be used for both width and height. If an object is passed, the screenshot size
  61306. * will be derived from the parameters. The precision property is a multiplier allowing
  61307. * rendering at a higher or lower resolution
  61308. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61309. * Check your browser for supported MIME types
  61310. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61311. * to the src parameter of an <img> to display it
  61312. */
  61313. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61314. /**
  61315. * Generates an image screenshot from the specified camera.
  61316. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61317. * @param engine The engine to use for rendering
  61318. * @param camera The camera to use for rendering
  61319. * @param size This parameter can be set to a single number or to an object with the
  61320. * following (optional) properties: precision, width, height. If a single number is passed,
  61321. * it will be used for both width and height. If an object is passed, the screenshot size
  61322. * will be derived from the parameters. The precision property is a multiplier allowing
  61323. * rendering at a higher or lower resolution
  61324. * @param successCallback The callback receives a single parameter which contains the
  61325. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61326. * src parameter of an <img> to display it
  61327. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61328. * Check your browser for supported MIME types
  61329. * @param samples Texture samples (default: 1)
  61330. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61331. * @param fileName A name for for the downloaded file.
  61332. */
  61333. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61334. /**
  61335. * Generates an image screenshot from the specified camera.
  61336. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61337. * @param engine The engine to use for rendering
  61338. * @param camera The camera to use for rendering
  61339. * @param size This parameter can be set to a single number or to an object with the
  61340. * following (optional) properties: precision, width, height. If a single number is passed,
  61341. * it will be used for both width and height. If an object is passed, the screenshot size
  61342. * will be derived from the parameters. The precision property is a multiplier allowing
  61343. * rendering at a higher or lower resolution
  61344. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61345. * Check your browser for supported MIME types
  61346. * @param samples Texture samples (default: 1)
  61347. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61348. * @param fileName A name for for the downloaded file.
  61349. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61350. * to the src parameter of an <img> to display it
  61351. */
  61352. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61353. /**
  61354. * Gets height and width for screenshot size
  61355. * @private
  61356. */
  61357. private static _getScreenshotSize;
  61358. }
  61359. }
  61360. declare module BABYLON {
  61361. /**
  61362. * A cursor which tracks a point on a path
  61363. */
  61364. export class PathCursor {
  61365. private path;
  61366. /**
  61367. * Stores path cursor callbacks for when an onchange event is triggered
  61368. */
  61369. private _onchange;
  61370. /**
  61371. * The value of the path cursor
  61372. */
  61373. value: number;
  61374. /**
  61375. * The animation array of the path cursor
  61376. */
  61377. animations: Animation[];
  61378. /**
  61379. * Initializes the path cursor
  61380. * @param path The path to track
  61381. */
  61382. constructor(path: Path2);
  61383. /**
  61384. * Gets the cursor point on the path
  61385. * @returns A point on the path cursor at the cursor location
  61386. */
  61387. getPoint(): Vector3;
  61388. /**
  61389. * Moves the cursor ahead by the step amount
  61390. * @param step The amount to move the cursor forward
  61391. * @returns This path cursor
  61392. */
  61393. moveAhead(step?: number): PathCursor;
  61394. /**
  61395. * Moves the cursor behind by the step amount
  61396. * @param step The amount to move the cursor back
  61397. * @returns This path cursor
  61398. */
  61399. moveBack(step?: number): PathCursor;
  61400. /**
  61401. * Moves the cursor by the step amount
  61402. * If the step amount is greater than one, an exception is thrown
  61403. * @param step The amount to move the cursor
  61404. * @returns This path cursor
  61405. */
  61406. move(step: number): PathCursor;
  61407. /**
  61408. * Ensures that the value is limited between zero and one
  61409. * @returns This path cursor
  61410. */
  61411. private ensureLimits;
  61412. /**
  61413. * Runs onchange callbacks on change (used by the animation engine)
  61414. * @returns This path cursor
  61415. */
  61416. private raiseOnChange;
  61417. /**
  61418. * Executes a function on change
  61419. * @param f A path cursor onchange callback
  61420. * @returns This path cursor
  61421. */
  61422. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61423. }
  61424. }
  61425. declare module BABYLON {
  61426. /** @hidden */
  61427. export var blurPixelShader: {
  61428. name: string;
  61429. shader: string;
  61430. };
  61431. }
  61432. declare module BABYLON {
  61433. /** @hidden */
  61434. export var pointCloudVertexDeclaration: {
  61435. name: string;
  61436. shader: string;
  61437. };
  61438. }
  61439. // Mixins
  61440. interface Window {
  61441. mozIndexedDB: IDBFactory;
  61442. webkitIndexedDB: IDBFactory;
  61443. msIndexedDB: IDBFactory;
  61444. webkitURL: typeof URL;
  61445. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61446. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61447. WebGLRenderingContext: WebGLRenderingContext;
  61448. MSGesture: MSGesture;
  61449. CANNON: any;
  61450. AudioContext: AudioContext;
  61451. webkitAudioContext: AudioContext;
  61452. PointerEvent: any;
  61453. Math: Math;
  61454. Uint8Array: Uint8ArrayConstructor;
  61455. Float32Array: Float32ArrayConstructor;
  61456. mozURL: typeof URL;
  61457. msURL: typeof URL;
  61458. VRFrameData: any; // WebVR, from specs 1.1
  61459. DracoDecoderModule: any;
  61460. setImmediate(handler: (...args: any[]) => void): number;
  61461. }
  61462. interface HTMLCanvasElement {
  61463. requestPointerLock(): void;
  61464. msRequestPointerLock?(): void;
  61465. mozRequestPointerLock?(): void;
  61466. webkitRequestPointerLock?(): void;
  61467. /** Track wether a record is in progress */
  61468. isRecording: boolean;
  61469. /** Capture Stream method defined by some browsers */
  61470. captureStream(fps?: number): MediaStream;
  61471. }
  61472. interface CanvasRenderingContext2D {
  61473. msImageSmoothingEnabled: boolean;
  61474. }
  61475. interface MouseEvent {
  61476. mozMovementX: number;
  61477. mozMovementY: number;
  61478. webkitMovementX: number;
  61479. webkitMovementY: number;
  61480. msMovementX: number;
  61481. msMovementY: number;
  61482. }
  61483. interface Navigator {
  61484. mozGetVRDevices: (any: any) => any;
  61485. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61486. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61487. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61488. webkitGetGamepads(): Gamepad[];
  61489. msGetGamepads(): Gamepad[];
  61490. webkitGamepads(): Gamepad[];
  61491. }
  61492. interface HTMLVideoElement {
  61493. mozSrcObject: any;
  61494. }
  61495. interface Math {
  61496. fround(x: number): number;
  61497. imul(a: number, b: number): number;
  61498. }
  61499. interface WebGLRenderingContext {
  61500. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61501. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61502. vertexAttribDivisor(index: number, divisor: number): void;
  61503. createVertexArray(): any;
  61504. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61505. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61506. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61507. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61508. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61509. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61510. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61511. // Queries
  61512. createQuery(): WebGLQuery;
  61513. deleteQuery(query: WebGLQuery): void;
  61514. beginQuery(target: number, query: WebGLQuery): void;
  61515. endQuery(target: number): void;
  61516. getQueryParameter(query: WebGLQuery, pname: number): any;
  61517. getQuery(target: number, pname: number): any;
  61518. MAX_SAMPLES: number;
  61519. RGBA8: number;
  61520. READ_FRAMEBUFFER: number;
  61521. DRAW_FRAMEBUFFER: number;
  61522. UNIFORM_BUFFER: number;
  61523. HALF_FLOAT_OES: number;
  61524. RGBA16F: number;
  61525. RGBA32F: number;
  61526. R32F: number;
  61527. RG32F: number;
  61528. RGB32F: number;
  61529. R16F: number;
  61530. RG16F: number;
  61531. RGB16F: number;
  61532. RED: number;
  61533. RG: number;
  61534. R8: number;
  61535. RG8: number;
  61536. UNSIGNED_INT_24_8: number;
  61537. DEPTH24_STENCIL8: number;
  61538. /* Multiple Render Targets */
  61539. drawBuffers(buffers: number[]): void;
  61540. readBuffer(src: number): void;
  61541. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61542. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61543. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61544. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61545. // Occlusion Query
  61546. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61547. ANY_SAMPLES_PASSED: number;
  61548. QUERY_RESULT_AVAILABLE: number;
  61549. QUERY_RESULT: number;
  61550. }
  61551. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61552. }
  61553. interface EXT_disjoint_timer_query {
  61554. QUERY_COUNTER_BITS_EXT: number;
  61555. TIME_ELAPSED_EXT: number;
  61556. TIMESTAMP_EXT: number;
  61557. GPU_DISJOINT_EXT: number;
  61558. QUERY_RESULT_EXT: number;
  61559. QUERY_RESULT_AVAILABLE_EXT: number;
  61560. queryCounterEXT(query: WebGLQuery, target: number): void;
  61561. createQueryEXT(): WebGLQuery;
  61562. beginQueryEXT(target: number, query: WebGLQuery): void;
  61563. endQueryEXT(target: number): void;
  61564. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61565. deleteQueryEXT(query: WebGLQuery): void;
  61566. }
  61567. interface WebGLUniformLocation { private _currentState: any;
  61568. }
  61569. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61570. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61571. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61572. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61573. interface WebGLRenderingContext {
  61574. readonly RASTERIZER_DISCARD: number;
  61575. readonly DEPTH_COMPONENT24: number;
  61576. readonly TEXTURE_3D: number;
  61577. readonly TEXTURE_2D_ARRAY: number;
  61578. readonly TEXTURE_COMPARE_FUNC: number;
  61579. readonly TEXTURE_COMPARE_MODE: number;
  61580. readonly COMPARE_REF_TO_TEXTURE: number;
  61581. readonly TEXTURE_WRAP_R: number;
  61582. readonly HALF_FLOAT: number;
  61583. readonly RGB8: number;
  61584. readonly RED_INTEGER: number;
  61585. readonly RG_INTEGER: number;
  61586. readonly RGB_INTEGER: number;
  61587. readonly RGBA_INTEGER: number;
  61588. readonly R8_SNORM: number;
  61589. readonly RG8_SNORM: number;
  61590. readonly RGB8_SNORM: number;
  61591. readonly RGBA8_SNORM: number;
  61592. readonly R8I: number;
  61593. readonly RG8I: number;
  61594. readonly RGB8I: number;
  61595. readonly RGBA8I: number;
  61596. readonly R8UI: number;
  61597. readonly RG8UI: number;
  61598. readonly RGB8UI: number;
  61599. readonly RGBA8UI: number;
  61600. readonly R16I: number;
  61601. readonly RG16I: number;
  61602. readonly RGB16I: number;
  61603. readonly RGBA16I: number;
  61604. readonly R16UI: number;
  61605. readonly RG16UI: number;
  61606. readonly RGB16UI: number;
  61607. readonly RGBA16UI: number;
  61608. readonly R32I: number;
  61609. readonly RG32I: number;
  61610. readonly RGB32I: number;
  61611. readonly RGBA32I: number;
  61612. readonly R32UI: number;
  61613. readonly RG32UI: number;
  61614. readonly RGB32UI: number;
  61615. readonly RGBA32UI: number;
  61616. readonly RGB10_A2UI: number;
  61617. readonly R11F_G11F_B10F: number;
  61618. readonly RGB9_E5: number;
  61619. readonly RGB10_A2: number;
  61620. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61621. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61622. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61623. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61624. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61625. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61626. 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;
  61627. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61628. readonly TRANSFORM_FEEDBACK: number;
  61629. readonly INTERLEAVED_ATTRIBS: number;
  61630. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61631. createTransformFeedback(): WebGLTransformFeedback;
  61632. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61633. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61634. beginTransformFeedback(primitiveMode: number): void;
  61635. endTransformFeedback(): void;
  61636. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61637. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61638. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61639. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61640. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61641. }
  61642. interface ImageBitmap {
  61643. readonly width: number;
  61644. readonly height: number;
  61645. close(): void;
  61646. }
  61647. interface WebGLQuery extends WebGLObject {
  61648. }
  61649. declare var WebGLQuery: {
  61650. prototype: WebGLQuery;
  61651. new(): WebGLQuery;
  61652. };
  61653. interface WebGLSampler extends WebGLObject {
  61654. }
  61655. declare var WebGLSampler: {
  61656. prototype: WebGLSampler;
  61657. new(): WebGLSampler;
  61658. };
  61659. interface WebGLSync extends WebGLObject {
  61660. }
  61661. declare var WebGLSync: {
  61662. prototype: WebGLSync;
  61663. new(): WebGLSync;
  61664. };
  61665. interface WebGLTransformFeedback extends WebGLObject {
  61666. }
  61667. declare var WebGLTransformFeedback: {
  61668. prototype: WebGLTransformFeedback;
  61669. new(): WebGLTransformFeedback;
  61670. };
  61671. interface WebGLVertexArrayObject extends WebGLObject {
  61672. }
  61673. declare var WebGLVertexArrayObject: {
  61674. prototype: WebGLVertexArrayObject;
  61675. new(): WebGLVertexArrayObject;
  61676. };
  61677. // Type definitions for WebVR API
  61678. // Project: https://w3c.github.io/webvr/
  61679. // Definitions by: six a <https://github.com/lostfictions>
  61680. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61681. interface VRDisplay extends EventTarget {
  61682. /**
  61683. * Dictionary of capabilities describing the VRDisplay.
  61684. */
  61685. readonly capabilities: VRDisplayCapabilities;
  61686. /**
  61687. * z-depth defining the far plane of the eye view frustum
  61688. * enables mapping of values in the render target depth
  61689. * attachment to scene coordinates. Initially set to 10000.0.
  61690. */
  61691. depthFar: number;
  61692. /**
  61693. * z-depth defining the near plane of the eye view frustum
  61694. * enables mapping of values in the render target depth
  61695. * attachment to scene coordinates. Initially set to 0.01.
  61696. */
  61697. depthNear: number;
  61698. /**
  61699. * An identifier for this distinct VRDisplay. Used as an
  61700. * association point in the Gamepad API.
  61701. */
  61702. readonly displayId: number;
  61703. /**
  61704. * A display name, a user-readable name identifying it.
  61705. */
  61706. readonly displayName: string;
  61707. readonly isConnected: boolean;
  61708. readonly isPresenting: boolean;
  61709. /**
  61710. * If this VRDisplay supports room-scale experiences, the optional
  61711. * stage attribute contains details on the room-scale parameters.
  61712. */
  61713. readonly stageParameters: VRStageParameters | null;
  61714. /**
  61715. * Passing the value returned by `requestAnimationFrame` to
  61716. * `cancelAnimationFrame` will unregister the callback.
  61717. * @param handle Define the hanle of the request to cancel
  61718. */
  61719. cancelAnimationFrame(handle: number): void;
  61720. /**
  61721. * Stops presenting to the VRDisplay.
  61722. * @returns a promise to know when it stopped
  61723. */
  61724. exitPresent(): Promise<void>;
  61725. /**
  61726. * Return the current VREyeParameters for the given eye.
  61727. * @param whichEye Define the eye we want the parameter for
  61728. * @returns the eye parameters
  61729. */
  61730. getEyeParameters(whichEye: string): VREyeParameters;
  61731. /**
  61732. * Populates the passed VRFrameData with the information required to render
  61733. * the current frame.
  61734. * @param frameData Define the data structure to populate
  61735. * @returns true if ok otherwise false
  61736. */
  61737. getFrameData(frameData: VRFrameData): boolean;
  61738. /**
  61739. * Get the layers currently being presented.
  61740. * @returns the list of VR layers
  61741. */
  61742. getLayers(): VRLayer[];
  61743. /**
  61744. * Return a VRPose containing the future predicted pose of the VRDisplay
  61745. * when the current frame will be presented. The value returned will not
  61746. * change until JavaScript has returned control to the browser.
  61747. *
  61748. * The VRPose will contain the position, orientation, velocity,
  61749. * and acceleration of each of these properties.
  61750. * @returns the pose object
  61751. */
  61752. getPose(): VRPose;
  61753. /**
  61754. * Return the current instantaneous pose of the VRDisplay, with no
  61755. * prediction applied.
  61756. * @returns the current instantaneous pose
  61757. */
  61758. getImmediatePose(): VRPose;
  61759. /**
  61760. * The callback passed to `requestAnimationFrame` will be called
  61761. * any time a new frame should be rendered. When the VRDisplay is
  61762. * presenting the callback will be called at the native refresh
  61763. * rate of the HMD. When not presenting this function acts
  61764. * identically to how window.requestAnimationFrame acts. Content should
  61765. * make no assumptions of frame rate or vsync behavior as the HMD runs
  61766. * asynchronously from other displays and at differing refresh rates.
  61767. * @param callback Define the eaction to run next frame
  61768. * @returns the request handle it
  61769. */
  61770. requestAnimationFrame(callback: FrameRequestCallback): number;
  61771. /**
  61772. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  61773. * Repeat calls while already presenting will update the VRLayers being displayed.
  61774. * @param layers Define the list of layer to present
  61775. * @returns a promise to know when the request has been fulfilled
  61776. */
  61777. requestPresent(layers: VRLayer[]): Promise<void>;
  61778. /**
  61779. * Reset the pose for this display, treating its current position and
  61780. * orientation as the "origin/zero" values. VRPose.position,
  61781. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  61782. * updated when calling resetPose(). This should be called in only
  61783. * sitting-space experiences.
  61784. */
  61785. resetPose(): void;
  61786. /**
  61787. * The VRLayer provided to the VRDisplay will be captured and presented
  61788. * in the HMD. Calling this function has the same effect on the source
  61789. * canvas as any other operation that uses its source image, and canvases
  61790. * created without preserveDrawingBuffer set to true will be cleared.
  61791. * @param pose Define the pose to submit
  61792. */
  61793. submitFrame(pose?: VRPose): void;
  61794. }
  61795. declare var VRDisplay: {
  61796. prototype: VRDisplay;
  61797. new(): VRDisplay;
  61798. };
  61799. interface VRLayer {
  61800. leftBounds?: number[] | Float32Array | null;
  61801. rightBounds?: number[] | Float32Array | null;
  61802. source?: HTMLCanvasElement | null;
  61803. }
  61804. interface VRDisplayCapabilities {
  61805. readonly canPresent: boolean;
  61806. readonly hasExternalDisplay: boolean;
  61807. readonly hasOrientation: boolean;
  61808. readonly hasPosition: boolean;
  61809. readonly maxLayers: number;
  61810. }
  61811. interface VREyeParameters {
  61812. /** @deprecated */
  61813. readonly fieldOfView: VRFieldOfView;
  61814. readonly offset: Float32Array;
  61815. readonly renderHeight: number;
  61816. readonly renderWidth: number;
  61817. }
  61818. interface VRFieldOfView {
  61819. readonly downDegrees: number;
  61820. readonly leftDegrees: number;
  61821. readonly rightDegrees: number;
  61822. readonly upDegrees: number;
  61823. }
  61824. interface VRFrameData {
  61825. readonly leftProjectionMatrix: Float32Array;
  61826. readonly leftViewMatrix: Float32Array;
  61827. readonly pose: VRPose;
  61828. readonly rightProjectionMatrix: Float32Array;
  61829. readonly rightViewMatrix: Float32Array;
  61830. readonly timestamp: number;
  61831. }
  61832. interface VRPose {
  61833. readonly angularAcceleration: Float32Array | null;
  61834. readonly angularVelocity: Float32Array | null;
  61835. readonly linearAcceleration: Float32Array | null;
  61836. readonly linearVelocity: Float32Array | null;
  61837. readonly orientation: Float32Array | null;
  61838. readonly position: Float32Array | null;
  61839. readonly timestamp: number;
  61840. }
  61841. interface VRStageParameters {
  61842. sittingToStandingTransform?: Float32Array;
  61843. sizeX?: number;
  61844. sizeY?: number;
  61845. }
  61846. interface Navigator {
  61847. getVRDisplays(): Promise<VRDisplay[]>;
  61848. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  61849. }
  61850. interface Window {
  61851. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  61852. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  61853. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  61854. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61855. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61856. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  61857. }
  61858. interface Gamepad {
  61859. readonly displayId: number;
  61860. }
  61861. type XRSessionMode =
  61862. | "inline"
  61863. | "immersive-vr"
  61864. | "immersive-ar";
  61865. type XRReferenceSpaceType =
  61866. | "viewer"
  61867. | "local"
  61868. | "local-floor"
  61869. | "bounded-floor"
  61870. | "unbounded";
  61871. type XREnvironmentBlendMode =
  61872. | "opaque"
  61873. | "additive"
  61874. | "alpha-blend";
  61875. type XRVisibilityState =
  61876. | "visible"
  61877. | "visible-blurred"
  61878. | "hidden";
  61879. type XRHandedness =
  61880. | "none"
  61881. | "left"
  61882. | "right";
  61883. type XRTargetRayMode =
  61884. | "gaze"
  61885. | "tracked-pointer"
  61886. | "screen";
  61887. type XREye =
  61888. | "none"
  61889. | "left"
  61890. | "right";
  61891. interface XRSpace extends EventTarget {
  61892. }
  61893. interface XRRenderState {
  61894. depthNear?: number;
  61895. depthFar?: number;
  61896. inlineVerticalFieldOfView?: number;
  61897. baseLayer?: XRWebGLLayer;
  61898. }
  61899. interface XRInputSource {
  61900. handedness: XRHandedness;
  61901. targetRayMode: XRTargetRayMode;
  61902. targetRaySpace: XRSpace;
  61903. gripSpace: XRSpace | undefined;
  61904. gamepad: Gamepad | undefined;
  61905. profiles: Array<string>;
  61906. }
  61907. interface XRSession {
  61908. addEventListener: Function;
  61909. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  61910. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  61911. requestAnimationFrame: Function;
  61912. end(): Promise<void>;
  61913. renderState: XRRenderState;
  61914. inputSources: Array<XRInputSource>;
  61915. }
  61916. interface XRReferenceSpace extends XRSpace {
  61917. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  61918. onreset: any;
  61919. }
  61920. interface XRFrame {
  61921. session: XRSession;
  61922. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  61923. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  61924. }
  61925. interface XRViewerPose extends XRPose {
  61926. views: Array<XRView>;
  61927. }
  61928. interface XRPose {
  61929. transform: XRRigidTransform;
  61930. emulatedPosition: boolean;
  61931. }
  61932. declare var XRWebGLLayer: {
  61933. prototype: XRWebGLLayer;
  61934. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  61935. };
  61936. interface XRWebGLLayer {
  61937. framebuffer: WebGLFramebuffer;
  61938. framebufferWidth: number;
  61939. framebufferHeight: number;
  61940. getViewport: Function;
  61941. }
  61942. interface XRRigidTransform {
  61943. position: DOMPointReadOnly;
  61944. orientation: DOMPointReadOnly;
  61945. matrix: Float32Array;
  61946. inverse: XRRigidTransform;
  61947. }
  61948. interface XRView {
  61949. eye: XREye;
  61950. projectionMatrix: Float32Array;
  61951. transform: XRRigidTransform;
  61952. }
  61953. interface XRInputSourceChangeEvent {
  61954. session: XRSession;
  61955. removed: Array<XRInputSource>;
  61956. added: Array<XRInputSource>;
  61957. }
  61958. /**
  61959. * @ignore
  61960. */
  61961. declare module BABYLON.GLTF2.Exporter {
  61962. }
  61963. /**
  61964. * @ignore
  61965. */
  61966. declare module BABYLON.GLTF1 {
  61967. }
  61968. declare module BABYLON.GUI {
  61969. /**
  61970. * Class used to specific a value and its associated unit
  61971. */
  61972. export class ValueAndUnit {
  61973. /** defines the unit to store */
  61974. unit: number;
  61975. /** defines a boolean indicating if the value can be negative */
  61976. negativeValueAllowed: boolean;
  61977. private _value;
  61978. private _originalUnit;
  61979. /**
  61980. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  61981. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61982. */
  61983. ignoreAdaptiveScaling: boolean;
  61984. /**
  61985. * Creates a new ValueAndUnit
  61986. * @param value defines the value to store
  61987. * @param unit defines the unit to store
  61988. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  61989. */
  61990. constructor(value: number,
  61991. /** defines the unit to store */
  61992. unit?: number,
  61993. /** defines a boolean indicating if the value can be negative */
  61994. negativeValueAllowed?: boolean);
  61995. /** Gets a boolean indicating if the value is a percentage */
  61996. readonly isPercentage: boolean;
  61997. /** Gets a boolean indicating if the value is store as pixel */
  61998. readonly isPixel: boolean;
  61999. /** Gets direct internal value */
  62000. readonly internalValue: number;
  62001. /**
  62002. * Gets value as pixel
  62003. * @param host defines the root host
  62004. * @param refValue defines the reference value for percentages
  62005. * @returns the value as pixel
  62006. */
  62007. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62008. /**
  62009. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62010. * @param value defines the value to store
  62011. * @param unit defines the unit to store
  62012. * @returns the current ValueAndUnit
  62013. */
  62014. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62015. /**
  62016. * Gets the value accordingly to its unit
  62017. * @param host defines the root host
  62018. * @returns the value
  62019. */
  62020. getValue(host: AdvancedDynamicTexture): number;
  62021. /**
  62022. * Gets a string representation of the value
  62023. * @param host defines the root host
  62024. * @param decimals defines an optional number of decimals to display
  62025. * @returns a string
  62026. */
  62027. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62028. /**
  62029. * Store a value parsed from a string
  62030. * @param source defines the source string
  62031. * @returns true if the value was successfully parsed
  62032. */
  62033. fromString(source: string | number): boolean;
  62034. private static _Regex;
  62035. private static _UNITMODE_PERCENTAGE;
  62036. private static _UNITMODE_PIXEL;
  62037. /** UNITMODE_PERCENTAGE */
  62038. static readonly UNITMODE_PERCENTAGE: number;
  62039. /** UNITMODE_PIXEL */
  62040. static readonly UNITMODE_PIXEL: number;
  62041. }
  62042. }
  62043. declare module BABYLON.GUI {
  62044. /**
  62045. * Define a style used by control to automatically setup properties based on a template.
  62046. * Only support font related properties so far
  62047. */
  62048. export class Style implements BABYLON.IDisposable {
  62049. private _fontFamily;
  62050. private _fontStyle;
  62051. private _fontWeight;
  62052. /** @hidden */ private _host: AdvancedDynamicTexture;
  62053. /** @hidden */ private _fontSize: ValueAndUnit;
  62054. /**
  62055. * BABYLON.Observable raised when the style values are changed
  62056. */
  62057. onChangedObservable: BABYLON.Observable<Style>;
  62058. /**
  62059. * Creates a new style object
  62060. * @param host defines the AdvancedDynamicTexture which hosts this style
  62061. */
  62062. constructor(host: AdvancedDynamicTexture);
  62063. /**
  62064. * Gets or sets the font size
  62065. */
  62066. fontSize: string | number;
  62067. /**
  62068. * Gets or sets the font family
  62069. */
  62070. fontFamily: string;
  62071. /**
  62072. * Gets or sets the font style
  62073. */
  62074. fontStyle: string;
  62075. /** Gets or sets font weight */
  62076. fontWeight: string;
  62077. /** Dispose all associated resources */
  62078. dispose(): void;
  62079. }
  62080. }
  62081. declare module BABYLON.GUI {
  62082. /**
  62083. * Class used to transport BABYLON.Vector2 information for pointer events
  62084. */
  62085. export class Vector2WithInfo extends BABYLON.Vector2 {
  62086. /** defines the current mouse button index */
  62087. buttonIndex: number;
  62088. /**
  62089. * Creates a new Vector2WithInfo
  62090. * @param source defines the vector2 data to transport
  62091. * @param buttonIndex defines the current mouse button index
  62092. */
  62093. constructor(source: BABYLON.Vector2,
  62094. /** defines the current mouse button index */
  62095. buttonIndex?: number);
  62096. }
  62097. /** Class used to provide 2D matrix features */
  62098. export class Matrix2D {
  62099. /** Gets the internal array of 6 floats used to store matrix data */
  62100. m: Float32Array;
  62101. /**
  62102. * Creates a new matrix
  62103. * @param m00 defines value for (0, 0)
  62104. * @param m01 defines value for (0, 1)
  62105. * @param m10 defines value for (1, 0)
  62106. * @param m11 defines value for (1, 1)
  62107. * @param m20 defines value for (2, 0)
  62108. * @param m21 defines value for (2, 1)
  62109. */
  62110. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62111. /**
  62112. * Fills the matrix from direct values
  62113. * @param m00 defines value for (0, 0)
  62114. * @param m01 defines value for (0, 1)
  62115. * @param m10 defines value for (1, 0)
  62116. * @param m11 defines value for (1, 1)
  62117. * @param m20 defines value for (2, 0)
  62118. * @param m21 defines value for (2, 1)
  62119. * @returns the current modified matrix
  62120. */
  62121. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62122. /**
  62123. * Gets matrix determinant
  62124. * @returns the determinant
  62125. */
  62126. determinant(): number;
  62127. /**
  62128. * Inverses the matrix and stores it in a target matrix
  62129. * @param result defines the target matrix
  62130. * @returns the current matrix
  62131. */
  62132. invertToRef(result: Matrix2D): Matrix2D;
  62133. /**
  62134. * Multiplies the current matrix with another one
  62135. * @param other defines the second operand
  62136. * @param result defines the target matrix
  62137. * @returns the current matrix
  62138. */
  62139. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62140. /**
  62141. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62142. * @param x defines the x coordinate to transform
  62143. * @param y defines the x coordinate to transform
  62144. * @param result defines the target vector2
  62145. * @returns the current matrix
  62146. */
  62147. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62148. /**
  62149. * Creates an identity matrix
  62150. * @returns a new matrix
  62151. */
  62152. static Identity(): Matrix2D;
  62153. /**
  62154. * Creates a translation matrix and stores it in a target matrix
  62155. * @param x defines the x coordinate of the translation
  62156. * @param y defines the y coordinate of the translation
  62157. * @param result defines the target matrix
  62158. */
  62159. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62160. /**
  62161. * Creates a scaling matrix and stores it in a target matrix
  62162. * @param x defines the x coordinate of the scaling
  62163. * @param y defines the y coordinate of the scaling
  62164. * @param result defines the target matrix
  62165. */
  62166. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62167. /**
  62168. * Creates a rotation matrix and stores it in a target matrix
  62169. * @param angle defines the rotation angle
  62170. * @param result defines the target matrix
  62171. */
  62172. static RotationToRef(angle: number, result: Matrix2D): void;
  62173. private static _TempPreTranslationMatrix;
  62174. private static _TempPostTranslationMatrix;
  62175. private static _TempRotationMatrix;
  62176. private static _TempScalingMatrix;
  62177. private static _TempCompose0;
  62178. private static _TempCompose1;
  62179. private static _TempCompose2;
  62180. /**
  62181. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62182. * @param tx defines the x coordinate of the translation
  62183. * @param ty defines the y coordinate of the translation
  62184. * @param angle defines the rotation angle
  62185. * @param scaleX defines the x coordinate of the scaling
  62186. * @param scaleY defines the y coordinate of the scaling
  62187. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  62188. * @param result defines the target matrix
  62189. */
  62190. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  62191. }
  62192. }
  62193. declare module BABYLON.GUI {
  62194. /**
  62195. * Class used to store 2D control sizes
  62196. */
  62197. export class Measure {
  62198. /** defines left coordinate */
  62199. left: number;
  62200. /** defines top coordinate */
  62201. top: number;
  62202. /** defines width dimension */
  62203. width: number;
  62204. /** defines height dimension */
  62205. height: number;
  62206. /**
  62207. * Creates a new measure
  62208. * @param left defines left coordinate
  62209. * @param top defines top coordinate
  62210. * @param width defines width dimension
  62211. * @param height defines height dimension
  62212. */
  62213. constructor(
  62214. /** defines left coordinate */
  62215. left: number,
  62216. /** defines top coordinate */
  62217. top: number,
  62218. /** defines width dimension */
  62219. width: number,
  62220. /** defines height dimension */
  62221. height: number);
  62222. /**
  62223. * Copy from another measure
  62224. * @param other defines the other measure to copy from
  62225. */
  62226. copyFrom(other: Measure): void;
  62227. /**
  62228. * Copy from a group of 4 floats
  62229. * @param left defines left coordinate
  62230. * @param top defines top coordinate
  62231. * @param width defines width dimension
  62232. * @param height defines height dimension
  62233. */
  62234. copyFromFloats(left: number, top: number, width: number, height: number): void;
  62235. /**
  62236. * Computes the axis aligned bounding box measure for two given measures
  62237. * @param a Input measure
  62238. * @param b Input measure
  62239. * @param result the resulting bounding measure
  62240. */
  62241. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  62242. /**
  62243. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  62244. * @param transform the matrix to transform the measure before computing the AABB
  62245. * @param result the resulting AABB
  62246. */
  62247. transformToRef(transform: Matrix2D, result: Measure): void;
  62248. /**
  62249. * Check equality between this measure and another one
  62250. * @param other defines the other measures
  62251. * @returns true if both measures are equals
  62252. */
  62253. isEqualsTo(other: Measure): boolean;
  62254. /**
  62255. * Creates an empty measure
  62256. * @returns a new measure
  62257. */
  62258. static Empty(): Measure;
  62259. }
  62260. }
  62261. declare module BABYLON.GUI {
  62262. /**
  62263. * Interface used to define a control that can receive focus
  62264. */
  62265. export interface IFocusableControl {
  62266. /**
  62267. * Function called when the control receives the focus
  62268. */
  62269. onFocus(): void;
  62270. /**
  62271. * Function called when the control loses the focus
  62272. */
  62273. onBlur(): void;
  62274. /**
  62275. * Function called to let the control handle keyboard events
  62276. * @param evt defines the current keyboard event
  62277. */
  62278. processKeyboard(evt: KeyboardEvent): void;
  62279. /**
  62280. * Function called to get the list of controls that should not steal the focus from this control
  62281. * @returns an array of controls
  62282. */
  62283. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62284. }
  62285. /**
  62286. * Class used to create texture to support 2D GUI elements
  62287. * @see http://doc.babylonjs.com/how_to/gui
  62288. */
  62289. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62290. private _isDirty;
  62291. private _renderObserver;
  62292. private _resizeObserver;
  62293. private _preKeyboardObserver;
  62294. private _pointerMoveObserver;
  62295. private _pointerObserver;
  62296. private _canvasPointerOutObserver;
  62297. private _background;
  62298. /** @hidden */ private _rootContainer: Container;
  62299. /** @hidden */ private _lastPickedControl: Control;
  62300. /** @hidden */ private _lastControlOver: {
  62301. [pointerId: number]: Control;
  62302. };
  62303. /** @hidden */ private _lastControlDown: {
  62304. [pointerId: number]: Control;
  62305. };
  62306. /** @hidden */ private _capturingControl: {
  62307. [pointerId: number]: Control;
  62308. };
  62309. /** @hidden */ private _shouldBlockPointer: boolean;
  62310. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62311. /** @hidden */ private _linkedControls: Control[];
  62312. private _isFullscreen;
  62313. private _fullscreenViewport;
  62314. private _idealWidth;
  62315. private _idealHeight;
  62316. private _useSmallestIdeal;
  62317. private _renderAtIdealSize;
  62318. private _focusedControl;
  62319. private _blockNextFocusCheck;
  62320. private _renderScale;
  62321. private _rootCanvas;
  62322. private _cursorChanged;
  62323. /**
  62324. * Define type to string to ensure compatibility across browsers
  62325. * Safari doesn't support DataTransfer constructor
  62326. */
  62327. private _clipboardData;
  62328. /**
  62329. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62330. */
  62331. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62332. /**
  62333. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62334. */
  62335. onControlPickedObservable: BABYLON.Observable<Control>;
  62336. /**
  62337. * BABYLON.Observable event triggered before layout is evaluated
  62338. */
  62339. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62340. /**
  62341. * BABYLON.Observable event triggered after the layout was evaluated
  62342. */
  62343. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62344. /**
  62345. * BABYLON.Observable event triggered before the texture is rendered
  62346. */
  62347. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62348. /**
  62349. * BABYLON.Observable event triggered after the texture was rendered
  62350. */
  62351. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62352. /**
  62353. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62354. */
  62355. premulAlpha: boolean;
  62356. /**
  62357. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62358. * Useful when you want more antialiasing
  62359. */
  62360. renderScale: number;
  62361. /** Gets or sets the background color */
  62362. background: string;
  62363. /**
  62364. * Gets or sets the ideal width used to design controls.
  62365. * The GUI will then rescale everything accordingly
  62366. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62367. */
  62368. idealWidth: number;
  62369. /**
  62370. * Gets or sets the ideal height used to design controls.
  62371. * The GUI will then rescale everything accordingly
  62372. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62373. */
  62374. idealHeight: number;
  62375. /**
  62376. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  62377. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62378. */
  62379. useSmallestIdeal: boolean;
  62380. /**
  62381. * Gets or sets a boolean indicating if adaptive scaling must be used
  62382. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62383. */
  62384. renderAtIdealSize: boolean;
  62385. /**
  62386. * Gets the underlying layer used to render the texture when in fullscreen mode
  62387. */
  62388. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  62389. /**
  62390. * Gets the root container control
  62391. */
  62392. readonly rootContainer: Container;
  62393. /**
  62394. * Returns an array containing the root container.
  62395. * This is mostly used to let the Inspector introspects the ADT
  62396. * @returns an array containing the rootContainer
  62397. */
  62398. getChildren(): Array<Container>;
  62399. /**
  62400. * Will return all controls that are inside this texture
  62401. * @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
  62402. * @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
  62403. * @return all child controls
  62404. */
  62405. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62406. /**
  62407. * Gets or sets the current focused control
  62408. */
  62409. focusedControl: BABYLON.Nullable<IFocusableControl>;
  62410. /**
  62411. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  62412. */
  62413. isForeground: boolean;
  62414. /**
  62415. * Gets or set information about clipboardData
  62416. */
  62417. clipboardData: string;
  62418. /**
  62419. * Creates a new AdvancedDynamicTexture
  62420. * @param name defines the name of the texture
  62421. * @param width defines the width of the texture
  62422. * @param height defines the height of the texture
  62423. * @param scene defines the hosting scene
  62424. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  62425. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  62426. */
  62427. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  62428. /**
  62429. * Get the current class name of the texture useful for serialization or dynamic coding.
  62430. * @returns "AdvancedDynamicTexture"
  62431. */
  62432. getClassName(): string;
  62433. /**
  62434. * Function used to execute a function on all controls
  62435. * @param func defines the function to execute
  62436. * @param container defines the container where controls belong. If null the root container will be used
  62437. */
  62438. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  62439. private _useInvalidateRectOptimization;
  62440. /**
  62441. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  62442. */
  62443. useInvalidateRectOptimization: boolean;
  62444. private _invalidatedRectangle;
  62445. /**
  62446. * Invalidates a rectangle area on the gui texture
  62447. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  62448. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  62449. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  62450. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  62451. */
  62452. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  62453. /**
  62454. * Marks the texture as dirty forcing a complete update
  62455. */
  62456. markAsDirty(): void;
  62457. /**
  62458. * Helper function used to create a new style
  62459. * @returns a new style
  62460. * @see http://doc.babylonjs.com/how_to/gui#styles
  62461. */
  62462. createStyle(): Style;
  62463. /**
  62464. * Adds a new control to the root container
  62465. * @param control defines the control to add
  62466. * @returns the current texture
  62467. */
  62468. addControl(control: Control): AdvancedDynamicTexture;
  62469. /**
  62470. * Removes a control from the root container
  62471. * @param control defines the control to remove
  62472. * @returns the current texture
  62473. */
  62474. removeControl(control: Control): AdvancedDynamicTexture;
  62475. /**
  62476. * Release all resources
  62477. */
  62478. dispose(): void;
  62479. private _onResize;
  62480. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  62481. /**
  62482. * Get screen coordinates for a vector3
  62483. * @param position defines the position to project
  62484. * @param worldMatrix defines the world matrix to use
  62485. * @returns the projected position
  62486. */
  62487. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  62488. private _checkUpdate;
  62489. private _clearMeasure;
  62490. private _render;
  62491. /** @hidden */ private _changeCursor(cursor: string): void;
  62492. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  62493. private _doPicking;
  62494. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  62495. [pointerId: number]: Control;
  62496. }, control: Control): void;
  62497. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  62498. /** Attach to all scene events required to support pointer events */
  62499. attach(): void;
  62500. /** @hidden */
  62501. private onClipboardCopy;
  62502. /** @hidden */
  62503. private onClipboardCut;
  62504. /** @hidden */
  62505. private onClipboardPaste;
  62506. /**
  62507. * Register the clipboard Events onto the canvas
  62508. */
  62509. registerClipboardEvents(): void;
  62510. /**
  62511. * Unregister the clipboard Events from the canvas
  62512. */
  62513. unRegisterClipboardEvents(): void;
  62514. /**
  62515. * Connect the texture to a hosting mesh to enable interactions
  62516. * @param mesh defines the mesh to attach to
  62517. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  62518. */
  62519. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  62520. /**
  62521. * Move the focus to a specific control
  62522. * @param control defines the control which will receive the focus
  62523. */
  62524. moveFocusToControl(control: IFocusableControl): void;
  62525. private _manageFocus;
  62526. private _attachToOnPointerOut;
  62527. /**
  62528. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  62529. * @param mesh defines the mesh which will receive the texture
  62530. * @param width defines the texture width (1024 by default)
  62531. * @param height defines the texture height (1024 by default)
  62532. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  62533. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  62534. * @returns a new AdvancedDynamicTexture
  62535. */
  62536. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  62537. /**
  62538. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  62539. * In this mode the texture will rely on a layer for its rendering.
  62540. * This allows it to be treated like any other layer.
  62541. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  62542. * LayerMask is set through advancedTexture.layer.layerMask
  62543. * @param name defines name for the texture
  62544. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  62545. * @param scene defines the hsoting scene
  62546. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  62547. * @returns a new AdvancedDynamicTexture
  62548. */
  62549. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  62550. }
  62551. }
  62552. declare module BABYLON.GUI {
  62553. /**
  62554. * Root class used for all 2D controls
  62555. * @see http://doc.babylonjs.com/how_to/gui#controls
  62556. */
  62557. export class Control {
  62558. /** defines the name of the control */
  62559. name?: string | undefined;
  62560. /**
  62561. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  62562. */
  62563. static AllowAlphaInheritance: boolean;
  62564. private _alpha;
  62565. private _alphaSet;
  62566. private _zIndex;
  62567. /** @hidden */ private _host: AdvancedDynamicTexture;
  62568. /** Gets or sets the control parent */
  62569. parent: BABYLON.Nullable<Container>;
  62570. /** @hidden */ private _currentMeasure: Measure;
  62571. private _fontFamily;
  62572. private _fontStyle;
  62573. private _fontWeight;
  62574. private _fontSize;
  62575. private _font;
  62576. /** @hidden */ private _width: ValueAndUnit;
  62577. /** @hidden */ private _height: ValueAndUnit;
  62578. /** @hidden */
  62579. protected _fontOffset: {
  62580. ascent: number;
  62581. height: number;
  62582. descent: number;
  62583. };
  62584. private _color;
  62585. private _style;
  62586. private _styleObserver;
  62587. /** @hidden */
  62588. protected _horizontalAlignment: number;
  62589. /** @hidden */
  62590. protected _verticalAlignment: number;
  62591. /** @hidden */
  62592. protected _isDirty: boolean;
  62593. /** @hidden */
  62594. protected _wasDirty: boolean;
  62595. /** @hidden */ private _tempParentMeasure: Measure;
  62596. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  62597. /** @hidden */
  62598. protected _cachedParentMeasure: Measure;
  62599. private _paddingLeft;
  62600. private _paddingRight;
  62601. private _paddingTop;
  62602. private _paddingBottom;
  62603. /** @hidden */ private _left: ValueAndUnit;
  62604. /** @hidden */ private _top: ValueAndUnit;
  62605. private _scaleX;
  62606. private _scaleY;
  62607. private _rotation;
  62608. private _transformCenterX;
  62609. private _transformCenterY;
  62610. /** @hidden */ private _transformMatrix: Matrix2D;
  62611. /** @hidden */
  62612. protected _invertTransformMatrix: Matrix2D;
  62613. /** @hidden */
  62614. protected _transformedPosition: BABYLON.Vector2;
  62615. private _isMatrixDirty;
  62616. private _cachedOffsetX;
  62617. private _cachedOffsetY;
  62618. private _isVisible;
  62619. private _isHighlighted;
  62620. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62621. private _fontSet;
  62622. private _dummyVector2;
  62623. private _downCount;
  62624. private _enterCount;
  62625. private _doNotRender;
  62626. private _downPointerIds;
  62627. protected _isEnabled: boolean;
  62628. protected _disabledColor: string;
  62629. /** @hidden */
  62630. protected _rebuildLayout: boolean;
  62631. /** @hidden */ private _isClipped: boolean;
  62632. /** @hidden */ private _tag: any;
  62633. /**
  62634. * 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
  62635. */
  62636. uniqueId: number;
  62637. /**
  62638. * Gets or sets an object used to store user defined information for the node
  62639. */
  62640. metadata: any;
  62641. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  62642. isHitTestVisible: boolean;
  62643. /** Gets or sets a boolean indicating if the control can block pointer events */
  62644. isPointerBlocker: boolean;
  62645. /** Gets or sets a boolean indicating if the control can be focusable */
  62646. isFocusInvisible: boolean;
  62647. /**
  62648. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  62649. * 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
  62650. */
  62651. clipChildren: boolean;
  62652. /**
  62653. * Gets or sets a boolean indicating that control content must be clipped
  62654. * 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
  62655. */
  62656. clipContent: boolean;
  62657. /**
  62658. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  62659. */
  62660. useBitmapCache: boolean;
  62661. private _cacheData;
  62662. private _shadowOffsetX;
  62663. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  62664. shadowOffsetX: number;
  62665. private _shadowOffsetY;
  62666. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  62667. shadowOffsetY: number;
  62668. private _shadowBlur;
  62669. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  62670. shadowBlur: number;
  62671. private _shadowColor;
  62672. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  62673. shadowColor: string;
  62674. /** Gets or sets the cursor to use when the control is hovered */
  62675. hoverCursor: string;
  62676. /** @hidden */
  62677. protected _linkOffsetX: ValueAndUnit;
  62678. /** @hidden */
  62679. protected _linkOffsetY: ValueAndUnit;
  62680. /** Gets the control type name */
  62681. readonly typeName: string;
  62682. /**
  62683. * Get the current class name of the control.
  62684. * @returns current class name
  62685. */
  62686. getClassName(): string;
  62687. /**
  62688. * An event triggered when the pointer move over the control.
  62689. */
  62690. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  62691. /**
  62692. * An event triggered when the pointer move out of the control.
  62693. */
  62694. onPointerOutObservable: BABYLON.Observable<Control>;
  62695. /**
  62696. * An event triggered when the pointer taps the control
  62697. */
  62698. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  62699. /**
  62700. * An event triggered when pointer up
  62701. */
  62702. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  62703. /**
  62704. * An event triggered when a control is clicked on
  62705. */
  62706. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  62707. /**
  62708. * An event triggered when pointer enters the control
  62709. */
  62710. onPointerEnterObservable: BABYLON.Observable<Control>;
  62711. /**
  62712. * An event triggered when the control is marked as dirty
  62713. */
  62714. onDirtyObservable: BABYLON.Observable<Control>;
  62715. /**
  62716. * An event triggered before drawing the control
  62717. */
  62718. onBeforeDrawObservable: BABYLON.Observable<Control>;
  62719. /**
  62720. * An event triggered after the control was drawn
  62721. */
  62722. onAfterDrawObservable: BABYLON.Observable<Control>;
  62723. /**
  62724. * Get the hosting AdvancedDynamicTexture
  62725. */
  62726. readonly host: AdvancedDynamicTexture;
  62727. /** Gets or set information about font offsets (used to render and align text) */
  62728. fontOffset: {
  62729. ascent: number;
  62730. height: number;
  62731. descent: number;
  62732. };
  62733. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  62734. alpha: number;
  62735. /**
  62736. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  62737. */
  62738. isHighlighted: boolean;
  62739. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  62740. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62741. */
  62742. scaleX: number;
  62743. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  62744. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62745. */
  62746. scaleY: number;
  62747. /** Gets or sets the rotation angle (0 by default)
  62748. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62749. */
  62750. rotation: number;
  62751. /** Gets or sets the transformation center on Y axis (0 by default)
  62752. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62753. */
  62754. transformCenterY: number;
  62755. /** Gets or sets the transformation center on X axis (0 by default)
  62756. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62757. */
  62758. transformCenterX: number;
  62759. /**
  62760. * Gets or sets the horizontal alignment
  62761. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62762. */
  62763. horizontalAlignment: number;
  62764. /**
  62765. * Gets or sets the vertical alignment
  62766. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62767. */
  62768. verticalAlignment: number;
  62769. /**
  62770. * Gets or sets control width
  62771. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62772. */
  62773. width: string | number;
  62774. /**
  62775. * Gets or sets the control width in pixel
  62776. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62777. */
  62778. widthInPixels: number;
  62779. /**
  62780. * Gets or sets control height
  62781. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62782. */
  62783. height: string | number;
  62784. /**
  62785. * Gets or sets control height in pixel
  62786. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62787. */
  62788. heightInPixels: number;
  62789. /** Gets or set font family */
  62790. fontFamily: string;
  62791. /** Gets or sets font style */
  62792. fontStyle: string;
  62793. /** Gets or sets font weight */
  62794. fontWeight: string;
  62795. /**
  62796. * Gets or sets style
  62797. * @see http://doc.babylonjs.com/how_to/gui#styles
  62798. */
  62799. style: BABYLON.Nullable<Style>;
  62800. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  62801. /** Gets or sets font size in pixels */
  62802. fontSizeInPixels: number;
  62803. /** Gets or sets font size */
  62804. fontSize: string | number;
  62805. /** Gets or sets foreground color */
  62806. color: string;
  62807. /** Gets or sets z index which is used to reorder controls on the z axis */
  62808. zIndex: number;
  62809. /** Gets or sets a boolean indicating if the control can be rendered */
  62810. notRenderable: boolean;
  62811. /** Gets or sets a boolean indicating if the control is visible */
  62812. isVisible: boolean;
  62813. /** Gets a boolean indicating that the control needs to update its rendering */
  62814. readonly isDirty: boolean;
  62815. /**
  62816. * Gets the current linked mesh (or null if none)
  62817. */
  62818. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62819. /**
  62820. * Gets or sets a value indicating the padding to use on the left of the control
  62821. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62822. */
  62823. paddingLeft: string | number;
  62824. /**
  62825. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  62826. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62827. */
  62828. paddingLeftInPixels: number;
  62829. /**
  62830. * Gets or sets a value indicating the padding to use on the right of the control
  62831. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62832. */
  62833. paddingRight: string | number;
  62834. /**
  62835. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  62836. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62837. */
  62838. paddingRightInPixels: number;
  62839. /**
  62840. * Gets or sets a value indicating the padding to use on the top of the control
  62841. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62842. */
  62843. paddingTop: string | number;
  62844. /**
  62845. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  62846. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62847. */
  62848. paddingTopInPixels: number;
  62849. /**
  62850. * Gets or sets a value indicating the padding to use on the bottom of the control
  62851. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62852. */
  62853. paddingBottom: string | number;
  62854. /**
  62855. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  62856. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62857. */
  62858. paddingBottomInPixels: number;
  62859. /**
  62860. * Gets or sets a value indicating the left coordinate of the control
  62861. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62862. */
  62863. left: string | number;
  62864. /**
  62865. * Gets or sets a value indicating the left coordinate in pixels of the control
  62866. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62867. */
  62868. leftInPixels: number;
  62869. /**
  62870. * Gets or sets a value indicating the top coordinate of the control
  62871. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62872. */
  62873. top: string | number;
  62874. /**
  62875. * Gets or sets a value indicating the top coordinate in pixels of the control
  62876. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62877. */
  62878. topInPixels: number;
  62879. /**
  62880. * Gets or sets a value indicating the offset on X axis to the linked mesh
  62881. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62882. */
  62883. linkOffsetX: string | number;
  62884. /**
  62885. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  62886. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62887. */
  62888. linkOffsetXInPixels: number;
  62889. /**
  62890. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  62891. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62892. */
  62893. linkOffsetY: string | number;
  62894. /**
  62895. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  62896. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62897. */
  62898. linkOffsetYInPixels: number;
  62899. /** Gets the center coordinate on X axis */
  62900. readonly centerX: number;
  62901. /** Gets the center coordinate on Y axis */
  62902. readonly centerY: number;
  62903. /** Gets or sets if control is Enabled*/
  62904. isEnabled: boolean;
  62905. /** Gets or sets background color of control if it's disabled*/
  62906. disabledColor: string;
  62907. /**
  62908. * Creates a new control
  62909. * @param name defines the name of the control
  62910. */
  62911. constructor(
  62912. /** defines the name of the control */
  62913. name?: string | undefined);
  62914. /** @hidden */
  62915. protected _getTypeName(): string;
  62916. /**
  62917. * Gets the first ascendant in the hierarchy of the given type
  62918. * @param className defines the required type
  62919. * @returns the ascendant or null if not found
  62920. */
  62921. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  62922. /** @hidden */ private _resetFontCache(): void;
  62923. /**
  62924. * Determines if a container is an ascendant of the current control
  62925. * @param container defines the container to look for
  62926. * @returns true if the container is one of the ascendant of the control
  62927. */
  62928. isAscendant(container: Control): boolean;
  62929. /**
  62930. * Gets coordinates in local control space
  62931. * @param globalCoordinates defines the coordinates to transform
  62932. * @returns the new coordinates in local space
  62933. */
  62934. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62935. /**
  62936. * Gets coordinates in local control space
  62937. * @param globalCoordinates defines the coordinates to transform
  62938. * @param result defines the target vector2 where to store the result
  62939. * @returns the current control
  62940. */
  62941. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  62942. /**
  62943. * Gets coordinates in parent local control space
  62944. * @param globalCoordinates defines the coordinates to transform
  62945. * @returns the new coordinates in parent local space
  62946. */
  62947. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62948. /**
  62949. * Move the current control to a vector3 position projected onto the screen.
  62950. * @param position defines the target position
  62951. * @param scene defines the hosting scene
  62952. */
  62953. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  62954. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62955. /**
  62956. * Will return all controls that have this control as ascendant
  62957. * @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
  62958. * @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
  62959. * @return all child controls
  62960. */
  62961. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62962. /**
  62963. * Link current control with a target mesh
  62964. * @param mesh defines the mesh to link with
  62965. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62966. */
  62967. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  62968. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  62969. /** @hidden */ private _offsetLeft(offset: number): void;
  62970. /** @hidden */ private _offsetTop(offset: number): void;
  62971. /** @hidden */ private _markMatrixAsDirty(): void;
  62972. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  62973. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  62974. /** @hidden */
  62975. protected invalidateRect(): void;
  62976. /** @hidden */ private _markAsDirty(force?: boolean): void;
  62977. /** @hidden */ private _markAllAsDirty(): void;
  62978. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  62979. /** @hidden */
  62980. protected _transform(context?: CanvasRenderingContext2D): void;
  62981. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  62982. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62983. /** @hidden */
  62984. protected _applyStates(context: CanvasRenderingContext2D): void;
  62985. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62986. /** @hidden */
  62987. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62988. protected _evaluateClippingState(parentMeasure: Measure): void;
  62989. /** @hidden */ private _measure(): void;
  62990. /** @hidden */
  62991. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62992. /** @hidden */
  62993. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62994. /** @hidden */
  62995. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62996. /** @hidden */
  62997. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62998. private static _ClipMeasure;
  62999. private _tmpMeasureA;
  63000. private _clip;
  63001. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63002. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63003. /**
  63004. * Tests if a given coordinates belong to the current control
  63005. * @param x defines x coordinate to test
  63006. * @param y defines y coordinate to test
  63007. * @returns true if the coordinates are inside the control
  63008. */
  63009. contains(x: number, y: number): boolean;
  63010. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63011. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63012. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  63013. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  63014. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63015. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63016. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63017. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63018. private _prepareFont;
  63019. /** Releases associated resources */
  63020. dispose(): void;
  63021. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63022. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63023. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63024. private static _VERTICAL_ALIGNMENT_TOP;
  63025. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63026. private static _VERTICAL_ALIGNMENT_CENTER;
  63027. /** HORIZONTAL_ALIGNMENT_LEFT */
  63028. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63029. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63030. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63031. /** HORIZONTAL_ALIGNMENT_CENTER */
  63032. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63033. /** VERTICAL_ALIGNMENT_TOP */
  63034. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63035. /** VERTICAL_ALIGNMENT_BOTTOM */
  63036. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63037. /** VERTICAL_ALIGNMENT_CENTER */
  63038. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63039. private static _FontHeightSizes;
  63040. /** @hidden */ private static _GetFontOffset(font: string): {
  63041. ascent: number;
  63042. height: number;
  63043. descent: number;
  63044. };
  63045. /**
  63046. * Creates a stack panel that can be used to render headers
  63047. * @param control defines the control to associate with the header
  63048. * @param text defines the text of the header
  63049. * @param size defines the size of the header
  63050. * @param options defines options used to configure the header
  63051. * @returns a new StackPanel
  63052. * @ignore
  63053. * @hidden
  63054. */
  63055. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63056. isHorizontal: boolean;
  63057. controlFirst: boolean;
  63058. }) => any;
  63059. /** @hidden */
  63060. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63061. }
  63062. }
  63063. declare module BABYLON.GUI {
  63064. /**
  63065. * Root class for 2D containers
  63066. * @see http://doc.babylonjs.com/how_to/gui#containers
  63067. */
  63068. export class Container extends Control {
  63069. name?: string | undefined;
  63070. /** @hidden */
  63071. protected _children: Control[];
  63072. /** @hidden */
  63073. protected _measureForChildren: Measure;
  63074. /** @hidden */
  63075. protected _background: string;
  63076. /** @hidden */
  63077. protected _adaptWidthToChildren: boolean;
  63078. /** @hidden */
  63079. protected _adaptHeightToChildren: boolean;
  63080. /**
  63081. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63082. */
  63083. logLayoutCycleErrors: boolean;
  63084. /**
  63085. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63086. */
  63087. maxLayoutCycle: number;
  63088. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63089. adaptHeightToChildren: boolean;
  63090. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63091. adaptWidthToChildren: boolean;
  63092. /** Gets or sets background color */
  63093. background: string;
  63094. /** Gets the list of children */
  63095. readonly children: Control[];
  63096. /**
  63097. * Creates a new Container
  63098. * @param name defines the name of the container
  63099. */
  63100. constructor(name?: string | undefined);
  63101. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  63102. /**
  63103. * Gets a child using its name
  63104. * @param name defines the child name to look for
  63105. * @returns the child control if found
  63106. */
  63107. getChildByName(name: string): BABYLON.Nullable<Control>;
  63108. /**
  63109. * Gets a child using its type and its name
  63110. * @param name defines the child name to look for
  63111. * @param type defines the child type to look for
  63112. * @returns the child control if found
  63113. */
  63114. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63115. /**
  63116. * Search for a specific control in children
  63117. * @param control defines the control to look for
  63118. * @returns true if the control is in child list
  63119. */
  63120. containsControl(control: Control): boolean;
  63121. /**
  63122. * Adds a new control to the current container
  63123. * @param control defines the control to add
  63124. * @returns the current container
  63125. */
  63126. addControl(control: BABYLON.Nullable<Control>): Container;
  63127. /**
  63128. * Removes all controls from the current container
  63129. * @returns the current container
  63130. */
  63131. clearControls(): Container;
  63132. /**
  63133. * Removes a control from the current container
  63134. * @param control defines the control to remove
  63135. * @returns the current container
  63136. */
  63137. removeControl(control: Control): Container;
  63138. /** @hidden */ private _reOrderControl(control: Control): void;
  63139. /** @hidden */ private _offsetLeft(offset: number): void;
  63140. /** @hidden */ private _offsetTop(offset: number): void;
  63141. /** @hidden */ private _markAllAsDirty(): void;
  63142. /** @hidden */
  63143. protected _localDraw(context: CanvasRenderingContext2D): void;
  63144. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  63145. /** @hidden */
  63146. protected _beforeLayout(): void;
  63147. /** @hidden */
  63148. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63149. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63150. protected _postMeasure(): void;
  63151. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  63152. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63153. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63154. /** @hidden */
  63155. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63156. /** Releases associated resources */
  63157. dispose(): void;
  63158. }
  63159. }
  63160. declare module BABYLON.GUI {
  63161. /** Class used to create rectangle container */
  63162. export class Rectangle extends Container {
  63163. name?: string | undefined;
  63164. private _thickness;
  63165. private _cornerRadius;
  63166. /** Gets or sets border thickness */
  63167. thickness: number;
  63168. /** Gets or sets the corner radius angle */
  63169. cornerRadius: number;
  63170. /**
  63171. * Creates a new Rectangle
  63172. * @param name defines the control name
  63173. */
  63174. constructor(name?: string | undefined);
  63175. protected _getTypeName(): string;
  63176. protected _localDraw(context: CanvasRenderingContext2D): void;
  63177. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63178. private _drawRoundedRect;
  63179. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63180. }
  63181. }
  63182. declare module BABYLON.GUI {
  63183. /**
  63184. * Enum that determines the text-wrapping mode to use.
  63185. */
  63186. export enum TextWrapping {
  63187. /**
  63188. * Clip the text when it's larger than Control.width; this is the default mode.
  63189. */
  63190. Clip = 0,
  63191. /**
  63192. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  63193. */
  63194. WordWrap = 1,
  63195. /**
  63196. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  63197. */
  63198. Ellipsis = 2
  63199. }
  63200. /**
  63201. * Class used to create text block control
  63202. */
  63203. export class TextBlock extends Control {
  63204. /**
  63205. * Defines the name of the control
  63206. */
  63207. name?: string | undefined;
  63208. private _text;
  63209. private _textWrapping;
  63210. private _textHorizontalAlignment;
  63211. private _textVerticalAlignment;
  63212. private _lines;
  63213. private _resizeToFit;
  63214. private _lineSpacing;
  63215. private _outlineWidth;
  63216. private _outlineColor;
  63217. /**
  63218. * An event triggered after the text is changed
  63219. */
  63220. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63221. /**
  63222. * An event triggered after the text was broken up into lines
  63223. */
  63224. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63225. /**
  63226. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63227. */
  63228. readonly lines: any[];
  63229. /**
  63230. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63231. */
  63232. /**
  63233. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63234. */
  63235. resizeToFit: boolean;
  63236. /**
  63237. * Gets or sets a boolean indicating if text must be wrapped
  63238. */
  63239. /**
  63240. * Gets or sets a boolean indicating if text must be wrapped
  63241. */
  63242. textWrapping: TextWrapping | boolean;
  63243. /**
  63244. * Gets or sets text to display
  63245. */
  63246. /**
  63247. * Gets or sets text to display
  63248. */
  63249. text: string;
  63250. /**
  63251. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63252. */
  63253. /**
  63254. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63255. */
  63256. textHorizontalAlignment: number;
  63257. /**
  63258. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63259. */
  63260. /**
  63261. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63262. */
  63263. textVerticalAlignment: number;
  63264. /**
  63265. * Gets or sets line spacing value
  63266. */
  63267. /**
  63268. * Gets or sets line spacing value
  63269. */
  63270. lineSpacing: string | number;
  63271. /**
  63272. * Gets or sets outlineWidth of the text to display
  63273. */
  63274. /**
  63275. * Gets or sets outlineWidth of the text to display
  63276. */
  63277. outlineWidth: number;
  63278. /**
  63279. * Gets or sets outlineColor of the text to display
  63280. */
  63281. /**
  63282. * Gets or sets outlineColor of the text to display
  63283. */
  63284. outlineColor: string;
  63285. /**
  63286. * Creates a new TextBlock object
  63287. * @param name defines the name of the control
  63288. * @param text defines the text to display (emptry string by default)
  63289. */
  63290. constructor(
  63291. /**
  63292. * Defines the name of the control
  63293. */
  63294. name?: string | undefined, text?: string);
  63295. protected _getTypeName(): string;
  63296. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63297. private _drawText;
  63298. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63299. protected _applyStates(context: CanvasRenderingContext2D): void;
  63300. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63301. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63302. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63303. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63304. protected _renderLines(context: CanvasRenderingContext2D): void;
  63305. /**
  63306. * Given a width constraint applied on the text block, find the expected height
  63307. * @returns expected height
  63308. */
  63309. computeExpectedHeight(): number;
  63310. dispose(): void;
  63311. }
  63312. }
  63313. declare module BABYLON.GUI {
  63314. /**
  63315. * Class used to create 2D images
  63316. */
  63317. export class Image extends Control {
  63318. name?: string | undefined;
  63319. private static _WorkingCanvas;
  63320. private _domImage;
  63321. private _imageWidth;
  63322. private _imageHeight;
  63323. private _loaded;
  63324. private _stretch;
  63325. private _source;
  63326. private _autoScale;
  63327. private _sourceLeft;
  63328. private _sourceTop;
  63329. private _sourceWidth;
  63330. private _sourceHeight;
  63331. private _cellWidth;
  63332. private _cellHeight;
  63333. private _cellId;
  63334. private _populateNinePatchSlicesFromImage;
  63335. private _sliceLeft;
  63336. private _sliceRight;
  63337. private _sliceTop;
  63338. private _sliceBottom;
  63339. private _detectPointerOnOpaqueOnly;
  63340. /**
  63341. * BABYLON.Observable notified when the content is loaded
  63342. */
  63343. onImageLoadedObservable: BABYLON.Observable<Image>;
  63344. /**
  63345. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  63346. */
  63347. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  63348. /**
  63349. * Gets a boolean indicating that the content is loaded
  63350. */
  63351. readonly isLoaded: boolean;
  63352. /**
  63353. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  63354. */
  63355. populateNinePatchSlicesFromImage: boolean;
  63356. /**
  63357. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  63358. * Beware using this as this will comsume more memory as the image has to be stored twice
  63359. */
  63360. detectPointerOnOpaqueOnly: boolean;
  63361. /**
  63362. * Gets or sets the left value for slicing (9-patch)
  63363. */
  63364. sliceLeft: number;
  63365. /**
  63366. * Gets or sets the right value for slicing (9-patch)
  63367. */
  63368. sliceRight: number;
  63369. /**
  63370. * Gets or sets the top value for slicing (9-patch)
  63371. */
  63372. sliceTop: number;
  63373. /**
  63374. * Gets or sets the bottom value for slicing (9-patch)
  63375. */
  63376. sliceBottom: number;
  63377. /**
  63378. * Gets or sets the left coordinate in the source image
  63379. */
  63380. sourceLeft: number;
  63381. /**
  63382. * Gets or sets the top coordinate in the source image
  63383. */
  63384. sourceTop: number;
  63385. /**
  63386. * Gets or sets the width to capture in the source image
  63387. */
  63388. sourceWidth: number;
  63389. /**
  63390. * Gets or sets the height to capture in the source image
  63391. */
  63392. sourceHeight: number;
  63393. /**
  63394. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  63395. * @see http://doc.babylonjs.com/how_to/gui#image
  63396. */
  63397. autoScale: boolean;
  63398. /** Gets or sets the streching mode used by the image */
  63399. stretch: number;
  63400. /**
  63401. * Gets or sets the internal DOM image used to render the control
  63402. */
  63403. domImage: HTMLImageElement;
  63404. private _onImageLoaded;
  63405. private _extractNinePatchSliceDataFromImage;
  63406. /**
  63407. * Gets or sets image source url
  63408. */
  63409. source: BABYLON.Nullable<string>;
  63410. /**
  63411. * Checks for svg document with icon id present
  63412. */
  63413. private _svgCheck;
  63414. /**
  63415. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  63416. * given external svg file and icon id
  63417. */
  63418. private _getSVGAttribs;
  63419. /**
  63420. * Gets or sets the cell width to use when animation sheet is enabled
  63421. * @see http://doc.babylonjs.com/how_to/gui#image
  63422. */
  63423. cellWidth: number;
  63424. /**
  63425. * Gets or sets the cell height to use when animation sheet is enabled
  63426. * @see http://doc.babylonjs.com/how_to/gui#image
  63427. */
  63428. cellHeight: number;
  63429. /**
  63430. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  63431. * @see http://doc.babylonjs.com/how_to/gui#image
  63432. */
  63433. cellId: number;
  63434. /**
  63435. * Creates a new Image
  63436. * @param name defines the control name
  63437. * @param url defines the image url
  63438. */
  63439. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  63440. /**
  63441. * Tests if a given coordinates belong to the current control
  63442. * @param x defines x coordinate to test
  63443. * @param y defines y coordinate to test
  63444. * @returns true if the coordinates are inside the control
  63445. */
  63446. contains(x: number, y: number): boolean;
  63447. protected _getTypeName(): string;
  63448. /** Force the control to synchronize with its content */
  63449. synchronizeSizeWithContent(): void;
  63450. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63451. private _prepareWorkingCanvasForOpaqueDetection;
  63452. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  63453. private _renderCornerPatch;
  63454. private _renderNinePatch;
  63455. dispose(): void;
  63456. /** STRETCH_NONE */
  63457. static readonly STRETCH_NONE: number;
  63458. /** STRETCH_FILL */
  63459. static readonly STRETCH_FILL: number;
  63460. /** STRETCH_UNIFORM */
  63461. static readonly STRETCH_UNIFORM: number;
  63462. /** STRETCH_EXTEND */
  63463. static readonly STRETCH_EXTEND: number;
  63464. /** NINE_PATCH */
  63465. static readonly STRETCH_NINE_PATCH: number;
  63466. }
  63467. }
  63468. declare module BABYLON.GUI {
  63469. /**
  63470. * Class used to create 2D buttons
  63471. */
  63472. export class Button extends Rectangle {
  63473. name?: string | undefined;
  63474. /**
  63475. * Function called to generate a pointer enter animation
  63476. */
  63477. pointerEnterAnimation: () => void;
  63478. /**
  63479. * Function called to generate a pointer out animation
  63480. */
  63481. pointerOutAnimation: () => void;
  63482. /**
  63483. * Function called to generate a pointer down animation
  63484. */
  63485. pointerDownAnimation: () => void;
  63486. /**
  63487. * Function called to generate a pointer up animation
  63488. */
  63489. pointerUpAnimation: () => void;
  63490. /**
  63491. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  63492. */
  63493. delegatePickingToChildren: boolean;
  63494. private _image;
  63495. /**
  63496. * Returns the image part of the button (if any)
  63497. */
  63498. readonly image: BABYLON.Nullable<Image>;
  63499. private _textBlock;
  63500. /**
  63501. * Returns the image part of the button (if any)
  63502. */
  63503. readonly textBlock: BABYLON.Nullable<TextBlock>;
  63504. /**
  63505. * Creates a new Button
  63506. * @param name defines the name of the button
  63507. */
  63508. constructor(name?: string | undefined);
  63509. protected _getTypeName(): string;
  63510. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63511. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  63512. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  63513. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63514. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63515. /**
  63516. * Creates a new button made with an image and a text
  63517. * @param name defines the name of the button
  63518. * @param text defines the text of the button
  63519. * @param imageUrl defines the url of the image
  63520. * @returns a new Button
  63521. */
  63522. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  63523. /**
  63524. * Creates a new button made with an image
  63525. * @param name defines the name of the button
  63526. * @param imageUrl defines the url of the image
  63527. * @returns a new Button
  63528. */
  63529. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  63530. /**
  63531. * Creates a new button made with a text
  63532. * @param name defines the name of the button
  63533. * @param text defines the text of the button
  63534. * @returns a new Button
  63535. */
  63536. static CreateSimpleButton(name: string, text: string): Button;
  63537. /**
  63538. * Creates a new button made with an image and a centered text
  63539. * @param name defines the name of the button
  63540. * @param text defines the text of the button
  63541. * @param imageUrl defines the url of the image
  63542. * @returns a new Button
  63543. */
  63544. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  63545. }
  63546. }
  63547. declare module BABYLON.GUI {
  63548. /**
  63549. * Class used to create a 2D stack panel container
  63550. */
  63551. export class StackPanel extends Container {
  63552. name?: string | undefined;
  63553. private _isVertical;
  63554. private _manualWidth;
  63555. private _manualHeight;
  63556. private _doNotTrackManualChanges;
  63557. /**
  63558. * Gets or sets a boolean indicating that layou warnings should be ignored
  63559. */
  63560. ignoreLayoutWarnings: boolean;
  63561. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  63562. isVertical: boolean;
  63563. /**
  63564. * Gets or sets panel width.
  63565. * This value should not be set when in horizontal mode as it will be computed automatically
  63566. */
  63567. width: string | number;
  63568. /**
  63569. * Gets or sets panel height.
  63570. * This value should not be set when in vertical mode as it will be computed automatically
  63571. */
  63572. height: string | number;
  63573. /**
  63574. * Creates a new StackPanel
  63575. * @param name defines control name
  63576. */
  63577. constructor(name?: string | undefined);
  63578. protected _getTypeName(): string;
  63579. /** @hidden */
  63580. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63581. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63582. protected _postMeasure(): void;
  63583. }
  63584. }
  63585. declare module BABYLON.GUI {
  63586. /**
  63587. * Class used to represent a 2D checkbox
  63588. */
  63589. export class Checkbox extends Control {
  63590. name?: string | undefined;
  63591. private _isChecked;
  63592. private _background;
  63593. private _checkSizeRatio;
  63594. private _thickness;
  63595. /** Gets or sets border thickness */
  63596. thickness: number;
  63597. /**
  63598. * BABYLON.Observable raised when isChecked property changes
  63599. */
  63600. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63601. /** Gets or sets a value indicating the ratio between overall size and check size */
  63602. checkSizeRatio: number;
  63603. /** Gets or sets background color */
  63604. background: string;
  63605. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63606. isChecked: boolean;
  63607. /**
  63608. * Creates a new CheckBox
  63609. * @param name defines the control name
  63610. */
  63611. constructor(name?: string | undefined);
  63612. protected _getTypeName(): string;
  63613. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63614. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63615. /**
  63616. * Utility function to easily create a checkbox with a header
  63617. * @param title defines the label to use for the header
  63618. * @param onValueChanged defines the callback to call when value changes
  63619. * @returns a StackPanel containing the checkbox and a textBlock
  63620. */
  63621. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  63622. }
  63623. }
  63624. declare module BABYLON.GUI {
  63625. /**
  63626. * Class used to store key control properties
  63627. */
  63628. export class KeyPropertySet {
  63629. /** Width */
  63630. width?: string;
  63631. /** Height */
  63632. height?: string;
  63633. /** Left padding */
  63634. paddingLeft?: string;
  63635. /** Right padding */
  63636. paddingRight?: string;
  63637. /** Top padding */
  63638. paddingTop?: string;
  63639. /** Bottom padding */
  63640. paddingBottom?: string;
  63641. /** Foreground color */
  63642. color?: string;
  63643. /** Background color */
  63644. background?: string;
  63645. }
  63646. /**
  63647. * Class used to create virtual keyboard
  63648. */
  63649. export class VirtualKeyboard extends StackPanel {
  63650. /** BABYLON.Observable raised when a key is pressed */
  63651. onKeyPressObservable: BABYLON.Observable<string>;
  63652. /** Gets or sets default key button width */
  63653. defaultButtonWidth: string;
  63654. /** Gets or sets default key button height */
  63655. defaultButtonHeight: string;
  63656. /** Gets or sets default key button left padding */
  63657. defaultButtonPaddingLeft: string;
  63658. /** Gets or sets default key button right padding */
  63659. defaultButtonPaddingRight: string;
  63660. /** Gets or sets default key button top padding */
  63661. defaultButtonPaddingTop: string;
  63662. /** Gets or sets default key button bottom padding */
  63663. defaultButtonPaddingBottom: string;
  63664. /** Gets or sets default key button foreground color */
  63665. defaultButtonColor: string;
  63666. /** Gets or sets default key button background color */
  63667. defaultButtonBackground: string;
  63668. /** Gets or sets shift button foreground color */
  63669. shiftButtonColor: string;
  63670. /** Gets or sets shift button thickness*/
  63671. selectedShiftThickness: number;
  63672. /** Gets shift key state */
  63673. shiftState: number;
  63674. protected _getTypeName(): string;
  63675. private _createKey;
  63676. /**
  63677. * Adds a new row of keys
  63678. * @param keys defines the list of keys to add
  63679. * @param propertySets defines the associated property sets
  63680. */
  63681. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  63682. /**
  63683. * Set the shift key to a specific state
  63684. * @param shiftState defines the new shift state
  63685. */
  63686. applyShiftState(shiftState: number): void;
  63687. private _currentlyConnectedInputText;
  63688. private _connectedInputTexts;
  63689. private _onKeyPressObserver;
  63690. /** Gets the input text control currently attached to the keyboard */
  63691. readonly connectedInputText: BABYLON.Nullable<InputText>;
  63692. /**
  63693. * Connects the keyboard with an input text control
  63694. *
  63695. * @param input defines the target control
  63696. */
  63697. connect(input: InputText): void;
  63698. /**
  63699. * Disconnects the keyboard from connected InputText controls
  63700. *
  63701. * @param input optionally defines a target control, otherwise all are disconnected
  63702. */
  63703. disconnect(input?: InputText): void;
  63704. private _removeConnectedInputObservables;
  63705. /**
  63706. * Release all resources
  63707. */
  63708. dispose(): void;
  63709. /**
  63710. * Creates a new keyboard using a default layout
  63711. *
  63712. * @param name defines control name
  63713. * @returns a new VirtualKeyboard
  63714. */
  63715. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  63716. }
  63717. }
  63718. declare module BABYLON.GUI {
  63719. /**
  63720. * Class used to create input text control
  63721. */
  63722. export class InputText extends Control implements IFocusableControl {
  63723. name?: string | undefined;
  63724. private _text;
  63725. private _placeholderText;
  63726. private _background;
  63727. private _focusedBackground;
  63728. private _focusedColor;
  63729. private _placeholderColor;
  63730. private _thickness;
  63731. private _margin;
  63732. private _autoStretchWidth;
  63733. private _maxWidth;
  63734. private _isFocused;
  63735. private _blinkTimeout;
  63736. private _blinkIsEven;
  63737. private _cursorOffset;
  63738. private _scrollLeft;
  63739. private _textWidth;
  63740. private _clickedCoordinate;
  63741. private _deadKey;
  63742. private _addKey;
  63743. private _currentKey;
  63744. private _isTextHighlightOn;
  63745. private _textHighlightColor;
  63746. private _highligherOpacity;
  63747. private _highlightedText;
  63748. private _startHighlightIndex;
  63749. private _endHighlightIndex;
  63750. private _cursorIndex;
  63751. private _onFocusSelectAll;
  63752. private _isPointerDown;
  63753. private _onClipboardObserver;
  63754. private _onPointerDblTapObserver;
  63755. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  63756. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  63757. promptMessage: string;
  63758. /** Force disable prompt on mobile device */
  63759. disableMobilePrompt: boolean;
  63760. /** BABYLON.Observable raised when the text changes */
  63761. onTextChangedObservable: BABYLON.Observable<InputText>;
  63762. /** BABYLON.Observable raised just before an entered character is to be added */
  63763. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  63764. /** BABYLON.Observable raised when the control gets the focus */
  63765. onFocusObservable: BABYLON.Observable<InputText>;
  63766. /** BABYLON.Observable raised when the control loses the focus */
  63767. onBlurObservable: BABYLON.Observable<InputText>;
  63768. /**Observable raised when the text is highlighted */
  63769. onTextHighlightObservable: BABYLON.Observable<InputText>;
  63770. /**Observable raised when copy event is triggered */
  63771. onTextCopyObservable: BABYLON.Observable<InputText>;
  63772. /** BABYLON.Observable raised when cut event is triggered */
  63773. onTextCutObservable: BABYLON.Observable<InputText>;
  63774. /** BABYLON.Observable raised when paste event is triggered */
  63775. onTextPasteObservable: BABYLON.Observable<InputText>;
  63776. /** BABYLON.Observable raised when a key event was processed */
  63777. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  63778. /** Gets or sets the maximum width allowed by the control */
  63779. maxWidth: string | number;
  63780. /** Gets the maximum width allowed by the control in pixels */
  63781. readonly maxWidthInPixels: number;
  63782. /** Gets or sets the text highlighter transparency; default: 0.4 */
  63783. highligherOpacity: number;
  63784. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  63785. onFocusSelectAll: boolean;
  63786. /** Gets or sets the text hightlight color */
  63787. textHighlightColor: string;
  63788. /** Gets or sets control margin */
  63789. margin: string;
  63790. /** Gets control margin in pixels */
  63791. readonly marginInPixels: number;
  63792. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  63793. autoStretchWidth: boolean;
  63794. /** Gets or sets border thickness */
  63795. thickness: number;
  63796. /** Gets or sets the background color when focused */
  63797. focusedBackground: string;
  63798. /** Gets or sets the background color when focused */
  63799. focusedColor: string;
  63800. /** Gets or sets the background color */
  63801. background: string;
  63802. /** Gets or sets the placeholder color */
  63803. placeholderColor: string;
  63804. /** Gets or sets the text displayed when the control is empty */
  63805. placeholderText: string;
  63806. /** Gets or sets the dead key flag */
  63807. deadKey: boolean;
  63808. /** Gets or sets the highlight text */
  63809. highlightedText: string;
  63810. /** Gets or sets if the current key should be added */
  63811. addKey: boolean;
  63812. /** Gets or sets the value of the current key being entered */
  63813. currentKey: string;
  63814. /** Gets or sets the text displayed in the control */
  63815. text: string;
  63816. /** Gets or sets control width */
  63817. width: string | number;
  63818. /**
  63819. * Creates a new InputText
  63820. * @param name defines the control name
  63821. * @param text defines the text of the control
  63822. */
  63823. constructor(name?: string | undefined, text?: string);
  63824. /** @hidden */
  63825. onBlur(): void;
  63826. /** @hidden */
  63827. onFocus(): void;
  63828. protected _getTypeName(): string;
  63829. /**
  63830. * Function called to get the list of controls that should not steal the focus from this control
  63831. * @returns an array of controls
  63832. */
  63833. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63834. /** @hidden */
  63835. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  63836. /** @hidden */
  63837. private _updateValueFromCursorIndex;
  63838. /** @hidden */
  63839. private _processDblClick;
  63840. /** @hidden */
  63841. private _selectAllText;
  63842. /**
  63843. * Handles the keyboard event
  63844. * @param evt Defines the KeyboardEvent
  63845. */
  63846. processKeyboard(evt: KeyboardEvent): void;
  63847. /** @hidden */
  63848. private _onCopyText;
  63849. /** @hidden */
  63850. private _onCutText;
  63851. /** @hidden */
  63852. private _onPasteText; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63853. protected _beforeRenderText(text: string): string;
  63854. dispose(): void;
  63855. }
  63856. }
  63857. declare module BABYLON.GUI {
  63858. /**
  63859. * Class used to create a 2D grid container
  63860. */
  63861. export class Grid extends Container {
  63862. name?: string | undefined;
  63863. private _rowDefinitions;
  63864. private _columnDefinitions;
  63865. private _cells;
  63866. private _childControls;
  63867. /**
  63868. * Gets the number of columns
  63869. */
  63870. readonly columnCount: number;
  63871. /**
  63872. * Gets the number of rows
  63873. */
  63874. readonly rowCount: number;
  63875. /** Gets the list of children */
  63876. readonly children: Control[];
  63877. /** Gets the list of cells (e.g. the containers) */
  63878. readonly cells: {
  63879. [key: string]: Container;
  63880. };
  63881. /**
  63882. * Gets the definition of a specific row
  63883. * @param index defines the index of the row
  63884. * @returns the row definition
  63885. */
  63886. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63887. /**
  63888. * Gets the definition of a specific column
  63889. * @param index defines the index of the column
  63890. * @returns the column definition
  63891. */
  63892. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63893. /**
  63894. * Adds a new row to the grid
  63895. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63896. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  63897. * @returns the current grid
  63898. */
  63899. addRowDefinition(height: number, isPixel?: boolean): Grid;
  63900. /**
  63901. * Adds a new column to the grid
  63902. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63903. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63904. * @returns the current grid
  63905. */
  63906. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  63907. /**
  63908. * Update a row definition
  63909. * @param index defines the index of the row to update
  63910. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63911. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  63912. * @returns the current grid
  63913. */
  63914. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  63915. /**
  63916. * Update a column definition
  63917. * @param index defines the index of the column to update
  63918. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63919. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63920. * @returns the current grid
  63921. */
  63922. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  63923. /**
  63924. * Gets the list of children stored in a specific cell
  63925. * @param row defines the row to check
  63926. * @param column defines the column to check
  63927. * @returns the list of controls
  63928. */
  63929. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  63930. /**
  63931. * Gets a string representing the child cell info (row x column)
  63932. * @param child defines the control to get info from
  63933. * @returns a string containing the child cell info (row x column)
  63934. */
  63935. getChildCellInfo(child: Control): string;
  63936. private _removeCell;
  63937. private _offsetCell;
  63938. /**
  63939. * Remove a column definition at specified index
  63940. * @param index defines the index of the column to remove
  63941. * @returns the current grid
  63942. */
  63943. removeColumnDefinition(index: number): Grid;
  63944. /**
  63945. * Remove a row definition at specified index
  63946. * @param index defines the index of the row to remove
  63947. * @returns the current grid
  63948. */
  63949. removeRowDefinition(index: number): Grid;
  63950. /**
  63951. * Adds a new control to the current grid
  63952. * @param control defines the control to add
  63953. * @param row defines the row where to add the control (0 by default)
  63954. * @param column defines the column where to add the control (0 by default)
  63955. * @returns the current grid
  63956. */
  63957. addControl(control: Control, row?: number, column?: number): Grid;
  63958. /**
  63959. * Removes a control from the current container
  63960. * @param control defines the control to remove
  63961. * @returns the current container
  63962. */
  63963. removeControl(control: Control): Container;
  63964. /**
  63965. * Creates a new Grid
  63966. * @param name defines control name
  63967. */
  63968. constructor(name?: string | undefined);
  63969. protected _getTypeName(): string;
  63970. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  63971. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63972. /** Releases associated resources */
  63973. dispose(): void;
  63974. }
  63975. }
  63976. declare module BABYLON.GUI {
  63977. /** Class used to create color pickers */
  63978. export class ColorPicker extends Control {
  63979. name?: string | undefined;
  63980. private static _Epsilon;
  63981. private _colorWheelCanvas;
  63982. private _value;
  63983. private _tmpColor;
  63984. private _pointerStartedOnSquare;
  63985. private _pointerStartedOnWheel;
  63986. private _squareLeft;
  63987. private _squareTop;
  63988. private _squareSize;
  63989. private _h;
  63990. private _s;
  63991. private _v;
  63992. private _lastPointerDownID;
  63993. /**
  63994. * BABYLON.Observable raised when the value changes
  63995. */
  63996. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  63997. /** Gets or sets the color of the color picker */
  63998. value: BABYLON.Color3;
  63999. /**
  64000. * Gets or sets control width
  64001. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64002. */
  64003. width: string | number;
  64004. /**
  64005. * Gets or sets control height
  64006. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64007. */
  64008. /** Gets or sets control height */
  64009. height: string | number;
  64010. /** Gets or sets control size */
  64011. size: string | number;
  64012. /**
  64013. * Creates a new ColorPicker
  64014. * @param name defines the control name
  64015. */
  64016. constructor(name?: string | undefined);
  64017. protected _getTypeName(): string;
  64018. /** @hidden */
  64019. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64020. private _updateSquareProps;
  64021. private _drawGradientSquare;
  64022. private _drawCircle;
  64023. private _createColorWheelCanvas;
  64024. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64025. private _pointerIsDown;
  64026. private _updateValueFromPointer;
  64027. private _isPointOnSquare;
  64028. private _isPointOnWheel; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64029. /**
  64030. * This function expands the color picker by creating a color picker dialog with manual
  64031. * color value input and the ability to save colors into an array to be used later in
  64032. * subsequent launches of the dialogue.
  64033. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64034. * @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.
  64035. * @returns picked color as a hex string and the saved colors array as hex strings.
  64036. */
  64037. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64038. pickerWidth?: string;
  64039. pickerHeight?: string;
  64040. headerHeight?: string;
  64041. lastColor?: string;
  64042. swatchLimit?: number;
  64043. numSwatchesPerLine?: number;
  64044. savedColors?: Array<string>;
  64045. }): Promise<{
  64046. savedColors?: string[];
  64047. pickedColor: string;
  64048. }>;
  64049. }
  64050. }
  64051. declare module BABYLON.GUI {
  64052. /** Class used to create 2D ellipse containers */
  64053. export class Ellipse extends Container {
  64054. name?: string | undefined;
  64055. private _thickness;
  64056. /** Gets or sets border thickness */
  64057. thickness: number;
  64058. /**
  64059. * Creates a new Ellipse
  64060. * @param name defines the control name
  64061. */
  64062. constructor(name?: string | undefined);
  64063. protected _getTypeName(): string;
  64064. protected _localDraw(context: CanvasRenderingContext2D): void;
  64065. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64066. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64067. }
  64068. }
  64069. declare module BABYLON.GUI {
  64070. /**
  64071. * Class used to create a password control
  64072. */
  64073. export class InputPassword extends InputText {
  64074. protected _beforeRenderText(text: string): string;
  64075. }
  64076. }
  64077. declare module BABYLON.GUI {
  64078. /** Class used to render 2D lines */
  64079. export class Line extends Control {
  64080. name?: string | undefined;
  64081. private _lineWidth;
  64082. private _x1;
  64083. private _y1;
  64084. private _x2;
  64085. private _y2;
  64086. private _dash;
  64087. private _connectedControl;
  64088. private _connectedControlDirtyObserver;
  64089. /** Gets or sets the dash pattern */
  64090. dash: Array<number>;
  64091. /** Gets or sets the control connected with the line end */
  64092. connectedControl: Control;
  64093. /** Gets or sets start coordinates on X axis */
  64094. x1: string | number;
  64095. /** Gets or sets start coordinates on Y axis */
  64096. y1: string | number;
  64097. /** Gets or sets end coordinates on X axis */
  64098. x2: string | number;
  64099. /** Gets or sets end coordinates on Y axis */
  64100. y2: string | number;
  64101. /** Gets or sets line width */
  64102. lineWidth: number;
  64103. /** Gets or sets horizontal alignment */
  64104. horizontalAlignment: number;
  64105. /** Gets or sets vertical alignment */
  64106. verticalAlignment: number;
  64107. private readonly _effectiveX2;
  64108. private readonly _effectiveY2;
  64109. /**
  64110. * Creates a new Line
  64111. * @param name defines the control name
  64112. */
  64113. constructor(name?: string | undefined);
  64114. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  64115. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64116. /**
  64117. * Move one end of the line given 3D cartesian coordinates.
  64118. * @param position Targeted world position
  64119. * @param scene BABYLON.Scene
  64120. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64121. */
  64122. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64123. /**
  64124. * Move one end of the line to a position in screen absolute space.
  64125. * @param projectedPosition Position in screen absolute space (X, Y)
  64126. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64127. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  64128. }
  64129. }
  64130. declare module BABYLON.GUI {
  64131. /**
  64132. * Class used to store a point for a MultiLine object.
  64133. * The point can be pure 2D coordinates, a mesh or a control
  64134. */
  64135. export class MultiLinePoint {
  64136. private _multiLine;
  64137. private _x;
  64138. private _y;
  64139. private _control;
  64140. private _mesh;
  64141. private _controlObserver;
  64142. private _meshObserver;
  64143. /** @hidden */ private _point: BABYLON.Vector2;
  64144. /**
  64145. * Creates a new MultiLinePoint
  64146. * @param multiLine defines the source MultiLine object
  64147. */
  64148. constructor(multiLine: MultiLine);
  64149. /** Gets or sets x coordinate */
  64150. x: string | number;
  64151. /** Gets or sets y coordinate */
  64152. y: string | number;
  64153. /** Gets or sets the control associated with this point */
  64154. control: BABYLON.Nullable<Control>;
  64155. /** Gets or sets the mesh associated with this point */
  64156. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64157. /** Resets links */
  64158. resetLinks(): void;
  64159. /**
  64160. * Gets a translation vector
  64161. * @returns the translation vector
  64162. */
  64163. translate(): BABYLON.Vector2;
  64164. private _translatePoint;
  64165. /** Release associated resources */
  64166. dispose(): void;
  64167. }
  64168. }
  64169. declare module BABYLON.GUI {
  64170. /**
  64171. * Class used to create multi line control
  64172. */
  64173. export class MultiLine extends Control {
  64174. name?: string | undefined;
  64175. private _lineWidth;
  64176. private _dash;
  64177. private _points;
  64178. private _minX;
  64179. private _minY;
  64180. private _maxX;
  64181. private _maxY;
  64182. /**
  64183. * Creates a new MultiLine
  64184. * @param name defines the control name
  64185. */
  64186. constructor(name?: string | undefined);
  64187. /** Gets or sets dash pattern */
  64188. dash: Array<number>;
  64189. /**
  64190. * Gets point stored at specified index
  64191. * @param index defines the index to look for
  64192. * @returns the requested point if found
  64193. */
  64194. getAt(index: number): MultiLinePoint;
  64195. /** Function called when a point is updated */
  64196. onPointUpdate: () => void;
  64197. /**
  64198. * Adds new points to the point collection
  64199. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64200. * @returns the list of created MultiLinePoint
  64201. */
  64202. add(...items: (AbstractMesh | Control | {
  64203. x: string | number;
  64204. y: string | number;
  64205. })[]): MultiLinePoint[];
  64206. /**
  64207. * Adds a new point to the point collection
  64208. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64209. * @returns the created MultiLinePoint
  64210. */
  64211. push(item?: (AbstractMesh | Control | {
  64212. x: string | number;
  64213. y: string | number;
  64214. })): MultiLinePoint;
  64215. /**
  64216. * Remove a specific value or point from the active point collection
  64217. * @param value defines the value or point to remove
  64218. */
  64219. remove(value: number | MultiLinePoint): void;
  64220. /**
  64221. * Resets this object to initial state (no point)
  64222. */
  64223. reset(): void;
  64224. /**
  64225. * Resets all links
  64226. */
  64227. resetLinks(): void;
  64228. /** Gets or sets line width */
  64229. lineWidth: number;
  64230. horizontalAlignment: number;
  64231. verticalAlignment: number;
  64232. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64233. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  64234. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64235. dispose(): void;
  64236. }
  64237. }
  64238. declare module BABYLON.GUI {
  64239. /**
  64240. * Class used to create radio button controls
  64241. */
  64242. export class RadioButton extends Control {
  64243. name?: string | undefined;
  64244. private _isChecked;
  64245. private _background;
  64246. private _checkSizeRatio;
  64247. private _thickness;
  64248. /** Gets or sets border thickness */
  64249. thickness: number;
  64250. /** Gets or sets group name */
  64251. group: string;
  64252. /** BABYLON.Observable raised when isChecked is changed */
  64253. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64254. /** Gets or sets a value indicating the ratio between overall size and check size */
  64255. checkSizeRatio: number;
  64256. /** Gets or sets background color */
  64257. background: string;
  64258. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64259. isChecked: boolean;
  64260. /**
  64261. * Creates a new RadioButton
  64262. * @param name defines the control name
  64263. */
  64264. constructor(name?: string | undefined);
  64265. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64266. /**
  64267. * Utility function to easily create a radio button with a header
  64268. * @param title defines the label to use for the header
  64269. * @param group defines the group to use for the radio button
  64270. * @param isChecked defines the initial state of the radio button
  64271. * @param onValueChanged defines the callback to call when value changes
  64272. * @returns a StackPanel containing the radio button and a textBlock
  64273. */
  64274. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64275. }
  64276. }
  64277. declare module BABYLON.GUI {
  64278. /**
  64279. * Class used to create slider controls
  64280. */
  64281. export class BaseSlider extends Control {
  64282. name?: string | undefined;
  64283. protected _thumbWidth: ValueAndUnit;
  64284. private _minimum;
  64285. private _maximum;
  64286. private _value;
  64287. private _isVertical;
  64288. protected _barOffset: ValueAndUnit;
  64289. private _isThumbClamped;
  64290. protected _displayThumb: boolean;
  64291. private _step;
  64292. private _lastPointerDownID;
  64293. protected _effectiveBarOffset: number;
  64294. protected _renderLeft: number;
  64295. protected _renderTop: number;
  64296. protected _renderWidth: number;
  64297. protected _renderHeight: number;
  64298. protected _backgroundBoxLength: number;
  64299. protected _backgroundBoxThickness: number;
  64300. protected _effectiveThumbThickness: number;
  64301. /** BABYLON.Observable raised when the sldier value changes */
  64302. onValueChangedObservable: BABYLON.Observable<number>;
  64303. /** Gets or sets a boolean indicating if the thumb must be rendered */
  64304. displayThumb: boolean;
  64305. /** Gets or sets a step to apply to values (0 by default) */
  64306. step: number;
  64307. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  64308. barOffset: string | number;
  64309. /** Gets main bar offset in pixels*/
  64310. readonly barOffsetInPixels: number;
  64311. /** Gets or sets thumb width */
  64312. thumbWidth: string | number;
  64313. /** Gets thumb width in pixels */
  64314. readonly thumbWidthInPixels: number;
  64315. /** Gets or sets minimum value */
  64316. minimum: number;
  64317. /** Gets or sets maximum value */
  64318. maximum: number;
  64319. /** Gets or sets current value */
  64320. value: number;
  64321. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  64322. isVertical: boolean;
  64323. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  64324. isThumbClamped: boolean;
  64325. /**
  64326. * Creates a new BaseSlider
  64327. * @param name defines the control name
  64328. */
  64329. constructor(name?: string | undefined);
  64330. protected _getTypeName(): string;
  64331. protected _getThumbPosition(): number;
  64332. protected _getThumbThickness(type: string): number;
  64333. protected _prepareRenderingData(type: string): void;
  64334. private _pointerIsDown;
  64335. /** @hidden */
  64336. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64337. }
  64338. }
  64339. declare module BABYLON.GUI {
  64340. /**
  64341. * Class used to create slider controls
  64342. */
  64343. export class Slider extends BaseSlider {
  64344. name?: string | undefined;
  64345. private _background;
  64346. private _borderColor;
  64347. private _isThumbCircle;
  64348. protected _displayValueBar: boolean;
  64349. /** Gets or sets a boolean indicating if the value bar must be rendered */
  64350. displayValueBar: boolean;
  64351. /** Gets or sets border color */
  64352. borderColor: string;
  64353. /** Gets or sets background color */
  64354. background: string;
  64355. /** Gets or sets a boolean indicating if the thumb should be round or square */
  64356. isThumbCircle: boolean;
  64357. /**
  64358. * Creates a new Slider
  64359. * @param name defines the control name
  64360. */
  64361. constructor(name?: string | undefined);
  64362. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64363. }
  64364. }
  64365. declare module BABYLON.GUI {
  64366. /** Class used to create a RadioGroup
  64367. * which contains groups of radio buttons
  64368. */
  64369. export class SelectorGroup {
  64370. /** name of SelectorGroup */
  64371. name: string;
  64372. private _groupPanel;
  64373. private _selectors;
  64374. private _groupHeader;
  64375. /**
  64376. * Creates a new SelectorGroup
  64377. * @param name of group, used as a group heading
  64378. */
  64379. constructor(
  64380. /** name of SelectorGroup */
  64381. name: string);
  64382. /** Gets the groupPanel of the SelectorGroup */
  64383. readonly groupPanel: StackPanel;
  64384. /** Gets the selectors array */
  64385. readonly selectors: StackPanel[];
  64386. /** Gets and sets the group header */
  64387. header: string;
  64388. /** @hidden */
  64389. private _addGroupHeader;
  64390. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  64391. /** Removes the selector at the given position
  64392. * @param selectorNb the position of the selector within the group
  64393. */
  64394. removeSelector(selectorNb: number): void;
  64395. }
  64396. /** Class used to create a CheckboxGroup
  64397. * which contains groups of checkbox buttons
  64398. */
  64399. export class CheckboxGroup extends SelectorGroup {
  64400. /** Adds a checkbox as a control
  64401. * @param text is the label for the selector
  64402. * @param func is the function called when the Selector is checked
  64403. * @param checked is true when Selector is checked
  64404. */
  64405. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  64406. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64407. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64408. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64409. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64410. }
  64411. /** Class used to create a RadioGroup
  64412. * which contains groups of radio buttons
  64413. */
  64414. export class RadioGroup extends SelectorGroup {
  64415. private _selectNb;
  64416. /** Adds a radio button as a control
  64417. * @param label is the label for the selector
  64418. * @param func is the function called when the Selector is checked
  64419. * @param checked is true when Selector is checked
  64420. */
  64421. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  64422. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64423. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64424. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64425. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64426. }
  64427. /** Class used to create a SliderGroup
  64428. * which contains groups of slider buttons
  64429. */
  64430. export class SliderGroup extends SelectorGroup {
  64431. /**
  64432. * Adds a slider to the SelectorGroup
  64433. * @param label is the label for the SliderBar
  64434. * @param func is the function called when the Slider moves
  64435. * @param unit is a string describing the units used, eg degrees or metres
  64436. * @param min is the minimum value for the Slider
  64437. * @param max is the maximum value for the Slider
  64438. * @param value is the start value for the Slider between min and max
  64439. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  64440. */
  64441. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  64442. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64443. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64444. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64445. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64446. }
  64447. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  64448. * @see http://doc.babylonjs.com/how_to/selector
  64449. */
  64450. export class SelectionPanel extends Rectangle {
  64451. /** name of SelectionPanel */
  64452. name: string;
  64453. /** an array of SelectionGroups */
  64454. groups: SelectorGroup[];
  64455. private _panel;
  64456. private _buttonColor;
  64457. private _buttonBackground;
  64458. private _headerColor;
  64459. private _barColor;
  64460. private _barHeight;
  64461. private _spacerHeight;
  64462. private _labelColor;
  64463. private _groups;
  64464. private _bars;
  64465. /**
  64466. * Creates a new SelectionPanel
  64467. * @param name of SelectionPanel
  64468. * @param groups is an array of SelectionGroups
  64469. */
  64470. constructor(
  64471. /** name of SelectionPanel */
  64472. name: string,
  64473. /** an array of SelectionGroups */
  64474. groups?: SelectorGroup[]);
  64475. protected _getTypeName(): string;
  64476. /** Gets or sets the headerColor */
  64477. headerColor: string;
  64478. private _setHeaderColor;
  64479. /** Gets or sets the button color */
  64480. buttonColor: string;
  64481. private _setbuttonColor;
  64482. /** Gets or sets the label color */
  64483. labelColor: string;
  64484. private _setLabelColor;
  64485. /** Gets or sets the button background */
  64486. buttonBackground: string;
  64487. private _setButtonBackground;
  64488. /** Gets or sets the color of separator bar */
  64489. barColor: string;
  64490. private _setBarColor;
  64491. /** Gets or sets the height of separator bar */
  64492. barHeight: string;
  64493. private _setBarHeight;
  64494. /** Gets or sets the height of spacers*/
  64495. spacerHeight: string;
  64496. private _setSpacerHeight;
  64497. /** Adds a bar between groups */
  64498. private _addSpacer;
  64499. /** Add a group to the selection panel
  64500. * @param group is the selector group to add
  64501. */
  64502. addGroup(group: SelectorGroup): void;
  64503. /** Remove the group from the given position
  64504. * @param groupNb is the position of the group in the list
  64505. */
  64506. removeGroup(groupNb: number): void;
  64507. /** Change a group header label
  64508. * @param label is the new group header label
  64509. * @param groupNb is the number of the group to relabel
  64510. * */
  64511. setHeaderName(label: string, groupNb: number): void;
  64512. /** Change selector label to the one given
  64513. * @param label is the new selector label
  64514. * @param groupNb is the number of the groupcontaining the selector
  64515. * @param selectorNb is the number of the selector within a group to relabel
  64516. * */
  64517. relabel(label: string, groupNb: number, selectorNb: number): void;
  64518. /** For a given group position remove the selector at the given position
  64519. * @param groupNb is the number of the group to remove the selector from
  64520. * @param selectorNb is the number of the selector within the group
  64521. */
  64522. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  64523. /** For a given group position of correct type add a checkbox button
  64524. * @param groupNb is the number of the group to remove the selector from
  64525. * @param label is the label for the selector
  64526. * @param func is the function called when the Selector is checked
  64527. * @param checked is true when Selector is checked
  64528. */
  64529. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64530. /** For a given group position of correct type add a radio button
  64531. * @param groupNb is the number of the group to remove the selector from
  64532. * @param label is the label for the selector
  64533. * @param func is the function called when the Selector is checked
  64534. * @param checked is true when Selector is checked
  64535. */
  64536. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64537. /**
  64538. * For a given slider group add a slider
  64539. * @param groupNb is the number of the group to add the slider to
  64540. * @param label is the label for the Slider
  64541. * @param func is the function called when the Slider moves
  64542. * @param unit is a string describing the units used, eg degrees or metres
  64543. * @param min is the minimum value for the Slider
  64544. * @param max is the maximum value for the Slider
  64545. * @param value is the start value for the Slider between min and max
  64546. * @param onVal is the function used to format the value displayed, eg radians to degrees
  64547. */
  64548. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  64549. }
  64550. }
  64551. declare module BABYLON.GUI {
  64552. /**
  64553. * Class used to hold a the container for ScrollViewer
  64554. * @hidden
  64555. */
  64556. export class _ScrollViewerWindow extends Container {
  64557. parentClientWidth: number;
  64558. parentClientHeight: number;
  64559. /**
  64560. * Creates a new ScrollViewerWindow
  64561. * @param name of ScrollViewerWindow
  64562. */
  64563. constructor(name?: string);
  64564. protected _getTypeName(): string;
  64565. /** @hidden */
  64566. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64567. protected _postMeasure(): void;
  64568. }
  64569. }
  64570. declare module BABYLON.GUI {
  64571. /**
  64572. * Class used to create slider controls
  64573. */
  64574. export class ScrollBar extends BaseSlider {
  64575. name?: string | undefined;
  64576. private _background;
  64577. private _borderColor;
  64578. private _thumbMeasure;
  64579. /** Gets or sets border color */
  64580. borderColor: string;
  64581. /** Gets or sets background color */
  64582. background: string;
  64583. /**
  64584. * Creates a new Slider
  64585. * @param name defines the control name
  64586. */
  64587. constructor(name?: string | undefined);
  64588. protected _getTypeName(): string;
  64589. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  64590. private _first;
  64591. private _originX;
  64592. private _originY;
  64593. /** @hidden */
  64594. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64595. }
  64596. }
  64597. declare module BABYLON.GUI {
  64598. /**
  64599. * Class used to hold a viewer window and sliders in a grid
  64600. */
  64601. export class ScrollViewer extends Rectangle {
  64602. private _grid;
  64603. private _horizontalBarSpace;
  64604. private _verticalBarSpace;
  64605. private _dragSpace;
  64606. private _horizontalBar;
  64607. private _verticalBar;
  64608. private _barColor;
  64609. private _barBackground;
  64610. private _barSize;
  64611. private _endLeft;
  64612. private _endTop;
  64613. private _window;
  64614. private _pointerIsOver;
  64615. private _wheelPrecision;
  64616. private _onPointerObserver;
  64617. private _clientWidth;
  64618. private _clientHeight;
  64619. /**
  64620. * Gets the horizontal scrollbar
  64621. */
  64622. readonly horizontalBar: ScrollBar;
  64623. /**
  64624. * Gets the vertical scrollbar
  64625. */
  64626. readonly verticalBar: ScrollBar;
  64627. /**
  64628. * Adds a new control to the current container
  64629. * @param control defines the control to add
  64630. * @returns the current container
  64631. */
  64632. addControl(control: BABYLON.Nullable<Control>): Container;
  64633. /**
  64634. * Removes a control from the current container
  64635. * @param control defines the control to remove
  64636. * @returns the current container
  64637. */
  64638. removeControl(control: Control): Container;
  64639. /** Gets the list of children */
  64640. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  64641. /**
  64642. * Creates a new ScrollViewer
  64643. * @param name of ScrollViewer
  64644. */
  64645. constructor(name?: string);
  64646. /** Reset the scroll viewer window to initial size */
  64647. resetWindow(): void;
  64648. protected _getTypeName(): string;
  64649. private _buildClientSizes;
  64650. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64651. protected _postMeasure(): void;
  64652. /**
  64653. * Gets or sets the mouse wheel precision
  64654. * from 0 to 1 with a default value of 0.05
  64655. * */
  64656. wheelPrecision: number;
  64657. /** Gets or sets the bar color */
  64658. barColor: string;
  64659. /** Gets or sets the size of the bar */
  64660. barSize: number;
  64661. /** Gets or sets the bar background */
  64662. barBackground: string;
  64663. /** @hidden */
  64664. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  64665. /** @hidden */
  64666. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64667. /** Releases associated resources */
  64668. dispose(): void;
  64669. }
  64670. }
  64671. declare module BABYLON.GUI {
  64672. /** Class used to render a grid */
  64673. export class DisplayGrid extends Control {
  64674. name?: string | undefined;
  64675. private _cellWidth;
  64676. private _cellHeight;
  64677. private _minorLineTickness;
  64678. private _minorLineColor;
  64679. private _majorLineTickness;
  64680. private _majorLineColor;
  64681. private _majorLineFrequency;
  64682. private _background;
  64683. private _displayMajorLines;
  64684. private _displayMinorLines;
  64685. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  64686. displayMinorLines: boolean;
  64687. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  64688. displayMajorLines: boolean;
  64689. /** Gets or sets background color (Black by default) */
  64690. background: string;
  64691. /** Gets or sets the width of each cell (20 by default) */
  64692. cellWidth: number;
  64693. /** Gets or sets the height of each cell (20 by default) */
  64694. cellHeight: number;
  64695. /** Gets or sets the tickness of minor lines (1 by default) */
  64696. minorLineTickness: number;
  64697. /** Gets or sets the color of minor lines (DarkGray by default) */
  64698. minorLineColor: string;
  64699. /** Gets or sets the tickness of major lines (2 by default) */
  64700. majorLineTickness: number;
  64701. /** Gets or sets the color of major lines (White by default) */
  64702. majorLineColor: string;
  64703. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  64704. majorLineFrequency: number;
  64705. /**
  64706. * Creates a new GridDisplayRectangle
  64707. * @param name defines the control name
  64708. */
  64709. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  64710. protected _getTypeName(): string;
  64711. }
  64712. }
  64713. declare module BABYLON.GUI {
  64714. /**
  64715. * Class used to create slider controls based on images
  64716. */
  64717. export class ImageBasedSlider extends BaseSlider {
  64718. name?: string | undefined;
  64719. private _backgroundImage;
  64720. private _thumbImage;
  64721. private _valueBarImage;
  64722. private _tempMeasure;
  64723. displayThumb: boolean;
  64724. /**
  64725. * Gets or sets the image used to render the background
  64726. */
  64727. backgroundImage: Image;
  64728. /**
  64729. * Gets or sets the image used to render the value bar
  64730. */
  64731. valueBarImage: Image;
  64732. /**
  64733. * Gets or sets the image used to render the thumb
  64734. */
  64735. thumbImage: Image;
  64736. /**
  64737. * Creates a new ImageBasedSlider
  64738. * @param name defines the control name
  64739. */
  64740. constructor(name?: string | undefined);
  64741. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64742. }
  64743. }
  64744. declare module BABYLON.GUI {
  64745. /**
  64746. * Forcing an export so that this code will execute
  64747. * @hidden
  64748. */
  64749. const name = "Statics";
  64750. }
  64751. declare module BABYLON.GUI {
  64752. /**
  64753. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  64754. */
  64755. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  64756. /**
  64757. * Define the instrumented AdvancedDynamicTexture.
  64758. */
  64759. texture: AdvancedDynamicTexture;
  64760. private _captureRenderTime;
  64761. private _renderTime;
  64762. private _captureLayoutTime;
  64763. private _layoutTime;
  64764. private _onBeginRenderObserver;
  64765. private _onEndRenderObserver;
  64766. private _onBeginLayoutObserver;
  64767. private _onEndLayoutObserver;
  64768. /**
  64769. * Gets the perf counter used to capture render time
  64770. */
  64771. readonly renderTimeCounter: BABYLON.PerfCounter;
  64772. /**
  64773. * Gets the perf counter used to capture layout time
  64774. */
  64775. readonly layoutTimeCounter: BABYLON.PerfCounter;
  64776. /**
  64777. * Enable or disable the render time capture
  64778. */
  64779. captureRenderTime: boolean;
  64780. /**
  64781. * Enable or disable the layout time capture
  64782. */
  64783. captureLayoutTime: boolean;
  64784. /**
  64785. * Instantiates a new advanced dynamic texture instrumentation.
  64786. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  64787. * @param texture Defines the AdvancedDynamicTexture to instrument
  64788. */
  64789. constructor(
  64790. /**
  64791. * Define the instrumented AdvancedDynamicTexture.
  64792. */
  64793. texture: AdvancedDynamicTexture);
  64794. /**
  64795. * Dispose and release associated resources.
  64796. */
  64797. dispose(): void;
  64798. }
  64799. }
  64800. declare module BABYLON.GUI {
  64801. /**
  64802. * Class used to create containers for controls
  64803. */
  64804. export class Container3D extends Control3D {
  64805. private _blockLayout;
  64806. /**
  64807. * Gets the list of child controls
  64808. */
  64809. protected _children: Control3D[];
  64810. /**
  64811. * Gets the list of child controls
  64812. */
  64813. readonly children: Array<Control3D>;
  64814. /**
  64815. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  64816. * This is helpful to optimize layout operation when adding multiple children in a row
  64817. */
  64818. blockLayout: boolean;
  64819. /**
  64820. * Creates a new container
  64821. * @param name defines the container name
  64822. */
  64823. constructor(name?: string);
  64824. /**
  64825. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  64826. * @returns the current container
  64827. */
  64828. updateLayout(): Container3D;
  64829. /**
  64830. * Gets a boolean indicating if the given control is in the children of this control
  64831. * @param control defines the control to check
  64832. * @returns true if the control is in the child list
  64833. */
  64834. containsControl(control: Control3D): boolean;
  64835. /**
  64836. * Adds a control to the children of this control
  64837. * @param control defines the control to add
  64838. * @returns the current container
  64839. */
  64840. addControl(control: Control3D): Container3D;
  64841. /**
  64842. * This function will be called everytime a new control is added
  64843. */
  64844. protected _arrangeChildren(): void;
  64845. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64846. /**
  64847. * Removes a control from the children of this control
  64848. * @param control defines the control to remove
  64849. * @returns the current container
  64850. */
  64851. removeControl(control: Control3D): Container3D;
  64852. protected _getTypeName(): string;
  64853. /**
  64854. * Releases all associated resources
  64855. */
  64856. dispose(): void;
  64857. /** Control rotation will remain unchanged */
  64858. static readonly UNSET_ORIENTATION: number;
  64859. /** Control will rotate to make it look at sphere central axis */
  64860. static readonly FACEORIGIN_ORIENTATION: number;
  64861. /** Control will rotate to make it look back at sphere central axis */
  64862. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  64863. /** Control will rotate to look at z axis (0, 0, 1) */
  64864. static readonly FACEFORWARD_ORIENTATION: number;
  64865. /** Control will rotate to look at negative z axis (0, 0, -1) */
  64866. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  64867. }
  64868. }
  64869. declare module BABYLON.GUI {
  64870. /**
  64871. * Class used to manage 3D user interface
  64872. * @see http://doc.babylonjs.com/how_to/gui3d
  64873. */
  64874. export class GUI3DManager implements BABYLON.IDisposable {
  64875. private _scene;
  64876. private _sceneDisposeObserver;
  64877. private _utilityLayer;
  64878. private _rootContainer;
  64879. private _pointerObserver;
  64880. private _pointerOutObserver;
  64881. /** @hidden */ private _lastPickedControl: Control3D;
  64882. /** @hidden */ private _lastControlOver: {
  64883. [pointerId: number]: Control3D;
  64884. };
  64885. /** @hidden */ private _lastControlDown: {
  64886. [pointerId: number]: Control3D;
  64887. };
  64888. /**
  64889. * BABYLON.Observable raised when the point picked by the pointer events changed
  64890. */
  64891. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  64892. /** @hidden */ private _sharedMaterials: {
  64893. [key: string]: BABYLON.Material;
  64894. };
  64895. /** Gets the hosting scene */
  64896. readonly scene: BABYLON.Scene;
  64897. /** Gets associated utility layer */
  64898. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  64899. /**
  64900. * Creates a new GUI3DManager
  64901. * @param scene
  64902. */
  64903. constructor(scene?: BABYLON.Scene);
  64904. private _handlePointerOut;
  64905. private _doPicking;
  64906. /**
  64907. * Gets the root container
  64908. */
  64909. readonly rootContainer: Container3D;
  64910. /**
  64911. * Gets a boolean indicating if the given control is in the root child list
  64912. * @param control defines the control to check
  64913. * @returns true if the control is in the root child list
  64914. */
  64915. containsControl(control: Control3D): boolean;
  64916. /**
  64917. * Adds a control to the root child list
  64918. * @param control defines the control to add
  64919. * @returns the current manager
  64920. */
  64921. addControl(control: Control3D): GUI3DManager;
  64922. /**
  64923. * Removes a control from the root child list
  64924. * @param control defines the control to remove
  64925. * @returns the current container
  64926. */
  64927. removeControl(control: Control3D): GUI3DManager;
  64928. /**
  64929. * Releases all associated resources
  64930. */
  64931. dispose(): void;
  64932. }
  64933. }
  64934. declare module BABYLON.GUI {
  64935. /**
  64936. * Class used to transport BABYLON.Vector3 information for pointer events
  64937. */
  64938. export class Vector3WithInfo extends BABYLON.Vector3 {
  64939. /** defines the current mouse button index */
  64940. buttonIndex: number;
  64941. /**
  64942. * Creates a new Vector3WithInfo
  64943. * @param source defines the vector3 data to transport
  64944. * @param buttonIndex defines the current mouse button index
  64945. */
  64946. constructor(source: BABYLON.Vector3,
  64947. /** defines the current mouse button index */
  64948. buttonIndex?: number);
  64949. }
  64950. }
  64951. declare module BABYLON.GUI {
  64952. /**
  64953. * Class used as base class for controls
  64954. */
  64955. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  64956. /** Defines the control name */
  64957. name?: string | undefined;
  64958. /** @hidden */ private _host: GUI3DManager;
  64959. private _node;
  64960. private _downCount;
  64961. private _enterCount;
  64962. private _downPointerIds;
  64963. private _isVisible;
  64964. /** Gets or sets the control position in world space */
  64965. position: BABYLON.Vector3;
  64966. /** Gets or sets the control scaling in world space */
  64967. scaling: BABYLON.Vector3;
  64968. /** Callback used to start pointer enter animation */
  64969. pointerEnterAnimation: () => void;
  64970. /** Callback used to start pointer out animation */
  64971. pointerOutAnimation: () => void;
  64972. /** Callback used to start pointer down animation */
  64973. pointerDownAnimation: () => void;
  64974. /** Callback used to start pointer up animation */
  64975. pointerUpAnimation: () => void;
  64976. /**
  64977. * An event triggered when the pointer move over the control
  64978. */
  64979. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  64980. /**
  64981. * An event triggered when the pointer move out of the control
  64982. */
  64983. onPointerOutObservable: BABYLON.Observable<Control3D>;
  64984. /**
  64985. * An event triggered when the pointer taps the control
  64986. */
  64987. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  64988. /**
  64989. * An event triggered when pointer is up
  64990. */
  64991. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  64992. /**
  64993. * An event triggered when a control is clicked on (with a mouse)
  64994. */
  64995. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  64996. /**
  64997. * An event triggered when pointer enters the control
  64998. */
  64999. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65000. /**
  65001. * Gets or sets the parent container
  65002. */
  65003. parent: BABYLON.Nullable<Container3D>;
  65004. private _behaviors;
  65005. /**
  65006. * Gets the list of attached behaviors
  65007. * @see http://doc.babylonjs.com/features/behaviour
  65008. */
  65009. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65010. /**
  65011. * Attach a behavior to the control
  65012. * @see http://doc.babylonjs.com/features/behaviour
  65013. * @param behavior defines the behavior to attach
  65014. * @returns the current control
  65015. */
  65016. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65017. /**
  65018. * Remove an attached behavior
  65019. * @see http://doc.babylonjs.com/features/behaviour
  65020. * @param behavior defines the behavior to attach
  65021. * @returns the current control
  65022. */
  65023. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65024. /**
  65025. * Gets an attached behavior by name
  65026. * @param name defines the name of the behavior to look for
  65027. * @see http://doc.babylonjs.com/features/behaviour
  65028. * @returns null if behavior was not found else the requested behavior
  65029. */
  65030. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65031. /** Gets or sets a boolean indicating if the control is visible */
  65032. isVisible: boolean;
  65033. /**
  65034. * Creates a new control
  65035. * @param name defines the control name
  65036. */
  65037. constructor(
  65038. /** Defines the control name */
  65039. name?: string | undefined);
  65040. /**
  65041. * Gets a string representing the class name
  65042. */
  65043. readonly typeName: string;
  65044. /**
  65045. * Get the current class name of the control.
  65046. * @returns current class name
  65047. */
  65048. getClassName(): string;
  65049. protected _getTypeName(): string;
  65050. /**
  65051. * Gets the transform node used by this control
  65052. */
  65053. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65054. /**
  65055. * Gets the mesh used to render this control
  65056. */
  65057. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65058. /**
  65059. * Link the control as child of the given node
  65060. * @param node defines the node to link to. Use null to unlink the control
  65061. * @returns the current control
  65062. */
  65063. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65064. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  65065. /**
  65066. * Node creation.
  65067. * Can be overriden by children
  65068. * @param scene defines the scene where the node must be attached
  65069. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65070. */
  65071. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65072. /**
  65073. * Affect a material to the given mesh
  65074. * @param mesh defines the mesh which will represent the control
  65075. */
  65076. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65077. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  65078. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  65079. /** @hidden */ private _onPointerOut(target: Control3D): void;
  65080. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65081. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65082. /** @hidden */
  65083. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65084. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65085. /** @hidden */ private _disposeNode(): void;
  65086. /**
  65087. * Releases all associated resources
  65088. */
  65089. dispose(): void;
  65090. }
  65091. }
  65092. declare module BABYLON.GUI {
  65093. /**
  65094. * Class used as a root to all buttons
  65095. */
  65096. export class AbstractButton3D extends Control3D {
  65097. /**
  65098. * Creates a new button
  65099. * @param name defines the control name
  65100. */
  65101. constructor(name?: string);
  65102. protected _getTypeName(): string;
  65103. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65104. }
  65105. }
  65106. declare module BABYLON.GUI {
  65107. /**
  65108. * Class used to create a button in 3D
  65109. */
  65110. export class Button3D extends AbstractButton3D {
  65111. /** @hidden */
  65112. protected _currentMaterial: BABYLON.Material;
  65113. private _facadeTexture;
  65114. private _content;
  65115. private _contentResolution;
  65116. private _contentScaleRatio;
  65117. /**
  65118. * Gets or sets the texture resolution used to render content (512 by default)
  65119. */
  65120. contentResolution: BABYLON.int;
  65121. /**
  65122. * Gets or sets the texture scale ratio used to render content (2 by default)
  65123. */
  65124. contentScaleRatio: number;
  65125. protected _disposeFacadeTexture(): void;
  65126. protected _resetContent(): void;
  65127. /**
  65128. * Creates a new button
  65129. * @param name defines the control name
  65130. */
  65131. constructor(name?: string);
  65132. /**
  65133. * Gets or sets the GUI 2D content used to display the button's facade
  65134. */
  65135. content: Control;
  65136. /**
  65137. * Apply the facade texture (created from the content property).
  65138. * This function can be overloaded by child classes
  65139. * @param facadeTexture defines the AdvancedDynamicTexture to use
  65140. */
  65141. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65142. protected _getTypeName(): string;
  65143. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65144. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65145. /**
  65146. * Releases all associated resources
  65147. */
  65148. dispose(): void;
  65149. }
  65150. }
  65151. declare module BABYLON.GUI {
  65152. /**
  65153. * Abstract class used to create a container panel deployed on the surface of a volume
  65154. */
  65155. export abstract class VolumeBasedPanel extends Container3D {
  65156. private _columns;
  65157. private _rows;
  65158. private _rowThenColum;
  65159. private _orientation;
  65160. protected _cellWidth: number;
  65161. protected _cellHeight: number;
  65162. /**
  65163. * Gets or sets the distance between elements
  65164. */
  65165. margin: number;
  65166. /**
  65167. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65168. * | Value | Type | Description |
  65169. * | ----- | ----------------------------------- | ----------- |
  65170. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65171. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65172. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65173. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65174. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65175. */
  65176. orientation: number;
  65177. /**
  65178. * Gets or sets the number of columns requested (10 by default).
  65179. * The panel will automatically compute the number of rows based on number of child controls.
  65180. */
  65181. columns: BABYLON.int;
  65182. /**
  65183. * Gets or sets a the number of rows requested.
  65184. * The panel will automatically compute the number of columns based on number of child controls.
  65185. */
  65186. rows: BABYLON.int;
  65187. /**
  65188. * Creates new VolumeBasedPanel
  65189. */
  65190. constructor();
  65191. protected _arrangeChildren(): void;
  65192. /** Child classes must implement this function to provide correct control positioning */
  65193. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65194. /** Child classes can implement this function to provide additional processing */
  65195. protected _finalProcessing(): void;
  65196. }
  65197. }
  65198. declare module BABYLON.GUI {
  65199. /**
  65200. * Class used to create a container panel deployed on the surface of a cylinder
  65201. */
  65202. export class CylinderPanel extends VolumeBasedPanel {
  65203. private _radius;
  65204. /**
  65205. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65206. */
  65207. radius: BABYLON.float;
  65208. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65209. private _cylindricalMapping;
  65210. }
  65211. }
  65212. declare module BABYLON.GUI {
  65213. /** @hidden */
  65214. export var fluentVertexShader: {
  65215. name: string;
  65216. shader: string;
  65217. };
  65218. }
  65219. declare module BABYLON.GUI {
  65220. /** @hidden */
  65221. export var fluentPixelShader: {
  65222. name: string;
  65223. shader: string;
  65224. };
  65225. }
  65226. declare module BABYLON.GUI {
  65227. /** @hidden */
  65228. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65229. INNERGLOW: boolean;
  65230. BORDER: boolean;
  65231. HOVERLIGHT: boolean;
  65232. TEXTURE: boolean;
  65233. constructor();
  65234. }
  65235. /**
  65236. * Class used to render controls with fluent desgin
  65237. */
  65238. export class FluentMaterial extends BABYLON.PushMaterial {
  65239. /**
  65240. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65241. */
  65242. innerGlowColorIntensity: number;
  65243. /**
  65244. * Gets or sets the inner glow color (white by default)
  65245. */
  65246. innerGlowColor: BABYLON.Color3;
  65247. /**
  65248. * Gets or sets alpha value (default is 1.0)
  65249. */
  65250. alpha: number;
  65251. /**
  65252. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65253. */
  65254. albedoColor: BABYLON.Color3;
  65255. /**
  65256. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65257. */
  65258. renderBorders: boolean;
  65259. /**
  65260. * Gets or sets border width (default is 0.5)
  65261. */
  65262. borderWidth: number;
  65263. /**
  65264. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  65265. */
  65266. edgeSmoothingValue: number;
  65267. /**
  65268. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  65269. */
  65270. borderMinValue: number;
  65271. /**
  65272. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  65273. */
  65274. renderHoverLight: boolean;
  65275. /**
  65276. * Gets or sets the radius used to render the hover light (default is 1.0)
  65277. */
  65278. hoverRadius: number;
  65279. /**
  65280. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  65281. */
  65282. hoverColor: BABYLON.Color4;
  65283. /**
  65284. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  65285. */
  65286. hoverPosition: BABYLON.Vector3;
  65287. private _albedoTexture;
  65288. /** Gets or sets the texture to use for albedo color */
  65289. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65290. /**
  65291. * Creates a new Fluent material
  65292. * @param name defines the name of the material
  65293. * @param scene defines the hosting scene
  65294. */
  65295. constructor(name: string, scene: BABYLON.Scene);
  65296. needAlphaBlending(): boolean;
  65297. needAlphaTesting(): boolean;
  65298. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65299. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65300. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65301. getActiveTextures(): BABYLON.BaseTexture[];
  65302. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65303. dispose(forceDisposeEffect?: boolean): void;
  65304. clone(name: string): FluentMaterial;
  65305. serialize(): any;
  65306. getClassName(): string;
  65307. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  65308. }
  65309. }
  65310. declare module BABYLON.GUI {
  65311. /**
  65312. * Class used to create a holographic button in 3D
  65313. */
  65314. export class HolographicButton extends Button3D {
  65315. private _backPlate;
  65316. private _textPlate;
  65317. private _frontPlate;
  65318. private _text;
  65319. private _imageUrl;
  65320. private _shareMaterials;
  65321. private _frontMaterial;
  65322. private _backMaterial;
  65323. private _plateMaterial;
  65324. private _pickedPointObserver;
  65325. private _tooltipFade;
  65326. private _tooltipTextBlock;
  65327. private _tooltipTexture;
  65328. private _tooltipMesh;
  65329. private _tooltipHoverObserver;
  65330. private _tooltipOutObserver;
  65331. private _disposeTooltip;
  65332. /**
  65333. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  65334. */
  65335. tooltipText: BABYLON.Nullable<string>;
  65336. /**
  65337. * Gets or sets text for the button
  65338. */
  65339. text: string;
  65340. /**
  65341. * Gets or sets the image url for the button
  65342. */
  65343. imageUrl: string;
  65344. /**
  65345. * Gets the back material used by this button
  65346. */
  65347. readonly backMaterial: FluentMaterial;
  65348. /**
  65349. * Gets the front material used by this button
  65350. */
  65351. readonly frontMaterial: FluentMaterial;
  65352. /**
  65353. * Gets the plate material used by this button
  65354. */
  65355. readonly plateMaterial: BABYLON.StandardMaterial;
  65356. /**
  65357. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  65358. */
  65359. readonly shareMaterials: boolean;
  65360. /**
  65361. * Creates a new button
  65362. * @param name defines the control name
  65363. */
  65364. constructor(name?: string, shareMaterials?: boolean);
  65365. protected _getTypeName(): string;
  65366. private _rebuildContent;
  65367. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65368. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65369. private _createBackMaterial;
  65370. private _createFrontMaterial;
  65371. private _createPlateMaterial;
  65372. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  65373. /**
  65374. * Releases all associated resources
  65375. */
  65376. dispose(): void;
  65377. }
  65378. }
  65379. declare module BABYLON.GUI {
  65380. /**
  65381. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  65382. */
  65383. export class MeshButton3D extends Button3D {
  65384. /** @hidden */
  65385. protected _currentMesh: BABYLON.Mesh;
  65386. /**
  65387. * Creates a new 3D button based on a mesh
  65388. * @param mesh mesh to become a 3D button
  65389. * @param name defines the control name
  65390. */
  65391. constructor(mesh: BABYLON.Mesh, name?: string);
  65392. protected _getTypeName(): string;
  65393. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65394. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65395. }
  65396. }
  65397. declare module BABYLON.GUI {
  65398. /**
  65399. * Class used to create a container panel deployed on the surface of a plane
  65400. */
  65401. export class PlanePanel extends VolumeBasedPanel {
  65402. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65403. }
  65404. }
  65405. declare module BABYLON.GUI {
  65406. /**
  65407. * Class used to create a container panel where items get randomized planar mapping
  65408. */
  65409. export class ScatterPanel extends VolumeBasedPanel {
  65410. private _iteration;
  65411. /**
  65412. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  65413. */
  65414. iteration: BABYLON.float;
  65415. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65416. private _scatterMapping;
  65417. protected _finalProcessing(): void;
  65418. }
  65419. }
  65420. declare module BABYLON.GUI {
  65421. /**
  65422. * Class used to create a container panel deployed on the surface of a sphere
  65423. */
  65424. export class SpherePanel extends VolumeBasedPanel {
  65425. private _radius;
  65426. /**
  65427. * Gets or sets the radius of the sphere where to project controls (5 by default)
  65428. */
  65429. radius: BABYLON.float;
  65430. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65431. private _sphericalMapping;
  65432. }
  65433. }
  65434. declare module BABYLON.GUI {
  65435. /**
  65436. * Class used to create a stack panel in 3D on XY plane
  65437. */
  65438. export class StackPanel3D extends Container3D {
  65439. private _isVertical;
  65440. /**
  65441. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  65442. */
  65443. isVertical: boolean;
  65444. /**
  65445. * Gets or sets the distance between elements
  65446. */
  65447. margin: number;
  65448. /**
  65449. * Creates new StackPanel
  65450. * @param isVertical
  65451. */
  65452. constructor(isVertical?: boolean);
  65453. protected _arrangeChildren(): void;
  65454. }
  65455. }
  65456. declare module BABYLON {
  65457. /**
  65458. * Mode that determines the coordinate system to use.
  65459. */
  65460. export enum GLTFLoaderCoordinateSystemMode {
  65461. /**
  65462. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  65463. */
  65464. AUTO = 0,
  65465. /**
  65466. * Sets the useRightHandedSystem flag on the scene.
  65467. */
  65468. FORCE_RIGHT_HANDED = 1
  65469. }
  65470. /**
  65471. * Mode that determines what animations will start.
  65472. */
  65473. export enum GLTFLoaderAnimationStartMode {
  65474. /**
  65475. * No animation will start.
  65476. */
  65477. NONE = 0,
  65478. /**
  65479. * The first animation will start.
  65480. */
  65481. FIRST = 1,
  65482. /**
  65483. * All animations will start.
  65484. */
  65485. ALL = 2
  65486. }
  65487. /**
  65488. * Interface that contains the data for the glTF asset.
  65489. */
  65490. export interface IGLTFLoaderData {
  65491. /**
  65492. * Object that represents the glTF JSON.
  65493. */
  65494. json: Object;
  65495. /**
  65496. * The BIN chunk of a binary glTF.
  65497. */
  65498. bin: Nullable<ArrayBufferView>;
  65499. }
  65500. /**
  65501. * Interface for extending the loader.
  65502. */
  65503. export interface IGLTFLoaderExtension {
  65504. /**
  65505. * The name of this extension.
  65506. */
  65507. readonly name: string;
  65508. /**
  65509. * Defines whether this extension is enabled.
  65510. */
  65511. enabled: boolean;
  65512. }
  65513. /**
  65514. * Loader state.
  65515. */
  65516. export enum GLTFLoaderState {
  65517. /**
  65518. * The asset is loading.
  65519. */
  65520. LOADING = 0,
  65521. /**
  65522. * The asset is ready for rendering.
  65523. */
  65524. READY = 1,
  65525. /**
  65526. * The asset is completely loaded.
  65527. */
  65528. COMPLETE = 2
  65529. }
  65530. /** @hidden */
  65531. export interface IGLTFLoader extends IDisposable {
  65532. readonly state: Nullable<GLTFLoaderState>;
  65533. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  65534. meshes: AbstractMesh[];
  65535. particleSystems: IParticleSystem[];
  65536. skeletons: Skeleton[];
  65537. animationGroups: AnimationGroup[];
  65538. }>;
  65539. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  65540. }
  65541. /**
  65542. * File loader for loading glTF files into a scene.
  65543. */
  65544. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65545. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65546. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65547. /**
  65548. * Raised when the asset has been parsed
  65549. */
  65550. onParsedObservable: Observable<IGLTFLoaderData>;
  65551. private _onParsedObserver;
  65552. /**
  65553. * Raised when the asset has been parsed
  65554. */
  65555. onParsed: (loaderData: IGLTFLoaderData) => void;
  65556. /**
  65557. * 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.
  65558. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  65559. * Defaults to true.
  65560. * @hidden
  65561. */
  65562. static IncrementalLoading: boolean;
  65563. /**
  65564. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  65565. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  65566. * @hidden
  65567. */
  65568. static HomogeneousCoordinates: boolean;
  65569. /**
  65570. * The coordinate system mode. Defaults to AUTO.
  65571. */
  65572. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  65573. /**
  65574. * The animation start mode. Defaults to FIRST.
  65575. */
  65576. animationStartMode: GLTFLoaderAnimationStartMode;
  65577. /**
  65578. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  65579. */
  65580. compileMaterials: boolean;
  65581. /**
  65582. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  65583. */
  65584. useClipPlane: boolean;
  65585. /**
  65586. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  65587. */
  65588. compileShadowGenerators: boolean;
  65589. /**
  65590. * Defines if the Alpha blended materials are only applied as coverage.
  65591. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  65592. * If true, no extra effects are applied to transparent pixels.
  65593. */
  65594. transparencyAsCoverage: boolean;
  65595. /**
  65596. * Function called before loading a url referenced by the asset.
  65597. */
  65598. preprocessUrlAsync: (url: string) => Promise<string>;
  65599. /**
  65600. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65601. */
  65602. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  65603. private _onMeshLoadedObserver;
  65604. /**
  65605. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65606. */
  65607. onMeshLoaded: (mesh: AbstractMesh) => void;
  65608. /**
  65609. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  65610. */
  65611. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  65612. private _onTextureLoadedObserver;
  65613. /**
  65614. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  65615. */
  65616. onTextureLoaded: (texture: BaseTexture) => void;
  65617. /**
  65618. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  65619. */
  65620. readonly onMaterialLoadedObservable: Observable<Material>;
  65621. private _onMaterialLoadedObserver;
  65622. /**
  65623. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  65624. */
  65625. onMaterialLoaded: (material: Material) => void;
  65626. /**
  65627. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  65628. */
  65629. readonly onCameraLoadedObservable: Observable<Camera>;
  65630. private _onCameraLoadedObserver;
  65631. /**
  65632. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  65633. */
  65634. onCameraLoaded: (camera: Camera) => void;
  65635. /**
  65636. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  65637. * For assets with LODs, raised when all of the LODs are complete.
  65638. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65639. */
  65640. readonly onCompleteObservable: Observable<void>;
  65641. private _onCompleteObserver;
  65642. /**
  65643. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  65644. * For assets with LODs, raised when all of the LODs are complete.
  65645. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65646. */
  65647. onComplete: () => void;
  65648. /**
  65649. * Observable raised when an error occurs.
  65650. */
  65651. readonly onErrorObservable: Observable<any>;
  65652. private _onErrorObserver;
  65653. /**
  65654. * Callback raised when an error occurs.
  65655. */
  65656. onError: (reason: any) => void;
  65657. /**
  65658. * Observable raised after the loader is disposed.
  65659. */
  65660. readonly onDisposeObservable: Observable<void>;
  65661. private _onDisposeObserver;
  65662. /**
  65663. * Callback raised after the loader is disposed.
  65664. */
  65665. onDispose: () => void;
  65666. /**
  65667. * Observable raised after a loader extension is created.
  65668. * Set additional options for a loader extension in this event.
  65669. */
  65670. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  65671. private _onExtensionLoadedObserver;
  65672. /**
  65673. * Callback raised after a loader extension is created.
  65674. */
  65675. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  65676. /**
  65677. * Defines if the loader logging is enabled.
  65678. */
  65679. loggingEnabled: boolean;
  65680. /**
  65681. * Defines if the loader should capture performance counters.
  65682. */
  65683. capturePerformanceCounters: boolean;
  65684. /**
  65685. * Defines if the loader should validate the asset.
  65686. */
  65687. validate: boolean;
  65688. /**
  65689. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  65690. */
  65691. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  65692. private _onValidatedObserver;
  65693. /**
  65694. * Callback raised after a loader extension is created.
  65695. */
  65696. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  65697. private _loader;
  65698. /**
  65699. * Name of the loader ("gltf")
  65700. */
  65701. name: string;
  65702. /**
  65703. * Supported file extensions of the loader (.gltf, .glb)
  65704. */
  65705. extensions: ISceneLoaderPluginExtensions;
  65706. /**
  65707. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  65708. */
  65709. dispose(): void;
  65710. /** @hidden */ private _clear(): void;
  65711. /**
  65712. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  65713. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65714. * @param scene the scene the meshes should be added to
  65715. * @param data the glTF data to load
  65716. * @param rootUrl root url to load from
  65717. * @param onProgress event that fires when loading progress has occured
  65718. * @param fileName Defines the name of the file to load
  65719. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65720. */
  65721. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65722. meshes: AbstractMesh[];
  65723. particleSystems: IParticleSystem[];
  65724. skeletons: Skeleton[];
  65725. animationGroups: AnimationGroup[];
  65726. }>;
  65727. /**
  65728. * Imports all objects from the loaded glTF data and adds them to the scene
  65729. * @param scene the scene the objects should be added to
  65730. * @param data the glTF data to load
  65731. * @param rootUrl root url to load from
  65732. * @param onProgress event that fires when loading progress has occured
  65733. * @param fileName Defines the name of the file to load
  65734. * @returns a promise which completes when objects have been loaded to the scene
  65735. */
  65736. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65737. /**
  65738. * Load into an asset container.
  65739. * @param scene The scene to load into
  65740. * @param data The data to import
  65741. * @param rootUrl The root url for scene and resources
  65742. * @param onProgress The callback when the load progresses
  65743. * @param fileName Defines the name of the file to load
  65744. * @returns The loaded asset container
  65745. */
  65746. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65747. /**
  65748. * If the data string can be loaded directly.
  65749. * @param data string contianing the file data
  65750. * @returns if the data can be loaded directly
  65751. */
  65752. canDirectLoad(data: string): boolean;
  65753. /**
  65754. * Rewrites a url by combining a root url and response url.
  65755. */
  65756. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  65757. /**
  65758. * Instantiates a glTF file loader plugin.
  65759. * @returns the created plugin
  65760. */
  65761. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  65762. /**
  65763. * The loader state or null if the loader is not active.
  65764. */
  65765. readonly loaderState: Nullable<GLTFLoaderState>;
  65766. /**
  65767. * Returns a promise that resolves when the asset is completely loaded.
  65768. * @returns a promise that resolves when the asset is completely loaded.
  65769. */
  65770. whenCompleteAsync(): Promise<void>;
  65771. private _parseAsync;
  65772. private _validateAsync;
  65773. private _getLoader;
  65774. private _unpackBinary;
  65775. private _unpackBinaryV1;
  65776. private _unpackBinaryV2;
  65777. private static _parseVersion;
  65778. private static _compareVersion;
  65779. private static _decodeBufferToText;
  65780. private static readonly _logSpaces;
  65781. private _logIndentLevel;
  65782. private _loggingEnabled;
  65783. /** @hidden */ private _log: (message: string) => void;
  65784. /** @hidden */ private _logOpen(message: string): void;
  65785. /** @hidden */ private _logClose(): void;
  65786. private _logEnabled;
  65787. private _logDisabled;
  65788. private _capturePerformanceCounters;
  65789. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  65790. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  65791. private _startPerformanceCounterEnabled;
  65792. private _startPerformanceCounterDisabled;
  65793. private _endPerformanceCounterEnabled;
  65794. private _endPerformanceCounterDisabled;
  65795. }
  65796. }
  65797. declare module BABYLON.GLTF1 {
  65798. /**
  65799. * Enums
  65800. * @hidden
  65801. */
  65802. export enum EComponentType {
  65803. BYTE = 5120,
  65804. UNSIGNED_BYTE = 5121,
  65805. SHORT = 5122,
  65806. UNSIGNED_SHORT = 5123,
  65807. FLOAT = 5126
  65808. }
  65809. /** @hidden */
  65810. export enum EShaderType {
  65811. FRAGMENT = 35632,
  65812. VERTEX = 35633
  65813. }
  65814. /** @hidden */
  65815. export enum EParameterType {
  65816. BYTE = 5120,
  65817. UNSIGNED_BYTE = 5121,
  65818. SHORT = 5122,
  65819. UNSIGNED_SHORT = 5123,
  65820. INT = 5124,
  65821. UNSIGNED_INT = 5125,
  65822. FLOAT = 5126,
  65823. FLOAT_VEC2 = 35664,
  65824. FLOAT_VEC3 = 35665,
  65825. FLOAT_VEC4 = 35666,
  65826. INT_VEC2 = 35667,
  65827. INT_VEC3 = 35668,
  65828. INT_VEC4 = 35669,
  65829. BOOL = 35670,
  65830. BOOL_VEC2 = 35671,
  65831. BOOL_VEC3 = 35672,
  65832. BOOL_VEC4 = 35673,
  65833. FLOAT_MAT2 = 35674,
  65834. FLOAT_MAT3 = 35675,
  65835. FLOAT_MAT4 = 35676,
  65836. SAMPLER_2D = 35678
  65837. }
  65838. /** @hidden */
  65839. export enum ETextureWrapMode {
  65840. CLAMP_TO_EDGE = 33071,
  65841. MIRRORED_REPEAT = 33648,
  65842. REPEAT = 10497
  65843. }
  65844. /** @hidden */
  65845. export enum ETextureFilterType {
  65846. NEAREST = 9728,
  65847. LINEAR = 9728,
  65848. NEAREST_MIPMAP_NEAREST = 9984,
  65849. LINEAR_MIPMAP_NEAREST = 9985,
  65850. NEAREST_MIPMAP_LINEAR = 9986,
  65851. LINEAR_MIPMAP_LINEAR = 9987
  65852. }
  65853. /** @hidden */
  65854. export enum ETextureFormat {
  65855. ALPHA = 6406,
  65856. RGB = 6407,
  65857. RGBA = 6408,
  65858. LUMINANCE = 6409,
  65859. LUMINANCE_ALPHA = 6410
  65860. }
  65861. /** @hidden */
  65862. export enum ECullingType {
  65863. FRONT = 1028,
  65864. BACK = 1029,
  65865. FRONT_AND_BACK = 1032
  65866. }
  65867. /** @hidden */
  65868. export enum EBlendingFunction {
  65869. ZERO = 0,
  65870. ONE = 1,
  65871. SRC_COLOR = 768,
  65872. ONE_MINUS_SRC_COLOR = 769,
  65873. DST_COLOR = 774,
  65874. ONE_MINUS_DST_COLOR = 775,
  65875. SRC_ALPHA = 770,
  65876. ONE_MINUS_SRC_ALPHA = 771,
  65877. DST_ALPHA = 772,
  65878. ONE_MINUS_DST_ALPHA = 773,
  65879. CONSTANT_COLOR = 32769,
  65880. ONE_MINUS_CONSTANT_COLOR = 32770,
  65881. CONSTANT_ALPHA = 32771,
  65882. ONE_MINUS_CONSTANT_ALPHA = 32772,
  65883. SRC_ALPHA_SATURATE = 776
  65884. }
  65885. /** @hidden */
  65886. export interface IGLTFProperty {
  65887. extensions?: {
  65888. [key: string]: any;
  65889. };
  65890. extras?: Object;
  65891. }
  65892. /** @hidden */
  65893. export interface IGLTFChildRootProperty extends IGLTFProperty {
  65894. name?: string;
  65895. }
  65896. /** @hidden */
  65897. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  65898. bufferView: string;
  65899. byteOffset: number;
  65900. byteStride: number;
  65901. count: number;
  65902. type: string;
  65903. componentType: EComponentType;
  65904. max?: number[];
  65905. min?: number[];
  65906. name?: string;
  65907. }
  65908. /** @hidden */
  65909. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  65910. buffer: string;
  65911. byteOffset: number;
  65912. byteLength: number;
  65913. byteStride: number;
  65914. target?: number;
  65915. }
  65916. /** @hidden */
  65917. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  65918. uri: string;
  65919. byteLength?: number;
  65920. type?: string;
  65921. }
  65922. /** @hidden */
  65923. export interface IGLTFShader extends IGLTFChildRootProperty {
  65924. uri: string;
  65925. type: EShaderType;
  65926. }
  65927. /** @hidden */
  65928. export interface IGLTFProgram extends IGLTFChildRootProperty {
  65929. attributes: string[];
  65930. fragmentShader: string;
  65931. vertexShader: string;
  65932. }
  65933. /** @hidden */
  65934. export interface IGLTFTechniqueParameter {
  65935. type: number;
  65936. count?: number;
  65937. semantic?: string;
  65938. node?: string;
  65939. value?: number | boolean | string | Array<any>;
  65940. source?: string;
  65941. babylonValue?: any;
  65942. }
  65943. /** @hidden */
  65944. export interface IGLTFTechniqueCommonProfile {
  65945. lightingModel: string;
  65946. texcoordBindings: Object;
  65947. parameters?: Array<any>;
  65948. }
  65949. /** @hidden */
  65950. export interface IGLTFTechniqueStatesFunctions {
  65951. blendColor?: number[];
  65952. blendEquationSeparate?: number[];
  65953. blendFuncSeparate?: number[];
  65954. colorMask: boolean[];
  65955. cullFace: number[];
  65956. }
  65957. /** @hidden */
  65958. export interface IGLTFTechniqueStates {
  65959. enable: number[];
  65960. functions: IGLTFTechniqueStatesFunctions;
  65961. }
  65962. /** @hidden */
  65963. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  65964. parameters: {
  65965. [key: string]: IGLTFTechniqueParameter;
  65966. };
  65967. program: string;
  65968. attributes: {
  65969. [key: string]: string;
  65970. };
  65971. uniforms: {
  65972. [key: string]: string;
  65973. };
  65974. states: IGLTFTechniqueStates;
  65975. }
  65976. /** @hidden */
  65977. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  65978. technique?: string;
  65979. values: string[];
  65980. }
  65981. /** @hidden */
  65982. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  65983. attributes: {
  65984. [key: string]: string;
  65985. };
  65986. indices: string;
  65987. material: string;
  65988. mode?: number;
  65989. }
  65990. /** @hidden */
  65991. export interface IGLTFMesh extends IGLTFChildRootProperty {
  65992. primitives: IGLTFMeshPrimitive[];
  65993. }
  65994. /** @hidden */
  65995. export interface IGLTFImage extends IGLTFChildRootProperty {
  65996. uri: string;
  65997. }
  65998. /** @hidden */
  65999. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66000. magFilter?: number;
  66001. minFilter?: number;
  66002. wrapS?: number;
  66003. wrapT?: number;
  66004. }
  66005. /** @hidden */
  66006. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66007. sampler: string;
  66008. source: string;
  66009. format?: ETextureFormat;
  66010. internalFormat?: ETextureFormat;
  66011. target?: number;
  66012. type?: number;
  66013. babylonTexture?: Texture;
  66014. }
  66015. /** @hidden */
  66016. export interface IGLTFAmbienLight {
  66017. color?: number[];
  66018. }
  66019. /** @hidden */
  66020. export interface IGLTFDirectionalLight {
  66021. color?: number[];
  66022. }
  66023. /** @hidden */
  66024. export interface IGLTFPointLight {
  66025. color?: number[];
  66026. constantAttenuation?: number;
  66027. linearAttenuation?: number;
  66028. quadraticAttenuation?: number;
  66029. }
  66030. /** @hidden */
  66031. export interface IGLTFSpotLight {
  66032. color?: number[];
  66033. constantAttenuation?: number;
  66034. fallOfAngle?: number;
  66035. fallOffExponent?: number;
  66036. linearAttenuation?: number;
  66037. quadraticAttenuation?: number;
  66038. }
  66039. /** @hidden */
  66040. export interface IGLTFLight extends IGLTFChildRootProperty {
  66041. type: string;
  66042. }
  66043. /** @hidden */
  66044. export interface IGLTFCameraOrthographic {
  66045. xmag: number;
  66046. ymag: number;
  66047. zfar: number;
  66048. znear: number;
  66049. }
  66050. /** @hidden */
  66051. export interface IGLTFCameraPerspective {
  66052. aspectRatio: number;
  66053. yfov: number;
  66054. zfar: number;
  66055. znear: number;
  66056. }
  66057. /** @hidden */
  66058. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66059. type: string;
  66060. }
  66061. /** @hidden */
  66062. export interface IGLTFAnimationChannelTarget {
  66063. id: string;
  66064. path: string;
  66065. }
  66066. /** @hidden */
  66067. export interface IGLTFAnimationChannel {
  66068. sampler: string;
  66069. target: IGLTFAnimationChannelTarget;
  66070. }
  66071. /** @hidden */
  66072. export interface IGLTFAnimationSampler {
  66073. input: string;
  66074. output: string;
  66075. interpolation?: string;
  66076. }
  66077. /** @hidden */
  66078. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  66079. channels?: IGLTFAnimationChannel[];
  66080. parameters?: {
  66081. [key: string]: string;
  66082. };
  66083. samplers?: {
  66084. [key: string]: IGLTFAnimationSampler;
  66085. };
  66086. }
  66087. /** @hidden */
  66088. export interface IGLTFNodeInstanceSkin {
  66089. skeletons: string[];
  66090. skin: string;
  66091. meshes: string[];
  66092. }
  66093. /** @hidden */
  66094. export interface IGLTFSkins extends IGLTFChildRootProperty {
  66095. bindShapeMatrix: number[];
  66096. inverseBindMatrices: string;
  66097. jointNames: string[];
  66098. babylonSkeleton?: Skeleton;
  66099. }
  66100. /** @hidden */
  66101. export interface IGLTFNode extends IGLTFChildRootProperty {
  66102. camera?: string;
  66103. children: string[];
  66104. skin?: string;
  66105. jointName?: string;
  66106. light?: string;
  66107. matrix: number[];
  66108. mesh?: string;
  66109. meshes?: string[];
  66110. rotation?: number[];
  66111. scale?: number[];
  66112. translation?: number[];
  66113. babylonNode?: Node;
  66114. }
  66115. /** @hidden */
  66116. export interface IGLTFScene extends IGLTFChildRootProperty {
  66117. nodes: string[];
  66118. }
  66119. /** @hidden */
  66120. export interface IGLTFRuntime {
  66121. extensions: {
  66122. [key: string]: any;
  66123. };
  66124. accessors: {
  66125. [key: string]: IGLTFAccessor;
  66126. };
  66127. buffers: {
  66128. [key: string]: IGLTFBuffer;
  66129. };
  66130. bufferViews: {
  66131. [key: string]: IGLTFBufferView;
  66132. };
  66133. meshes: {
  66134. [key: string]: IGLTFMesh;
  66135. };
  66136. lights: {
  66137. [key: string]: IGLTFLight;
  66138. };
  66139. cameras: {
  66140. [key: string]: IGLTFCamera;
  66141. };
  66142. nodes: {
  66143. [key: string]: IGLTFNode;
  66144. };
  66145. images: {
  66146. [key: string]: IGLTFImage;
  66147. };
  66148. textures: {
  66149. [key: string]: IGLTFTexture;
  66150. };
  66151. shaders: {
  66152. [key: string]: IGLTFShader;
  66153. };
  66154. programs: {
  66155. [key: string]: IGLTFProgram;
  66156. };
  66157. samplers: {
  66158. [key: string]: IGLTFSampler;
  66159. };
  66160. techniques: {
  66161. [key: string]: IGLTFTechnique;
  66162. };
  66163. materials: {
  66164. [key: string]: IGLTFMaterial;
  66165. };
  66166. animations: {
  66167. [key: string]: IGLTFAnimation;
  66168. };
  66169. skins: {
  66170. [key: string]: IGLTFSkins;
  66171. };
  66172. currentScene?: Object;
  66173. scenes: {
  66174. [key: string]: IGLTFScene;
  66175. };
  66176. extensionsUsed: string[];
  66177. extensionsRequired?: string[];
  66178. buffersCount: number;
  66179. shaderscount: number;
  66180. scene: Scene;
  66181. rootUrl: string;
  66182. loadedBufferCount: number;
  66183. loadedBufferViews: {
  66184. [name: string]: ArrayBufferView;
  66185. };
  66186. loadedShaderCount: number;
  66187. importOnlyMeshes: boolean;
  66188. importMeshesNames?: string[];
  66189. dummyNodes: Node[];
  66190. }
  66191. /** @hidden */
  66192. export interface INodeToRoot {
  66193. bone: Bone;
  66194. node: IGLTFNode;
  66195. id: string;
  66196. }
  66197. /** @hidden */
  66198. export interface IJointNode {
  66199. node: IGLTFNode;
  66200. id: string;
  66201. }
  66202. }
  66203. declare module BABYLON.GLTF1 {
  66204. /**
  66205. * Utils functions for GLTF
  66206. * @hidden
  66207. */
  66208. export class GLTFUtils {
  66209. /**
  66210. * Sets the given "parameter" matrix
  66211. * @param scene: the Scene object
  66212. * @param source: the source node where to pick the matrix
  66213. * @param parameter: the GLTF technique parameter
  66214. * @param uniformName: the name of the shader's uniform
  66215. * @param shaderMaterial: the shader material
  66216. */
  66217. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66218. /**
  66219. * Sets the given "parameter" matrix
  66220. * @param shaderMaterial: the shader material
  66221. * @param uniform: the name of the shader's uniform
  66222. * @param value: the value of the uniform
  66223. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66224. */
  66225. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66226. /**
  66227. * Returns the wrap mode of the texture
  66228. * @param mode: the mode value
  66229. */
  66230. static GetWrapMode(mode: number): number;
  66231. /**
  66232. * Returns the byte stride giving an accessor
  66233. * @param accessor: the GLTF accessor objet
  66234. */
  66235. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66236. /**
  66237. * Returns the texture filter mode giving a mode value
  66238. * @param mode: the filter mode value
  66239. */
  66240. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66241. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66242. /**
  66243. * Returns a buffer from its accessor
  66244. * @param gltfRuntime: the GLTF runtime
  66245. * @param accessor: the GLTF accessor
  66246. */
  66247. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66248. /**
  66249. * Decodes a buffer view into a string
  66250. * @param view: the buffer view
  66251. */
  66252. static DecodeBufferToText(view: ArrayBufferView): string;
  66253. /**
  66254. * Returns the default material of gltf. Related to
  66255. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  66256. * @param scene: the Babylon.js scene
  66257. */
  66258. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  66259. private static _DefaultMaterial;
  66260. }
  66261. }
  66262. declare module BABYLON.GLTF1 {
  66263. /**
  66264. * Implementation of the base glTF spec
  66265. * @hidden
  66266. */
  66267. export class GLTFLoaderBase {
  66268. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  66269. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66270. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  66271. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66272. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  66273. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66274. }
  66275. /**
  66276. * glTF V1 Loader
  66277. * @hidden
  66278. */
  66279. export class GLTFLoader implements IGLTFLoader {
  66280. static Extensions: {
  66281. [name: string]: GLTFLoaderExtension;
  66282. };
  66283. static RegisterExtension(extension: GLTFLoaderExtension): void;
  66284. state: Nullable<GLTFLoaderState>;
  66285. dispose(): void;
  66286. private _importMeshAsync;
  66287. /**
  66288. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  66289. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66290. * @param scene the scene the meshes should be added to
  66291. * @param data gltf data containing information of the meshes in a loaded file
  66292. * @param rootUrl root url to load from
  66293. * @param onProgress event that fires when loading progress has occured
  66294. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66295. */
  66296. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  66297. meshes: AbstractMesh[];
  66298. particleSystems: IParticleSystem[];
  66299. skeletons: Skeleton[];
  66300. animationGroups: AnimationGroup[];
  66301. }>;
  66302. private _loadAsync;
  66303. /**
  66304. * Imports all objects from a loaded gltf file and adds them to the scene
  66305. * @param scene the scene the objects should be added to
  66306. * @param data gltf data containing information of the meshes in a loaded file
  66307. * @param rootUrl root url to load from
  66308. * @param onProgress event that fires when loading progress has occured
  66309. * @returns a promise which completes when objects have been loaded to the scene
  66310. */
  66311. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  66312. private _loadShadersAsync;
  66313. private _loadBuffersAsync;
  66314. private _createNodes;
  66315. }
  66316. /** @hidden */
  66317. export abstract class GLTFLoaderExtension {
  66318. private _name;
  66319. constructor(name: string);
  66320. readonly name: string;
  66321. /**
  66322. * Defines an override for loading the runtime
  66323. * Return true to stop further extensions from loading the runtime
  66324. */
  66325. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  66326. /**
  66327. * Defines an onverride for creating gltf runtime
  66328. * Return true to stop further extensions from creating the runtime
  66329. */
  66330. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  66331. /**
  66332. * Defines an override for loading buffers
  66333. * Return true to stop further extensions from loading this buffer
  66334. */
  66335. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  66336. /**
  66337. * Defines an override for loading texture buffers
  66338. * Return true to stop further extensions from loading this texture data
  66339. */
  66340. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66341. /**
  66342. * Defines an override for creating textures
  66343. * Return true to stop further extensions from loading this texture
  66344. */
  66345. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  66346. /**
  66347. * Defines an override for loading shader strings
  66348. * Return true to stop further extensions from loading this shader data
  66349. */
  66350. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66351. /**
  66352. * Defines an override for loading materials
  66353. * Return true to stop further extensions from loading this material
  66354. */
  66355. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66356. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  66357. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  66358. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66359. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66360. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  66361. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66362. private static LoadTextureBufferAsync;
  66363. private static CreateTextureAsync;
  66364. private static ApplyExtensions;
  66365. }
  66366. }
  66367. declare module BABYLON.GLTF1 {
  66368. /** @hidden */
  66369. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  66370. private _bin;
  66371. constructor();
  66372. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  66373. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66374. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66375. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66376. }
  66377. }
  66378. declare module BABYLON.GLTF1 {
  66379. /** @hidden */
  66380. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  66381. constructor();
  66382. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  66383. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66384. private _loadTexture;
  66385. }
  66386. }
  66387. declare module BABYLON.GLTF2.Loader {
  66388. /**
  66389. * Loader interface with an index field.
  66390. */
  66391. export interface IArrayItem {
  66392. /**
  66393. * The index of this item in the array.
  66394. */
  66395. index: number;
  66396. }
  66397. /**
  66398. * Loader interface with additional members.
  66399. */
  66400. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  66401. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66402. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  66403. }
  66404. /**
  66405. * Loader interface with additional members.
  66406. */
  66407. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  66408. }
  66409. /** @hidden */
  66410. export interface _IAnimationSamplerData {
  66411. input: Float32Array;
  66412. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  66413. output: Float32Array;
  66414. }
  66415. /**
  66416. * Loader interface with additional members.
  66417. */
  66418. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  66419. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  66420. }
  66421. /**
  66422. * Loader interface with additional members.
  66423. */
  66424. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  66425. channels: IAnimationChannel[];
  66426. samplers: IAnimationSampler[];
  66427. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  66428. }
  66429. /**
  66430. * Loader interface with additional members.
  66431. */
  66432. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  66433. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66434. }
  66435. /**
  66436. * Loader interface with additional members.
  66437. */
  66438. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  66439. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66440. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  66441. }
  66442. /**
  66443. * Loader interface with additional members.
  66444. */
  66445. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  66446. }
  66447. /**
  66448. * Loader interface with additional members.
  66449. */
  66450. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  66451. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66452. }
  66453. /**
  66454. * Loader interface with additional members.
  66455. */
  66456. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  66457. }
  66458. /**
  66459. * Loader interface with additional members.
  66460. */
  66461. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  66462. }
  66463. /**
  66464. * Loader interface with additional members.
  66465. */
  66466. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  66467. baseColorTexture?: ITextureInfo;
  66468. metallicRoughnessTexture?: ITextureInfo;
  66469. }
  66470. /**
  66471. * Loader interface with additional members.
  66472. */
  66473. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  66474. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66475. normalTexture?: IMaterialNormalTextureInfo;
  66476. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66477. emissiveTexture?: ITextureInfo;
  66478. /** @hidden */ private _data?: {
  66479. [babylonDrawMode: number]: {
  66480. babylonMaterial: Material;
  66481. babylonMeshes: AbstractMesh[];
  66482. promise: Promise<void>;
  66483. };
  66484. };
  66485. }
  66486. /**
  66487. * Loader interface with additional members.
  66488. */
  66489. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  66490. primitives: IMeshPrimitive[];
  66491. }
  66492. /**
  66493. * Loader interface with additional members.
  66494. */
  66495. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  66496. /** @hidden */ private _instanceData?: {
  66497. babylonSourceMesh: Mesh;
  66498. promise: Promise<any>;
  66499. };
  66500. }
  66501. /**
  66502. * Loader interface with additional members.
  66503. */
  66504. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  66505. /**
  66506. * The parent glTF node.
  66507. */
  66508. parent?: INode;
  66509. /** @hidden */ private _babylonTransformNode?: TransformNode;
  66510. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  66511. /** @hidden */ private _babylonBones?: Bone[];
  66512. /** @hidden */ private _numMorphTargets?: number;
  66513. }
  66514. /** @hidden */
  66515. export interface _ISamplerData {
  66516. noMipMaps: boolean;
  66517. samplingMode: number;
  66518. wrapU: number;
  66519. wrapV: number;
  66520. }
  66521. /**
  66522. * Loader interface with additional members.
  66523. */
  66524. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  66525. /** @hidden */ private _data?: _ISamplerData;
  66526. }
  66527. /**
  66528. * Loader interface with additional members.
  66529. */
  66530. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  66531. }
  66532. /**
  66533. * Loader interface with additional members.
  66534. */
  66535. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  66536. /** @hidden */ private _data?: {
  66537. babylonSkeleton: Skeleton;
  66538. promise: Promise<void>;
  66539. };
  66540. }
  66541. /**
  66542. * Loader interface with additional members.
  66543. */
  66544. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  66545. }
  66546. /**
  66547. * Loader interface with additional members.
  66548. */
  66549. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  66550. }
  66551. /**
  66552. * Loader interface with additional members.
  66553. */
  66554. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  66555. accessors?: IAccessor[];
  66556. animations?: IAnimation[];
  66557. buffers?: IBuffer[];
  66558. bufferViews?: IBufferView[];
  66559. cameras?: ICamera[];
  66560. images?: IImage[];
  66561. materials?: IMaterial[];
  66562. meshes?: IMesh[];
  66563. nodes?: INode[];
  66564. samplers?: ISampler[];
  66565. scenes?: IScene[];
  66566. skins?: ISkin[];
  66567. textures?: ITexture[];
  66568. }
  66569. }
  66570. declare module BABYLON.GLTF2 {
  66571. /**
  66572. * Interface for a glTF loader extension.
  66573. */
  66574. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  66575. /**
  66576. * Called after the loader state changes to LOADING.
  66577. */
  66578. onLoading?(): void;
  66579. /**
  66580. * Called after the loader state changes to READY.
  66581. */
  66582. onReady?(): void;
  66583. /**
  66584. * Define this method to modify the default behavior when loading scenes.
  66585. * @param context The context when loading the asset
  66586. * @param scene The glTF scene property
  66587. * @returns A promise that resolves when the load is complete or null if not handled
  66588. */
  66589. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  66590. /**
  66591. * Define this method to modify the default behavior when loading nodes.
  66592. * @param context The context when loading the asset
  66593. * @param node The glTF node property
  66594. * @param assign A function called synchronously after parsing the glTF properties
  66595. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  66596. */
  66597. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66598. /**
  66599. * Define this method to modify the default behavior when loading cameras.
  66600. * @param context The context when loading the asset
  66601. * @param camera The glTF camera property
  66602. * @param assign A function called synchronously after parsing the glTF properties
  66603. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  66604. */
  66605. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66606. /**
  66607. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  66608. * @param context The context when loading the asset
  66609. * @param primitive The glTF mesh primitive property
  66610. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  66611. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66612. /**
  66613. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66614. * @param context The context when loading the asset
  66615. * @param name The mesh name when loading the asset
  66616. * @param node The glTF node when loading the asset
  66617. * @param mesh The glTF mesh when loading the asset
  66618. * @param primitive The glTF mesh primitive property
  66619. * @param assign A function called synchronously after parsing the glTF properties
  66620. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66621. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66622. /**
  66623. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  66624. * @param context The context when loading the asset
  66625. * @param material The glTF material property
  66626. * @param assign A function called synchronously after parsing the glTF properties
  66627. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  66628. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66629. /**
  66630. * Define this method to modify the default behavior when creating materials.
  66631. * @param context The context when loading the asset
  66632. * @param material The glTF material property
  66633. * @param babylonDrawMode The draw mode for the Babylon material
  66634. * @returns The Babylon material or null if not handled
  66635. */
  66636. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66637. /**
  66638. * Define this method to modify the default behavior when loading material properties.
  66639. * @param context The context when loading the asset
  66640. * @param material The glTF material property
  66641. * @param babylonMaterial The Babylon material
  66642. * @returns A promise that resolves when the load is complete or null if not handled
  66643. */
  66644. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66645. /**
  66646. * Define this method to modify the default behavior when loading texture infos.
  66647. * @param context The context when loading the asset
  66648. * @param textureInfo The glTF texture info property
  66649. * @param assign A function called synchronously after parsing the glTF properties
  66650. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  66651. */
  66652. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66653. /**
  66654. * Define this method to modify the default behavior when loading animations.
  66655. * @param context The context when loading the asset
  66656. * @param animation The glTF animation property
  66657. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  66658. */
  66659. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66660. /**
  66661. * @hidden Define this method to modify the default behavior when loading skins.
  66662. * @param context The context when loading the asset
  66663. * @param node The glTF node property
  66664. * @param skin The glTF skin property
  66665. * @returns A promise that resolves when the load is complete or null if not handled
  66666. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  66667. /**
  66668. * @hidden Define this method to modify the default behavior when loading uris.
  66669. * @param context The context when loading the asset
  66670. * @param property The glTF property associated with the uri
  66671. * @param uri The uri to load
  66672. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  66673. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66674. }
  66675. }
  66676. declare module BABYLON.GLTF2 {
  66677. /**
  66678. * Helper class for working with arrays when loading the glTF asset
  66679. */
  66680. export class ArrayItem {
  66681. /**
  66682. * Gets an item from the given array.
  66683. * @param context The context when loading the asset
  66684. * @param array The array to get the item from
  66685. * @param index The index to the array
  66686. * @returns The array item
  66687. */
  66688. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  66689. /**
  66690. * Assign an `index` field to each item of the given array.
  66691. * @param array The array of items
  66692. */
  66693. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  66694. }
  66695. /**
  66696. * The glTF 2.0 loader
  66697. */
  66698. export class GLTFLoader implements IGLTFLoader {
  66699. /** @hidden */ private _completePromises: Promise<any>[];
  66700. private _disposed;
  66701. private _parent;
  66702. private _state;
  66703. private _extensions;
  66704. private _rootUrl;
  66705. private _fileName;
  66706. private _uniqueRootUrl;
  66707. private _gltf;
  66708. private _babylonScene;
  66709. private _rootBabylonMesh;
  66710. private _defaultBabylonMaterialData;
  66711. private _progressCallback?;
  66712. private _requests;
  66713. private static readonly _DefaultSampler;
  66714. private static _ExtensionNames;
  66715. private static _ExtensionFactories;
  66716. /**
  66717. * Registers a loader extension.
  66718. * @param name The name of the loader extension.
  66719. * @param factory The factory function that creates the loader extension.
  66720. */
  66721. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  66722. /**
  66723. * Unregisters a loader extension.
  66724. * @param name The name of the loader extenion.
  66725. * @returns A boolean indicating whether the extension has been unregistered
  66726. */
  66727. static UnregisterExtension(name: string): boolean;
  66728. /**
  66729. * Gets the loader state.
  66730. */
  66731. readonly state: Nullable<GLTFLoaderState>;
  66732. /**
  66733. * The glTF object parsed from the JSON.
  66734. */
  66735. readonly gltf: IGLTF;
  66736. /**
  66737. * The Babylon scene when loading the asset.
  66738. */
  66739. readonly babylonScene: Scene;
  66740. /**
  66741. * The root Babylon mesh when loading the asset.
  66742. */
  66743. readonly rootBabylonMesh: Mesh;
  66744. /** @hidden */
  66745. constructor(parent: GLTFFileLoader);
  66746. /** @hidden */
  66747. dispose(): void;
  66748. /** @hidden */
  66749. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66750. meshes: AbstractMesh[];
  66751. particleSystems: IParticleSystem[];
  66752. skeletons: Skeleton[];
  66753. animationGroups: AnimationGroup[];
  66754. }>;
  66755. /** @hidden */
  66756. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66757. private _loadAsync;
  66758. private _loadData;
  66759. private _setupData;
  66760. private _loadExtensions;
  66761. private _checkExtensions;
  66762. private _setState;
  66763. private _createRootNode;
  66764. /**
  66765. * Loads a glTF scene.
  66766. * @param context The context when loading the asset
  66767. * @param scene The glTF scene property
  66768. * @returns A promise that resolves when the load is complete
  66769. */
  66770. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  66771. private _forEachPrimitive;
  66772. private _getMeshes;
  66773. private _getSkeletons;
  66774. private _getAnimationGroups;
  66775. private _startAnimations;
  66776. /**
  66777. * Loads a glTF node.
  66778. * @param context The context when loading the asset
  66779. * @param node The glTF node property
  66780. * @param assign A function called synchronously after parsing the glTF properties
  66781. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  66782. */
  66783. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  66784. private _loadMeshAsync;
  66785. /**
  66786. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66787. * @param context The context when loading the asset
  66788. * @param name The mesh name when loading the asset
  66789. * @param node The glTF node when loading the asset
  66790. * @param mesh The glTF mesh when loading the asset
  66791. * @param primitive The glTF mesh primitive property
  66792. * @param assign A function called synchronously after parsing the glTF properties
  66793. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66794. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66795. private _loadVertexDataAsync;
  66796. private _createMorphTargets;
  66797. private _loadMorphTargetsAsync;
  66798. private _loadMorphTargetVertexDataAsync;
  66799. private static _LoadTransform;
  66800. private _loadSkinAsync;
  66801. private _loadBones;
  66802. private _loadBone;
  66803. private _loadSkinInverseBindMatricesDataAsync;
  66804. private _updateBoneMatrices;
  66805. private _getNodeMatrix;
  66806. /**
  66807. * Loads a glTF camera.
  66808. * @param context The context when loading the asset
  66809. * @param camera The glTF camera property
  66810. * @param assign A function called synchronously after parsing the glTF properties
  66811. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  66812. */
  66813. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  66814. private _loadAnimationsAsync;
  66815. /**
  66816. * Loads a glTF animation.
  66817. * @param context The context when loading the asset
  66818. * @param animation The glTF animation property
  66819. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  66820. */
  66821. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  66822. /**
  66823. * @hidden Loads a glTF animation channel.
  66824. * @param context The context when loading the asset
  66825. * @param animationContext The context of the animation when loading the asset
  66826. * @param animation The glTF animation property
  66827. * @param channel The glTF animation channel property
  66828. * @param babylonAnimationGroup The babylon animation group property
  66829. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  66830. * @returns A void promise when the channel load is complete
  66831. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  66832. private _loadAnimationSamplerAsync;
  66833. private _loadBufferAsync;
  66834. /**
  66835. * Loads a glTF buffer view.
  66836. * @param context The context when loading the asset
  66837. * @param bufferView The glTF buffer view property
  66838. * @returns A promise that resolves with the loaded data when the load is complete
  66839. */
  66840. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  66841. private _loadAccessorAsync;
  66842. private _loadFloatAccessorAsync;
  66843. private _loadIndicesAccessorAsync;
  66844. private _loadVertexBufferViewAsync;
  66845. private _loadVertexAccessorAsync;
  66846. private _loadMaterialMetallicRoughnessPropertiesAsync;
  66847. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  66848. private _createDefaultMaterial;
  66849. /**
  66850. * Creates a Babylon material from a glTF material.
  66851. * @param context The context when loading the asset
  66852. * @param material The glTF material property
  66853. * @param babylonDrawMode The draw mode for the Babylon material
  66854. * @returns The Babylon material
  66855. */
  66856. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  66857. /**
  66858. * Loads properties from a glTF material into a Babylon material.
  66859. * @param context The context when loading the asset
  66860. * @param material The glTF material property
  66861. * @param babylonMaterial The Babylon material
  66862. * @returns A promise that resolves when the load is complete
  66863. */
  66864. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66865. /**
  66866. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  66867. * @param context The context when loading the asset
  66868. * @param material The glTF material property
  66869. * @param babylonMaterial The Babylon material
  66870. * @returns A promise that resolves when the load is complete
  66871. */
  66872. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66873. /**
  66874. * Loads the alpha properties from a glTF material into a Babylon material.
  66875. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  66876. * @param context The context when loading the asset
  66877. * @param material The glTF material property
  66878. * @param babylonMaterial The Babylon material
  66879. */
  66880. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  66881. /**
  66882. * Loads a glTF texture info.
  66883. * @param context The context when loading the asset
  66884. * @param textureInfo The glTF texture info property
  66885. * @param assign A function called synchronously after parsing the glTF properties
  66886. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  66887. */
  66888. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  66889. private _loadTextureAsync;
  66890. private _loadSampler;
  66891. /**
  66892. * Loads a glTF image.
  66893. * @param context The context when loading the asset
  66894. * @param image The glTF image property
  66895. * @returns A promise that resolves with the loaded data when the load is complete
  66896. */
  66897. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  66898. /**
  66899. * Loads a glTF uri.
  66900. * @param context The context when loading the asset
  66901. * @param property The glTF property associated with the uri
  66902. * @param uri The base64 or relative uri
  66903. * @returns A promise that resolves with the loaded data when the load is complete
  66904. */
  66905. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  66906. private _onProgress;
  66907. /**
  66908. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  66909. * @param babylonObject the Babylon object with metadata
  66910. * @param pointer the JSON pointer
  66911. */
  66912. static AddPointerMetadata(babylonObject: {
  66913. metadata: any;
  66914. }, pointer: string): void;
  66915. private static _GetTextureWrapMode;
  66916. private static _GetTextureSamplingMode;
  66917. private static _GetTypedArrayConstructor;
  66918. private static _GetTypedArray;
  66919. private static _GetNumComponents;
  66920. private static _ValidateUri;
  66921. private static _GetDrawMode;
  66922. private _compileMaterialsAsync;
  66923. private _compileShadowGeneratorsAsync;
  66924. private _forEachExtensions;
  66925. private _applyExtensions;
  66926. private _extensionsOnLoading;
  66927. private _extensionsOnReady;
  66928. private _extensionsLoadSceneAsync;
  66929. private _extensionsLoadNodeAsync;
  66930. private _extensionsLoadCameraAsync;
  66931. private _extensionsLoadVertexDataAsync;
  66932. private _extensionsLoadMeshPrimitiveAsync;
  66933. private _extensionsLoadMaterialAsync;
  66934. private _extensionsCreateMaterial;
  66935. private _extensionsLoadMaterialPropertiesAsync;
  66936. private _extensionsLoadTextureInfoAsync;
  66937. private _extensionsLoadAnimationAsync;
  66938. private _extensionsLoadSkinAsync;
  66939. private _extensionsLoadUriAsync;
  66940. /**
  66941. * Helper method called by a loader extension to load an glTF extension.
  66942. * @param context The context when loading the asset
  66943. * @param property The glTF property to load the extension from
  66944. * @param extensionName The name of the extension to load
  66945. * @param actionAsync The action to run
  66946. * @returns The promise returned by actionAsync or null if the extension does not exist
  66947. */
  66948. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66949. /**
  66950. * Helper method called by a loader extension to load a glTF extra.
  66951. * @param context The context when loading the asset
  66952. * @param property The glTF property to load the extra from
  66953. * @param extensionName The name of the extension to load
  66954. * @param actionAsync The action to run
  66955. * @returns The promise returned by actionAsync or null if the extra does not exist
  66956. */
  66957. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66958. /**
  66959. * Increments the indentation level and logs a message.
  66960. * @param message The message to log
  66961. */
  66962. logOpen(message: string): void;
  66963. /**
  66964. * Decrements the indentation level.
  66965. */
  66966. logClose(): void;
  66967. /**
  66968. * Logs a message
  66969. * @param message The message to log
  66970. */
  66971. log(message: string): void;
  66972. /**
  66973. * Starts a performance counter.
  66974. * @param counterName The name of the performance counter
  66975. */
  66976. startPerformanceCounter(counterName: string): void;
  66977. /**
  66978. * Ends a performance counter.
  66979. * @param counterName The name of the performance counter
  66980. */
  66981. endPerformanceCounter(counterName: string): void;
  66982. }
  66983. }
  66984. declare module BABYLON.GLTF2.Loader.Extensions {
  66985. /**
  66986. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  66987. */
  66988. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  66989. /** The name of this extension. */
  66990. readonly name: string;
  66991. /** Defines whether this extension is enabled. */
  66992. enabled: boolean;
  66993. private _loader;
  66994. private _lights?;
  66995. /** @hidden */
  66996. constructor(loader: GLTFLoader);
  66997. /** @hidden */
  66998. dispose(): void;
  66999. /** @hidden */
  67000. onLoading(): void;
  67001. /** @hidden */
  67002. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67003. private _loadLightAsync;
  67004. }
  67005. }
  67006. declare module BABYLON.GLTF2.Loader.Extensions {
  67007. /**
  67008. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67009. */
  67010. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67011. /** The name of this extension. */
  67012. readonly name: string;
  67013. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67014. dracoCompression?: DracoCompression;
  67015. /** Defines whether this extension is enabled. */
  67016. enabled: boolean;
  67017. private _loader;
  67018. /** @hidden */
  67019. constructor(loader: GLTFLoader);
  67020. /** @hidden */
  67021. dispose(): void;
  67022. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67023. }
  67024. }
  67025. declare module BABYLON.GLTF2.Loader.Extensions {
  67026. /**
  67027. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67028. */
  67029. export class KHR_lights implements IGLTFLoaderExtension {
  67030. /** The name of this extension. */
  67031. readonly name: string;
  67032. /** Defines whether this extension is enabled. */
  67033. enabled: boolean;
  67034. private _loader;
  67035. private _lights?;
  67036. /** @hidden */
  67037. constructor(loader: GLTFLoader);
  67038. /** @hidden */
  67039. dispose(): void;
  67040. /** @hidden */
  67041. onLoading(): void;
  67042. /** @hidden */
  67043. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67044. }
  67045. }
  67046. declare module BABYLON.GLTF2.Loader.Extensions {
  67047. /**
  67048. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67049. */
  67050. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67051. /** The name of this extension. */
  67052. readonly name: string;
  67053. /** Defines whether this extension is enabled. */
  67054. enabled: boolean;
  67055. private _loader;
  67056. /** @hidden */
  67057. constructor(loader: GLTFLoader);
  67058. /** @hidden */
  67059. dispose(): void;
  67060. /** @hidden */
  67061. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67062. private _loadSpecularGlossinessPropertiesAsync;
  67063. }
  67064. }
  67065. declare module BABYLON.GLTF2.Loader.Extensions {
  67066. /**
  67067. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67068. */
  67069. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67070. /** The name of this extension. */
  67071. readonly name: string;
  67072. /** Defines whether this extension is enabled. */
  67073. enabled: boolean;
  67074. private _loader;
  67075. /** @hidden */
  67076. constructor(loader: GLTFLoader);
  67077. /** @hidden */
  67078. dispose(): void;
  67079. /** @hidden */
  67080. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67081. private _loadUnlitPropertiesAsync;
  67082. }
  67083. }
  67084. declare module BABYLON.GLTF2.Loader.Extensions {
  67085. /**
  67086. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  67087. */
  67088. export class KHR_texture_transform implements IGLTFLoaderExtension {
  67089. /** The name of this extension. */
  67090. readonly name: string;
  67091. /** Defines whether this extension is enabled. */
  67092. enabled: boolean;
  67093. private _loader;
  67094. /** @hidden */
  67095. constructor(loader: GLTFLoader);
  67096. /** @hidden */
  67097. dispose(): void;
  67098. /** @hidden */
  67099. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67100. }
  67101. }
  67102. declare module BABYLON.GLTF2.Loader.Extensions {
  67103. /**
  67104. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  67105. */
  67106. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  67107. /** The name of this extension. */
  67108. readonly name: string;
  67109. /** Defines whether this extension is enabled. */
  67110. enabled: boolean;
  67111. private _loader;
  67112. private _clips;
  67113. private _emitters;
  67114. /** @hidden */
  67115. constructor(loader: GLTFLoader);
  67116. /** @hidden */
  67117. dispose(): void;
  67118. /** @hidden */
  67119. onLoading(): void;
  67120. /** @hidden */
  67121. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67122. /** @hidden */
  67123. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67124. /** @hidden */
  67125. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67126. private _loadClipAsync;
  67127. private _loadEmitterAsync;
  67128. private _getEventAction;
  67129. private _loadAnimationEventAsync;
  67130. }
  67131. }
  67132. declare module BABYLON.GLTF2.Loader.Extensions {
  67133. /**
  67134. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67135. */
  67136. export class MSFT_lod implements IGLTFLoaderExtension {
  67137. /** The name of this extension. */
  67138. readonly name: string;
  67139. /** Defines whether this extension is enabled. */
  67140. enabled: boolean;
  67141. /**
  67142. * Maximum number of LODs to load, starting from the lowest LOD.
  67143. */
  67144. maxLODsToLoad: number;
  67145. /**
  67146. * Observable raised when all node LODs of one level are loaded.
  67147. * The event data is the index of the loaded LOD starting from zero.
  67148. * Dispose the loader to cancel the loading of the next level of LODs.
  67149. */
  67150. onNodeLODsLoadedObservable: Observable<number>;
  67151. /**
  67152. * Observable raised when all material LODs of one level are loaded.
  67153. * The event data is the index of the loaded LOD starting from zero.
  67154. * Dispose the loader to cancel the loading of the next level of LODs.
  67155. */
  67156. onMaterialLODsLoadedObservable: Observable<number>;
  67157. private _loader;
  67158. private _nodeIndexLOD;
  67159. private _nodeSignalLODs;
  67160. private _nodePromiseLODs;
  67161. private _materialIndexLOD;
  67162. private _materialSignalLODs;
  67163. private _materialPromiseLODs;
  67164. /** @hidden */
  67165. constructor(loader: GLTFLoader);
  67166. /** @hidden */
  67167. dispose(): void;
  67168. /** @hidden */
  67169. onReady(): void;
  67170. /** @hidden */
  67171. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67172. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67173. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67174. /**
  67175. * Gets an array of LOD properties from lowest to highest.
  67176. */
  67177. private _getLODs;
  67178. private _disposeUnusedMaterials;
  67179. }
  67180. }
  67181. declare module BABYLON.GLTF2.Loader.Extensions {
  67182. /** @hidden */
  67183. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67184. readonly name: string;
  67185. enabled: boolean;
  67186. private _loader;
  67187. constructor(loader: GLTFLoader);
  67188. dispose(): void;
  67189. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67190. }
  67191. }
  67192. declare module BABYLON.GLTF2.Loader.Extensions {
  67193. /** @hidden */
  67194. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67195. readonly name: string;
  67196. enabled: boolean;
  67197. private _loader;
  67198. constructor(loader: GLTFLoader);
  67199. dispose(): void;
  67200. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67201. }
  67202. }
  67203. declare module BABYLON.GLTF2.Loader.Extensions {
  67204. /**
  67205. * Store glTF extras (if present) in BJS objects' metadata
  67206. */
  67207. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67208. /** The name of this extension. */
  67209. readonly name: string;
  67210. /** Defines whether this extension is enabled. */
  67211. enabled: boolean;
  67212. private _loader;
  67213. private _assignExtras;
  67214. /** @hidden */
  67215. constructor(loader: GLTFLoader);
  67216. /** @hidden */
  67217. dispose(): void;
  67218. /** @hidden */
  67219. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67220. /** @hidden */
  67221. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67222. /** @hidden */
  67223. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67224. }
  67225. }
  67226. declare module BABYLON {
  67227. /**
  67228. * Class reading and parsing the MTL file bundled with the obj file.
  67229. */
  67230. export class MTLFileLoader {
  67231. /**
  67232. * All material loaded from the mtl will be set here
  67233. */
  67234. materials: StandardMaterial[];
  67235. /**
  67236. * This function will read the mtl file and create each material described inside
  67237. * This function could be improve by adding :
  67238. * -some component missing (Ni, Tf...)
  67239. * -including the specific options available
  67240. *
  67241. * @param scene defines the scene the material will be created in
  67242. * @param data defines the mtl data to parse
  67243. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  67244. */
  67245. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  67246. /**
  67247. * Gets the texture for the material.
  67248. *
  67249. * If the material is imported from input file,
  67250. * We sanitize the url to ensure it takes the textre from aside the material.
  67251. *
  67252. * @param rootUrl The root url to load from
  67253. * @param value The value stored in the mtl
  67254. * @return The Texture
  67255. */
  67256. private static _getTexture;
  67257. }
  67258. /**
  67259. * Options for loading OBJ/MTL files
  67260. */
  67261. type MeshLoadOptions = {
  67262. /**
  67263. * Defines if UVs are optimized by default during load.
  67264. */
  67265. OptimizeWithUV: boolean;
  67266. /**
  67267. * Defines custom scaling of UV coordinates of loaded meshes.
  67268. */
  67269. UVScaling: Vector2;
  67270. /**
  67271. * Invert model on y-axis (does a model scaling inversion)
  67272. */
  67273. InvertY: boolean;
  67274. /**
  67275. * Invert Y-Axis of referenced textures on load
  67276. */
  67277. InvertTextureY: boolean;
  67278. /**
  67279. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67280. */
  67281. ImportVertexColors: boolean;
  67282. /**
  67283. * Compute the normals for the model, even if normals are present in the file.
  67284. */
  67285. ComputeNormals: boolean;
  67286. /**
  67287. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67288. */
  67289. SkipMaterials: boolean;
  67290. /**
  67291. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67292. */
  67293. MaterialLoadingFailsSilently: boolean;
  67294. };
  67295. /**
  67296. * OBJ file type loader.
  67297. * This is a babylon scene loader plugin.
  67298. */
  67299. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67300. /**
  67301. * Defines if UVs are optimized by default during load.
  67302. */
  67303. static OPTIMIZE_WITH_UV: boolean;
  67304. /**
  67305. * Invert model on y-axis (does a model scaling inversion)
  67306. */
  67307. static INVERT_Y: boolean;
  67308. /**
  67309. * Invert Y-Axis of referenced textures on load
  67310. */
  67311. static INVERT_TEXTURE_Y: boolean;
  67312. /**
  67313. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67314. */
  67315. static IMPORT_VERTEX_COLORS: boolean;
  67316. /**
  67317. * Compute the normals for the model, even if normals are present in the file.
  67318. */
  67319. static COMPUTE_NORMALS: boolean;
  67320. /**
  67321. * Defines custom scaling of UV coordinates of loaded meshes.
  67322. */
  67323. static UV_SCALING: Vector2;
  67324. /**
  67325. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67326. */
  67327. static SKIP_MATERIALS: boolean;
  67328. /**
  67329. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67330. *
  67331. * Defaults to true for backwards compatibility.
  67332. */
  67333. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  67334. /**
  67335. * Defines the name of the plugin.
  67336. */
  67337. name: string;
  67338. /**
  67339. * Defines the extension the plugin is able to load.
  67340. */
  67341. extensions: string;
  67342. /** @hidden */
  67343. obj: RegExp;
  67344. /** @hidden */
  67345. group: RegExp;
  67346. /** @hidden */
  67347. mtllib: RegExp;
  67348. /** @hidden */
  67349. usemtl: RegExp;
  67350. /** @hidden */
  67351. smooth: RegExp;
  67352. /** @hidden */
  67353. vertexPattern: RegExp;
  67354. /** @hidden */
  67355. normalPattern: RegExp;
  67356. /** @hidden */
  67357. uvPattern: RegExp;
  67358. /** @hidden */
  67359. facePattern1: RegExp;
  67360. /** @hidden */
  67361. facePattern2: RegExp;
  67362. /** @hidden */
  67363. facePattern3: RegExp;
  67364. /** @hidden */
  67365. facePattern4: RegExp;
  67366. /** @hidden */
  67367. facePattern5: RegExp;
  67368. private _meshLoadOptions;
  67369. /**
  67370. * Creates loader for .OBJ files
  67371. *
  67372. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  67373. */
  67374. constructor(meshLoadOptions?: MeshLoadOptions);
  67375. private static readonly currentMeshLoadOptions;
  67376. /**
  67377. * Calls synchronously the MTL file attached to this obj.
  67378. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  67379. * Without this function materials are not displayed in the first frame (but displayed after).
  67380. * In consequence it is impossible to get material information in your HTML file
  67381. *
  67382. * @param url The URL of the MTL file
  67383. * @param rootUrl
  67384. * @param onSuccess Callback function to be called when the MTL file is loaded
  67385. * @private
  67386. */
  67387. private _loadMTL;
  67388. /**
  67389. * Instantiates a OBJ file loader plugin.
  67390. * @returns the created plugin
  67391. */
  67392. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  67393. /**
  67394. * If the data string can be loaded directly.
  67395. *
  67396. * @param data string containing the file data
  67397. * @returns if the data can be loaded directly
  67398. */
  67399. canDirectLoad(data: string): boolean;
  67400. /**
  67401. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  67402. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67403. * @param scene the scene the meshes should be added to
  67404. * @param data the OBJ data to load
  67405. * @param rootUrl root url to load from
  67406. * @param onProgress event that fires when loading progress has occured
  67407. * @param fileName Defines the name of the file to load
  67408. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67409. */
  67410. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67411. meshes: AbstractMesh[];
  67412. particleSystems: IParticleSystem[];
  67413. skeletons: Skeleton[];
  67414. animationGroups: AnimationGroup[];
  67415. }>;
  67416. /**
  67417. * Imports all objects from the loaded OBJ data and adds them to the scene
  67418. * @param scene the scene the objects should be added to
  67419. * @param data the OBJ data to load
  67420. * @param rootUrl root url to load from
  67421. * @param onProgress event that fires when loading progress has occured
  67422. * @param fileName Defines the name of the file to load
  67423. * @returns a promise which completes when objects have been loaded to the scene
  67424. */
  67425. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67426. /**
  67427. * Load into an asset container.
  67428. * @param scene The scene to load into
  67429. * @param data The data to import
  67430. * @param rootUrl The root url for scene and resources
  67431. * @param onProgress The callback when the load progresses
  67432. * @param fileName Defines the name of the file to load
  67433. * @returns The loaded asset container
  67434. */
  67435. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67436. /**
  67437. * Read the OBJ file and create an Array of meshes.
  67438. * Each mesh contains all information given by the OBJ and the MTL file.
  67439. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  67440. *
  67441. * @param meshesNames
  67442. * @param scene Scene The scene where are displayed the data
  67443. * @param data String The content of the obj file
  67444. * @param rootUrl String The path to the folder
  67445. * @returns Array<AbstractMesh>
  67446. * @private
  67447. */
  67448. private _parseSolid;
  67449. }
  67450. }
  67451. declare module BABYLON {
  67452. /**
  67453. * STL file type loader.
  67454. * This is a babylon scene loader plugin.
  67455. */
  67456. export class STLFileLoader implements ISceneLoaderPlugin {
  67457. /** @hidden */
  67458. solidPattern: RegExp;
  67459. /** @hidden */
  67460. facetsPattern: RegExp;
  67461. /** @hidden */
  67462. normalPattern: RegExp;
  67463. /** @hidden */
  67464. vertexPattern: RegExp;
  67465. /**
  67466. * Defines the name of the plugin.
  67467. */
  67468. name: string;
  67469. /**
  67470. * Defines the extensions the stl loader is able to load.
  67471. * force data to come in as an ArrayBuffer
  67472. * we'll convert to string if it looks like it's an ASCII .stl
  67473. */
  67474. extensions: ISceneLoaderPluginExtensions;
  67475. /**
  67476. * Import meshes into a scene.
  67477. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  67478. * @param scene The scene to import into
  67479. * @param data The data to import
  67480. * @param rootUrl The root url for scene and resources
  67481. * @param meshes The meshes array to import into
  67482. * @param particleSystems The particle systems array to import into
  67483. * @param skeletons The skeletons array to import into
  67484. * @param onError The callback when import fails
  67485. * @returns True if successful or false otherwise
  67486. */
  67487. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  67488. /**
  67489. * Load into a scene.
  67490. * @param scene The scene to load into
  67491. * @param data The data to import
  67492. * @param rootUrl The root url for scene and resources
  67493. * @param onError The callback when import fails
  67494. * @returns true if successful or false otherwise
  67495. */
  67496. load(scene: Scene, data: any, rootUrl: string): boolean;
  67497. /**
  67498. * Load into an asset container.
  67499. * @param scene The scene to load into
  67500. * @param data The data to import
  67501. * @param rootUrl The root url for scene and resources
  67502. * @param onError The callback when import fails
  67503. * @returns The loaded asset container
  67504. */
  67505. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  67506. private _isBinary;
  67507. private _parseBinary;
  67508. private _parseASCII;
  67509. }
  67510. }
  67511. declare module BABYLON {
  67512. /**
  67513. * Class for generating OBJ data from a Babylon scene.
  67514. */
  67515. export class OBJExport {
  67516. /**
  67517. * Exports the geometry of a Mesh array in .OBJ file format (text)
  67518. * @param mesh defines the list of meshes to serialize
  67519. * @param materials defines if materials should be exported
  67520. * @param matlibname defines the name of the associated mtl file
  67521. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  67522. * @returns the OBJ content
  67523. */
  67524. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  67525. /**
  67526. * Exports the material(s) of a mesh in .MTL file format (text)
  67527. * @param mesh defines the mesh to extract the material from
  67528. * @returns the mtl content
  67529. */
  67530. static MTL(mesh: Mesh): string;
  67531. }
  67532. }
  67533. declare module BABYLON {
  67534. /** @hidden */
  67535. export var __IGLTFExporterExtension: number;
  67536. /**
  67537. * Interface for extending the exporter
  67538. * @hidden
  67539. */
  67540. export interface IGLTFExporterExtension {
  67541. /**
  67542. * The name of this extension
  67543. */
  67544. readonly name: string;
  67545. /**
  67546. * Defines whether this extension is enabled
  67547. */
  67548. enabled: boolean;
  67549. /**
  67550. * Defines whether this extension is required
  67551. */
  67552. required: boolean;
  67553. }
  67554. }
  67555. declare module BABYLON.GLTF2.Exporter {
  67556. /** @hidden */
  67557. export var __IGLTFExporterExtensionV2: number;
  67558. /**
  67559. * Interface for a glTF exporter extension
  67560. * @hidden
  67561. */
  67562. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  67563. /**
  67564. * Define this method to modify the default behavior before exporting a texture
  67565. * @param context The context when loading the asset
  67566. * @param babylonTexture The glTF texture info property
  67567. * @param mimeType The mime-type of the generated image
  67568. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  67569. */
  67570. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67571. /**
  67572. * Define this method to modify the default behavior when exporting texture info
  67573. * @param context The context when loading the asset
  67574. * @param meshPrimitive glTF mesh primitive
  67575. * @param babylonSubMesh Babylon submesh
  67576. * @param binaryWriter glTF serializer binary writer instance
  67577. * @returns nullable IMeshPrimitive promise
  67578. */
  67579. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67580. /**
  67581. * Define this method to modify the default behavior when exporting a node
  67582. * @param context The context when exporting the node
  67583. * @param node glTF node
  67584. * @param babylonNode BabylonJS node
  67585. * @returns nullable INode promise
  67586. */
  67587. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67588. /**
  67589. * Called after the exporter state changes to EXPORTING
  67590. */
  67591. onExporting?(): void;
  67592. }
  67593. }
  67594. declare module BABYLON.GLTF2.Exporter {
  67595. /**
  67596. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  67597. * @hidden
  67598. */
  67599. export class _GLTFMaterialExporter {
  67600. /**
  67601. * Represents the dielectric specular values for R, G and B
  67602. */
  67603. private static readonly _DielectricSpecular;
  67604. /**
  67605. * Allows the maximum specular power to be defined for material calculations
  67606. */
  67607. private static readonly _MaxSpecularPower;
  67608. /**
  67609. * Mapping to store textures
  67610. */
  67611. private _textureMap;
  67612. /**
  67613. * Numeric tolerance value
  67614. */
  67615. private static readonly _Epsilon;
  67616. /**
  67617. * Reference to the glTF Exporter
  67618. */
  67619. private _exporter;
  67620. constructor(exporter: _Exporter);
  67621. /**
  67622. * Specifies if two colors are approximately equal in value
  67623. * @param color1 first color to compare to
  67624. * @param color2 second color to compare to
  67625. * @param epsilon threshold value
  67626. */
  67627. private static FuzzyEquals;
  67628. /**
  67629. * Gets the materials from a Babylon scene and converts them to glTF materials
  67630. * @param scene babylonjs scene
  67631. * @param mimeType texture mime type
  67632. * @param images array of images
  67633. * @param textures array of textures
  67634. * @param materials array of materials
  67635. * @param imageData mapping of texture names to base64 textures
  67636. * @param hasTextureCoords specifies if texture coordinates are present on the material
  67637. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67638. /**
  67639. * Makes a copy of the glTF material without the texture parameters
  67640. * @param originalMaterial original glTF material
  67641. * @returns glTF material without texture parameters
  67642. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  67643. /**
  67644. * Specifies if the material has any texture parameters present
  67645. * @param material glTF Material
  67646. * @returns boolean specifying if texture parameters are present
  67647. */ private _hasTexturesPresent(material: IMaterial): boolean;
  67648. /**
  67649. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  67650. * @param babylonStandardMaterial
  67651. * @returns glTF Metallic Roughness Material representation
  67652. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  67653. /**
  67654. * Computes the metallic factor
  67655. * @param diffuse diffused value
  67656. * @param specular specular value
  67657. * @param oneMinusSpecularStrength one minus the specular strength
  67658. * @returns metallic value
  67659. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  67660. /**
  67661. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  67662. * @param glTFMaterial glTF material
  67663. * @param babylonMaterial Babylon material
  67664. */
  67665. private static _SetAlphaMode;
  67666. /**
  67667. * Converts a Babylon Standard Material to a glTF Material
  67668. * @param babylonStandardMaterial BJS Standard Material
  67669. * @param mimeType mime type to use for the textures
  67670. * @param images array of glTF image interfaces
  67671. * @param textures array of glTF texture interfaces
  67672. * @param materials array of glTF material interfaces
  67673. * @param imageData map of image file name to data
  67674. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67675. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67676. /**
  67677. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67678. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  67679. * @param mimeType mime type to use for the textures
  67680. * @param images array of glTF image interfaces
  67681. * @param textures array of glTF texture interfaces
  67682. * @param materials array of glTF material interfaces
  67683. * @param imageData map of image file name to data
  67684. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67685. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67686. /**
  67687. * Converts an image typed array buffer to a base64 image
  67688. * @param buffer typed array buffer
  67689. * @param width width of the image
  67690. * @param height height of the image
  67691. * @param mimeType mimetype of the image
  67692. * @returns base64 image string
  67693. */
  67694. private _createBase64FromCanvasAsync;
  67695. /**
  67696. * Generates a white texture based on the specified width and height
  67697. * @param width width of the texture in pixels
  67698. * @param height height of the texture in pixels
  67699. * @param scene babylonjs scene
  67700. * @returns white texture
  67701. */
  67702. private _createWhiteTexture;
  67703. /**
  67704. * 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
  67705. * @param texture1 first texture to resize
  67706. * @param texture2 second texture to resize
  67707. * @param scene babylonjs scene
  67708. * @returns resized textures or null
  67709. */
  67710. private _resizeTexturesToSameDimensions;
  67711. /**
  67712. * Converts an array of pixels to a Float32Array
  67713. * Throws an error if the pixel format is not supported
  67714. * @param pixels - array buffer containing pixel values
  67715. * @returns Float32 of pixels
  67716. */
  67717. private _convertPixelArrayToFloat32;
  67718. /**
  67719. * Convert Specular Glossiness Textures to Metallic Roughness
  67720. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  67721. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  67722. * @param diffuseTexture texture used to store diffuse information
  67723. * @param specularGlossinessTexture texture used to store specular and glossiness information
  67724. * @param factors specular glossiness material factors
  67725. * @param mimeType the mime type to use for the texture
  67726. * @returns pbr metallic roughness interface or null
  67727. */
  67728. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  67729. /**
  67730. * Converts specular glossiness material properties to metallic roughness
  67731. * @param specularGlossiness interface with specular glossiness material properties
  67732. * @returns interface with metallic roughness material properties
  67733. */
  67734. private _convertSpecularGlossinessToMetallicRoughness;
  67735. /**
  67736. * Calculates the surface reflectance, independent of lighting conditions
  67737. * @param color Color source to calculate brightness from
  67738. * @returns number representing the perceived brightness, or zero if color is undefined
  67739. */
  67740. private _getPerceivedBrightness;
  67741. /**
  67742. * Returns the maximum color component value
  67743. * @param color
  67744. * @returns maximum color component value, or zero if color is null or undefined
  67745. */
  67746. private _getMaxComponent;
  67747. /**
  67748. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  67749. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67750. * @param mimeType mime type to use for the textures
  67751. * @param images array of glTF image interfaces
  67752. * @param textures array of glTF texture interfaces
  67753. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67754. * @param imageData map of image file name to data
  67755. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67756. * @returns glTF PBR Metallic Roughness factors
  67757. */
  67758. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  67759. private _getGLTFTextureSampler;
  67760. private _getGLTFTextureWrapMode;
  67761. private _getGLTFTextureWrapModesSampler;
  67762. /**
  67763. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  67764. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67765. * @param mimeType mime type to use for the textures
  67766. * @param images array of glTF image interfaces
  67767. * @param textures array of glTF texture interfaces
  67768. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67769. * @param imageData map of image file name to data
  67770. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67771. * @returns glTF PBR Metallic Roughness factors
  67772. */
  67773. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  67774. /**
  67775. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67776. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67777. * @param mimeType mime type to use for the textures
  67778. * @param images array of glTF image interfaces
  67779. * @param textures array of glTF texture interfaces
  67780. * @param materials array of glTF material interfaces
  67781. * @param imageData map of image file name to data
  67782. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67783. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67784. private setMetallicRoughnessPbrMaterial;
  67785. private getPixelsFromTexture;
  67786. /**
  67787. * Extracts a texture from a Babylon texture into file data and glTF data
  67788. * @param babylonTexture Babylon texture to extract
  67789. * @param mimeType Mime Type of the babylonTexture
  67790. * @return glTF texture info, or null if the texture format is not supported
  67791. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67792. /**
  67793. * Builds a texture from base64 string
  67794. * @param base64Texture base64 texture string
  67795. * @param baseTextureName Name to use for the texture
  67796. * @param mimeType image mime type for the texture
  67797. * @param images array of images
  67798. * @param textures array of textures
  67799. * @param imageData map of image data
  67800. * @returns glTF texture info, or null if the texture format is not supported
  67801. */
  67802. private _getTextureInfoFromBase64;
  67803. }
  67804. }
  67805. declare module BABYLON {
  67806. /**
  67807. * Class for holding and downloading glTF file data
  67808. */
  67809. export class GLTFData {
  67810. /**
  67811. * Object which contains the file name as the key and its data as the value
  67812. */
  67813. glTFFiles: {
  67814. [fileName: string]: string | Blob;
  67815. };
  67816. /**
  67817. * Initializes the glTF file object
  67818. */
  67819. constructor();
  67820. /**
  67821. * Downloads the glTF data as files based on their names and data
  67822. */
  67823. downloadFiles(): void;
  67824. }
  67825. }
  67826. declare module BABYLON {
  67827. /**
  67828. * Holds a collection of exporter options and parameters
  67829. */
  67830. export interface IExportOptions {
  67831. /**
  67832. * Function which indicates whether a babylon node should be exported or not
  67833. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  67834. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  67835. */
  67836. shouldExportNode?(node: Node): boolean;
  67837. /**
  67838. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  67839. * @param metadata source metadata to read from
  67840. * @returns the data to store to glTF node extras
  67841. */
  67842. metadataSelector?(metadata: any): any;
  67843. /**
  67844. * The sample rate to bake animation curves
  67845. */
  67846. animationSampleRate?: number;
  67847. /**
  67848. * Begin serialization without waiting for the scene to be ready
  67849. */
  67850. exportWithoutWaitingForScene?: boolean;
  67851. }
  67852. /**
  67853. * Class for generating glTF data from a Babylon scene.
  67854. */
  67855. export class GLTF2Export {
  67856. /**
  67857. * Exports the geometry of the scene to .gltf file format asynchronously
  67858. * @param scene Babylon scene with scene hierarchy information
  67859. * @param filePrefix File prefix to use when generating the glTF file
  67860. * @param options Exporter options
  67861. * @returns Returns an object with a .gltf file and associates texture names
  67862. * as keys and their data and paths as values
  67863. */
  67864. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67865. private static _PreExportAsync;
  67866. private static _PostExportAsync;
  67867. /**
  67868. * Exports the geometry of the scene to .glb file format asychronously
  67869. * @param scene Babylon scene with scene hierarchy information
  67870. * @param filePrefix File prefix to use when generating glb file
  67871. * @param options Exporter options
  67872. * @returns Returns an object with a .glb filename as key and data as value
  67873. */
  67874. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67875. }
  67876. }
  67877. declare module BABYLON.GLTF2.Exporter {
  67878. /**
  67879. * @hidden
  67880. */
  67881. export class _GLTFUtilities {
  67882. /**
  67883. * Creates a buffer view based on the supplied arguments
  67884. * @param bufferIndex index value of the specified buffer
  67885. * @param byteOffset byte offset value
  67886. * @param byteLength byte length of the bufferView
  67887. * @param byteStride byte distance between conequential elements
  67888. * @param name name of the buffer view
  67889. * @returns bufferView for glTF
  67890. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  67891. /**
  67892. * Creates an accessor based on the supplied arguments
  67893. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  67894. * @param name The name of the accessor
  67895. * @param type The type of the accessor
  67896. * @param componentType The datatype of components in the attribute
  67897. * @param count The number of attributes referenced by this accessor
  67898. * @param byteOffset The offset relative to the start of the bufferView in bytes
  67899. * @param min Minimum value of each component in this attribute
  67900. * @param max Maximum value of each component in this attribute
  67901. * @returns accessor for glTF
  67902. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  67903. /**
  67904. * Calculates the minimum and maximum values of an array of position floats
  67905. * @param positions Positions array of a mesh
  67906. * @param vertexStart Starting vertex offset to calculate min and max values
  67907. * @param vertexCount Number of vertices to check for min and max values
  67908. * @returns min number array and max number array
  67909. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  67910. min: number[];
  67911. max: number[];
  67912. };
  67913. /**
  67914. * Converts a new right-handed Vector3
  67915. * @param vector vector3 array
  67916. * @returns right-handed Vector3
  67917. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  67918. /**
  67919. * Converts a Vector3 to right-handed
  67920. * @param vector Vector3 to convert to right-handed
  67921. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  67922. /**
  67923. * Converts a three element number array to right-handed
  67924. * @param vector number array to convert to right-handed
  67925. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  67926. /**
  67927. * Converts a new right-handed Vector3
  67928. * @param vector vector3 array
  67929. * @returns right-handed Vector3
  67930. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  67931. /**
  67932. * Converts a Vector3 to right-handed
  67933. * @param vector Vector3 to convert to right-handed
  67934. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  67935. /**
  67936. * Converts a three element number array to right-handed
  67937. * @param vector number array to convert to right-handed
  67938. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  67939. /**
  67940. * Converts a Vector4 to right-handed
  67941. * @param vector Vector4 to convert to right-handed
  67942. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  67943. /**
  67944. * Converts a Vector4 to right-handed
  67945. * @param vector Vector4 to convert to right-handed
  67946. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  67947. /**
  67948. * Converts a Quaternion to right-handed
  67949. * @param quaternion Source quaternion to convert to right-handed
  67950. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  67951. /**
  67952. * Converts a Quaternion to right-handed
  67953. * @param quaternion Source quaternion to convert to right-handed
  67954. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  67955. }
  67956. }
  67957. declare module BABYLON.GLTF2.Exporter {
  67958. /**
  67959. * Converts Babylon Scene into glTF 2.0.
  67960. * @hidden
  67961. */
  67962. export class _Exporter {
  67963. /**
  67964. * Stores the glTF to export
  67965. */ private _glTF: IGLTF;
  67966. /**
  67967. * Stores all generated buffer views, which represents views into the main glTF buffer data
  67968. */ private _bufferViews: IBufferView[];
  67969. /**
  67970. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  67971. */ private _accessors: IAccessor[];
  67972. /**
  67973. * Stores all the generated nodes, which contains transform and/or mesh information per node
  67974. */
  67975. private _nodes;
  67976. /**
  67977. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  67978. */
  67979. private _scenes;
  67980. /**
  67981. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  67982. */
  67983. private _meshes;
  67984. /**
  67985. * Stores all the generated material information, which represents the appearance of each primitive
  67986. */ private _materials: IMaterial[]; private _materialMap: {
  67987. [materialID: number]: number;
  67988. };
  67989. /**
  67990. * Stores all the generated texture information, which is referenced by glTF materials
  67991. */ private _textures: ITexture[];
  67992. /**
  67993. * Stores all the generated image information, which is referenced by glTF textures
  67994. */ private _images: IImage[];
  67995. /**
  67996. * Stores all the texture samplers
  67997. */ private _samplers: ISampler[];
  67998. /**
  67999. * Stores all the generated animation samplers, which is referenced by glTF animations
  68000. */
  68001. /**
  68002. * Stores the animations for glTF models
  68003. */
  68004. private _animations;
  68005. /**
  68006. * Stores the total amount of bytes stored in the glTF buffer
  68007. */
  68008. private _totalByteLength;
  68009. /**
  68010. * Stores a reference to the Babylon scene containing the source geometry and material information
  68011. */ private _babylonScene: Scene;
  68012. /**
  68013. * Stores a map of the image data, where the key is the file name and the value
  68014. * is the image data
  68015. */ private _imageData: {
  68016. [fileName: string]: {
  68017. data: Uint8Array;
  68018. mimeType: ImageMimeType;
  68019. };
  68020. };
  68021. /**
  68022. * Stores a map of the unique id of a node to its index in the node array
  68023. */
  68024. private _nodeMap;
  68025. /**
  68026. * Specifies if the Babylon scene should be converted to right-handed on export
  68027. */ private _convertToRightHandedSystem: boolean;
  68028. /**
  68029. * Baked animation sample rate
  68030. */
  68031. private _animationSampleRate;
  68032. private _options;
  68033. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  68034. private _extensions;
  68035. private static _ExtensionNames;
  68036. private static _ExtensionFactories;
  68037. private _applyExtensions; private _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; private _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; private _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68038. private _forEachExtensions;
  68039. private _extensionsOnExporting;
  68040. /**
  68041. * Load glTF serializer extensions
  68042. */
  68043. private _loadExtensions;
  68044. /**
  68045. * Creates a glTF Exporter instance, which can accept optional exporter options
  68046. * @param babylonScene Babylon scene object
  68047. * @param options Options to modify the behavior of the exporter
  68048. */
  68049. constructor(babylonScene: Scene, options?: IExportOptions);
  68050. /**
  68051. * Registers a glTF exporter extension
  68052. * @param name Name of the extension to export
  68053. * @param factory The factory function that creates the exporter extension
  68054. */
  68055. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68056. /**
  68057. * Un-registers an exporter extension
  68058. * @param name The name fo the exporter extension
  68059. * @returns A boolean indicating whether the extension has been un-registered
  68060. */
  68061. static UnregisterExtension(name: string): boolean;
  68062. /**
  68063. * Lazy load a local engine with premultiplied alpha set to false
  68064. */ private _getLocalEngine(): Engine;
  68065. private reorderIndicesBasedOnPrimitiveMode;
  68066. /**
  68067. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68068. * clock-wise during export to glTF
  68069. * @param submesh BabylonJS submesh
  68070. * @param primitiveMode Primitive mode of the mesh
  68071. * @param sideOrientation the winding order of the submesh
  68072. * @param vertexBufferKind The type of vertex attribute
  68073. * @param meshAttributeArray The vertex attribute data
  68074. * @param byteOffset The offset to the binary data
  68075. * @param binaryWriter The binary data for the glTF file
  68076. */
  68077. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68078. /**
  68079. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68080. * clock-wise during export to glTF
  68081. * @param submesh BabylonJS submesh
  68082. * @param primitiveMode Primitive mode of the mesh
  68083. * @param sideOrientation the winding order of the submesh
  68084. * @param vertexBufferKind The type of vertex attribute
  68085. * @param meshAttributeArray The vertex attribute data
  68086. * @param byteOffset The offset to the binary data
  68087. * @param binaryWriter The binary data for the glTF file
  68088. */
  68089. private reorderTriangleFillMode;
  68090. /**
  68091. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68092. * clock-wise during export to glTF
  68093. * @param submesh BabylonJS submesh
  68094. * @param primitiveMode Primitive mode of the mesh
  68095. * @param sideOrientation the winding order of the submesh
  68096. * @param vertexBufferKind The type of vertex attribute
  68097. * @param meshAttributeArray The vertex attribute data
  68098. * @param byteOffset The offset to the binary data
  68099. * @param binaryWriter The binary data for the glTF file
  68100. */
  68101. private reorderTriangleStripDrawMode;
  68102. /**
  68103. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68104. * clock-wise during export to glTF
  68105. * @param submesh BabylonJS submesh
  68106. * @param primitiveMode Primitive mode of the mesh
  68107. * @param sideOrientation the winding order of the submesh
  68108. * @param vertexBufferKind The type of vertex attribute
  68109. * @param meshAttributeArray The vertex attribute data
  68110. * @param byteOffset The offset to the binary data
  68111. * @param binaryWriter The binary data for the glTF file
  68112. */
  68113. private reorderTriangleFanMode;
  68114. /**
  68115. * Writes the vertex attribute data to binary
  68116. * @param vertices The vertices to write to the binary writer
  68117. * @param byteOffset The offset into the binary writer to overwrite binary data
  68118. * @param vertexAttributeKind The vertex attribute type
  68119. * @param meshAttributeArray The vertex attribute data
  68120. * @param binaryWriter The writer containing the binary data
  68121. */
  68122. private writeVertexAttributeData;
  68123. /**
  68124. * Writes mesh attribute data to a data buffer
  68125. * Returns the bytelength of the data
  68126. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68127. * @param meshAttributeArray Array containing the attribute data
  68128. * @param binaryWriter The buffer to write the binary data to
  68129. * @param indices Used to specify the order of the vertex data
  68130. */
  68131. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68132. /**
  68133. * Generates glTF json data
  68134. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68135. * @param glTFPrefix Text to use when prefixing a glTF file
  68136. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68137. * @returns json data as string
  68138. */
  68139. private generateJSON;
  68140. /**
  68141. * Generates data for .gltf and .bin files based on the glTF prefix string
  68142. * @param glTFPrefix Text to use when prefixing a glTF file
  68143. * @returns GLTFData with glTF file data
  68144. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68145. /**
  68146. * Creates a binary buffer for glTF
  68147. * @returns array buffer for binary data
  68148. */
  68149. private _generateBinaryAsync;
  68150. /**
  68151. * Pads the number to a multiple of 4
  68152. * @param num number to pad
  68153. * @returns padded number
  68154. */
  68155. private _getPadding;
  68156. /**
  68157. * Generates a glb file from the json and binary data
  68158. * Returns an object with the glb file name as the key and data as the value
  68159. * @param glTFPrefix
  68160. * @returns object with glb filename as key and data as value
  68161. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68162. /**
  68163. * Sets the TRS for each node
  68164. * @param node glTF Node for storing the transformation data
  68165. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68166. */
  68167. private setNodeTransformation;
  68168. private getVertexBufferFromMesh;
  68169. /**
  68170. * Creates a bufferview based on the vertices type for the Babylon mesh
  68171. * @param kind Indicates the type of vertices data
  68172. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68173. * @param binaryWriter The buffer to write the bufferview data to
  68174. */
  68175. private createBufferViewKind;
  68176. /**
  68177. * The primitive mode of the Babylon mesh
  68178. * @param babylonMesh The BabylonJS mesh
  68179. */
  68180. private getMeshPrimitiveMode;
  68181. /**
  68182. * Sets the primitive mode of the glTF mesh primitive
  68183. * @param meshPrimitive glTF mesh primitive
  68184. * @param primitiveMode The primitive mode
  68185. */
  68186. private setPrimitiveMode;
  68187. /**
  68188. * Sets the vertex attribute accessor based of the glTF mesh primitive
  68189. * @param meshPrimitive glTF mesh primitive
  68190. * @param attributeKind vertex attribute
  68191. * @returns boolean specifying if uv coordinates are present
  68192. */
  68193. private setAttributeKind;
  68194. /**
  68195. * Sets data for the primitive attributes of each submesh
  68196. * @param mesh glTF Mesh object to store the primitive attribute information
  68197. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  68198. * @param binaryWriter Buffer to write the attribute data to
  68199. */
  68200. private setPrimitiveAttributesAsync;
  68201. /**
  68202. * Creates a glTF scene based on the array of meshes
  68203. * Returns the the total byte offset
  68204. * @param babylonScene Babylon scene to get the mesh data from
  68205. * @param binaryWriter Buffer to write binary data to
  68206. */
  68207. private createSceneAsync;
  68208. /**
  68209. * Creates a mapping of Node unique id to node index and handles animations
  68210. * @param babylonScene Babylon Scene
  68211. * @param nodes Babylon transform nodes
  68212. * @param binaryWriter Buffer to write binary data to
  68213. * @returns Node mapping of unique id to index
  68214. */
  68215. private createNodeMapAndAnimationsAsync;
  68216. /**
  68217. * Creates a glTF node from a Babylon mesh
  68218. * @param babylonMesh Source Babylon mesh
  68219. * @param binaryWriter Buffer for storing geometry data
  68220. * @returns glTF node
  68221. */
  68222. private createNodeAsync;
  68223. }
  68224. /**
  68225. * @hidden
  68226. *
  68227. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  68228. */
  68229. export class _BinaryWriter {
  68230. /**
  68231. * Array buffer which stores all binary data
  68232. */
  68233. private _arrayBuffer;
  68234. /**
  68235. * View of the array buffer
  68236. */
  68237. private _dataView;
  68238. /**
  68239. * byte offset of data in array buffer
  68240. */
  68241. private _byteOffset;
  68242. /**
  68243. * Initialize binary writer with an initial byte length
  68244. * @param byteLength Initial byte length of the array buffer
  68245. */
  68246. constructor(byteLength: number);
  68247. /**
  68248. * Resize the array buffer to the specified byte length
  68249. * @param byteLength
  68250. */
  68251. private resizeBuffer;
  68252. /**
  68253. * Get an array buffer with the length of the byte offset
  68254. * @returns ArrayBuffer resized to the byte offset
  68255. */
  68256. getArrayBuffer(): ArrayBuffer;
  68257. /**
  68258. * Get the byte offset of the array buffer
  68259. * @returns byte offset
  68260. */
  68261. getByteOffset(): number;
  68262. /**
  68263. * Stores an UInt8 in the array buffer
  68264. * @param entry
  68265. * @param byteOffset If defined, specifies where to set the value as an offset.
  68266. */
  68267. setUInt8(entry: number, byteOffset?: number): void;
  68268. /**
  68269. * Gets an UInt32 in the array buffer
  68270. * @param entry
  68271. * @param byteOffset If defined, specifies where to set the value as an offset.
  68272. */
  68273. getUInt32(byteOffset: number): number;
  68274. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68275. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68276. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68277. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68278. /**
  68279. * Stores a Float32 in the array buffer
  68280. * @param entry
  68281. */
  68282. setFloat32(entry: number, byteOffset?: number): void;
  68283. /**
  68284. * Stores an UInt32 in the array buffer
  68285. * @param entry
  68286. * @param byteOffset If defined, specifies where to set the value as an offset.
  68287. */
  68288. setUInt32(entry: number, byteOffset?: number): void;
  68289. }
  68290. }
  68291. declare module BABYLON.GLTF2.Exporter {
  68292. /**
  68293. * @hidden
  68294. * Interface to store animation data.
  68295. */
  68296. export interface _IAnimationData {
  68297. /**
  68298. * Keyframe data.
  68299. */
  68300. inputs: number[];
  68301. /**
  68302. * Value data.
  68303. */
  68304. outputs: number[][];
  68305. /**
  68306. * Animation interpolation data.
  68307. */
  68308. samplerInterpolation: AnimationSamplerInterpolation;
  68309. /**
  68310. * Minimum keyframe value.
  68311. */
  68312. inputsMin: number;
  68313. /**
  68314. * Maximum keyframe value.
  68315. */
  68316. inputsMax: number;
  68317. }
  68318. /**
  68319. * @hidden
  68320. */
  68321. export interface _IAnimationInfo {
  68322. /**
  68323. * The target channel for the animation
  68324. */
  68325. animationChannelTargetPath: AnimationChannelTargetPath;
  68326. /**
  68327. * The glTF accessor type for the data.
  68328. */
  68329. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  68330. /**
  68331. * Specifies if quaternions should be used.
  68332. */
  68333. useQuaternion: boolean;
  68334. }
  68335. /**
  68336. * @hidden
  68337. * Utility class for generating glTF animation data from BabylonJS.
  68338. */
  68339. export class _GLTFAnimation {
  68340. /**
  68341. * @ignore
  68342. *
  68343. * Creates glTF channel animation from BabylonJS animation.
  68344. * @param babylonTransformNode - BabylonJS mesh.
  68345. * @param animation - animation.
  68346. * @param animationChannelTargetPath - The target animation channel.
  68347. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  68348. * @param useQuaternion - Specifies if quaternions are used.
  68349. * @returns nullable IAnimationData
  68350. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  68351. private static _DeduceAnimationInfo;
  68352. /**
  68353. * @ignore
  68354. * Create node animations from the transform node animations
  68355. * @param babylonNode
  68356. * @param runtimeGLTFAnimation
  68357. * @param idleGLTFAnimations
  68358. * @param nodeMap
  68359. * @param nodes
  68360. * @param binaryWriter
  68361. * @param bufferViews
  68362. * @param accessors
  68363. * @param convertToRightHandedSystem
  68364. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  68365. [key: number]: number;
  68366. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68367. /**
  68368. * @ignore
  68369. * Create node animations from the animation groups
  68370. * @param babylonScene
  68371. * @param glTFAnimations
  68372. * @param nodeMap
  68373. * @param nodes
  68374. * @param binaryWriter
  68375. * @param bufferViews
  68376. * @param accessors
  68377. * @param convertToRightHandedSystem
  68378. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  68379. [key: number]: number;
  68380. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68381. private static AddAnimation;
  68382. /**
  68383. * Create a baked animation
  68384. * @param babylonTransformNode BabylonJS mesh
  68385. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  68386. * @param animationChannelTargetPath animation target channel
  68387. * @param minFrame minimum animation frame
  68388. * @param maxFrame maximum animation frame
  68389. * @param fps frames per second of the animation
  68390. * @param inputs input key frames of the animation
  68391. * @param outputs output key frame data of the animation
  68392. * @param convertToRightHandedSystem converts the values to right-handed
  68393. * @param useQuaternion specifies if quaternions should be used
  68394. */
  68395. private static _CreateBakedAnimation;
  68396. private static _ConvertFactorToVector3OrQuaternion;
  68397. private static _SetInterpolatedValue;
  68398. /**
  68399. * Creates linear animation from the animation key frames
  68400. * @param babylonTransformNode BabylonJS mesh
  68401. * @param animation BabylonJS animation
  68402. * @param animationChannelTargetPath The target animation channel
  68403. * @param frameDelta The difference between the last and first frame of the animation
  68404. * @param inputs Array to store the key frame times
  68405. * @param outputs Array to store the key frame data
  68406. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68407. * @param useQuaternion Specifies if quaternions are used in the animation
  68408. */
  68409. private static _CreateLinearOrStepAnimation;
  68410. /**
  68411. * Creates cubic spline animation from the animation key frames
  68412. * @param babylonTransformNode BabylonJS mesh
  68413. * @param animation BabylonJS animation
  68414. * @param animationChannelTargetPath The target animation channel
  68415. * @param frameDelta The difference between the last and first frame of the animation
  68416. * @param inputs Array to store the key frame times
  68417. * @param outputs Array to store the key frame data
  68418. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68419. * @param useQuaternion Specifies if quaternions are used in the animation
  68420. */
  68421. private static _CreateCubicSplineAnimation;
  68422. private static _GetBasePositionRotationOrScale;
  68423. /**
  68424. * Adds a key frame value
  68425. * @param keyFrame
  68426. * @param animation
  68427. * @param outputs
  68428. * @param animationChannelTargetPath
  68429. * @param basePositionRotationOrScale
  68430. * @param convertToRightHandedSystem
  68431. * @param useQuaternion
  68432. */
  68433. private static _AddKeyframeValue;
  68434. /**
  68435. * Determine the interpolation based on the key frames
  68436. * @param keyFrames
  68437. * @param animationChannelTargetPath
  68438. * @param useQuaternion
  68439. */
  68440. private static _DeduceInterpolation;
  68441. /**
  68442. * Adds an input tangent or output tangent to the output data
  68443. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  68444. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  68445. * @param outputs The animation data by keyframe
  68446. * @param animationChannelTargetPath The target animation channel
  68447. * @param interpolation The interpolation type
  68448. * @param keyFrame The key frame with the animation data
  68449. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  68450. * @param useQuaternion Specifies if quaternions are used
  68451. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  68452. */
  68453. private static AddSplineTangent;
  68454. /**
  68455. * Get the minimum and maximum key frames' frame values
  68456. * @param keyFrames animation key frames
  68457. * @returns the minimum and maximum key frame value
  68458. */
  68459. private static calculateMinMaxKeyFrames;
  68460. }
  68461. }
  68462. declare module BABYLON.GLTF2.Exporter {
  68463. /** @hidden */
  68464. export var textureTransformPixelShader: {
  68465. name: string;
  68466. shader: string;
  68467. };
  68468. }
  68469. declare module BABYLON.GLTF2.Exporter.Extensions {
  68470. /**
  68471. * @hidden
  68472. */
  68473. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  68474. /** Name of this extension */
  68475. readonly name: string;
  68476. /** Defines whether this extension is enabled */
  68477. enabled: boolean;
  68478. /** Defines whether this extension is required */
  68479. required: boolean;
  68480. /** Reference to the glTF exporter */
  68481. private _exporter;
  68482. constructor(exporter: _Exporter);
  68483. dispose(): void;
  68484. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68485. /**
  68486. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  68487. * @param babylonTexture
  68488. * @param offset
  68489. * @param rotation
  68490. * @param scale
  68491. * @param scene
  68492. */
  68493. private _textureTransformTextureAsync;
  68494. }
  68495. }
  68496. declare module BABYLON.GLTF2.Exporter.Extensions {
  68497. /**
  68498. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68499. */
  68500. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  68501. /** The name of this extension. */
  68502. readonly name: string;
  68503. /** Defines whether this extension is enabled. */
  68504. enabled: boolean;
  68505. /** Defines whether this extension is required */
  68506. required: boolean;
  68507. /** Reference to the glTF exporter */
  68508. private _exporter;
  68509. private _lights;
  68510. /** @hidden */
  68511. constructor(exporter: _Exporter);
  68512. /** @hidden */
  68513. dispose(): void;
  68514. /** @hidden */
  68515. onExporting(): void;
  68516. /**
  68517. * Define this method to modify the default behavior when exporting a node
  68518. * @param context The context when exporting the node
  68519. * @param node glTF node
  68520. * @param babylonNode BabylonJS node
  68521. * @returns nullable INode promise
  68522. */
  68523. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68524. }
  68525. }
  68526. declare module BABYLON {
  68527. /**
  68528. * Class for generating STL data from a Babylon scene.
  68529. */
  68530. export class STLExport {
  68531. /**
  68532. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  68533. * @param meshes list defines the mesh to serialize
  68534. * @param download triggers the automatic download of the file.
  68535. * @param fileName changes the downloads fileName.
  68536. * @param binary changes the STL to a binary type.
  68537. * @param isLittleEndian toggle for binary type exporter.
  68538. * @returns the STL as UTF8 string
  68539. */
  68540. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  68541. }
  68542. }
  68543. declare module "babylonjs-gltf2interface" {
  68544. export = BABYLON.GLTF2;
  68545. }
  68546. /**
  68547. * Module for glTF 2.0 Interface
  68548. */
  68549. declare module BABYLON.GLTF2 {
  68550. /**
  68551. * The datatype of the components in the attribute
  68552. */
  68553. const enum AccessorComponentType {
  68554. /**
  68555. * Byte
  68556. */
  68557. BYTE = 5120,
  68558. /**
  68559. * Unsigned Byte
  68560. */
  68561. UNSIGNED_BYTE = 5121,
  68562. /**
  68563. * Short
  68564. */
  68565. SHORT = 5122,
  68566. /**
  68567. * Unsigned Short
  68568. */
  68569. UNSIGNED_SHORT = 5123,
  68570. /**
  68571. * Unsigned Int
  68572. */
  68573. UNSIGNED_INT = 5125,
  68574. /**
  68575. * Float
  68576. */
  68577. FLOAT = 5126,
  68578. }
  68579. /**
  68580. * Specifies if the attirbute is a scalar, vector, or matrix
  68581. */
  68582. const enum AccessorType {
  68583. /**
  68584. * Scalar
  68585. */
  68586. SCALAR = "SCALAR",
  68587. /**
  68588. * Vector2
  68589. */
  68590. VEC2 = "VEC2",
  68591. /**
  68592. * Vector3
  68593. */
  68594. VEC3 = "VEC3",
  68595. /**
  68596. * Vector4
  68597. */
  68598. VEC4 = "VEC4",
  68599. /**
  68600. * Matrix2x2
  68601. */
  68602. MAT2 = "MAT2",
  68603. /**
  68604. * Matrix3x3
  68605. */
  68606. MAT3 = "MAT3",
  68607. /**
  68608. * Matrix4x4
  68609. */
  68610. MAT4 = "MAT4",
  68611. }
  68612. /**
  68613. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68614. */
  68615. const enum AnimationChannelTargetPath {
  68616. /**
  68617. * Translation
  68618. */
  68619. TRANSLATION = "translation",
  68620. /**
  68621. * Rotation
  68622. */
  68623. ROTATION = "rotation",
  68624. /**
  68625. * Scale
  68626. */
  68627. SCALE = "scale",
  68628. /**
  68629. * Weights
  68630. */
  68631. WEIGHTS = "weights",
  68632. }
  68633. /**
  68634. * Interpolation algorithm
  68635. */
  68636. const enum AnimationSamplerInterpolation {
  68637. /**
  68638. * The animated values are linearly interpolated between keyframes
  68639. */
  68640. LINEAR = "LINEAR",
  68641. /**
  68642. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  68643. */
  68644. STEP = "STEP",
  68645. /**
  68646. * The animation's interpolation is computed using a cubic spline with specified tangents
  68647. */
  68648. CUBICSPLINE = "CUBICSPLINE",
  68649. }
  68650. /**
  68651. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68652. */
  68653. const enum CameraType {
  68654. /**
  68655. * A perspective camera containing properties to create a perspective projection matrix
  68656. */
  68657. PERSPECTIVE = "perspective",
  68658. /**
  68659. * An orthographic camera containing properties to create an orthographic projection matrix
  68660. */
  68661. ORTHOGRAPHIC = "orthographic",
  68662. }
  68663. /**
  68664. * The mime-type of the image
  68665. */
  68666. const enum ImageMimeType {
  68667. /**
  68668. * JPEG Mime-type
  68669. */
  68670. JPEG = "image/jpeg",
  68671. /**
  68672. * PNG Mime-type
  68673. */
  68674. PNG = "image/png",
  68675. }
  68676. /**
  68677. * The alpha rendering mode of the material
  68678. */
  68679. const enum MaterialAlphaMode {
  68680. /**
  68681. * The alpha value is ignored and the rendered output is fully opaque
  68682. */
  68683. OPAQUE = "OPAQUE",
  68684. /**
  68685. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  68686. */
  68687. MASK = "MASK",
  68688. /**
  68689. * 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)
  68690. */
  68691. BLEND = "BLEND",
  68692. }
  68693. /**
  68694. * The type of the primitives to render
  68695. */
  68696. const enum MeshPrimitiveMode {
  68697. /**
  68698. * Points
  68699. */
  68700. POINTS = 0,
  68701. /**
  68702. * Lines
  68703. */
  68704. LINES = 1,
  68705. /**
  68706. * Line Loop
  68707. */
  68708. LINE_LOOP = 2,
  68709. /**
  68710. * Line Strip
  68711. */
  68712. LINE_STRIP = 3,
  68713. /**
  68714. * Triangles
  68715. */
  68716. TRIANGLES = 4,
  68717. /**
  68718. * Triangle Strip
  68719. */
  68720. TRIANGLE_STRIP = 5,
  68721. /**
  68722. * Triangle Fan
  68723. */
  68724. TRIANGLE_FAN = 6,
  68725. }
  68726. /**
  68727. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68728. */
  68729. const enum TextureMagFilter {
  68730. /**
  68731. * Nearest
  68732. */
  68733. NEAREST = 9728,
  68734. /**
  68735. * Linear
  68736. */
  68737. LINEAR = 9729,
  68738. }
  68739. /**
  68740. * Minification filter. All valid values correspond to WebGL enums
  68741. */
  68742. const enum TextureMinFilter {
  68743. /**
  68744. * Nearest
  68745. */
  68746. NEAREST = 9728,
  68747. /**
  68748. * Linear
  68749. */
  68750. LINEAR = 9729,
  68751. /**
  68752. * Nearest Mip-Map Nearest
  68753. */
  68754. NEAREST_MIPMAP_NEAREST = 9984,
  68755. /**
  68756. * Linear Mipmap Nearest
  68757. */
  68758. LINEAR_MIPMAP_NEAREST = 9985,
  68759. /**
  68760. * Nearest Mipmap Linear
  68761. */
  68762. NEAREST_MIPMAP_LINEAR = 9986,
  68763. /**
  68764. * Linear Mipmap Linear
  68765. */
  68766. LINEAR_MIPMAP_LINEAR = 9987,
  68767. }
  68768. /**
  68769. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68770. */
  68771. const enum TextureWrapMode {
  68772. /**
  68773. * Clamp to Edge
  68774. */
  68775. CLAMP_TO_EDGE = 33071,
  68776. /**
  68777. * Mirrored Repeat
  68778. */
  68779. MIRRORED_REPEAT = 33648,
  68780. /**
  68781. * Repeat
  68782. */
  68783. REPEAT = 10497,
  68784. }
  68785. /**
  68786. * glTF Property
  68787. */
  68788. interface IProperty {
  68789. /**
  68790. * Dictionary object with extension-specific objects
  68791. */
  68792. extensions?: {
  68793. [key: string]: any;
  68794. };
  68795. /**
  68796. * Application-Specific data
  68797. */
  68798. extras?: any;
  68799. }
  68800. /**
  68801. * glTF Child of Root Property
  68802. */
  68803. interface IChildRootProperty extends IProperty {
  68804. /**
  68805. * The user-defined name of this object
  68806. */
  68807. name?: string;
  68808. }
  68809. /**
  68810. * Indices of those attributes that deviate from their initialization value
  68811. */
  68812. interface IAccessorSparseIndices extends IProperty {
  68813. /**
  68814. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68815. */
  68816. bufferView: number;
  68817. /**
  68818. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68819. */
  68820. byteOffset?: number;
  68821. /**
  68822. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  68823. */
  68824. componentType: AccessorComponentType;
  68825. }
  68826. /**
  68827. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  68828. */
  68829. interface IAccessorSparseValues extends IProperty {
  68830. /**
  68831. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68832. */
  68833. bufferView: number;
  68834. /**
  68835. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68836. */
  68837. byteOffset?: number;
  68838. }
  68839. /**
  68840. * Sparse storage of attributes that deviate from their initialization value
  68841. */
  68842. interface IAccessorSparse extends IProperty {
  68843. /**
  68844. * The number of attributes encoded in this sparse accessor
  68845. */
  68846. count: number;
  68847. /**
  68848. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  68849. */
  68850. indices: IAccessorSparseIndices;
  68851. /**
  68852. * 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
  68853. */
  68854. values: IAccessorSparseValues;
  68855. }
  68856. /**
  68857. * 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
  68858. */
  68859. interface IAccessor extends IChildRootProperty {
  68860. /**
  68861. * The index of the bufferview
  68862. */
  68863. bufferView?: number;
  68864. /**
  68865. * The offset relative to the start of the bufferView in bytes
  68866. */
  68867. byteOffset?: number;
  68868. /**
  68869. * The datatype of components in the attribute
  68870. */
  68871. componentType: AccessorComponentType;
  68872. /**
  68873. * Specifies whether integer data values should be normalized
  68874. */
  68875. normalized?: boolean;
  68876. /**
  68877. * The number of attributes referenced by this accessor
  68878. */
  68879. count: number;
  68880. /**
  68881. * Specifies if the attribute is a scalar, vector, or matrix
  68882. */
  68883. type: AccessorType;
  68884. /**
  68885. * Maximum value of each component in this attribute
  68886. */
  68887. max?: number[];
  68888. /**
  68889. * Minimum value of each component in this attribute
  68890. */
  68891. min?: number[];
  68892. /**
  68893. * Sparse storage of attributes that deviate from their initialization value
  68894. */
  68895. sparse?: IAccessorSparse;
  68896. }
  68897. /**
  68898. * Targets an animation's sampler at a node's property
  68899. */
  68900. interface IAnimationChannel extends IProperty {
  68901. /**
  68902. * The index of a sampler in this animation used to compute the value for the target
  68903. */
  68904. sampler: number;
  68905. /**
  68906. * The index of the node and TRS property to target
  68907. */
  68908. target: IAnimationChannelTarget;
  68909. }
  68910. /**
  68911. * The index of the node and TRS property that an animation channel targets
  68912. */
  68913. interface IAnimationChannelTarget extends IProperty {
  68914. /**
  68915. * The index of the node to target
  68916. */
  68917. node: number;
  68918. /**
  68919. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68920. */
  68921. path: AnimationChannelTargetPath;
  68922. }
  68923. /**
  68924. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68925. */
  68926. interface IAnimationSampler extends IProperty {
  68927. /**
  68928. * The index of an accessor containing keyframe input values, e.g., time
  68929. */
  68930. input: number;
  68931. /**
  68932. * Interpolation algorithm
  68933. */
  68934. interpolation?: AnimationSamplerInterpolation;
  68935. /**
  68936. * The index of an accessor, containing keyframe output values
  68937. */
  68938. output: number;
  68939. }
  68940. /**
  68941. * A keyframe animation
  68942. */
  68943. interface IAnimation extends IChildRootProperty {
  68944. /**
  68945. * An array of channels, each of which targets an animation's sampler at a node's property
  68946. */
  68947. channels: IAnimationChannel[];
  68948. /**
  68949. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68950. */
  68951. samplers: IAnimationSampler[];
  68952. }
  68953. /**
  68954. * Metadata about the glTF asset
  68955. */
  68956. interface IAsset extends IChildRootProperty {
  68957. /**
  68958. * A copyright message suitable for display to credit the content creator
  68959. */
  68960. copyright?: string;
  68961. /**
  68962. * Tool that generated this glTF model. Useful for debugging
  68963. */
  68964. generator?: string;
  68965. /**
  68966. * The glTF version that this asset targets
  68967. */
  68968. version: string;
  68969. /**
  68970. * The minimum glTF version that this asset targets
  68971. */
  68972. minVersion?: string;
  68973. }
  68974. /**
  68975. * A buffer points to binary geometry, animation, or skins
  68976. */
  68977. interface IBuffer extends IChildRootProperty {
  68978. /**
  68979. * 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
  68980. */
  68981. uri?: string;
  68982. /**
  68983. * The length of the buffer in bytes
  68984. */
  68985. byteLength: number;
  68986. }
  68987. /**
  68988. * A view into a buffer generally representing a subset of the buffer
  68989. */
  68990. interface IBufferView extends IChildRootProperty {
  68991. /**
  68992. * The index of the buffer
  68993. */
  68994. buffer: number;
  68995. /**
  68996. * The offset into the buffer in bytes
  68997. */
  68998. byteOffset?: number;
  68999. /**
  69000. * The lenth of the bufferView in bytes
  69001. */
  69002. byteLength: number;
  69003. /**
  69004. * The stride, in bytes
  69005. */
  69006. byteStride?: number;
  69007. }
  69008. /**
  69009. * An orthographic camera containing properties to create an orthographic projection matrix
  69010. */
  69011. interface ICameraOrthographic extends IProperty {
  69012. /**
  69013. * The floating-point horizontal magnification of the view. Must not be zero
  69014. */
  69015. xmag: number;
  69016. /**
  69017. * The floating-point vertical magnification of the view. Must not be zero
  69018. */
  69019. ymag: number;
  69020. /**
  69021. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69022. */
  69023. zfar: number;
  69024. /**
  69025. * The floating-point distance to the near clipping plane
  69026. */
  69027. znear: number;
  69028. }
  69029. /**
  69030. * A perspective camera containing properties to create a perspective projection matrix
  69031. */
  69032. interface ICameraPerspective extends IProperty {
  69033. /**
  69034. * The floating-point aspect ratio of the field of view
  69035. */
  69036. aspectRatio?: number;
  69037. /**
  69038. * The floating-point vertical field of view in radians
  69039. */
  69040. yfov: number;
  69041. /**
  69042. * The floating-point distance to the far clipping plane
  69043. */
  69044. zfar?: number;
  69045. /**
  69046. * The floating-point distance to the near clipping plane
  69047. */
  69048. znear: number;
  69049. }
  69050. /**
  69051. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69052. */
  69053. interface ICamera extends IChildRootProperty {
  69054. /**
  69055. * An orthographic camera containing properties to create an orthographic projection matrix
  69056. */
  69057. orthographic?: ICameraOrthographic;
  69058. /**
  69059. * A perspective camera containing properties to create a perspective projection matrix
  69060. */
  69061. perspective?: ICameraPerspective;
  69062. /**
  69063. * Specifies if the camera uses a perspective or orthographic projection
  69064. */
  69065. type: CameraType;
  69066. }
  69067. /**
  69068. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69069. */
  69070. interface IImage extends IChildRootProperty {
  69071. /**
  69072. * 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
  69073. */
  69074. uri?: string;
  69075. /**
  69076. * The image's MIME type
  69077. */
  69078. mimeType?: ImageMimeType;
  69079. /**
  69080. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69081. */
  69082. bufferView?: number;
  69083. }
  69084. /**
  69085. * Material Normal Texture Info
  69086. */
  69087. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69088. /**
  69089. * The scalar multiplier applied to each normal vector of the normal texture
  69090. */
  69091. scale?: number;
  69092. }
  69093. /**
  69094. * Material Occlusion Texture Info
  69095. */
  69096. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69097. /**
  69098. * A scalar multiplier controlling the amount of occlusion applied
  69099. */
  69100. strength?: number;
  69101. }
  69102. /**
  69103. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69104. */
  69105. interface IMaterialPbrMetallicRoughness {
  69106. /**
  69107. * The material's base color factor
  69108. */
  69109. baseColorFactor?: number[];
  69110. /**
  69111. * The base color texture
  69112. */
  69113. baseColorTexture?: ITextureInfo;
  69114. /**
  69115. * The metalness of the material
  69116. */
  69117. metallicFactor?: number;
  69118. /**
  69119. * The roughness of the material
  69120. */
  69121. roughnessFactor?: number;
  69122. /**
  69123. * The metallic-roughness texture
  69124. */
  69125. metallicRoughnessTexture?: ITextureInfo;
  69126. }
  69127. /**
  69128. * The material appearance of a primitive
  69129. */
  69130. interface IMaterial extends IChildRootProperty {
  69131. /**
  69132. * 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
  69133. */
  69134. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69135. /**
  69136. * The normal map texture
  69137. */
  69138. normalTexture?: IMaterialNormalTextureInfo;
  69139. /**
  69140. * The occlusion map texture
  69141. */
  69142. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69143. /**
  69144. * The emissive map texture
  69145. */
  69146. emissiveTexture?: ITextureInfo;
  69147. /**
  69148. * 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
  69149. */
  69150. emissiveFactor?: number[];
  69151. /**
  69152. * The alpha rendering mode of the material
  69153. */
  69154. alphaMode?: MaterialAlphaMode;
  69155. /**
  69156. * The alpha cutoff value of the material
  69157. */
  69158. alphaCutoff?: number;
  69159. /**
  69160. * Specifies whether the material is double sided
  69161. */
  69162. doubleSided?: boolean;
  69163. }
  69164. /**
  69165. * Geometry to be rendered with the given material
  69166. */
  69167. interface IMeshPrimitive extends IProperty {
  69168. /**
  69169. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69170. */
  69171. attributes: {
  69172. [name: string]: number;
  69173. };
  69174. /**
  69175. * The index of the accessor that contains the indices
  69176. */
  69177. indices?: number;
  69178. /**
  69179. * The index of the material to apply to this primitive when rendering
  69180. */
  69181. material?: number;
  69182. /**
  69183. * The type of primitives to render. All valid values correspond to WebGL enums
  69184. */
  69185. mode?: MeshPrimitiveMode;
  69186. /**
  69187. * 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
  69188. */
  69189. targets?: {
  69190. [name: string]: number;
  69191. }[];
  69192. }
  69193. /**
  69194. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  69195. */
  69196. interface IMesh extends IChildRootProperty {
  69197. /**
  69198. * An array of primitives, each defining geometry to be rendered with a material
  69199. */
  69200. primitives: IMeshPrimitive[];
  69201. /**
  69202. * Array of weights to be applied to the Morph Targets
  69203. */
  69204. weights?: number[];
  69205. }
  69206. /**
  69207. * A node in the node hierarchy
  69208. */
  69209. interface INode extends IChildRootProperty {
  69210. /**
  69211. * The index of the camera referenced by this node
  69212. */
  69213. camera?: number;
  69214. /**
  69215. * The indices of this node's children
  69216. */
  69217. children?: number[];
  69218. /**
  69219. * The index of the skin referenced by this node
  69220. */
  69221. skin?: number;
  69222. /**
  69223. * A floating-point 4x4 transformation matrix stored in column-major order
  69224. */
  69225. matrix?: number[];
  69226. /**
  69227. * The index of the mesh in this node
  69228. */
  69229. mesh?: number;
  69230. /**
  69231. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  69232. */
  69233. rotation?: number[];
  69234. /**
  69235. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  69236. */
  69237. scale?: number[];
  69238. /**
  69239. * The node's translation along the x, y, and z axes
  69240. */
  69241. translation?: number[];
  69242. /**
  69243. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  69244. */
  69245. weights?: number[];
  69246. }
  69247. /**
  69248. * Texture sampler properties for filtering and wrapping modes
  69249. */
  69250. interface ISampler extends IChildRootProperty {
  69251. /**
  69252. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69253. */
  69254. magFilter?: TextureMagFilter;
  69255. /**
  69256. * Minification filter. All valid values correspond to WebGL enums
  69257. */
  69258. minFilter?: TextureMinFilter;
  69259. /**
  69260. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69261. */
  69262. wrapS?: TextureWrapMode;
  69263. /**
  69264. * T (V) wrapping mode. All valid values correspond to WebGL enums
  69265. */
  69266. wrapT?: TextureWrapMode;
  69267. }
  69268. /**
  69269. * The root nodes of a scene
  69270. */
  69271. interface IScene extends IChildRootProperty {
  69272. /**
  69273. * The indices of each root node
  69274. */
  69275. nodes: number[];
  69276. }
  69277. /**
  69278. * Joints and matrices defining a skin
  69279. */
  69280. interface ISkin extends IChildRootProperty {
  69281. /**
  69282. * 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
  69283. */
  69284. inverseBindMatrices?: number;
  69285. /**
  69286. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  69287. */
  69288. skeleton?: number;
  69289. /**
  69290. * 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)
  69291. */
  69292. joints: number[];
  69293. }
  69294. /**
  69295. * A texture and its sampler
  69296. */
  69297. interface ITexture extends IChildRootProperty {
  69298. /**
  69299. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  69300. */
  69301. sampler?: number;
  69302. /**
  69303. * The index of the image used by this texture
  69304. */
  69305. source: number;
  69306. }
  69307. /**
  69308. * Reference to a texture
  69309. */
  69310. interface ITextureInfo extends IProperty {
  69311. /**
  69312. * The index of the texture
  69313. */
  69314. index: number;
  69315. /**
  69316. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  69317. */
  69318. texCoord?: number;
  69319. }
  69320. /**
  69321. * The root object for a glTF asset
  69322. */
  69323. interface IGLTF extends IProperty {
  69324. /**
  69325. * An array of accessors. An accessor is a typed view into a bufferView
  69326. */
  69327. accessors?: IAccessor[];
  69328. /**
  69329. * An array of keyframe animations
  69330. */
  69331. animations?: IAnimation[];
  69332. /**
  69333. * Metadata about the glTF asset
  69334. */
  69335. asset: IAsset;
  69336. /**
  69337. * An array of buffers. A buffer points to binary geometry, animation, or skins
  69338. */
  69339. buffers?: IBuffer[];
  69340. /**
  69341. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  69342. */
  69343. bufferViews?: IBufferView[];
  69344. /**
  69345. * An array of cameras
  69346. */
  69347. cameras?: ICamera[];
  69348. /**
  69349. * Names of glTF extensions used somewhere in this asset
  69350. */
  69351. extensionsUsed?: string[];
  69352. /**
  69353. * Names of glTF extensions required to properly load this asset
  69354. */
  69355. extensionsRequired?: string[];
  69356. /**
  69357. * An array of images. An image defines data used to create a texture
  69358. */
  69359. images?: IImage[];
  69360. /**
  69361. * An array of materials. A material defines the appearance of a primitive
  69362. */
  69363. materials?: IMaterial[];
  69364. /**
  69365. * An array of meshes. A mesh is a set of primitives to be rendered
  69366. */
  69367. meshes?: IMesh[];
  69368. /**
  69369. * An array of nodes
  69370. */
  69371. nodes?: INode[];
  69372. /**
  69373. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  69374. */
  69375. samplers?: ISampler[];
  69376. /**
  69377. * The index of the default scene
  69378. */
  69379. scene?: number;
  69380. /**
  69381. * An array of scenes
  69382. */
  69383. scenes?: IScene[];
  69384. /**
  69385. * An array of skins. A skin is defined by joints and matrices
  69386. */
  69387. skins?: ISkin[];
  69388. /**
  69389. * An array of textures
  69390. */
  69391. textures?: ITexture[];
  69392. }
  69393. /**
  69394. * The glTF validation results
  69395. * @ignore
  69396. */
  69397. interface IGLTFValidationResults {
  69398. info: {
  69399. generator: string;
  69400. hasAnimations: boolean;
  69401. hasDefaultScene: boolean;
  69402. hasMaterials: boolean;
  69403. hasMorphTargets: boolean;
  69404. hasSkins: boolean;
  69405. hasTextures: boolean;
  69406. maxAttributesUsed: number;
  69407. primitivesCount: number
  69408. };
  69409. issues: {
  69410. messages: Array<string>;
  69411. numErrors: number;
  69412. numHints: number;
  69413. numInfos: number;
  69414. numWarnings: number;
  69415. truncated: boolean
  69416. };
  69417. mimeType: string;
  69418. uri: string;
  69419. validatedAt: string;
  69420. validatorVersion: string;
  69421. }
  69422. /**
  69423. * The glTF validation options
  69424. */
  69425. interface IGLTFValidationOptions {
  69426. /** Uri to use */
  69427. uri?: string;
  69428. /** Function used to load external resources */
  69429. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  69430. /** Boolean indicating that we need to validate accessor data */
  69431. validateAccessorData?: boolean;
  69432. /** max number of issues allowed */
  69433. maxIssues?: number;
  69434. /** Ignored issues */
  69435. ignoredIssues?: Array<string>;
  69436. /** Value to override severy settings */
  69437. severityOverrides?: Object;
  69438. }
  69439. /**
  69440. * The glTF validator object
  69441. * @ignore
  69442. */
  69443. interface IGLTFValidator {
  69444. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69445. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69446. }
  69447. }
  69448. declare module BABYLON {
  69449. /** @hidden */
  69450. export var cellPixelShader: {
  69451. name: string;
  69452. shader: string;
  69453. };
  69454. }
  69455. declare module BABYLON {
  69456. /** @hidden */
  69457. export var cellVertexShader: {
  69458. name: string;
  69459. shader: string;
  69460. };
  69461. }
  69462. declare module BABYLON {
  69463. export class CellMaterial extends BABYLON.PushMaterial {
  69464. private _diffuseTexture;
  69465. diffuseTexture: BABYLON.BaseTexture;
  69466. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  69467. computeHighLevel: boolean;
  69468. private _disableLighting;
  69469. disableLighting: boolean;
  69470. private _maxSimultaneousLights;
  69471. maxSimultaneousLights: number;
  69472. private _renderId;
  69473. constructor(name: string, scene: BABYLON.Scene);
  69474. needAlphaBlending(): boolean;
  69475. needAlphaTesting(): boolean;
  69476. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69477. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69478. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69479. getAnimatables(): BABYLON.IAnimatable[];
  69480. getActiveTextures(): BABYLON.BaseTexture[];
  69481. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69482. dispose(forceDisposeEffect?: boolean): void;
  69483. getClassName(): string;
  69484. clone(name: string): CellMaterial;
  69485. serialize(): any;
  69486. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  69487. }
  69488. }
  69489. declare module BABYLON {
  69490. export class CustomShaderStructure {
  69491. FragmentStore: string;
  69492. VertexStore: string;
  69493. constructor();
  69494. }
  69495. export class ShaderSpecialParts {
  69496. constructor();
  69497. Fragment_Begin: string;
  69498. Fragment_Definitions: string;
  69499. Fragment_MainBegin: string;
  69500. Fragment_Custom_Diffuse: string;
  69501. Fragment_Before_Lights: string;
  69502. Fragment_Before_Fog: string;
  69503. Fragment_Custom_Alpha: string;
  69504. Fragment_Before_FragColor: string;
  69505. Vertex_Begin: string;
  69506. Vertex_Definitions: string;
  69507. Vertex_MainBegin: string;
  69508. Vertex_Before_PositionUpdated: string;
  69509. Vertex_Before_NormalUpdated: string;
  69510. Vertex_MainEnd: string;
  69511. }
  69512. export class CustomMaterial extends BABYLON.StandardMaterial {
  69513. static ShaderIndexer: number;
  69514. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  69515. FragmentShader: string;
  69516. VertexShader: string;
  69517. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69518. ReviewUniform(name: string, arr: string[]): string[];
  69519. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  69520. constructor(name: string, scene: BABYLON.Scene);
  69521. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  69522. Fragment_Begin(shaderPart: string): CustomMaterial;
  69523. Fragment_Definitions(shaderPart: string): CustomMaterial;
  69524. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  69525. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  69526. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  69527. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  69528. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  69529. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  69530. Vertex_Begin(shaderPart: string): CustomMaterial;
  69531. Vertex_Definitions(shaderPart: string): CustomMaterial;
  69532. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  69533. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  69534. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  69535. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  69536. }
  69537. }
  69538. declare module BABYLON {
  69539. export class ShaderAlebdoParts {
  69540. constructor();
  69541. Fragment_Begin: string;
  69542. Fragment_Definitions: string;
  69543. Fragment_MainBegin: string;
  69544. Fragment_Custom_Albedo: string;
  69545. Fragment_Before_Lights: string;
  69546. Fragment_Custom_MetallicRoughness: string;
  69547. Fragment_Custom_MicroSurface: string;
  69548. Fragment_Before_Fog: string;
  69549. Fragment_Custom_Alpha: string;
  69550. Fragment_Before_FragColor: string;
  69551. Vertex_Begin: string;
  69552. Vertex_Definitions: string;
  69553. Vertex_MainBegin: string;
  69554. Vertex_Before_PositionUpdated: string;
  69555. Vertex_Before_NormalUpdated: string;
  69556. Vertex_MainEnd: string;
  69557. }
  69558. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  69559. static ShaderIndexer: number;
  69560. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  69561. FragmentShader: string;
  69562. VertexShader: string;
  69563. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69564. ReviewUniform(name: string, arr: string[]): string[];
  69565. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  69566. constructor(name: string, scene: BABYLON.Scene);
  69567. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  69568. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  69569. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  69570. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  69571. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  69572. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  69573. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  69574. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  69575. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  69576. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  69577. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  69578. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  69579. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  69580. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  69581. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  69582. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  69583. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  69584. }
  69585. }
  69586. declare module BABYLON {
  69587. /** @hidden */
  69588. export var firePixelShader: {
  69589. name: string;
  69590. shader: string;
  69591. };
  69592. }
  69593. declare module BABYLON {
  69594. /** @hidden */
  69595. export var fireVertexShader: {
  69596. name: string;
  69597. shader: string;
  69598. };
  69599. }
  69600. declare module BABYLON {
  69601. export class FireMaterial extends BABYLON.PushMaterial {
  69602. private _diffuseTexture;
  69603. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69604. private _distortionTexture;
  69605. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69606. private _opacityTexture;
  69607. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69608. diffuseColor: BABYLON.Color3;
  69609. speed: number;
  69610. private _scaledDiffuse;
  69611. private _renderId;
  69612. private _lastTime;
  69613. constructor(name: string, scene: BABYLON.Scene);
  69614. needAlphaBlending(): boolean;
  69615. needAlphaTesting(): boolean;
  69616. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69617. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69618. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69619. getAnimatables(): BABYLON.IAnimatable[];
  69620. getActiveTextures(): BABYLON.BaseTexture[];
  69621. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69622. getClassName(): string;
  69623. dispose(forceDisposeEffect?: boolean): void;
  69624. clone(name: string): FireMaterial;
  69625. serialize(): any;
  69626. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  69627. }
  69628. }
  69629. declare module BABYLON {
  69630. /** @hidden */
  69631. export var furPixelShader: {
  69632. name: string;
  69633. shader: string;
  69634. };
  69635. }
  69636. declare module BABYLON {
  69637. /** @hidden */
  69638. export var furVertexShader: {
  69639. name: string;
  69640. shader: string;
  69641. };
  69642. }
  69643. declare module BABYLON {
  69644. export class FurMaterial extends BABYLON.PushMaterial {
  69645. private _diffuseTexture;
  69646. diffuseTexture: BABYLON.BaseTexture;
  69647. private _heightTexture;
  69648. heightTexture: BABYLON.BaseTexture;
  69649. diffuseColor: BABYLON.Color3;
  69650. furLength: number;
  69651. furAngle: number;
  69652. furColor: BABYLON.Color3;
  69653. furOffset: number;
  69654. furSpacing: number;
  69655. furGravity: BABYLON.Vector3;
  69656. furSpeed: number;
  69657. furDensity: number;
  69658. furOcclusion: number;
  69659. furTexture: BABYLON.DynamicTexture;
  69660. private _disableLighting;
  69661. disableLighting: boolean;
  69662. private _maxSimultaneousLights;
  69663. maxSimultaneousLights: number;
  69664. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  69665. private _renderId;
  69666. private _furTime;
  69667. constructor(name: string, scene: BABYLON.Scene);
  69668. furTime: number;
  69669. needAlphaBlending(): boolean;
  69670. needAlphaTesting(): boolean;
  69671. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69672. updateFur(): void;
  69673. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69674. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69675. getAnimatables(): BABYLON.IAnimatable[];
  69676. getActiveTextures(): BABYLON.BaseTexture[];
  69677. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69678. dispose(forceDisposeEffect?: boolean): void;
  69679. clone(name: string): FurMaterial;
  69680. serialize(): any;
  69681. getClassName(): string;
  69682. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  69683. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  69684. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  69685. }
  69686. }
  69687. declare module BABYLON {
  69688. /** @hidden */
  69689. export var gradientPixelShader: {
  69690. name: string;
  69691. shader: string;
  69692. };
  69693. }
  69694. declare module BABYLON {
  69695. /** @hidden */
  69696. export var gradientVertexShader: {
  69697. name: string;
  69698. shader: string;
  69699. };
  69700. }
  69701. declare module BABYLON {
  69702. export class GradientMaterial extends BABYLON.PushMaterial {
  69703. private _maxSimultaneousLights;
  69704. maxSimultaneousLights: number;
  69705. topColor: BABYLON.Color3;
  69706. topColorAlpha: number;
  69707. bottomColor: BABYLON.Color3;
  69708. bottomColorAlpha: number;
  69709. offset: number;
  69710. scale: number;
  69711. smoothness: number;
  69712. private _disableLighting;
  69713. disableLighting: boolean;
  69714. private _renderId;
  69715. constructor(name: string, scene: BABYLON.Scene);
  69716. needAlphaBlending(): boolean;
  69717. needAlphaTesting(): boolean;
  69718. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69719. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69720. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69721. getAnimatables(): BABYLON.IAnimatable[];
  69722. dispose(forceDisposeEffect?: boolean): void;
  69723. clone(name: string): GradientMaterial;
  69724. serialize(): any;
  69725. getClassName(): string;
  69726. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  69727. }
  69728. }
  69729. declare module BABYLON {
  69730. /** @hidden */
  69731. export var gridPixelShader: {
  69732. name: string;
  69733. shader: string;
  69734. };
  69735. }
  69736. declare module BABYLON {
  69737. /** @hidden */
  69738. export var gridVertexShader: {
  69739. name: string;
  69740. shader: string;
  69741. };
  69742. }
  69743. declare module BABYLON {
  69744. /**
  69745. * The grid materials allows you to wrap any shape with a grid.
  69746. * Colors are customizable.
  69747. */
  69748. export class GridMaterial extends BABYLON.PushMaterial {
  69749. /**
  69750. * Main color of the grid (e.g. between lines)
  69751. */
  69752. mainColor: BABYLON.Color3;
  69753. /**
  69754. * Color of the grid lines.
  69755. */
  69756. lineColor: BABYLON.Color3;
  69757. /**
  69758. * The scale of the grid compared to unit.
  69759. */
  69760. gridRatio: number;
  69761. /**
  69762. * Allows setting an offset for the grid lines.
  69763. */
  69764. gridOffset: BABYLON.Vector3;
  69765. /**
  69766. * The frequency of thicker lines.
  69767. */
  69768. majorUnitFrequency: number;
  69769. /**
  69770. * The visibility of minor units in the grid.
  69771. */
  69772. minorUnitVisibility: number;
  69773. /**
  69774. * The grid opacity outside of the lines.
  69775. */
  69776. opacity: number;
  69777. /**
  69778. * Determine RBG output is premultiplied by alpha value.
  69779. */
  69780. preMultiplyAlpha: boolean;
  69781. private _opacityTexture;
  69782. opacityTexture: BABYLON.BaseTexture;
  69783. private _gridControl;
  69784. private _renderId;
  69785. /**
  69786. * constructor
  69787. * @param name The name given to the material in order to identify it afterwards.
  69788. * @param scene The scene the material is used in.
  69789. */
  69790. constructor(name: string, scene: BABYLON.Scene);
  69791. /**
  69792. * Returns wehter or not the grid requires alpha blending.
  69793. */
  69794. needAlphaBlending(): boolean;
  69795. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69796. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69797. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69798. /**
  69799. * Dispose the material and its associated resources.
  69800. * @param forceDisposeEffect will also dispose the used effect when true
  69801. */
  69802. dispose(forceDisposeEffect?: boolean): void;
  69803. clone(name: string): GridMaterial;
  69804. serialize(): any;
  69805. getClassName(): string;
  69806. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  69807. }
  69808. }
  69809. declare module BABYLON {
  69810. /** @hidden */
  69811. export var lavaPixelShader: {
  69812. name: string;
  69813. shader: string;
  69814. };
  69815. }
  69816. declare module BABYLON {
  69817. /** @hidden */
  69818. export var lavaVertexShader: {
  69819. name: string;
  69820. shader: string;
  69821. };
  69822. }
  69823. declare module BABYLON {
  69824. export class LavaMaterial extends BABYLON.PushMaterial {
  69825. private _diffuseTexture;
  69826. diffuseTexture: BABYLON.BaseTexture;
  69827. noiseTexture: BABYLON.BaseTexture;
  69828. fogColor: BABYLON.Color3;
  69829. speed: number;
  69830. movingSpeed: number;
  69831. lowFrequencySpeed: number;
  69832. fogDensity: number;
  69833. private _lastTime;
  69834. diffuseColor: BABYLON.Color3;
  69835. private _disableLighting;
  69836. disableLighting: boolean;
  69837. private _unlit;
  69838. unlit: boolean;
  69839. private _maxSimultaneousLights;
  69840. maxSimultaneousLights: number;
  69841. private _scaledDiffuse;
  69842. private _renderId;
  69843. constructor(name: string, scene: BABYLON.Scene);
  69844. needAlphaBlending(): boolean;
  69845. needAlphaTesting(): boolean;
  69846. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69847. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69848. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69849. getAnimatables(): BABYLON.IAnimatable[];
  69850. getActiveTextures(): BABYLON.BaseTexture[];
  69851. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69852. dispose(forceDisposeEffect?: boolean): void;
  69853. clone(name: string): LavaMaterial;
  69854. serialize(): any;
  69855. getClassName(): string;
  69856. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  69857. }
  69858. }
  69859. declare module BABYLON {
  69860. /** @hidden */
  69861. export var mixPixelShader: {
  69862. name: string;
  69863. shader: string;
  69864. };
  69865. }
  69866. declare module BABYLON {
  69867. /** @hidden */
  69868. export var mixVertexShader: {
  69869. name: string;
  69870. shader: string;
  69871. };
  69872. }
  69873. declare module BABYLON {
  69874. export class MixMaterial extends BABYLON.PushMaterial {
  69875. /**
  69876. * Mix textures
  69877. */
  69878. private _mixTexture1;
  69879. mixTexture1: BABYLON.BaseTexture;
  69880. private _mixTexture2;
  69881. mixTexture2: BABYLON.BaseTexture;
  69882. /**
  69883. * Diffuse textures
  69884. */
  69885. private _diffuseTexture1;
  69886. diffuseTexture1: BABYLON.Texture;
  69887. private _diffuseTexture2;
  69888. diffuseTexture2: BABYLON.Texture;
  69889. private _diffuseTexture3;
  69890. diffuseTexture3: BABYLON.Texture;
  69891. private _diffuseTexture4;
  69892. diffuseTexture4: BABYLON.Texture;
  69893. private _diffuseTexture5;
  69894. diffuseTexture5: BABYLON.Texture;
  69895. private _diffuseTexture6;
  69896. diffuseTexture6: BABYLON.Texture;
  69897. private _diffuseTexture7;
  69898. diffuseTexture7: BABYLON.Texture;
  69899. private _diffuseTexture8;
  69900. diffuseTexture8: BABYLON.Texture;
  69901. /**
  69902. * Uniforms
  69903. */
  69904. diffuseColor: BABYLON.Color3;
  69905. specularColor: BABYLON.Color3;
  69906. specularPower: number;
  69907. private _disableLighting;
  69908. disableLighting: boolean;
  69909. private _maxSimultaneousLights;
  69910. maxSimultaneousLights: number;
  69911. private _renderId;
  69912. constructor(name: string, scene: BABYLON.Scene);
  69913. needAlphaBlending(): boolean;
  69914. needAlphaTesting(): boolean;
  69915. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69916. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69917. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69918. getAnimatables(): BABYLON.IAnimatable[];
  69919. getActiveTextures(): BABYLON.BaseTexture[];
  69920. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69921. dispose(forceDisposeEffect?: boolean): void;
  69922. clone(name: string): MixMaterial;
  69923. serialize(): any;
  69924. getClassName(): string;
  69925. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  69926. }
  69927. }
  69928. declare module BABYLON {
  69929. /** @hidden */
  69930. export var normalPixelShader: {
  69931. name: string;
  69932. shader: string;
  69933. };
  69934. }
  69935. declare module BABYLON {
  69936. /** @hidden */
  69937. export var normalVertexShader: {
  69938. name: string;
  69939. shader: string;
  69940. };
  69941. }
  69942. declare module BABYLON {
  69943. export class NormalMaterial extends BABYLON.PushMaterial {
  69944. private _diffuseTexture;
  69945. diffuseTexture: BABYLON.BaseTexture;
  69946. diffuseColor: BABYLON.Color3;
  69947. private _disableLighting;
  69948. disableLighting: boolean;
  69949. private _maxSimultaneousLights;
  69950. maxSimultaneousLights: number;
  69951. private _renderId;
  69952. constructor(name: string, scene: BABYLON.Scene);
  69953. needAlphaBlending(): boolean;
  69954. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69955. needAlphaTesting(): boolean;
  69956. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69957. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69958. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69959. getAnimatables(): BABYLON.IAnimatable[];
  69960. getActiveTextures(): BABYLON.BaseTexture[];
  69961. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69962. dispose(forceDisposeEffect?: boolean): void;
  69963. clone(name: string): NormalMaterial;
  69964. serialize(): any;
  69965. getClassName(): string;
  69966. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  69967. }
  69968. }
  69969. declare module BABYLON {
  69970. /** @hidden */
  69971. export var shadowOnlyPixelShader: {
  69972. name: string;
  69973. shader: string;
  69974. };
  69975. }
  69976. declare module BABYLON {
  69977. /** @hidden */
  69978. export var shadowOnlyVertexShader: {
  69979. name: string;
  69980. shader: string;
  69981. };
  69982. }
  69983. declare module BABYLON {
  69984. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  69985. private _renderId;
  69986. private _activeLight;
  69987. constructor(name: string, scene: BABYLON.Scene);
  69988. shadowColor: BABYLON.Color3;
  69989. needAlphaBlending(): boolean;
  69990. needAlphaTesting(): boolean;
  69991. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69992. activeLight: BABYLON.IShadowLight;
  69993. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69994. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69995. clone(name: string): ShadowOnlyMaterial;
  69996. serialize(): any;
  69997. getClassName(): string;
  69998. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  69999. }
  70000. }
  70001. declare module BABYLON {
  70002. /** @hidden */
  70003. export var simplePixelShader: {
  70004. name: string;
  70005. shader: string;
  70006. };
  70007. }
  70008. declare module BABYLON {
  70009. /** @hidden */
  70010. export var simpleVertexShader: {
  70011. name: string;
  70012. shader: string;
  70013. };
  70014. }
  70015. declare module BABYLON {
  70016. export class SimpleMaterial extends BABYLON.PushMaterial {
  70017. private _diffuseTexture;
  70018. diffuseTexture: BABYLON.BaseTexture;
  70019. diffuseColor: BABYLON.Color3;
  70020. private _disableLighting;
  70021. disableLighting: boolean;
  70022. private _maxSimultaneousLights;
  70023. maxSimultaneousLights: number;
  70024. private _renderId;
  70025. constructor(name: string, scene: BABYLON.Scene);
  70026. needAlphaBlending(): boolean;
  70027. needAlphaTesting(): boolean;
  70028. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70029. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70030. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70031. getAnimatables(): BABYLON.IAnimatable[];
  70032. getActiveTextures(): BABYLON.BaseTexture[];
  70033. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70034. dispose(forceDisposeEffect?: boolean): void;
  70035. clone(name: string): SimpleMaterial;
  70036. serialize(): any;
  70037. getClassName(): string;
  70038. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70039. }
  70040. }
  70041. declare module BABYLON {
  70042. /** @hidden */
  70043. export var skyPixelShader: {
  70044. name: string;
  70045. shader: string;
  70046. };
  70047. }
  70048. declare module BABYLON {
  70049. /** @hidden */
  70050. export var skyVertexShader: {
  70051. name: string;
  70052. shader: string;
  70053. };
  70054. }
  70055. declare module BABYLON {
  70056. /**
  70057. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70058. * @see https://doc.babylonjs.com/extensions/sky
  70059. */
  70060. export class SkyMaterial extends BABYLON.PushMaterial {
  70061. /**
  70062. * Defines the overall luminance of sky in interval ]0, 1[.
  70063. */
  70064. luminance: number;
  70065. /**
  70066. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70067. */
  70068. turbidity: number;
  70069. /**
  70070. * Defines the sky appearance (light intensity).
  70071. */
  70072. rayleigh: number;
  70073. /**
  70074. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70075. */
  70076. mieCoefficient: number;
  70077. /**
  70078. * Defines the amount of haze particles following the Mie scattering theory.
  70079. */
  70080. mieDirectionalG: number;
  70081. /**
  70082. * Defines the distance of the sun according to the active scene camera.
  70083. */
  70084. distance: number;
  70085. /**
  70086. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70087. * "inclined".
  70088. */
  70089. inclination: number;
  70090. /**
  70091. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70092. * an object direction and a reference direction.
  70093. */
  70094. azimuth: number;
  70095. /**
  70096. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70097. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70098. */
  70099. sunPosition: BABYLON.Vector3;
  70100. /**
  70101. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70102. * .sunPosition property.
  70103. */
  70104. useSunPosition: boolean;
  70105. /**
  70106. * Defines an offset vector used to get a horizon offset.
  70107. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70108. */
  70109. cameraOffset: BABYLON.Vector3;
  70110. private _cameraPosition;
  70111. private _renderId;
  70112. /**
  70113. * Instantiates a new sky material.
  70114. * This material allows to create dynamic and texture free
  70115. * effects for skyboxes by taking care of the atmosphere state.
  70116. * @see https://doc.babylonjs.com/extensions/sky
  70117. * @param name Define the name of the material in the scene
  70118. * @param scene Define the scene the material belong to
  70119. */
  70120. constructor(name: string, scene: BABYLON.Scene);
  70121. /**
  70122. * Specifies if the material will require alpha blending
  70123. * @returns a boolean specifying if alpha blending is needed
  70124. */
  70125. needAlphaBlending(): boolean;
  70126. /**
  70127. * Specifies if this material should be rendered in alpha test mode
  70128. * @returns false as the sky material doesn't need alpha testing.
  70129. */
  70130. needAlphaTesting(): boolean;
  70131. /**
  70132. * Get the texture used for alpha test purpose.
  70133. * @returns null as the sky material has no texture.
  70134. */
  70135. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70136. /**
  70137. * Get if the submesh is ready to be used and all its information available.
  70138. * Child classes can use it to update shaders
  70139. * @param mesh defines the mesh to check
  70140. * @param subMesh defines which submesh to check
  70141. * @param useInstances specifies that instances should be used
  70142. * @returns a boolean indicating that the submesh is ready or not
  70143. */
  70144. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70145. /**
  70146. * Binds the submesh to this material by preparing the effect and shader to draw
  70147. * @param world defines the world transformation matrix
  70148. * @param mesh defines the mesh containing the submesh
  70149. * @param subMesh defines the submesh to bind the material to
  70150. */
  70151. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70152. /**
  70153. * Get the list of animatables in the material.
  70154. * @returns the list of animatables object used in the material
  70155. */
  70156. getAnimatables(): BABYLON.IAnimatable[];
  70157. /**
  70158. * Disposes the material
  70159. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70160. */
  70161. dispose(forceDisposeEffect?: boolean): void;
  70162. /**
  70163. * Makes a duplicate of the material, and gives it a new name
  70164. * @param name defines the new name for the duplicated material
  70165. * @returns the cloned material
  70166. */
  70167. clone(name: string): SkyMaterial;
  70168. /**
  70169. * Serializes this material in a JSON representation
  70170. * @returns the serialized material object
  70171. */
  70172. serialize(): any;
  70173. /**
  70174. * Gets the current class name of the material e.g. "SkyMaterial"
  70175. * Mainly use in serialization.
  70176. * @returns the class name
  70177. */
  70178. getClassName(): string;
  70179. /**
  70180. * Creates a sky material from parsed material data
  70181. * @param source defines the JSON representation of the material
  70182. * @param scene defines the hosting scene
  70183. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70184. * @returns a new sky material
  70185. */
  70186. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  70187. }
  70188. }
  70189. declare module BABYLON {
  70190. /** @hidden */
  70191. export var terrainPixelShader: {
  70192. name: string;
  70193. shader: string;
  70194. };
  70195. }
  70196. declare module BABYLON {
  70197. /** @hidden */
  70198. export var terrainVertexShader: {
  70199. name: string;
  70200. shader: string;
  70201. };
  70202. }
  70203. declare module BABYLON {
  70204. export class TerrainMaterial extends BABYLON.PushMaterial {
  70205. private _mixTexture;
  70206. mixTexture: BABYLON.BaseTexture;
  70207. private _diffuseTexture1;
  70208. diffuseTexture1: BABYLON.Texture;
  70209. private _diffuseTexture2;
  70210. diffuseTexture2: BABYLON.Texture;
  70211. private _diffuseTexture3;
  70212. diffuseTexture3: BABYLON.Texture;
  70213. private _bumpTexture1;
  70214. bumpTexture1: BABYLON.Texture;
  70215. private _bumpTexture2;
  70216. bumpTexture2: BABYLON.Texture;
  70217. private _bumpTexture3;
  70218. bumpTexture3: BABYLON.Texture;
  70219. diffuseColor: BABYLON.Color3;
  70220. specularColor: BABYLON.Color3;
  70221. specularPower: number;
  70222. private _disableLighting;
  70223. disableLighting: boolean;
  70224. private _maxSimultaneousLights;
  70225. maxSimultaneousLights: number;
  70226. private _renderId;
  70227. constructor(name: string, scene: BABYLON.Scene);
  70228. needAlphaBlending(): boolean;
  70229. needAlphaTesting(): boolean;
  70230. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70231. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70232. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70233. getAnimatables(): BABYLON.IAnimatable[];
  70234. getActiveTextures(): BABYLON.BaseTexture[];
  70235. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70236. dispose(forceDisposeEffect?: boolean): void;
  70237. clone(name: string): TerrainMaterial;
  70238. serialize(): any;
  70239. getClassName(): string;
  70240. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  70241. }
  70242. }
  70243. declare module BABYLON {
  70244. /** @hidden */
  70245. export var triplanarPixelShader: {
  70246. name: string;
  70247. shader: string;
  70248. };
  70249. }
  70250. declare module BABYLON {
  70251. /** @hidden */
  70252. export var triplanarVertexShader: {
  70253. name: string;
  70254. shader: string;
  70255. };
  70256. }
  70257. declare module BABYLON {
  70258. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  70259. mixTexture: BABYLON.BaseTexture;
  70260. private _diffuseTextureX;
  70261. diffuseTextureX: BABYLON.BaseTexture;
  70262. private _diffuseTextureY;
  70263. diffuseTextureY: BABYLON.BaseTexture;
  70264. private _diffuseTextureZ;
  70265. diffuseTextureZ: BABYLON.BaseTexture;
  70266. private _normalTextureX;
  70267. normalTextureX: BABYLON.BaseTexture;
  70268. private _normalTextureY;
  70269. normalTextureY: BABYLON.BaseTexture;
  70270. private _normalTextureZ;
  70271. normalTextureZ: BABYLON.BaseTexture;
  70272. tileSize: number;
  70273. diffuseColor: BABYLON.Color3;
  70274. specularColor: BABYLON.Color3;
  70275. specularPower: number;
  70276. private _disableLighting;
  70277. disableLighting: boolean;
  70278. private _maxSimultaneousLights;
  70279. maxSimultaneousLights: number;
  70280. private _renderId;
  70281. constructor(name: string, scene: BABYLON.Scene);
  70282. needAlphaBlending(): boolean;
  70283. needAlphaTesting(): boolean;
  70284. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70285. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70286. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70287. getAnimatables(): BABYLON.IAnimatable[];
  70288. getActiveTextures(): BABYLON.BaseTexture[];
  70289. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70290. dispose(forceDisposeEffect?: boolean): void;
  70291. clone(name: string): TriPlanarMaterial;
  70292. serialize(): any;
  70293. getClassName(): string;
  70294. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  70295. }
  70296. }
  70297. declare module BABYLON {
  70298. /** @hidden */
  70299. export var waterPixelShader: {
  70300. name: string;
  70301. shader: string;
  70302. };
  70303. }
  70304. declare module BABYLON {
  70305. /** @hidden */
  70306. export var waterVertexShader: {
  70307. name: string;
  70308. shader: string;
  70309. };
  70310. }
  70311. declare module BABYLON {
  70312. export class WaterMaterial extends BABYLON.PushMaterial {
  70313. renderTargetSize: BABYLON.Vector2;
  70314. private _bumpTexture;
  70315. bumpTexture: BABYLON.BaseTexture;
  70316. diffuseColor: BABYLON.Color3;
  70317. specularColor: BABYLON.Color3;
  70318. specularPower: number;
  70319. private _disableLighting;
  70320. disableLighting: boolean;
  70321. private _maxSimultaneousLights;
  70322. maxSimultaneousLights: number;
  70323. /**
  70324. * @param {number}: Represents the wind force
  70325. */
  70326. windForce: number;
  70327. /**
  70328. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  70329. */
  70330. windDirection: BABYLON.Vector2;
  70331. /**
  70332. * @param {number}: Wave height, represents the height of the waves
  70333. */
  70334. waveHeight: number;
  70335. /**
  70336. * @param {number}: Bump height, represents the bump height related to the bump map
  70337. */
  70338. bumpHeight: number;
  70339. /**
  70340. * @param {boolean}: Add a smaller moving bump to less steady waves.
  70341. */
  70342. private _bumpSuperimpose;
  70343. bumpSuperimpose: boolean;
  70344. /**
  70345. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  70346. */
  70347. private _fresnelSeparate;
  70348. fresnelSeparate: boolean;
  70349. /**
  70350. * @param {boolean}: bump Waves modify the reflection.
  70351. */
  70352. private _bumpAffectsReflection;
  70353. bumpAffectsReflection: boolean;
  70354. /**
  70355. * @param {number}: The water color blended with the refraction (near)
  70356. */
  70357. waterColor: BABYLON.Color3;
  70358. /**
  70359. * @param {number}: The blend factor related to the water color
  70360. */
  70361. colorBlendFactor: number;
  70362. /**
  70363. * @param {number}: The water color blended with the reflection (far)
  70364. */
  70365. waterColor2: BABYLON.Color3;
  70366. /**
  70367. * @param {number}: The blend factor related to the water color (reflection, far)
  70368. */
  70369. colorBlendFactor2: number;
  70370. /**
  70371. * @param {number}: Represents the maximum length of a wave
  70372. */
  70373. waveLength: number;
  70374. /**
  70375. * @param {number}: Defines the waves speed
  70376. */
  70377. waveSpeed: number;
  70378. /**
  70379. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  70380. * will avoid calculating useless pixels in the pixel shader of the water material.
  70381. */
  70382. disableClipPlane: boolean;
  70383. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  70384. private _mesh;
  70385. private _refractionRTT;
  70386. private _reflectionRTT;
  70387. private _reflectionTransform;
  70388. private _lastTime;
  70389. private _lastDeltaTime;
  70390. private _renderId;
  70391. private _useLogarithmicDepth;
  70392. private _waitingRenderList;
  70393. private _imageProcessingConfiguration;
  70394. private _imageProcessingObserver;
  70395. /**
  70396. * Gets a boolean indicating that current material needs to register RTT
  70397. */
  70398. readonly hasRenderTargetTextures: boolean;
  70399. /**
  70400. * Constructor
  70401. */
  70402. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  70403. useLogarithmicDepth: boolean;
  70404. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70405. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70406. addToRenderList(node: any): void;
  70407. enableRenderTargets(enable: boolean): void;
  70408. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  70409. readonly renderTargetsEnabled: boolean;
  70410. needAlphaBlending(): boolean;
  70411. needAlphaTesting(): boolean;
  70412. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70413. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70414. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70415. private _createRenderTargets;
  70416. getAnimatables(): BABYLON.IAnimatable[];
  70417. getActiveTextures(): BABYLON.BaseTexture[];
  70418. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70419. dispose(forceDisposeEffect?: boolean): void;
  70420. clone(name: string): WaterMaterial;
  70421. serialize(): any;
  70422. getClassName(): string;
  70423. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  70424. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  70425. }
  70426. }
  70427. declare module BABYLON {
  70428. /** @hidden */
  70429. export var asciiartPixelShader: {
  70430. name: string;
  70431. shader: string;
  70432. };
  70433. }
  70434. declare module BABYLON {
  70435. /**
  70436. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  70437. *
  70438. * It basically takes care rendering the font front the given font size to a texture.
  70439. * This is used later on in the postprocess.
  70440. */
  70441. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  70442. private _font;
  70443. private _text;
  70444. private _charSize;
  70445. /**
  70446. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70447. */
  70448. readonly charSize: number;
  70449. /**
  70450. * Create a new instance of the Ascii Art FontTexture class
  70451. * @param name the name of the texture
  70452. * @param font the font to use, use the W3C CSS notation
  70453. * @param text the caracter set to use in the rendering.
  70454. * @param scene the scene that owns the texture
  70455. */
  70456. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70457. /**
  70458. * Gets the max char width of a font.
  70459. * @param font the font to use, use the W3C CSS notation
  70460. * @return the max char width
  70461. */
  70462. private getFontWidth;
  70463. /**
  70464. * Gets the max char height of a font.
  70465. * @param font the font to use, use the W3C CSS notation
  70466. * @return the max char height
  70467. */
  70468. private getFontHeight;
  70469. /**
  70470. * Clones the current AsciiArtTexture.
  70471. * @return the clone of the texture.
  70472. */
  70473. clone(): AsciiArtFontTexture;
  70474. /**
  70475. * Parses a json object representing the texture and returns an instance of it.
  70476. * @param source the source JSON representation
  70477. * @param scene the scene to create the texture for
  70478. * @return the parsed texture
  70479. */
  70480. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  70481. }
  70482. /**
  70483. * Option available in the Ascii Art Post Process.
  70484. */
  70485. export interface IAsciiArtPostProcessOptions {
  70486. /**
  70487. * The font to use following the w3c font definition.
  70488. */
  70489. font?: string;
  70490. /**
  70491. * The character set to use in the postprocess.
  70492. */
  70493. characterSet?: string;
  70494. /**
  70495. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70496. * This number is defined between 0 and 1;
  70497. */
  70498. mixToTile?: number;
  70499. /**
  70500. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70501. * This number is defined between 0 and 1;
  70502. */
  70503. mixToNormal?: number;
  70504. }
  70505. /**
  70506. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  70507. *
  70508. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70509. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  70510. */
  70511. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  70512. /**
  70513. * The font texture used to render the char in the post process.
  70514. */
  70515. private _asciiArtFontTexture;
  70516. /**
  70517. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70518. * This number is defined between 0 and 1;
  70519. */
  70520. mixToTile: number;
  70521. /**
  70522. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70523. * This number is defined between 0 and 1;
  70524. */
  70525. mixToNormal: number;
  70526. /**
  70527. * Instantiates a new Ascii Art Post Process.
  70528. * @param name the name to give to the postprocess
  70529. * @camera the camera to apply the post process to.
  70530. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  70531. */
  70532. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  70533. }
  70534. }
  70535. declare module BABYLON {
  70536. /** @hidden */
  70537. export var digitalrainPixelShader: {
  70538. name: string;
  70539. shader: string;
  70540. };
  70541. }
  70542. declare module BABYLON {
  70543. /**
  70544. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  70545. *
  70546. * It basically takes care rendering the font front the given font size to a texture.
  70547. * This is used later on in the postprocess.
  70548. */
  70549. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  70550. private _font;
  70551. private _text;
  70552. private _charSize;
  70553. /**
  70554. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70555. */
  70556. readonly charSize: number;
  70557. /**
  70558. * Create a new instance of the Digital Rain FontTexture class
  70559. * @param name the name of the texture
  70560. * @param font the font to use, use the W3C CSS notation
  70561. * @param text the caracter set to use in the rendering.
  70562. * @param scene the scene that owns the texture
  70563. */
  70564. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70565. /**
  70566. * Gets the max char width of a font.
  70567. * @param font the font to use, use the W3C CSS notation
  70568. * @return the max char width
  70569. */
  70570. private getFontWidth;
  70571. /**
  70572. * Gets the max char height of a font.
  70573. * @param font the font to use, use the W3C CSS notation
  70574. * @return the max char height
  70575. */
  70576. private getFontHeight;
  70577. /**
  70578. * Clones the current DigitalRainFontTexture.
  70579. * @return the clone of the texture.
  70580. */
  70581. clone(): DigitalRainFontTexture;
  70582. /**
  70583. * Parses a json object representing the texture and returns an instance of it.
  70584. * @param source the source JSON representation
  70585. * @param scene the scene to create the texture for
  70586. * @return the parsed texture
  70587. */
  70588. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  70589. }
  70590. /**
  70591. * Option available in the Digital Rain Post Process.
  70592. */
  70593. export interface IDigitalRainPostProcessOptions {
  70594. /**
  70595. * The font to use following the w3c font definition.
  70596. */
  70597. font?: string;
  70598. /**
  70599. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70600. * This number is defined between 0 and 1;
  70601. */
  70602. mixToTile?: number;
  70603. /**
  70604. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70605. * This number is defined between 0 and 1;
  70606. */
  70607. mixToNormal?: number;
  70608. }
  70609. /**
  70610. * DigitalRainPostProcess helps rendering everithing in digital rain.
  70611. *
  70612. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70613. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  70614. */
  70615. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  70616. /**
  70617. * The font texture used to render the char in the post process.
  70618. */
  70619. private _digitalRainFontTexture;
  70620. /**
  70621. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70622. * This number is defined between 0 and 1;
  70623. */
  70624. mixToTile: number;
  70625. /**
  70626. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70627. * This number is defined between 0 and 1;
  70628. */
  70629. mixToNormal: number;
  70630. /**
  70631. * Instantiates a new Digital Rain Post Process.
  70632. * @param name the name to give to the postprocess
  70633. * @camera the camera to apply the post process to.
  70634. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  70635. */
  70636. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  70637. }
  70638. }
  70639. declare module BABYLON {
  70640. /** @hidden */
  70641. export var oceanPostProcessPixelShader: {
  70642. name: string;
  70643. shader: string;
  70644. };
  70645. }
  70646. declare module BABYLON {
  70647. /**
  70648. * Option available in the Ocean Post Process.
  70649. */
  70650. export interface IOceanPostProcessOptions {
  70651. /**
  70652. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70653. */
  70654. reflectionSize?: number | {
  70655. width: number;
  70656. height: number;
  70657. } | {
  70658. ratio: number;
  70659. };
  70660. /**
  70661. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70662. */
  70663. refractionSize?: number | {
  70664. width: number;
  70665. height: number;
  70666. } | {
  70667. ratio: number;
  70668. };
  70669. }
  70670. /**
  70671. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  70672. *
  70673. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70674. * Example usage:
  70675. * var pp = new OceanPostProcess("myOcean", camera);
  70676. * pp.reflectionEnabled = true;
  70677. * pp.refractionEnabled = true;
  70678. */
  70679. export class OceanPostProcess extends BABYLON.PostProcess {
  70680. /**
  70681. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  70682. */
  70683. /**
  70684. * Sets weither or not the real-time reflection is enabled on the ocean.
  70685. * Is set to true, the reflection mirror texture will be used as reflection texture.
  70686. */
  70687. reflectionEnabled: boolean;
  70688. /**
  70689. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  70690. */
  70691. /**
  70692. * Sets weither or not the real-time refraction is enabled on the ocean.
  70693. * Is set to true, the refraction render target texture will be used as refraction texture.
  70694. */
  70695. refractionEnabled: boolean;
  70696. /**
  70697. * Gets wether or not the post-processes is supported by the running hardware.
  70698. * This requires draw buffer supports.
  70699. */
  70700. readonly isSupported: boolean;
  70701. /**
  70702. * This is the reflection mirror texture used to display reflections on the ocean.
  70703. * By default, render list is empty.
  70704. */
  70705. reflectionTexture: BABYLON.MirrorTexture;
  70706. /**
  70707. * This is the refraction render target texture used to display refraction on the ocean.
  70708. * By default, render list is empty.
  70709. */
  70710. refractionTexture: BABYLON.RenderTargetTexture;
  70711. private _time;
  70712. private _cameraRotation;
  70713. private _cameraViewMatrix;
  70714. private _reflectionEnabled;
  70715. private _refractionEnabled;
  70716. private _geometryRenderer;
  70717. /**
  70718. * Instantiates a new Ocean Post Process.
  70719. * @param name the name to give to the postprocess.
  70720. * @camera the camera to apply the post process to.
  70721. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  70722. */
  70723. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  70724. /**
  70725. * Returns the appropriate defines according to the current configuration.
  70726. */
  70727. private _getDefines;
  70728. /**
  70729. * Computes the current camera rotation as the shader requires a camera rotation.
  70730. */
  70731. private _computeCameraRotation;
  70732. }
  70733. }
  70734. declare module BABYLON {
  70735. /** @hidden */
  70736. export var brickProceduralTexturePixelShader: {
  70737. name: string;
  70738. shader: string;
  70739. };
  70740. }
  70741. declare module BABYLON {
  70742. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  70743. private _numberOfBricksHeight;
  70744. private _numberOfBricksWidth;
  70745. private _jointColor;
  70746. private _brickColor;
  70747. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70748. updateShaderUniforms(): void;
  70749. numberOfBricksHeight: number;
  70750. numberOfBricksWidth: number;
  70751. jointColor: BABYLON.Color3;
  70752. brickColor: BABYLON.Color3;
  70753. /**
  70754. * Serializes this brick procedural texture
  70755. * @returns a serialized brick procedural texture object
  70756. */
  70757. serialize(): any;
  70758. /**
  70759. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  70760. * @param parsedTexture defines parsed texture data
  70761. * @param scene defines the current scene
  70762. * @param rootUrl defines the root URL containing brick procedural texture information
  70763. * @returns a parsed Brick Procedural BABYLON.Texture
  70764. */
  70765. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  70766. }
  70767. }
  70768. declare module BABYLON {
  70769. /** @hidden */
  70770. export var cloudProceduralTexturePixelShader: {
  70771. name: string;
  70772. shader: string;
  70773. };
  70774. }
  70775. declare module BABYLON {
  70776. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  70777. private _skyColor;
  70778. private _cloudColor;
  70779. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70780. updateShaderUniforms(): void;
  70781. skyColor: BABYLON.Color4;
  70782. cloudColor: BABYLON.Color4;
  70783. /**
  70784. * Serializes this cloud procedural texture
  70785. * @returns a serialized cloud procedural texture object
  70786. */
  70787. serialize(): any;
  70788. /**
  70789. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  70790. * @param parsedTexture defines parsed texture data
  70791. * @param scene defines the current scene
  70792. * @param rootUrl defines the root URL containing cloud procedural texture information
  70793. * @returns a parsed Cloud Procedural BABYLON.Texture
  70794. */
  70795. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  70796. }
  70797. }
  70798. declare module BABYLON {
  70799. /** @hidden */
  70800. export var fireProceduralTexturePixelShader: {
  70801. name: string;
  70802. shader: string;
  70803. };
  70804. }
  70805. declare module BABYLON {
  70806. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  70807. private _time;
  70808. private _speed;
  70809. private _autoGenerateTime;
  70810. private _fireColors;
  70811. private _alphaThreshold;
  70812. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70813. updateShaderUniforms(): void;
  70814. render(useCameraPostProcess?: boolean): void;
  70815. static readonly PurpleFireColors: BABYLON.Color3[];
  70816. static readonly GreenFireColors: BABYLON.Color3[];
  70817. static readonly RedFireColors: BABYLON.Color3[];
  70818. static readonly BlueFireColors: BABYLON.Color3[];
  70819. autoGenerateTime: boolean;
  70820. fireColors: BABYLON.Color3[];
  70821. time: number;
  70822. speed: BABYLON.Vector2;
  70823. alphaThreshold: number;
  70824. /**
  70825. * Serializes this fire procedural texture
  70826. * @returns a serialized fire procedural texture object
  70827. */
  70828. serialize(): any;
  70829. /**
  70830. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  70831. * @param parsedTexture defines parsed texture data
  70832. * @param scene defines the current scene
  70833. * @param rootUrl defines the root URL containing fire procedural texture information
  70834. * @returns a parsed Fire Procedural BABYLON.Texture
  70835. */
  70836. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  70837. }
  70838. }
  70839. declare module BABYLON {
  70840. /** @hidden */
  70841. export var grassProceduralTexturePixelShader: {
  70842. name: string;
  70843. shader: string;
  70844. };
  70845. }
  70846. declare module BABYLON {
  70847. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  70848. private _grassColors;
  70849. private _groundColor;
  70850. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70851. updateShaderUniforms(): void;
  70852. grassColors: BABYLON.Color3[];
  70853. groundColor: BABYLON.Color3;
  70854. /**
  70855. * Serializes this grass procedural texture
  70856. * @returns a serialized grass procedural texture object
  70857. */
  70858. serialize(): any;
  70859. /**
  70860. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  70861. * @param parsedTexture defines parsed texture data
  70862. * @param scene defines the current scene
  70863. * @param rootUrl defines the root URL containing grass procedural texture information
  70864. * @returns a parsed Grass Procedural BABYLON.Texture
  70865. */
  70866. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  70867. }
  70868. }
  70869. declare module BABYLON {
  70870. /** @hidden */
  70871. export var marbleProceduralTexturePixelShader: {
  70872. name: string;
  70873. shader: string;
  70874. };
  70875. }
  70876. declare module BABYLON {
  70877. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  70878. private _numberOfTilesHeight;
  70879. private _numberOfTilesWidth;
  70880. private _amplitude;
  70881. private _jointColor;
  70882. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70883. updateShaderUniforms(): void;
  70884. numberOfTilesHeight: number;
  70885. amplitude: number;
  70886. numberOfTilesWidth: number;
  70887. jointColor: BABYLON.Color3;
  70888. /**
  70889. * Serializes this marble procedural texture
  70890. * @returns a serialized marble procedural texture object
  70891. */
  70892. serialize(): any;
  70893. /**
  70894. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  70895. * @param parsedTexture defines parsed texture data
  70896. * @param scene defines the current scene
  70897. * @param rootUrl defines the root URL containing marble procedural texture information
  70898. * @returns a parsed Marble Procedural BABYLON.Texture
  70899. */
  70900. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  70901. }
  70902. }
  70903. declare module BABYLON {
  70904. /** @hidden */
  70905. export var normalMapProceduralTexturePixelShader: {
  70906. name: string;
  70907. shader: string;
  70908. };
  70909. }
  70910. declare module BABYLON {
  70911. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  70912. private _baseTexture;
  70913. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70914. updateShaderUniforms(): void;
  70915. render(useCameraPostProcess?: boolean): void;
  70916. resize(size: any, generateMipMaps: any): void;
  70917. baseTexture: BABYLON.Texture;
  70918. /**
  70919. * Serializes this normal map procedural texture
  70920. * @returns a serialized normal map procedural texture object
  70921. */
  70922. serialize(): any;
  70923. /**
  70924. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  70925. * @param parsedTexture defines parsed texture data
  70926. * @param scene defines the current scene
  70927. * @param rootUrl defines the root URL containing normal map procedural texture information
  70928. * @returns a parsed Normal Map Procedural BABYLON.Texture
  70929. */
  70930. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  70931. }
  70932. }
  70933. declare module BABYLON {
  70934. /** @hidden */
  70935. export var perlinNoiseProceduralTexturePixelShader: {
  70936. name: string;
  70937. shader: string;
  70938. };
  70939. }
  70940. declare module BABYLON {
  70941. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  70942. time: number;
  70943. timeScale: number;
  70944. translationSpeed: number;
  70945. private _currentTranslation;
  70946. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70947. updateShaderUniforms(): void;
  70948. render(useCameraPostProcess?: boolean): void;
  70949. resize(size: any, generateMipMaps: any): void;
  70950. /**
  70951. * Serializes this perlin noise procedural texture
  70952. * @returns a serialized perlin noise procedural texture object
  70953. */
  70954. serialize(): any;
  70955. /**
  70956. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  70957. * @param parsedTexture defines parsed texture data
  70958. * @param scene defines the current scene
  70959. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  70960. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  70961. */
  70962. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  70963. }
  70964. }
  70965. declare module BABYLON {
  70966. /** @hidden */
  70967. export var roadProceduralTexturePixelShader: {
  70968. name: string;
  70969. shader: string;
  70970. };
  70971. }
  70972. declare module BABYLON {
  70973. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  70974. private _roadColor;
  70975. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70976. updateShaderUniforms(): void;
  70977. roadColor: BABYLON.Color3;
  70978. /**
  70979. * Serializes this road procedural texture
  70980. * @returns a serialized road procedural texture object
  70981. */
  70982. serialize(): any;
  70983. /**
  70984. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  70985. * @param parsedTexture defines parsed texture data
  70986. * @param scene defines the current scene
  70987. * @param rootUrl defines the root URL containing road procedural texture information
  70988. * @returns a parsed Road Procedural BABYLON.Texture
  70989. */
  70990. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  70991. }
  70992. }
  70993. declare module BABYLON {
  70994. /** @hidden */
  70995. export var starfieldProceduralTexturePixelShader: {
  70996. name: string;
  70997. shader: string;
  70998. };
  70999. }
  71000. declare module BABYLON {
  71001. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71002. private _time;
  71003. private _alpha;
  71004. private _beta;
  71005. private _zoom;
  71006. private _formuparam;
  71007. private _stepsize;
  71008. private _tile;
  71009. private _brightness;
  71010. private _darkmatter;
  71011. private _distfading;
  71012. private _saturation;
  71013. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71014. updateShaderUniforms(): void;
  71015. time: number;
  71016. alpha: number;
  71017. beta: number;
  71018. formuparam: number;
  71019. stepsize: number;
  71020. zoom: number;
  71021. tile: number;
  71022. brightness: number;
  71023. darkmatter: number;
  71024. distfading: number;
  71025. saturation: number;
  71026. /**
  71027. * Serializes this starfield procedural texture
  71028. * @returns a serialized starfield procedural texture object
  71029. */
  71030. serialize(): any;
  71031. /**
  71032. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71033. * @param parsedTexture defines parsed texture data
  71034. * @param scene defines the current scene
  71035. * @param rootUrl defines the root URL containing startfield procedural texture information
  71036. * @returns a parsed Starfield Procedural BABYLON.Texture
  71037. */
  71038. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71039. }
  71040. }
  71041. declare module BABYLON {
  71042. /** @hidden */
  71043. export var woodProceduralTexturePixelShader: {
  71044. name: string;
  71045. shader: string;
  71046. };
  71047. }
  71048. declare module BABYLON {
  71049. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71050. private _ampScale;
  71051. private _woodColor;
  71052. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71053. updateShaderUniforms(): void;
  71054. ampScale: number;
  71055. woodColor: BABYLON.Color3;
  71056. /**
  71057. * Serializes this wood procedural texture
  71058. * @returns a serialized wood procedural texture object
  71059. */
  71060. serialize(): any;
  71061. /**
  71062. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71063. * @param parsedTexture defines parsed texture data
  71064. * @param scene defines the current scene
  71065. * @param rootUrl defines the root URL containing wood procedural texture information
  71066. * @returns a parsed Wood Procedural BABYLON.Texture
  71067. */
  71068. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71069. }
  71070. }