babylon.d.txt 3.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */ private _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Helper to manipulate strings
  378. */
  379. export class StringTools {
  380. /**
  381. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  382. * @param str Source string
  383. * @param suffix Suffix to search for in the source string
  384. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  385. */
  386. static EndsWith(str: string, suffix: string): boolean;
  387. /**
  388. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static StartsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Decodes a buffer into a string
  396. * @param buffer The buffer to decode
  397. * @returns The decoded string
  398. */
  399. static Decode(buffer: Uint8Array | Uint16Array): string;
  400. /**
  401. * Encode a buffer to a base64 string
  402. * @param buffer defines the buffer to encode
  403. * @returns the encoded string
  404. */
  405. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  406. }
  407. }
  408. declare module BABYLON {
  409. /**
  410. * Class containing a set of static utilities functions for deep copy.
  411. */
  412. export class DeepCopier {
  413. /**
  414. * Tries to copy an object by duplicating every property
  415. * @param source defines the source object
  416. * @param destination defines the target object
  417. * @param doNotCopyList defines a list of properties to avoid
  418. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  419. */
  420. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  421. }
  422. }
  423. declare module BABYLON {
  424. /**
  425. * Class containing a set of static utilities functions for precision date
  426. */
  427. export class PrecisionDate {
  428. /**
  429. * Gets either window.performance.now() if supported or Date.now() else
  430. */
  431. static readonly Now: number;
  432. }
  433. }
  434. declare module BABYLON {
  435. /** @hidden */
  436. export class _DevTools {
  437. static WarnImport(name: string): string;
  438. }
  439. }
  440. declare module BABYLON {
  441. /**
  442. * Interface used to define the mechanism to get data from the network
  443. */
  444. export interface IWebRequest {
  445. /**
  446. * Returns client's response url
  447. */
  448. responseURL: string;
  449. /**
  450. * Returns client's status
  451. */
  452. status: number;
  453. /**
  454. * Returns client's status as a text
  455. */
  456. statusText: string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  462. */
  463. export class WebRequest implements IWebRequest {
  464. private _xhr;
  465. /**
  466. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  467. * i.e. when loading files, where the server/service expects an Authorization header
  468. */
  469. static CustomRequestHeaders: {
  470. [key: string]: string;
  471. };
  472. /**
  473. * Add callback functions in this array to update all the requests before they get sent to the network
  474. */
  475. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  476. private _injectCustomRequestHeaders;
  477. /**
  478. * Gets or sets a function to be called when loading progress changes
  479. */
  480. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  481. /**
  482. * Returns client's state
  483. */
  484. readonly readyState: number;
  485. /**
  486. * Returns client's status
  487. */
  488. readonly status: number;
  489. /**
  490. * Returns client's status as a text
  491. */
  492. readonly statusText: string;
  493. /**
  494. * Returns client's response
  495. */
  496. readonly response: any;
  497. /**
  498. * Returns client's response url
  499. */
  500. readonly responseURL: string;
  501. /**
  502. * Returns client's response as text
  503. */
  504. readonly responseText: string;
  505. /**
  506. * Gets or sets the expected response type
  507. */
  508. responseType: XMLHttpRequestResponseType;
  509. /** @hidden */
  510. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  511. /** @hidden */
  512. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  513. /**
  514. * Cancels any network activity
  515. */
  516. abort(): void;
  517. /**
  518. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  519. * @param body defines an optional request body
  520. */
  521. send(body?: Document | BodyInit | null): void;
  522. /**
  523. * Sets the request method, request URL
  524. * @param method defines the method to use (GET, POST, etc..)
  525. * @param url defines the url to connect with
  526. */
  527. open(method: string, url: string): void;
  528. /**
  529. * Sets the value of a request header.
  530. * @param name The name of the header whose value is to be set
  531. * @param value The value to set as the body of the header
  532. */
  533. setRequestHeader(name: string, value: string): void;
  534. /**
  535. * Get the string containing the text of a particular header's value.
  536. * @param name The name of the header
  537. * @returns The string containing the text of the given header name
  538. */
  539. getResponseHeader(name: string): Nullable<string>;
  540. }
  541. }
  542. declare module BABYLON {
  543. /**
  544. * File request interface
  545. */
  546. export interface IFileRequest {
  547. /**
  548. * Raised when the request is complete (success or error).
  549. */
  550. onCompleteObservable: Observable<IFileRequest>;
  551. /**
  552. * Aborts the request for a file.
  553. */
  554. abort: () => void;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * Define options used to create a render target texture
  560. */
  561. export class RenderTargetCreationOptions {
  562. /**
  563. * Specifies is mipmaps must be generated
  564. */
  565. generateMipMaps?: boolean;
  566. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  567. generateDepthBuffer?: boolean;
  568. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  569. generateStencilBuffer?: boolean;
  570. /** Defines texture type (int by default) */
  571. type?: number;
  572. /** Defines sampling mode (trilinear by default) */
  573. samplingMode?: number;
  574. /** Defines format (RGBA by default) */
  575. format?: number;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * @hidden
  581. **/
  582. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  583. }
  584. }
  585. declare module BABYLON {
  586. /** Defines the cross module used constants to avoid circular dependncies */
  587. export class Constants {
  588. /** Defines that alpha blending is disabled */
  589. static readonly ALPHA_DISABLE: number;
  590. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  591. static readonly ALPHA_ADD: number;
  592. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  593. static readonly ALPHA_COMBINE: number;
  594. /** Defines that alpha blending to DEST - SRC * DEST */
  595. static readonly ALPHA_SUBTRACT: number;
  596. /** Defines that alpha blending to SRC * DEST */
  597. static readonly ALPHA_MULTIPLY: number;
  598. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  599. static readonly ALPHA_MAXIMIZED: number;
  600. /** Defines that alpha blending to SRC + DEST */
  601. static readonly ALPHA_ONEONE: number;
  602. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_PREMULTIPLIED: number;
  604. /**
  605. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  607. */
  608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  609. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  610. static readonly ALPHA_INTERPOLATE: number;
  611. /**
  612. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_SCREENMODE: number;
  616. /**
  617. * Defines that alpha blending to SRC + DST
  618. * Alpha will be set to SRC ALPHA + DST ALPHA
  619. */
  620. static readonly ALPHA_ONEONE_ONEONE: number;
  621. /**
  622. * Defines that alpha blending to SRC * DST ALPHA + DST
  623. * Alpha will be set to 0
  624. */
  625. static readonly ALPHA_ALPHATOCOLOR: number;
  626. /**
  627. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  628. */
  629. static readonly ALPHA_REVERSEONEMINUS: number;
  630. /**
  631. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  632. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  633. */
  634. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  635. /**
  636. * Defines that alpha blending to SRC + DST
  637. * Alpha will be set to SRC ALPHA
  638. */
  639. static readonly ALPHA_ONEONE_ONEZERO: number;
  640. /** Defines that alpha blending equation a SUM */
  641. static readonly ALPHA_EQUATION_ADD: number;
  642. /** Defines that alpha blending equation a SUBSTRACTION */
  643. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  644. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  645. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  646. /** Defines that alpha blending equation a MAX operation */
  647. static readonly ALPHA_EQUATION_MAX: number;
  648. /** Defines that alpha blending equation a MIN operation */
  649. static readonly ALPHA_EQUATION_MIN: number;
  650. /**
  651. * Defines that alpha blending equation a DARKEN operation:
  652. * It takes the min of the src and sums the alpha channels.
  653. */
  654. static readonly ALPHA_EQUATION_DARKEN: number;
  655. /** Defines that the ressource is not delayed*/
  656. static readonly DELAYLOADSTATE_NONE: number;
  657. /** Defines that the ressource was successfully delay loaded */
  658. static readonly DELAYLOADSTATE_LOADED: number;
  659. /** Defines that the ressource is currently delay loading */
  660. static readonly DELAYLOADSTATE_LOADING: number;
  661. /** Defines that the ressource is delayed and has not started loading */
  662. static readonly DELAYLOADSTATE_NOTLOADED: number;
  663. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  664. static readonly NEVER: number;
  665. /** 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 */
  666. static readonly ALWAYS: number;
  667. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  668. static readonly LESS: number;
  669. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  670. static readonly EQUAL: number;
  671. /** 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 */
  672. static readonly LEQUAL: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  674. static readonly GREATER: number;
  675. /** 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 */
  676. static readonly GEQUAL: number;
  677. /** 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 */
  678. static readonly NOTEQUAL: number;
  679. /** Passed to stencilOperation to specify that stencil value must be kept */
  680. static readonly KEEP: number;
  681. /** Passed to stencilOperation to specify that stencil value must be replaced */
  682. static readonly REPLACE: number;
  683. /** Passed to stencilOperation to specify that stencil value must be incremented */
  684. static readonly INCR: number;
  685. /** Passed to stencilOperation to specify that stencil value must be decremented */
  686. static readonly DECR: number;
  687. /** Passed to stencilOperation to specify that stencil value must be inverted */
  688. static readonly INVERT: number;
  689. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  690. static readonly INCR_WRAP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  692. static readonly DECR_WRAP: number;
  693. /** Texture is not repeating outside of 0..1 UVs */
  694. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  695. /** Texture is repeating outside of 0..1 UVs */
  696. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  697. /** Texture is repeating and mirrored */
  698. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  699. /** ALPHA */
  700. static readonly TEXTUREFORMAT_ALPHA: number;
  701. /** LUMINANCE */
  702. static readonly TEXTUREFORMAT_LUMINANCE: number;
  703. /** LUMINANCE_ALPHA */
  704. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  705. /** RGB */
  706. static readonly TEXTUREFORMAT_RGB: number;
  707. /** RGBA */
  708. static readonly TEXTUREFORMAT_RGBA: number;
  709. /** RED */
  710. static readonly TEXTUREFORMAT_RED: number;
  711. /** RED (2nd reference) */
  712. static readonly TEXTUREFORMAT_R: number;
  713. /** RG */
  714. static readonly TEXTUREFORMAT_RG: number;
  715. /** RED_INTEGER */
  716. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  717. /** RED_INTEGER (2nd reference) */
  718. static readonly TEXTUREFORMAT_R_INTEGER: number;
  719. /** RG_INTEGER */
  720. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  721. /** RGB_INTEGER */
  722. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  723. /** RGBA_INTEGER */
  724. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  725. /** UNSIGNED_BYTE */
  726. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  727. /** UNSIGNED_BYTE (2nd reference) */
  728. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  729. /** FLOAT */
  730. static readonly TEXTURETYPE_FLOAT: number;
  731. /** HALF_FLOAT */
  732. static readonly TEXTURETYPE_HALF_FLOAT: number;
  733. /** BYTE */
  734. static readonly TEXTURETYPE_BYTE: number;
  735. /** SHORT */
  736. static readonly TEXTURETYPE_SHORT: number;
  737. /** UNSIGNED_SHORT */
  738. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  739. /** INT */
  740. static readonly TEXTURETYPE_INT: number;
  741. /** UNSIGNED_INT */
  742. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  743. /** UNSIGNED_SHORT_4_4_4_4 */
  744. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  745. /** UNSIGNED_SHORT_5_5_5_1 */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  747. /** UNSIGNED_SHORT_5_6_5 */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  749. /** UNSIGNED_INT_2_10_10_10_REV */
  750. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  751. /** UNSIGNED_INT_24_8 */
  752. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  753. /** UNSIGNED_INT_10F_11F_11F_REV */
  754. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  755. /** UNSIGNED_INT_5_9_9_9_REV */
  756. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  757. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  758. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  759. /** nearest is mag = nearest and min = nearest and mip = linear */
  760. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  761. /** Bilinear is mag = linear and min = linear and mip = nearest */
  762. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  763. /** Trilinear is mag = linear and min = linear and mip = linear */
  764. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  765. /** nearest is mag = nearest and min = nearest and mip = linear */
  766. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  767. /** Bilinear is mag = linear and min = linear and mip = nearest */
  768. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  769. /** Trilinear is mag = linear and min = linear and mip = linear */
  770. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  771. /** mag = nearest and min = nearest and mip = nearest */
  772. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  773. /** mag = nearest and min = linear and mip = nearest */
  774. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  775. /** mag = nearest and min = linear and mip = linear */
  776. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  777. /** mag = nearest and min = linear and mip = none */
  778. static readonly TEXTURE_NEAREST_LINEAR: number;
  779. /** mag = nearest and min = nearest and mip = none */
  780. static readonly TEXTURE_NEAREST_NEAREST: number;
  781. /** mag = linear and min = nearest and mip = nearest */
  782. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  783. /** mag = linear and min = nearest and mip = linear */
  784. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  785. /** mag = linear and min = linear and mip = none */
  786. static readonly TEXTURE_LINEAR_LINEAR: number;
  787. /** mag = linear and min = nearest and mip = none */
  788. static readonly TEXTURE_LINEAR_NEAREST: number;
  789. /** Explicit coordinates mode */
  790. static readonly TEXTURE_EXPLICIT_MODE: number;
  791. /** Spherical coordinates mode */
  792. static readonly TEXTURE_SPHERICAL_MODE: number;
  793. /** Planar coordinates mode */
  794. static readonly TEXTURE_PLANAR_MODE: number;
  795. /** Cubic coordinates mode */
  796. static readonly TEXTURE_CUBIC_MODE: number;
  797. /** Projection coordinates mode */
  798. static readonly TEXTURE_PROJECTION_MODE: number;
  799. /** Skybox coordinates mode */
  800. static readonly TEXTURE_SKYBOX_MODE: number;
  801. /** Inverse Cubic coordinates mode */
  802. static readonly TEXTURE_INVCUBIC_MODE: number;
  803. /** Equirectangular coordinates mode */
  804. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  805. /** Equirectangular Fixed coordinates mode */
  806. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  807. /** Equirectangular Fixed Mirrored coordinates mode */
  808. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  809. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  810. static readonly SCALEMODE_FLOOR: number;
  811. /** Defines that texture rescaling will look for the nearest power of 2 size */
  812. static readonly SCALEMODE_NEAREST: number;
  813. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  814. static readonly SCALEMODE_CEILING: number;
  815. /**
  816. * The dirty texture flag value
  817. */
  818. static readonly MATERIAL_TextureDirtyFlag: number;
  819. /**
  820. * The dirty light flag value
  821. */
  822. static readonly MATERIAL_LightDirtyFlag: number;
  823. /**
  824. * The dirty fresnel flag value
  825. */
  826. static readonly MATERIAL_FresnelDirtyFlag: number;
  827. /**
  828. * The dirty attribute flag value
  829. */
  830. static readonly MATERIAL_AttributesDirtyFlag: number;
  831. /**
  832. * The dirty misc flag value
  833. */
  834. static readonly MATERIAL_MiscDirtyFlag: number;
  835. /**
  836. * The all dirty flag value
  837. */
  838. static readonly MATERIAL_AllDirtyFlag: number;
  839. /**
  840. * Returns the triangle fill mode
  841. */
  842. static readonly MATERIAL_TriangleFillMode: number;
  843. /**
  844. * Returns the wireframe mode
  845. */
  846. static readonly MATERIAL_WireFrameFillMode: number;
  847. /**
  848. * Returns the point fill mode
  849. */
  850. static readonly MATERIAL_PointFillMode: number;
  851. /**
  852. * Returns the point list draw mode
  853. */
  854. static readonly MATERIAL_PointListDrawMode: number;
  855. /**
  856. * Returns the line list draw mode
  857. */
  858. static readonly MATERIAL_LineListDrawMode: number;
  859. /**
  860. * Returns the line loop draw mode
  861. */
  862. static readonly MATERIAL_LineLoopDrawMode: number;
  863. /**
  864. * Returns the line strip draw mode
  865. */
  866. static readonly MATERIAL_LineStripDrawMode: number;
  867. /**
  868. * Returns the triangle strip draw mode
  869. */
  870. static readonly MATERIAL_TriangleStripDrawMode: number;
  871. /**
  872. * Returns the triangle fan draw mode
  873. */
  874. static readonly MATERIAL_TriangleFanDrawMode: number;
  875. /**
  876. * Stores the clock-wise side orientation
  877. */
  878. static readonly MATERIAL_ClockWiseSideOrientation: number;
  879. /**
  880. * Stores the counter clock-wise side orientation
  881. */
  882. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  883. /**
  884. * Nothing
  885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  886. */
  887. static readonly ACTION_NothingTrigger: number;
  888. /**
  889. * On pick
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_OnPickTrigger: number;
  893. /**
  894. * On left pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnLeftPickTrigger: number;
  898. /**
  899. * On right pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnRightPickTrigger: number;
  903. /**
  904. * On center pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnCenterPickTrigger: number;
  908. /**
  909. * On pick down
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnPickDownTrigger: number;
  913. /**
  914. * On double pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnDoublePickTrigger: number;
  918. /**
  919. * On pick up
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickUpTrigger: number;
  923. /**
  924. * On pick out.
  925. * This trigger will only be raised if you also declared a OnPickDown
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnPickOutTrigger: number;
  929. /**
  930. * On long press
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnLongPressTrigger: number;
  934. /**
  935. * On pointer over
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPointerOverTrigger: number;
  939. /**
  940. * On pointer out
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOutTrigger: number;
  944. /**
  945. * On every frame
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnEveryFrameTrigger: number;
  949. /**
  950. * On intersection enter
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnIntersectionEnterTrigger: number;
  954. /**
  955. * On intersection exit
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionExitTrigger: number;
  959. /**
  960. * On key down
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnKeyDownTrigger: number;
  964. /**
  965. * On key up
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyUpTrigger: number;
  969. /**
  970. * Billboard mode will only apply to Y axis
  971. */
  972. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  973. /**
  974. * Billboard mode will apply to all axes
  975. */
  976. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  977. /**
  978. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  981. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  982. * Test order :
  983. * Is the bounding sphere outside the frustum ?
  984. * If not, are the bounding box vertices outside the frustum ?
  985. * It not, then the cullable object is in the frustum.
  986. */
  987. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  988. /** Culling strategy : Bounding Sphere Only.
  989. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  990. * It's also less accurate than the standard because some not visible objects can still be selected.
  991. * Test : is the bounding sphere outside the frustum ?
  992. * If not, then the cullable object is in the frustum.
  993. */
  994. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  995. /** Culling strategy : Optimistic Inclusion.
  996. * This in an inclusion test first, then the standard exclusion test.
  997. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  998. * 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.
  999. * Anyway, it's as accurate as the standard strategy.
  1000. * Test :
  1001. * Is the cullable object bounding sphere center in the frustum ?
  1002. * If not, apply the default culling strategy.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1005. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1006. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1007. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1015. /**
  1016. * No logging while loading
  1017. */
  1018. static readonly SCENELOADER_NO_LOGGING: number;
  1019. /**
  1020. * Minimal logging while loading
  1021. */
  1022. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1023. /**
  1024. * Summary logging while loading
  1025. */
  1026. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1027. /**
  1028. * Detailled logging while loading
  1029. */
  1030. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1031. }
  1032. }
  1033. declare module BABYLON {
  1034. /**
  1035. * This represents the required contract to create a new type of texture loader.
  1036. */
  1037. export interface IInternalTextureLoader {
  1038. /**
  1039. * Defines wether the loader supports cascade loading the different faces.
  1040. */
  1041. supportCascades: boolean;
  1042. /**
  1043. * This returns if the loader support the current file information.
  1044. * @param extension defines the file extension of the file being loaded
  1045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1046. * @param fallback defines the fallback internal texture if any
  1047. * @param isBase64 defines whether the texture is encoded as a base64
  1048. * @param isBuffer defines whether the texture data are stored as a buffer
  1049. * @returns true if the loader can load the specified file
  1050. */
  1051. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1052. /**
  1053. * Transform the url before loading if required.
  1054. * @param rootUrl the url of the texture
  1055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1056. * @returns the transformed texture
  1057. */
  1058. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1059. /**
  1060. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1061. * @param rootUrl the url of the texture
  1062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1063. * @returns the fallback texture
  1064. */
  1065. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1066. /**
  1067. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1068. * @param data contains the texture data
  1069. * @param texture defines the BabylonJS internal texture
  1070. * @param createPolynomials will be true if polynomials have been requested
  1071. * @param onLoad defines the callback to trigger once the texture is ready
  1072. * @param onError defines the callback to trigger in case of error
  1073. */
  1074. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1075. /**
  1076. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1077. * @param data contains the texture data
  1078. * @param texture defines the BabylonJS internal texture
  1079. * @param callback defines the method to call once ready to upload
  1080. */
  1081. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1082. }
  1083. }
  1084. declare module BABYLON {
  1085. /**
  1086. * Class used to store and describe the pipeline context associated with an effect
  1087. */
  1088. export interface IPipelineContext {
  1089. /**
  1090. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1091. */
  1092. isAsync: boolean;
  1093. /**
  1094. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1095. */
  1096. isReady: boolean;
  1097. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. readonly underlyingResource: any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. readonly currentLine: string;
  1173. readonly canRead: boolean;
  1174. lines: string[];
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderCodeTestNode extends ShaderCodeNode {
  1196. testExpression: ShaderDefineExpression;
  1197. isValid(preprocessors: {
  1198. [key: string]: string;
  1199. }): boolean;
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1205. define: string;
  1206. not: boolean;
  1207. constructor(define: string, not?: boolean);
  1208. isTrue(preprocessors: {
  1209. [key: string]: string;
  1210. }): boolean;
  1211. }
  1212. }
  1213. declare module BABYLON {
  1214. /** @hidden */
  1215. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1216. leftOperand: ShaderDefineExpression;
  1217. rightOperand: ShaderDefineExpression;
  1218. isTrue(preprocessors: {
  1219. [key: string]: string;
  1220. }): boolean;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1226. leftOperand: ShaderDefineExpression;
  1227. rightOperand: ShaderDefineExpression;
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1236. define: string;
  1237. operand: string;
  1238. testValue: string;
  1239. constructor(define: string, operand: string, testValue: string);
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /**
  1247. * Class used to enable access to offline support
  1248. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1249. */
  1250. export interface IOfflineProvider {
  1251. /**
  1252. * Gets a boolean indicating if scene must be saved in the database
  1253. */
  1254. enableSceneOffline: boolean;
  1255. /**
  1256. * Gets a boolean indicating if textures must be saved in the database
  1257. */
  1258. enableTexturesOffline: boolean;
  1259. /**
  1260. * Open the offline support and make it available
  1261. * @param successCallback defines the callback to call on success
  1262. * @param errorCallback defines the callback to call on error
  1263. */
  1264. open(successCallback: () => void, errorCallback: () => void): void;
  1265. /**
  1266. * Loads an image from the offline support
  1267. * @param url defines the url to load from
  1268. * @param image defines the target DOM image
  1269. */
  1270. loadImage(url: string, image: HTMLImageElement): void;
  1271. /**
  1272. * Loads a file from offline support
  1273. * @param url defines the URL to load from
  1274. * @param sceneLoaded defines a callback to call on success
  1275. * @param progressCallBack defines a callback to call when progress changed
  1276. * @param errorCallback defines a callback to call on error
  1277. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1278. */
  1279. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1280. }
  1281. }
  1282. declare module BABYLON {
  1283. /**
  1284. * Class used to help managing file picking and drag'n'drop
  1285. * File Storage
  1286. */
  1287. export class FilesInputStore {
  1288. /**
  1289. * List of files ready to be loaded
  1290. */
  1291. static FilesToLoad: {
  1292. [key: string]: File;
  1293. };
  1294. }
  1295. }
  1296. declare module BABYLON {
  1297. /**
  1298. * Class used to define a retry strategy when error happens while loading assets
  1299. */
  1300. export class RetryStrategy {
  1301. /**
  1302. * Function used to defines an exponential back off strategy
  1303. * @param maxRetries defines the maximum number of retries (3 by default)
  1304. * @param baseInterval defines the interval between retries
  1305. * @returns the strategy function to use
  1306. */
  1307. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1308. }
  1309. }
  1310. declare module BABYLON {
  1311. /**
  1312. * @ignore
  1313. * Application error to support additional information when loading a file
  1314. */
  1315. export abstract class BaseError extends Error {
  1316. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1317. }
  1318. }
  1319. declare module BABYLON {
  1320. /** @ignore */
  1321. export class LoadFileError extends BaseError {
  1322. request?: WebRequest;
  1323. file?: File;
  1324. /**
  1325. * Creates a new LoadFileError
  1326. * @param message defines the message of the error
  1327. * @param request defines the optional web request
  1328. * @param file defines the optional file
  1329. */
  1330. constructor(message: string, object?: WebRequest | File);
  1331. }
  1332. /** @ignore */
  1333. export class RequestFileError extends BaseError {
  1334. request: WebRequest;
  1335. /**
  1336. * Creates a new LoadFileError
  1337. * @param message defines the message of the error
  1338. * @param request defines the optional web request
  1339. */
  1340. constructor(message: string, request: WebRequest);
  1341. }
  1342. /** @ignore */
  1343. export class ReadFileError extends BaseError {
  1344. file: File;
  1345. /**
  1346. * Creates a new ReadFileError
  1347. * @param message defines the message of the error
  1348. * @param file defines the optional file
  1349. */
  1350. constructor(message: string, file: File);
  1351. }
  1352. /**
  1353. * @hidden
  1354. */
  1355. export class FileTools {
  1356. /**
  1357. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1358. */
  1359. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1360. /**
  1361. * Gets or sets the base URL to use to load assets
  1362. */
  1363. static BaseUrl: string;
  1364. /**
  1365. * Default behaviour for cors in the application.
  1366. * It can be a string if the expected behavior is identical in the entire app.
  1367. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1368. */
  1369. static CorsBehavior: string | ((url: string | string[]) => string);
  1370. /**
  1371. * Gets or sets a function used to pre-process url before using them to load assets
  1372. */
  1373. static PreprocessUrl: (url: string) => string;
  1374. /**
  1375. * Removes unwanted characters from an url
  1376. * @param url defines the url to clean
  1377. * @returns the cleaned url
  1378. */
  1379. private static _CleanUrl;
  1380. /**
  1381. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1382. * @param url define the url we are trying
  1383. * @param element define the dom element where to configure the cors policy
  1384. */
  1385. static SetCorsBehavior(url: string | string[], element: {
  1386. crossOrigin: string | null;
  1387. }): void;
  1388. /**
  1389. * Loads an image as an HTMLImageElement.
  1390. * @param input url string, ArrayBuffer, or Blob to load
  1391. * @param onLoad callback called when the image successfully loads
  1392. * @param onError callback called when the image fails to load
  1393. * @param offlineProvider offline provider for caching
  1394. * @param mimeType optional mime type
  1395. * @returns the HTMLImageElement of the loaded image
  1396. */
  1397. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1398. /**
  1399. * Reads a file from a File object
  1400. * @param file defines the file to load
  1401. * @param onSuccess defines the callback to call when data is loaded
  1402. * @param onProgress defines the callback to call during loading process
  1403. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1404. * @param onError defines the callback to call when an error occurs
  1405. * @returns a file request object
  1406. */
  1407. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1408. /**
  1409. * Loads a file from a url
  1410. * @param url url to load
  1411. * @param onSuccess callback called when the file successfully loads
  1412. * @param onProgress callback called while file is loading (if the server supports this mode)
  1413. * @param offlineProvider defines the offline provider for caching
  1414. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1415. * @param onError callback called when the file fails to load
  1416. * @returns a file request object
  1417. */
  1418. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1419. /**
  1420. * Loads a file
  1421. * @param url url to load
  1422. * @param onSuccess callback called when the file successfully loads
  1423. * @param onProgress callback called while file is loading (if the server supports this mode)
  1424. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1425. * @param onError callback called when the file fails to load
  1426. * @param onOpened callback called when the web request is opened
  1427. * @returns a file request object
  1428. */
  1429. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1430. /**
  1431. * Checks if the loaded document was accessed via `file:`-Protocol.
  1432. * @returns boolean
  1433. */
  1434. static IsFileURL(): boolean;
  1435. }
  1436. }
  1437. declare module BABYLON {
  1438. /** @hidden */
  1439. export class ShaderProcessor {
  1440. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1441. private static _ProcessPrecision;
  1442. private static _ExtractOperation;
  1443. private static _BuildSubExpression;
  1444. private static _BuildExpression;
  1445. private static _MoveCursorWithinIf;
  1446. private static _MoveCursor;
  1447. private static _EvaluatePreProcessors;
  1448. private static _PreparePreProcessors;
  1449. private static _ProcessShaderConversion;
  1450. private static _ProcessIncludes;
  1451. }
  1452. }
  1453. declare module BABYLON {
  1454. /**
  1455. * @hidden
  1456. */
  1457. export interface IColor4Like {
  1458. r: float;
  1459. g: float;
  1460. b: float;
  1461. a: float;
  1462. }
  1463. /**
  1464. * @hidden
  1465. */
  1466. export interface IColor3Like {
  1467. r: float;
  1468. g: float;
  1469. b: float;
  1470. }
  1471. /**
  1472. * @hidden
  1473. */
  1474. export interface IVector4Like {
  1475. x: float;
  1476. y: float;
  1477. z: float;
  1478. w: float;
  1479. }
  1480. /**
  1481. * @hidden
  1482. */
  1483. export interface IVector3Like {
  1484. x: float;
  1485. y: float;
  1486. z: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IVector2Like {
  1492. x: float;
  1493. y: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IMatrixLike {
  1499. toArray(): DeepImmutable<Float32Array>;
  1500. updateFlag: int;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IViewportLike {
  1506. x: float;
  1507. y: float;
  1508. width: float;
  1509. height: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IPlaneLike {
  1515. normal: IVector3Like;
  1516. d: float;
  1517. normalize(): void;
  1518. }
  1519. }
  1520. declare module BABYLON {
  1521. /**
  1522. * Interface used to define common properties for effect fallbacks
  1523. */
  1524. export interface IEffectFallbacks {
  1525. /**
  1526. * Removes the defines that should be removed when falling back.
  1527. * @param currentDefines defines the current define statements for the shader.
  1528. * @param effect defines the current effect we try to compile
  1529. * @returns The resulting defines with defines of the current rank removed.
  1530. */
  1531. reduce(currentDefines: string, effect: Effect): string;
  1532. /**
  1533. * Removes the fallback from the bound mesh.
  1534. */
  1535. unBindMesh(): void;
  1536. /**
  1537. * Checks to see if more fallbacks are still availible.
  1538. */
  1539. hasMoreFallbacks: boolean;
  1540. }
  1541. }
  1542. declare module BABYLON {
  1543. /**
  1544. * Class used to evalaute queries containing `and` and `or` operators
  1545. */
  1546. export class AndOrNotEvaluator {
  1547. /**
  1548. * Evaluate a query
  1549. * @param query defines the query to evaluate
  1550. * @param evaluateCallback defines the callback used to filter result
  1551. * @returns true if the query matches
  1552. */
  1553. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1554. private static _HandleParenthesisContent;
  1555. private static _SimplifyNegation;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to store custom tags
  1561. */
  1562. export class Tags {
  1563. /**
  1564. * Adds support for tags on the given object
  1565. * @param obj defines the object to use
  1566. */
  1567. static EnableFor(obj: any): void;
  1568. /**
  1569. * Removes tags support
  1570. * @param obj defines the object to use
  1571. */
  1572. static DisableFor(obj: any): void;
  1573. /**
  1574. * Gets a boolean indicating if the given object has tags
  1575. * @param obj defines the object to use
  1576. * @returns a boolean
  1577. */
  1578. static HasTags(obj: any): boolean;
  1579. /**
  1580. * Gets the tags available on a given object
  1581. * @param obj defines the object to use
  1582. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1583. * @returns the tags
  1584. */
  1585. static GetTags(obj: any, asString?: boolean): any;
  1586. /**
  1587. * Adds tags to an object
  1588. * @param obj defines the object to use
  1589. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1590. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1591. */
  1592. static AddTagsTo(obj: any, tagsString: string): void;
  1593. /**
  1594. * @hidden
  1595. */ private static _AddTagTo(obj: any, tag: string): void;
  1596. /**
  1597. * Removes specific tags from a specific object
  1598. * @param obj defines the object to use
  1599. * @param tagsString defines the tags to remove
  1600. */
  1601. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1602. /**
  1603. * @hidden
  1604. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  1605. /**
  1606. * Defines if tags hosted on an object match a given query
  1607. * @param obj defines the object to use
  1608. * @param tagsQuery defines the tag query
  1609. * @returns a boolean
  1610. */
  1611. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Scalar computation library
  1617. */
  1618. export class Scalar {
  1619. /**
  1620. * Two pi constants convenient for computation.
  1621. */
  1622. static TwoPi: number;
  1623. /**
  1624. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1625. * @param a number
  1626. * @param b number
  1627. * @param epsilon (default = 1.401298E-45)
  1628. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1629. */
  1630. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1631. /**
  1632. * Returns a string : the upper case translation of the number i to hexadecimal.
  1633. * @param i number
  1634. * @returns the upper case translation of the number i to hexadecimal.
  1635. */
  1636. static ToHex(i: number): string;
  1637. /**
  1638. * Returns -1 if value is negative and +1 is value is positive.
  1639. * @param value the value
  1640. * @returns the value itself if it's equal to zero.
  1641. */
  1642. static Sign(value: number): number;
  1643. /**
  1644. * Returns the value itself if it's between min and max.
  1645. * Returns min if the value is lower than min.
  1646. * Returns max if the value is greater than max.
  1647. * @param value the value to clmap
  1648. * @param min the min value to clamp to (default: 0)
  1649. * @param max the max value to clamp to (default: 1)
  1650. * @returns the clamped value
  1651. */
  1652. static Clamp(value: number, min?: number, max?: number): number;
  1653. /**
  1654. * the log2 of value.
  1655. * @param value the value to compute log2 of
  1656. * @returns the log2 of value.
  1657. */
  1658. static Log2(value: number): number;
  1659. /**
  1660. * Loops the value, so that it is never larger than length and never smaller than 0.
  1661. *
  1662. * This is similar to the modulo operator but it works with floating point numbers.
  1663. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1664. * With t = 5 and length = 2.5, the result would be 0.0.
  1665. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1666. * @param value the value
  1667. * @param length the length
  1668. * @returns the looped value
  1669. */
  1670. static Repeat(value: number, length: number): number;
  1671. /**
  1672. * Normalize the value between 0.0 and 1.0 using min and max values
  1673. * @param value value to normalize
  1674. * @param min max to normalize between
  1675. * @param max min to normalize between
  1676. * @returns the normalized value
  1677. */
  1678. static Normalize(value: number, min: number, max: number): number;
  1679. /**
  1680. * Denormalize the value from 0.0 and 1.0 using min and max values
  1681. * @param normalized value to denormalize
  1682. * @param min max to denormalize between
  1683. * @param max min to denormalize between
  1684. * @returns the denormalized value
  1685. */
  1686. static Denormalize(normalized: number, min: number, max: number): number;
  1687. /**
  1688. * Calculates the shortest difference between two given angles given in degrees.
  1689. * @param current current angle in degrees
  1690. * @param target target angle in degrees
  1691. * @returns the delta
  1692. */
  1693. static DeltaAngle(current: number, target: number): number;
  1694. /**
  1695. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1696. * @param tx value
  1697. * @param length length
  1698. * @returns The returned value will move back and forth between 0 and length
  1699. */
  1700. static PingPong(tx: number, length: number): number;
  1701. /**
  1702. * Interpolates between min and max with smoothing at the limits.
  1703. *
  1704. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1705. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1706. * @param from from
  1707. * @param to to
  1708. * @param tx value
  1709. * @returns the smooth stepped value
  1710. */
  1711. static SmoothStep(from: number, to: number, tx: number): number;
  1712. /**
  1713. * Moves a value current towards target.
  1714. *
  1715. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1716. * Negative values of maxDelta pushes the value away from target.
  1717. * @param current current value
  1718. * @param target target value
  1719. * @param maxDelta max distance to move
  1720. * @returns resulting value
  1721. */
  1722. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1723. /**
  1724. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1725. *
  1726. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1727. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1728. * @param current current value
  1729. * @param target target value
  1730. * @param maxDelta max distance to move
  1731. * @returns resulting angle
  1732. */
  1733. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1734. /**
  1735. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1736. * @param start start value
  1737. * @param end target value
  1738. * @param amount amount to lerp between
  1739. * @returns the lerped value
  1740. */
  1741. static Lerp(start: number, end: number, amount: number): number;
  1742. /**
  1743. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1744. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1745. * @param start start value
  1746. * @param end target value
  1747. * @param amount amount to lerp between
  1748. * @returns the lerped value
  1749. */
  1750. static LerpAngle(start: number, end: number, amount: number): number;
  1751. /**
  1752. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1753. * @param a start value
  1754. * @param b target value
  1755. * @param value value between a and b
  1756. * @returns the inverseLerp value
  1757. */
  1758. static InverseLerp(a: number, b: number, value: number): number;
  1759. /**
  1760. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1761. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1762. * @param value1 spline value
  1763. * @param tangent1 spline value
  1764. * @param value2 spline value
  1765. * @param tangent2 spline value
  1766. * @param amount input value
  1767. * @returns hermite result
  1768. */
  1769. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1770. /**
  1771. * Returns a random float number between and min and max values
  1772. * @param min min value of random
  1773. * @param max max value of random
  1774. * @returns random value
  1775. */
  1776. static RandomRange(min: number, max: number): number;
  1777. /**
  1778. * This function returns percentage of a number in a given range.
  1779. *
  1780. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1781. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1782. * @param number to convert to percentage
  1783. * @param min min range
  1784. * @param max max range
  1785. * @returns the percentage
  1786. */
  1787. static RangeToPercent(number: number, min: number, max: number): number;
  1788. /**
  1789. * This function returns number that corresponds to the percentage in a given range.
  1790. *
  1791. * PercentToRange(0.34,0,100) will return 34.
  1792. * @param percent to convert to number
  1793. * @param min min range
  1794. * @param max max range
  1795. * @returns the number
  1796. */
  1797. static PercentToRange(percent: number, min: number, max: number): number;
  1798. /**
  1799. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1800. * @param angle The angle to normalize in radian.
  1801. * @return The converted angle.
  1802. */
  1803. static NormalizeRadians(angle: number): number;
  1804. }
  1805. }
  1806. declare module BABYLON {
  1807. /**
  1808. * Constant used to convert a value to gamma space
  1809. * @ignorenaming
  1810. */
  1811. export const ToGammaSpace: number;
  1812. /**
  1813. * Constant used to convert a value to linear space
  1814. * @ignorenaming
  1815. */
  1816. export const ToLinearSpace = 2.2;
  1817. /**
  1818. * Constant used to define the minimal number value in Babylon.js
  1819. * @ignorenaming
  1820. */
  1821. let Epsilon: number;
  1822. }
  1823. declare module BABYLON {
  1824. /**
  1825. * Class used to represent a viewport on screen
  1826. */
  1827. export class Viewport {
  1828. /** viewport left coordinate */
  1829. x: number;
  1830. /** viewport top coordinate */
  1831. y: number;
  1832. /**viewport width */
  1833. width: number;
  1834. /** viewport height */
  1835. height: number;
  1836. /**
  1837. * Creates a Viewport object located at (x, y) and sized (width, height)
  1838. * @param x defines viewport left coordinate
  1839. * @param y defines viewport top coordinate
  1840. * @param width defines the viewport width
  1841. * @param height defines the viewport height
  1842. */
  1843. constructor(
  1844. /** viewport left coordinate */
  1845. x: number,
  1846. /** viewport top coordinate */
  1847. y: number,
  1848. /**viewport width */
  1849. width: number,
  1850. /** viewport height */
  1851. height: number);
  1852. /**
  1853. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1854. * @param renderWidth defines the rendering width
  1855. * @param renderHeight defines the rendering height
  1856. * @returns a new Viewport
  1857. */
  1858. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1859. /**
  1860. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1861. * @param renderWidth defines the rendering width
  1862. * @param renderHeight defines the rendering height
  1863. * @param ref defines the target viewport
  1864. * @returns the current viewport
  1865. */
  1866. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1867. /**
  1868. * Returns a new Viewport copied from the current one
  1869. * @returns a new Viewport
  1870. */
  1871. clone(): Viewport;
  1872. }
  1873. }
  1874. declare module BABYLON {
  1875. /**
  1876. * Class containing a set of static utilities functions for arrays.
  1877. */
  1878. export class ArrayTools {
  1879. /**
  1880. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1881. * @param size the number of element to construct and put in the array
  1882. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1883. * @returns a new array filled with new objects
  1884. */
  1885. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1886. }
  1887. }
  1888. declare module BABYLON {
  1889. /**
  1890. * Class representing a vector containing 2 coordinates
  1891. */
  1892. export class Vector2 {
  1893. /** defines the first coordinate */
  1894. x: number;
  1895. /** defines the second coordinate */
  1896. y: number;
  1897. /**
  1898. * Creates a new Vector2 from the given x and y coordinates
  1899. * @param x defines the first coordinate
  1900. * @param y defines the second coordinate
  1901. */
  1902. constructor(
  1903. /** defines the first coordinate */
  1904. x?: number,
  1905. /** defines the second coordinate */
  1906. y?: number);
  1907. /**
  1908. * Gets a string with the Vector2 coordinates
  1909. * @returns a string with the Vector2 coordinates
  1910. */
  1911. toString(): string;
  1912. /**
  1913. * Gets class name
  1914. * @returns the string "Vector2"
  1915. */
  1916. getClassName(): string;
  1917. /**
  1918. * Gets current vector hash code
  1919. * @returns the Vector2 hash code as a number
  1920. */
  1921. getHashCode(): number;
  1922. /**
  1923. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1924. * @param array defines the source array
  1925. * @param index defines the offset in source array
  1926. * @returns the current Vector2
  1927. */
  1928. toArray(array: FloatArray, index?: number): Vector2;
  1929. /**
  1930. * Copy the current vector to an array
  1931. * @returns a new array with 2 elements: the Vector2 coordinates.
  1932. */
  1933. asArray(): number[];
  1934. /**
  1935. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1936. * @param source defines the source Vector2
  1937. * @returns the current updated Vector2
  1938. */
  1939. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1940. /**
  1941. * Sets the Vector2 coordinates with the given floats
  1942. * @param x defines the first coordinate
  1943. * @param y defines the second coordinate
  1944. * @returns the current updated Vector2
  1945. */
  1946. copyFromFloats(x: number, y: number): Vector2;
  1947. /**
  1948. * Sets the Vector2 coordinates with the given floats
  1949. * @param x defines the first coordinate
  1950. * @param y defines the second coordinate
  1951. * @returns the current updated Vector2
  1952. */
  1953. set(x: number, y: number): Vector2;
  1954. /**
  1955. * Add another vector with the current one
  1956. * @param otherVector defines the other vector
  1957. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1958. */
  1959. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1960. /**
  1961. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1962. * @param otherVector defines the other vector
  1963. * @param result defines the target vector
  1964. * @returns the unmodified current Vector2
  1965. */
  1966. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1967. /**
  1968. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1969. * @param otherVector defines the other vector
  1970. * @returns the current updated Vector2
  1971. */
  1972. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1973. /**
  1974. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1975. * @param otherVector defines the other vector
  1976. * @returns a new Vector2
  1977. */
  1978. addVector3(otherVector: Vector3): Vector2;
  1979. /**
  1980. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1981. * @param otherVector defines the other vector
  1982. * @returns a new Vector2
  1983. */
  1984. subtract(otherVector: Vector2): Vector2;
  1985. /**
  1986. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1987. * @param otherVector defines the other vector
  1988. * @param result defines the target vector
  1989. * @returns the unmodified current Vector2
  1990. */
  1991. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1992. /**
  1993. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1994. * @param otherVector defines the other vector
  1995. * @returns the current updated Vector2
  1996. */
  1997. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Multiplies in place the current Vector2 coordinates by the given ones
  2000. * @param otherVector defines the other vector
  2001. * @returns the current updated Vector2
  2002. */
  2003. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2004. /**
  2005. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2006. * @param otherVector defines the other vector
  2007. * @returns a new Vector2
  2008. */
  2009. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2010. /**
  2011. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2012. * @param otherVector defines the other vector
  2013. * @param result defines the target vector
  2014. * @returns the unmodified current Vector2
  2015. */
  2016. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2019. * @param x defines the first coordinate
  2020. * @param y defines the second coordinate
  2021. * @returns a new Vector2
  2022. */
  2023. multiplyByFloats(x: number, y: number): Vector2;
  2024. /**
  2025. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2026. * @param otherVector defines the other vector
  2027. * @returns a new Vector2
  2028. */
  2029. divide(otherVector: Vector2): Vector2;
  2030. /**
  2031. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @param result defines the target vector
  2034. * @returns the unmodified current Vector2
  2035. */
  2036. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2037. /**
  2038. * Divides the current Vector2 coordinates by the given ones
  2039. * @param otherVector defines the other vector
  2040. * @returns the current updated Vector2
  2041. */
  2042. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2043. /**
  2044. * Gets a new Vector2 with current Vector2 negated coordinates
  2045. * @returns a new Vector2
  2046. */
  2047. negate(): Vector2;
  2048. /**
  2049. * Multiply the Vector2 coordinates by scale
  2050. * @param scale defines the scaling factor
  2051. * @returns the current updated Vector2
  2052. */
  2053. scaleInPlace(scale: number): Vector2;
  2054. /**
  2055. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2056. * @param scale defines the scaling factor
  2057. * @returns a new Vector2
  2058. */
  2059. scale(scale: number): Vector2;
  2060. /**
  2061. * Scale the current Vector2 values by a factor to a given Vector2
  2062. * @param scale defines the scale factor
  2063. * @param result defines the Vector2 object where to store the result
  2064. * @returns the unmodified current Vector2
  2065. */
  2066. scaleToRef(scale: number, result: Vector2): Vector2;
  2067. /**
  2068. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2069. * @param scale defines the scale factor
  2070. * @param result defines the Vector2 object where to store the result
  2071. * @returns the unmodified current Vector2
  2072. */
  2073. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2074. /**
  2075. * Gets a boolean if two vectors are equals
  2076. * @param otherVector defines the other vector
  2077. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2078. */
  2079. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2080. /**
  2081. * Gets a boolean if two vectors are equals (using an epsilon value)
  2082. * @param otherVector defines the other vector
  2083. * @param epsilon defines the minimal distance to consider equality
  2084. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2085. */
  2086. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2087. /**
  2088. * Gets a new Vector2 from current Vector2 floored values
  2089. * @returns a new Vector2
  2090. */
  2091. floor(): Vector2;
  2092. /**
  2093. * Gets a new Vector2 from current Vector2 floored values
  2094. * @returns a new Vector2
  2095. */
  2096. fract(): Vector2;
  2097. /**
  2098. * Gets the length of the vector
  2099. * @returns the vector length (float)
  2100. */
  2101. length(): number;
  2102. /**
  2103. * Gets the vector squared length
  2104. * @returns the vector squared length (float)
  2105. */
  2106. lengthSquared(): number;
  2107. /**
  2108. * Normalize the vector
  2109. * @returns the current updated Vector2
  2110. */
  2111. normalize(): Vector2;
  2112. /**
  2113. * Gets a new Vector2 copied from the Vector2
  2114. * @returns a new Vector2
  2115. */
  2116. clone(): Vector2;
  2117. /**
  2118. * Gets a new Vector2(0, 0)
  2119. * @returns a new Vector2
  2120. */
  2121. static Zero(): Vector2;
  2122. /**
  2123. * Gets a new Vector2(1, 1)
  2124. * @returns a new Vector2
  2125. */
  2126. static One(): Vector2;
  2127. /**
  2128. * Gets a new Vector2 set from the given index element of the given array
  2129. * @param array defines the data source
  2130. * @param offset defines the offset in the data source
  2131. * @returns a new Vector2
  2132. */
  2133. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2134. /**
  2135. * Sets "result" from the given index element of the given array
  2136. * @param array defines the data source
  2137. * @param offset defines the offset in the data source
  2138. * @param result defines the target vector
  2139. */
  2140. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2141. /**
  2142. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2143. * @param value1 defines 1st point of control
  2144. * @param value2 defines 2nd point of control
  2145. * @param value3 defines 3rd point of control
  2146. * @param value4 defines 4th point of control
  2147. * @param amount defines the interpolation factor
  2148. * @returns a new Vector2
  2149. */
  2150. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2151. /**
  2152. * 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".
  2153. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2154. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2155. * @param value defines the value to clamp
  2156. * @param min defines the lower limit
  2157. * @param max defines the upper limit
  2158. * @returns a new Vector2
  2159. */
  2160. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2161. /**
  2162. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2163. * @param value1 defines the 1st control point
  2164. * @param tangent1 defines the outgoing tangent
  2165. * @param value2 defines the 2nd control point
  2166. * @param tangent2 defines the incoming tangent
  2167. * @param amount defines the interpolation factor
  2168. * @returns a new Vector2
  2169. */
  2170. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2171. /**
  2172. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2173. * @param start defines the start vector
  2174. * @param end defines the end vector
  2175. * @param amount defines the interpolation factor
  2176. * @returns a new Vector2
  2177. */
  2178. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2179. /**
  2180. * Gets the dot product of the vector "left" and the vector "right"
  2181. * @param left defines first vector
  2182. * @param right defines second vector
  2183. * @returns the dot product (float)
  2184. */
  2185. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2186. /**
  2187. * Returns a new Vector2 equal to the normalized given vector
  2188. * @param vector defines the vector to normalize
  2189. * @returns a new Vector2
  2190. */
  2191. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2192. /**
  2193. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2194. * @param left defines 1st vector
  2195. * @param right defines 2nd vector
  2196. * @returns a new Vector2
  2197. */
  2198. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2201. * @param left defines 1st vector
  2202. * @param right defines 2nd vector
  2203. * @returns a new Vector2
  2204. */
  2205. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2208. * @param vector defines the vector to transform
  2209. * @param transformation defines the matrix to apply
  2210. * @returns a new Vector2
  2211. */
  2212. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2213. /**
  2214. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2215. * @param vector defines the vector to transform
  2216. * @param transformation defines the matrix to apply
  2217. * @param result defines the target vector
  2218. */
  2219. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2220. /**
  2221. * Determines if a given vector is included in a triangle
  2222. * @param p defines the vector to test
  2223. * @param p0 defines 1st triangle point
  2224. * @param p1 defines 2nd triangle point
  2225. * @param p2 defines 3rd triangle point
  2226. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2227. */
  2228. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2229. /**
  2230. * Gets the distance between the vectors "value1" and "value2"
  2231. * @param value1 defines first vector
  2232. * @param value2 defines second vector
  2233. * @returns the distance between vectors
  2234. */
  2235. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2236. /**
  2237. * Returns the squared distance between the vectors "value1" and "value2"
  2238. * @param value1 defines first vector
  2239. * @param value2 defines second vector
  2240. * @returns the squared distance between vectors
  2241. */
  2242. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2243. /**
  2244. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2245. * @param value1 defines first vector
  2246. * @param value2 defines second vector
  2247. * @returns a new Vector2
  2248. */
  2249. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2250. /**
  2251. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2252. * @param p defines the middle point
  2253. * @param segA defines one point of the segment
  2254. * @param segB defines the other point of the segment
  2255. * @returns the shortest distance
  2256. */
  2257. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2258. }
  2259. /**
  2260. * Classed used to store (x,y,z) vector representation
  2261. * A Vector3 is the main object used in 3D geometry
  2262. * It can represent etiher the coordinates of a point the space, either a direction
  2263. * Reminder: js uses a left handed forward facing system
  2264. */
  2265. export class Vector3 {
  2266. /**
  2267. * Defines the first coordinates (on X axis)
  2268. */
  2269. x: number;
  2270. /**
  2271. * Defines the second coordinates (on Y axis)
  2272. */
  2273. y: number;
  2274. /**
  2275. * Defines the third coordinates (on Z axis)
  2276. */
  2277. z: number;
  2278. private static _UpReadOnly;
  2279. private static _ZeroReadOnly;
  2280. /**
  2281. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2282. * @param x defines the first coordinates (on X axis)
  2283. * @param y defines the second coordinates (on Y axis)
  2284. * @param z defines the third coordinates (on Z axis)
  2285. */
  2286. constructor(
  2287. /**
  2288. * Defines the first coordinates (on X axis)
  2289. */
  2290. x?: number,
  2291. /**
  2292. * Defines the second coordinates (on Y axis)
  2293. */
  2294. y?: number,
  2295. /**
  2296. * Defines the third coordinates (on Z axis)
  2297. */
  2298. z?: number);
  2299. /**
  2300. * Creates a string representation of the Vector3
  2301. * @returns a string with the Vector3 coordinates.
  2302. */
  2303. toString(): string;
  2304. /**
  2305. * Gets the class name
  2306. * @returns the string "Vector3"
  2307. */
  2308. getClassName(): string;
  2309. /**
  2310. * Creates the Vector3 hash code
  2311. * @returns a number which tends to be unique between Vector3 instances
  2312. */
  2313. getHashCode(): number;
  2314. /**
  2315. * Creates an array containing three elements : the coordinates of the Vector3
  2316. * @returns a new array of numbers
  2317. */
  2318. asArray(): number[];
  2319. /**
  2320. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2321. * @param array defines the destination array
  2322. * @param index defines the offset in the destination array
  2323. * @returns the current Vector3
  2324. */
  2325. toArray(array: FloatArray, index?: number): Vector3;
  2326. /**
  2327. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2328. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2329. */
  2330. toQuaternion(): Quaternion;
  2331. /**
  2332. * Adds the given vector to the current Vector3
  2333. * @param otherVector defines the second operand
  2334. * @returns the current updated Vector3
  2335. */
  2336. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2337. /**
  2338. * Adds the given coordinates to the current Vector3
  2339. * @param x defines the x coordinate of the operand
  2340. * @param y defines the y coordinate of the operand
  2341. * @param z defines the z coordinate of the operand
  2342. * @returns the current updated Vector3
  2343. */
  2344. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2345. /**
  2346. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2347. * @param otherVector defines the second operand
  2348. * @returns the resulting Vector3
  2349. */
  2350. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2351. /**
  2352. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2353. * @param otherVector defines the second operand
  2354. * @param result defines the Vector3 object where to store the result
  2355. * @returns the current Vector3
  2356. */
  2357. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2358. /**
  2359. * Subtract the given vector from the current Vector3
  2360. * @param otherVector defines the second operand
  2361. * @returns the current updated Vector3
  2362. */
  2363. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2366. * @param otherVector defines the second operand
  2367. * @returns the resulting Vector3
  2368. */
  2369. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2370. /**
  2371. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2372. * @param otherVector defines the second operand
  2373. * @param result defines the Vector3 object where to store the result
  2374. * @returns the current Vector3
  2375. */
  2376. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2377. /**
  2378. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2379. * @param x defines the x coordinate of the operand
  2380. * @param y defines the y coordinate of the operand
  2381. * @param z defines the z coordinate of the operand
  2382. * @returns the resulting Vector3
  2383. */
  2384. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2385. /**
  2386. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2387. * @param x defines the x coordinate of the operand
  2388. * @param y defines the y coordinate of the operand
  2389. * @param z defines the z coordinate of the operand
  2390. * @param result defines the Vector3 object where to store the result
  2391. * @returns the current Vector3
  2392. */
  2393. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2394. /**
  2395. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2396. * @returns a new Vector3
  2397. */
  2398. negate(): Vector3;
  2399. /**
  2400. * Multiplies the Vector3 coordinates by the float "scale"
  2401. * @param scale defines the multiplier factor
  2402. * @returns the current updated Vector3
  2403. */
  2404. scaleInPlace(scale: number): Vector3;
  2405. /**
  2406. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2407. * @param scale defines the multiplier factor
  2408. * @returns a new Vector3
  2409. */
  2410. scale(scale: number): Vector3;
  2411. /**
  2412. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2413. * @param scale defines the multiplier factor
  2414. * @param result defines the Vector3 object where to store the result
  2415. * @returns the current Vector3
  2416. */
  2417. scaleToRef(scale: number, result: Vector3): Vector3;
  2418. /**
  2419. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2420. * @param scale defines the scale factor
  2421. * @param result defines the Vector3 object where to store the result
  2422. * @returns the unmodified current Vector3
  2423. */
  2424. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2425. /**
  2426. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2427. * @param otherVector defines the second operand
  2428. * @returns true if both vectors are equals
  2429. */
  2430. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2431. /**
  2432. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2433. * @param otherVector defines the second operand
  2434. * @param epsilon defines the minimal distance to define values as equals
  2435. * @returns true if both vectors are distant less than epsilon
  2436. */
  2437. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2438. /**
  2439. * Returns true if the current Vector3 coordinates equals the given floats
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @returns true if both vectors are equals
  2444. */
  2445. equalsToFloats(x: number, y: number, z: number): boolean;
  2446. /**
  2447. * Multiplies the current Vector3 coordinates by the given ones
  2448. * @param otherVector defines the second operand
  2449. * @returns the current updated Vector3
  2450. */
  2451. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2452. /**
  2453. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2454. * @param otherVector defines the second operand
  2455. * @returns the new Vector3
  2456. */
  2457. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2458. /**
  2459. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2460. * @param otherVector defines the second operand
  2461. * @param result defines the Vector3 object where to store the result
  2462. * @returns the current Vector3
  2463. */
  2464. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2465. /**
  2466. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2467. * @param x defines the x coordinate of the operand
  2468. * @param y defines the y coordinate of the operand
  2469. * @param z defines the z coordinate of the operand
  2470. * @returns the new Vector3
  2471. */
  2472. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2473. /**
  2474. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2475. * @param otherVector defines the second operand
  2476. * @returns the new Vector3
  2477. */
  2478. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2479. /**
  2480. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2481. * @param otherVector defines the second operand
  2482. * @param result defines the Vector3 object where to store the result
  2483. * @returns the current Vector3
  2484. */
  2485. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2486. /**
  2487. * Divides the current Vector3 coordinates by the given ones.
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. divideInPlace(otherVector: Vector3): Vector3;
  2492. /**
  2493. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2494. * @param other defines the second operand
  2495. * @returns the current updated Vector3
  2496. */
  2497. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2498. /**
  2499. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2500. * @param other defines the second operand
  2501. * @returns the current updated Vector3
  2502. */
  2503. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2504. /**
  2505. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2506. * @param x defines the x coordinate of the operand
  2507. * @param y defines the y coordinate of the operand
  2508. * @param z defines the z coordinate of the operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2522. * Check if is non uniform within a certain amount of decimal places to account for this
  2523. * @param epsilon the amount the values can differ
  2524. * @returns if the the vector is non uniform to a certain number of decimal places
  2525. */
  2526. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2527. /**
  2528. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2529. */
  2530. readonly isNonUniform: boolean;
  2531. /**
  2532. * Gets a new Vector3 from current Vector3 floored values
  2533. * @returns a new Vector3
  2534. */
  2535. floor(): Vector3;
  2536. /**
  2537. * Gets a new Vector3 from current Vector3 floored values
  2538. * @returns a new Vector3
  2539. */
  2540. fract(): Vector3;
  2541. /**
  2542. * Gets the length of the Vector3
  2543. * @returns the length of the Vector3
  2544. */
  2545. length(): number;
  2546. /**
  2547. * Gets the squared length of the Vector3
  2548. * @returns squared length of the Vector3
  2549. */
  2550. lengthSquared(): number;
  2551. /**
  2552. * Normalize the current Vector3.
  2553. * Please note that this is an in place operation.
  2554. * @returns the current updated Vector3
  2555. */
  2556. normalize(): Vector3;
  2557. /**
  2558. * Reorders the x y z properties of the vector in place
  2559. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2560. * @returns the current updated vector
  2561. */
  2562. reorderInPlace(order: string): this;
  2563. /**
  2564. * Rotates the vector around 0,0,0 by a quaternion
  2565. * @param quaternion the rotation quaternion
  2566. * @param result vector to store the result
  2567. * @returns the resulting vector
  2568. */
  2569. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2570. /**
  2571. * Rotates a vector around a given point
  2572. * @param quaternion the rotation quaternion
  2573. * @param point the point to rotate around
  2574. * @param result vector to store the result
  2575. * @returns the resulting vector
  2576. */
  2577. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2578. /**
  2579. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2580. * The cross product is then orthogonal to both current and "other"
  2581. * @param other defines the right operand
  2582. * @returns the cross product
  2583. */
  2584. cross(other: Vector3): Vector3;
  2585. /**
  2586. * Normalize the current Vector3 with the given input length.
  2587. * Please note that this is an in place operation.
  2588. * @param len the length of the vector
  2589. * @returns the current updated Vector3
  2590. */
  2591. normalizeFromLength(len: number): Vector3;
  2592. /**
  2593. * Normalize the current Vector3 to a new vector
  2594. * @returns the new Vector3
  2595. */
  2596. normalizeToNew(): Vector3;
  2597. /**
  2598. * Normalize the current Vector3 to the reference
  2599. * @param reference define the Vector3 to update
  2600. * @returns the updated Vector3
  2601. */
  2602. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2603. /**
  2604. * Creates a new Vector3 copied from the current Vector3
  2605. * @returns the new Vector3
  2606. */
  2607. clone(): Vector3;
  2608. /**
  2609. * Copies the given vector coordinates to the current Vector3 ones
  2610. * @param source defines the source Vector3
  2611. * @returns the current updated Vector3
  2612. */
  2613. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2614. /**
  2615. * Copies the given floats to the current Vector3 coordinates
  2616. * @param x defines the x coordinate of the operand
  2617. * @param y defines the y coordinate of the operand
  2618. * @param z defines the z coordinate of the operand
  2619. * @returns the current updated Vector3
  2620. */
  2621. copyFromFloats(x: number, y: number, z: number): Vector3;
  2622. /**
  2623. * Copies the given floats to the current Vector3 coordinates
  2624. * @param x defines the x coordinate of the operand
  2625. * @param y defines the y coordinate of the operand
  2626. * @param z defines the z coordinate of the operand
  2627. * @returns the current updated Vector3
  2628. */
  2629. set(x: number, y: number, z: number): Vector3;
  2630. /**
  2631. * Copies the given float to the current Vector3 coordinates
  2632. * @param v defines the x, y and z coordinates of the operand
  2633. * @returns the current updated Vector3
  2634. */
  2635. setAll(v: number): Vector3;
  2636. /**
  2637. * Get the clip factor between two vectors
  2638. * @param vector0 defines the first operand
  2639. * @param vector1 defines the second operand
  2640. * @param axis defines the axis to use
  2641. * @param size defines the size along the axis
  2642. * @returns the clip factor
  2643. */
  2644. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2645. /**
  2646. * Get angle between two vectors
  2647. * @param vector0 angle between vector0 and vector1
  2648. * @param vector1 angle between vector0 and vector1
  2649. * @param normal direction of the normal
  2650. * @return the angle between vector0 and vector1
  2651. */
  2652. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2653. /**
  2654. * Returns a new Vector3 set from the index "offset" of the given array
  2655. * @param array defines the source array
  2656. * @param offset defines the offset in the source array
  2657. * @returns the new Vector3
  2658. */
  2659. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2660. /**
  2661. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2662. * This function is deprecated. Use FromArray instead
  2663. * @param array defines the source array
  2664. * @param offset defines the offset in the source array
  2665. * @returns the new Vector3
  2666. */
  2667. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2668. /**
  2669. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2670. * @param array defines the source array
  2671. * @param offset defines the offset in the source array
  2672. * @param result defines the Vector3 where to store the result
  2673. */
  2674. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2675. /**
  2676. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2677. * This function is deprecated. Use FromArrayToRef instead.
  2678. * @param array defines the source array
  2679. * @param offset defines the offset in the source array
  2680. * @param result defines the Vector3 where to store the result
  2681. */
  2682. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2683. /**
  2684. * Sets the given vector "result" with the given floats.
  2685. * @param x defines the x coordinate of the source
  2686. * @param y defines the y coordinate of the source
  2687. * @param z defines the z coordinate of the source
  2688. * @param result defines the Vector3 where to store the result
  2689. */
  2690. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2691. /**
  2692. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2693. * @returns a new empty Vector3
  2694. */
  2695. static Zero(): Vector3;
  2696. /**
  2697. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2698. * @returns a new unit Vector3
  2699. */
  2700. static One(): Vector3;
  2701. /**
  2702. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2703. * @returns a new up Vector3
  2704. */
  2705. static Up(): Vector3;
  2706. /**
  2707. * Gets a up Vector3 that must not be updated
  2708. */
  2709. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2710. /**
  2711. * Gets a zero Vector3 that must not be updated
  2712. */
  2713. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2714. /**
  2715. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2716. * @returns a new down Vector3
  2717. */
  2718. static Down(): Vector3;
  2719. /**
  2720. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2721. * @returns a new forward Vector3
  2722. */
  2723. static Forward(): Vector3;
  2724. /**
  2725. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2726. * @returns a new forward Vector3
  2727. */
  2728. static Backward(): Vector3;
  2729. /**
  2730. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2731. * @returns a new right Vector3
  2732. */
  2733. static Right(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2736. * @returns a new left Vector3
  2737. */
  2738. static Left(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2741. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2742. * @param vector defines the Vector3 to transform
  2743. * @param transformation defines the transformation matrix
  2744. * @returns the transformed Vector3
  2745. */
  2746. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2747. /**
  2748. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2749. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @param result defines the Vector3 where to store the result
  2753. */
  2754. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2755. /**
  2756. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2757. * This method computes tranformed coordinates only, not transformed direction vectors
  2758. * @param x define the x coordinate of the source vector
  2759. * @param y define the y coordinate of the source vector
  2760. * @param z define the z coordinate of the source vector
  2761. * @param transformation defines the transformation matrix
  2762. * @param result defines the Vector3 where to store the result
  2763. */
  2764. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2765. /**
  2766. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2767. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2768. * @param vector defines the Vector3 to transform
  2769. * @param transformation defines the transformation matrix
  2770. * @returns the new Vector3
  2771. */
  2772. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2773. /**
  2774. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2775. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2776. * @param vector defines the Vector3 to transform
  2777. * @param transformation defines the transformation matrix
  2778. * @param result defines the Vector3 where to store the result
  2779. */
  2780. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2781. /**
  2782. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2783. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2784. * @param x define the x coordinate of the source vector
  2785. * @param y define the y coordinate of the source vector
  2786. * @param z define the z coordinate of the source vector
  2787. * @param transformation defines the transformation matrix
  2788. * @param result defines the Vector3 where to store the result
  2789. */
  2790. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2791. /**
  2792. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2793. * @param value1 defines the first control point
  2794. * @param value2 defines the second control point
  2795. * @param value3 defines the third control point
  2796. * @param value4 defines the fourth control point
  2797. * @param amount defines the amount on the spline to use
  2798. * @returns the new Vector3
  2799. */
  2800. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2801. /**
  2802. * 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"
  2803. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2804. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2805. * @param value defines the current value
  2806. * @param min defines the lower range value
  2807. * @param max defines the upper range value
  2808. * @returns the new Vector3
  2809. */
  2810. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2811. /**
  2812. * 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"
  2813. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2814. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2815. * @param value defines the current value
  2816. * @param min defines the lower range value
  2817. * @param max defines the upper range value
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2821. /**
  2822. * Checks if a given vector is inside a specific range
  2823. * @param v defines the vector to test
  2824. * @param min defines the minimum range
  2825. * @param max defines the maximum range
  2826. */
  2827. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2828. /**
  2829. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2830. * @param value1 defines the first control point
  2831. * @param tangent1 defines the first tangent vector
  2832. * @param value2 defines the second control point
  2833. * @param tangent2 defines the second tangent vector
  2834. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2835. * @returns the new Vector3
  2836. */
  2837. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2838. /**
  2839. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2840. * @param start defines the start value
  2841. * @param end defines the end value
  2842. * @param amount max defines amount between both (between 0 and 1)
  2843. * @returns the new Vector3
  2844. */
  2845. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2848. * @param start defines the start value
  2849. * @param end defines the end value
  2850. * @param amount max defines amount between both (between 0 and 1)
  2851. * @param result defines the Vector3 where to store the result
  2852. */
  2853. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2854. /**
  2855. * Returns the dot product (float) between the vectors "left" and "right"
  2856. * @param left defines the left operand
  2857. * @param right defines the right operand
  2858. * @returns the dot product
  2859. */
  2860. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2861. /**
  2862. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2863. * The cross product is then orthogonal to both "left" and "right"
  2864. * @param left defines the left operand
  2865. * @param right defines the right operand
  2866. * @returns the cross product
  2867. */
  2868. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2869. /**
  2870. * Sets the given vector "result" with the cross product of "left" and "right"
  2871. * The cross product is then orthogonal to both "left" and "right"
  2872. * @param left defines the left operand
  2873. * @param right defines the right operand
  2874. * @param result defines the Vector3 where to store the result
  2875. */
  2876. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2877. /**
  2878. * Returns a new Vector3 as the normalization of the given vector
  2879. * @param vector defines the Vector3 to normalize
  2880. * @returns the new Vector3
  2881. */
  2882. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2883. /**
  2884. * Sets the given vector "result" with the normalization of the given first vector
  2885. * @param vector defines the Vector3 to normalize
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2889. /**
  2890. * Project a Vector3 onto screen space
  2891. * @param vector defines the Vector3 to project
  2892. * @param world defines the world matrix to use
  2893. * @param transform defines the transform (view x projection) matrix to use
  2894. * @param viewport defines the screen viewport to use
  2895. * @returns the new Vector3
  2896. */
  2897. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2898. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2899. /**
  2900. * Unproject from screen space to object space
  2901. * @param source defines the screen space Vector3 to use
  2902. * @param viewportWidth defines the current width of the viewport
  2903. * @param viewportHeight defines the current height of the viewport
  2904. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2905. * @param transform defines the transform (view x projection) matrix to use
  2906. * @returns the new Vector3
  2907. */
  2908. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2909. /**
  2910. * Unproject from screen space to object space
  2911. * @param source defines the screen space Vector3 to use
  2912. * @param viewportWidth defines the current width of the viewport
  2913. * @param viewportHeight defines the current height of the viewport
  2914. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2915. * @param view defines the view matrix to use
  2916. * @param projection defines the projection matrix to use
  2917. * @returns the new Vector3
  2918. */
  2919. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2920. /**
  2921. * Unproject from screen space to object space
  2922. * @param source defines the screen space Vector3 to use
  2923. * @param viewportWidth defines the current width of the viewport
  2924. * @param viewportHeight defines the current height of the viewport
  2925. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2926. * @param view defines the view matrix to use
  2927. * @param projection defines the projection matrix to use
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Unproject from screen space to object space
  2933. * @param sourceX defines the screen space x coordinate to use
  2934. * @param sourceY defines the screen space y coordinate to use
  2935. * @param sourceZ defines the screen space z coordinate to use
  2936. * @param viewportWidth defines the current width of the viewport
  2937. * @param viewportHeight defines the current height of the viewport
  2938. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2939. * @param view defines the view matrix to use
  2940. * @param projection defines the projection matrix to use
  2941. * @param result defines the Vector3 where to store the result
  2942. */
  2943. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2944. /**
  2945. * Gets the minimal coordinate values between two Vector3
  2946. * @param left defines the first operand
  2947. * @param right defines the second operand
  2948. * @returns the new Vector3
  2949. */
  2950. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2951. /**
  2952. * Gets the maximal coordinate values between two Vector3
  2953. * @param left defines the first operand
  2954. * @param right defines the second operand
  2955. * @returns the new Vector3
  2956. */
  2957. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2958. /**
  2959. * Returns the distance between the vectors "value1" and "value2"
  2960. * @param value1 defines the first operand
  2961. * @param value2 defines the second operand
  2962. * @returns the distance
  2963. */
  2964. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2965. /**
  2966. * Returns the squared distance between the vectors "value1" and "value2"
  2967. * @param value1 defines the first operand
  2968. * @param value2 defines the second operand
  2969. * @returns the squared distance
  2970. */
  2971. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2972. /**
  2973. * Returns a new Vector3 located at the center between "value1" and "value2"
  2974. * @param value1 defines the first operand
  2975. * @param value2 defines the second operand
  2976. * @returns the new Vector3
  2977. */
  2978. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2979. /**
  2980. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2981. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2982. * to something in order to rotate it from its local system to the given target system
  2983. * Note: axis1, axis2 and axis3 are normalized during this operation
  2984. * @param axis1 defines the first axis
  2985. * @param axis2 defines the second axis
  2986. * @param axis3 defines the third axis
  2987. * @returns a new Vector3
  2988. */
  2989. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2992. * @param axis1 defines the first axis
  2993. * @param axis2 defines the second axis
  2994. * @param axis3 defines the third axis
  2995. * @param ref defines the Vector3 where to store the result
  2996. */
  2997. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2998. }
  2999. /**
  3000. * Vector4 class created for EulerAngle class conversion to Quaternion
  3001. */
  3002. export class Vector4 {
  3003. /** x value of the vector */
  3004. x: number;
  3005. /** y value of the vector */
  3006. y: number;
  3007. /** z value of the vector */
  3008. z: number;
  3009. /** w value of the vector */
  3010. w: number;
  3011. /**
  3012. * Creates a Vector4 object from the given floats.
  3013. * @param x x value of the vector
  3014. * @param y y value of the vector
  3015. * @param z z value of the vector
  3016. * @param w w value of the vector
  3017. */
  3018. constructor(
  3019. /** x value of the vector */
  3020. x: number,
  3021. /** y value of the vector */
  3022. y: number,
  3023. /** z value of the vector */
  3024. z: number,
  3025. /** w value of the vector */
  3026. w: number);
  3027. /**
  3028. * Returns the string with the Vector4 coordinates.
  3029. * @returns a string containing all the vector values
  3030. */
  3031. toString(): string;
  3032. /**
  3033. * Returns the string "Vector4".
  3034. * @returns "Vector4"
  3035. */
  3036. getClassName(): string;
  3037. /**
  3038. * Returns the Vector4 hash code.
  3039. * @returns a unique hash code
  3040. */
  3041. getHashCode(): number;
  3042. /**
  3043. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3044. * @returns the resulting array
  3045. */
  3046. asArray(): number[];
  3047. /**
  3048. * Populates the given array from the given index with the Vector4 coordinates.
  3049. * @param array array to populate
  3050. * @param index index of the array to start at (default: 0)
  3051. * @returns the Vector4.
  3052. */
  3053. toArray(array: FloatArray, index?: number): Vector4;
  3054. /**
  3055. * Adds the given vector to the current Vector4.
  3056. * @param otherVector the vector to add
  3057. * @returns the updated Vector4.
  3058. */
  3059. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3060. /**
  3061. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3062. * @param otherVector the vector to add
  3063. * @returns the resulting vector
  3064. */
  3065. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3066. /**
  3067. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3068. * @param otherVector the vector to add
  3069. * @param result the vector to store the result
  3070. * @returns the current Vector4.
  3071. */
  3072. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3073. /**
  3074. * Subtract in place the given vector from the current Vector4.
  3075. * @param otherVector the vector to subtract
  3076. * @returns the updated Vector4.
  3077. */
  3078. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3079. /**
  3080. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3081. * @param otherVector the vector to add
  3082. * @returns the new vector with the result
  3083. */
  3084. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3085. /**
  3086. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3087. * @param otherVector the vector to subtract
  3088. * @param result the vector to store the result
  3089. * @returns the current Vector4.
  3090. */
  3091. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3092. /**
  3093. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3094. */
  3095. /**
  3096. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3097. * @param x value to subtract
  3098. * @param y value to subtract
  3099. * @param z value to subtract
  3100. * @param w value to subtract
  3101. * @returns new vector containing the result
  3102. */
  3103. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3104. /**
  3105. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3106. * @param x value to subtract
  3107. * @param y value to subtract
  3108. * @param z value to subtract
  3109. * @param w value to subtract
  3110. * @param result the vector to store the result in
  3111. * @returns the current Vector4.
  3112. */
  3113. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3114. /**
  3115. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3116. * @returns a new vector with the negated values
  3117. */
  3118. negate(): Vector4;
  3119. /**
  3120. * Multiplies the current Vector4 coordinates by scale (float).
  3121. * @param scale the number to scale with
  3122. * @returns the updated Vector4.
  3123. */
  3124. scaleInPlace(scale: number): Vector4;
  3125. /**
  3126. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3127. * @param scale the number to scale with
  3128. * @returns a new vector with the result
  3129. */
  3130. scale(scale: number): Vector4;
  3131. /**
  3132. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3133. * @param scale the number to scale with
  3134. * @param result a vector to store the result in
  3135. * @returns the current Vector4.
  3136. */
  3137. scaleToRef(scale: number, result: Vector4): Vector4;
  3138. /**
  3139. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3140. * @param scale defines the scale factor
  3141. * @param result defines the Vector4 object where to store the result
  3142. * @returns the unmodified current Vector4
  3143. */
  3144. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3145. /**
  3146. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3147. * @param otherVector the vector to compare against
  3148. * @returns true if they are equal
  3149. */
  3150. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3151. /**
  3152. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3153. * @param otherVector vector to compare against
  3154. * @param epsilon (Default: very small number)
  3155. * @returns true if they are equal
  3156. */
  3157. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3158. /**
  3159. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3160. * @param x x value to compare against
  3161. * @param y y value to compare against
  3162. * @param z z value to compare against
  3163. * @param w w value to compare against
  3164. * @returns true if equal
  3165. */
  3166. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3167. /**
  3168. * Multiplies in place the current Vector4 by the given one.
  3169. * @param otherVector vector to multiple with
  3170. * @returns the updated Vector4.
  3171. */
  3172. multiplyInPlace(otherVector: Vector4): Vector4;
  3173. /**
  3174. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3175. * @param otherVector vector to multiple with
  3176. * @returns resulting new vector
  3177. */
  3178. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3179. /**
  3180. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3181. * @param otherVector vector to multiple with
  3182. * @param result vector to store the result
  3183. * @returns the current Vector4.
  3184. */
  3185. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3186. /**
  3187. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3188. * @param x x value multiply with
  3189. * @param y y value multiply with
  3190. * @param z z value multiply with
  3191. * @param w w value multiply with
  3192. * @returns resulting new vector
  3193. */
  3194. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3195. /**
  3196. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3197. * @param otherVector vector to devide with
  3198. * @returns resulting new vector
  3199. */
  3200. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3201. /**
  3202. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3203. * @param otherVector vector to devide with
  3204. * @param result vector to store the result
  3205. * @returns the current Vector4.
  3206. */
  3207. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3208. /**
  3209. * Divides the current Vector3 coordinates by the given ones.
  3210. * @param otherVector vector to devide with
  3211. * @returns the updated Vector3.
  3212. */
  3213. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3214. /**
  3215. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3216. * @param other defines the second operand
  3217. * @returns the current updated Vector4
  3218. */
  3219. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3220. /**
  3221. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3222. * @param other defines the second operand
  3223. * @returns the current updated Vector4
  3224. */
  3225. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3226. /**
  3227. * Gets a new Vector4 from current Vector4 floored values
  3228. * @returns a new Vector4
  3229. */
  3230. floor(): Vector4;
  3231. /**
  3232. * Gets a new Vector4 from current Vector3 floored values
  3233. * @returns a new Vector4
  3234. */
  3235. fract(): Vector4;
  3236. /**
  3237. * Returns the Vector4 length (float).
  3238. * @returns the length
  3239. */
  3240. length(): number;
  3241. /**
  3242. * Returns the Vector4 squared length (float).
  3243. * @returns the length squared
  3244. */
  3245. lengthSquared(): number;
  3246. /**
  3247. * Normalizes in place the Vector4.
  3248. * @returns the updated Vector4.
  3249. */
  3250. normalize(): Vector4;
  3251. /**
  3252. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3253. * @returns this converted to a new vector3
  3254. */
  3255. toVector3(): Vector3;
  3256. /**
  3257. * Returns a new Vector4 copied from the current one.
  3258. * @returns the new cloned vector
  3259. */
  3260. clone(): Vector4;
  3261. /**
  3262. * Updates the current Vector4 with the given one coordinates.
  3263. * @param source the source vector to copy from
  3264. * @returns the updated Vector4.
  3265. */
  3266. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3267. /**
  3268. * Updates the current Vector4 coordinates with the given floats.
  3269. * @param x float to copy from
  3270. * @param y float to copy from
  3271. * @param z float to copy from
  3272. * @param w float to copy from
  3273. * @returns the updated Vector4.
  3274. */
  3275. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3276. /**
  3277. * Updates the current Vector4 coordinates with the given floats.
  3278. * @param x float to set from
  3279. * @param y float to set from
  3280. * @param z float to set from
  3281. * @param w float to set from
  3282. * @returns the updated Vector4.
  3283. */
  3284. set(x: number, y: number, z: number, w: number): Vector4;
  3285. /**
  3286. * Copies the given float to the current Vector3 coordinates
  3287. * @param v defines the x, y, z and w coordinates of the operand
  3288. * @returns the current updated Vector3
  3289. */
  3290. setAll(v: number): Vector4;
  3291. /**
  3292. * Returns a new Vector4 set from the starting index of the given array.
  3293. * @param array the array to pull values from
  3294. * @param offset the offset into the array to start at
  3295. * @returns the new vector
  3296. */
  3297. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3298. /**
  3299. * Updates the given vector "result" from the starting index of the given array.
  3300. * @param array the array to pull values from
  3301. * @param offset the offset into the array to start at
  3302. * @param result the vector to store the result in
  3303. */
  3304. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3305. /**
  3306. * Updates the given vector "result" from the starting index of the given Float32Array.
  3307. * @param array the array to pull values from
  3308. * @param offset the offset into the array to start at
  3309. * @param result the vector to store the result in
  3310. */
  3311. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3312. /**
  3313. * Updates the given vector "result" coordinates from the given floats.
  3314. * @param x float to set from
  3315. * @param y float to set from
  3316. * @param z float to set from
  3317. * @param w float to set from
  3318. * @param result the vector to the floats in
  3319. */
  3320. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3321. /**
  3322. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3323. * @returns the new vector
  3324. */
  3325. static Zero(): Vector4;
  3326. /**
  3327. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3328. * @returns the new vector
  3329. */
  3330. static One(): Vector4;
  3331. /**
  3332. * Returns a new normalized Vector4 from the given one.
  3333. * @param vector the vector to normalize
  3334. * @returns the vector
  3335. */
  3336. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the normalization of the given one.
  3339. * @param vector the vector to normalize
  3340. * @param result the vector to store the result in
  3341. */
  3342. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3343. /**
  3344. * Returns a vector with the minimum values from the left and right vectors
  3345. * @param left left vector to minimize
  3346. * @param right right vector to minimize
  3347. * @returns a new vector with the minimum of the left and right vector values
  3348. */
  3349. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3350. /**
  3351. * Returns a vector with the maximum values from the left and right vectors
  3352. * @param left left vector to maximize
  3353. * @param right right vector to maximize
  3354. * @returns a new vector with the maximum of the left and right vector values
  3355. */
  3356. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3357. /**
  3358. * Returns the distance (float) between the vectors "value1" and "value2".
  3359. * @param value1 value to calulate the distance between
  3360. * @param value2 value to calulate the distance between
  3361. * @return the distance between the two vectors
  3362. */
  3363. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3364. /**
  3365. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3366. * @param value1 value to calulate the distance between
  3367. * @param value2 value to calulate the distance between
  3368. * @return the distance between the two vectors squared
  3369. */
  3370. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3371. /**
  3372. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3373. * @param value1 value to calulate the center between
  3374. * @param value2 value to calulate the center between
  3375. * @return the center between the two vectors
  3376. */
  3377. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3380. * This methods computes transformed normalized direction vectors only.
  3381. * @param vector the vector to transform
  3382. * @param transformation the transformation matrix to apply
  3383. * @returns the new vector
  3384. */
  3385. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3386. /**
  3387. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3388. * This methods computes transformed normalized direction vectors only.
  3389. * @param vector the vector to transform
  3390. * @param transformation the transformation matrix to apply
  3391. * @param result the vector to store the result in
  3392. */
  3393. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3394. /**
  3395. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3396. * This methods computes transformed normalized direction vectors only.
  3397. * @param x value to transform
  3398. * @param y value to transform
  3399. * @param z value to transform
  3400. * @param w value to transform
  3401. * @param transformation the transformation matrix to apply
  3402. * @param result the vector to store the results in
  3403. */
  3404. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3405. /**
  3406. * Creates a new Vector4 from a Vector3
  3407. * @param source defines the source data
  3408. * @param w defines the 4th component (default is 0)
  3409. * @returns a new Vector4
  3410. */
  3411. static FromVector3(source: Vector3, w?: number): Vector4;
  3412. }
  3413. /**
  3414. * Class used to store quaternion data
  3415. * @see https://en.wikipedia.org/wiki/Quaternion
  3416. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3417. */
  3418. export class Quaternion {
  3419. /** defines the first component (0 by default) */
  3420. x: number;
  3421. /** defines the second component (0 by default) */
  3422. y: number;
  3423. /** defines the third component (0 by default) */
  3424. z: number;
  3425. /** defines the fourth component (1.0 by default) */
  3426. w: number;
  3427. /**
  3428. * Creates a new Quaternion from the given floats
  3429. * @param x defines the first component (0 by default)
  3430. * @param y defines the second component (0 by default)
  3431. * @param z defines the third component (0 by default)
  3432. * @param w defines the fourth component (1.0 by default)
  3433. */
  3434. constructor(
  3435. /** defines the first component (0 by default) */
  3436. x?: number,
  3437. /** defines the second component (0 by default) */
  3438. y?: number,
  3439. /** defines the third component (0 by default) */
  3440. z?: number,
  3441. /** defines the fourth component (1.0 by default) */
  3442. w?: number);
  3443. /**
  3444. * Gets a string representation for the current quaternion
  3445. * @returns a string with the Quaternion coordinates
  3446. */
  3447. toString(): string;
  3448. /**
  3449. * Gets the class name of the quaternion
  3450. * @returns the string "Quaternion"
  3451. */
  3452. getClassName(): string;
  3453. /**
  3454. * Gets a hash code for this quaternion
  3455. * @returns the quaternion hash code
  3456. */
  3457. getHashCode(): number;
  3458. /**
  3459. * Copy the quaternion to an array
  3460. * @returns a new array populated with 4 elements from the quaternion coordinates
  3461. */
  3462. asArray(): number[];
  3463. /**
  3464. * Check if two quaternions are equals
  3465. * @param otherQuaternion defines the second operand
  3466. * @return true if the current quaternion and the given one coordinates are strictly equals
  3467. */
  3468. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3469. /**
  3470. * Clone the current quaternion
  3471. * @returns a new quaternion copied from the current one
  3472. */
  3473. clone(): Quaternion;
  3474. /**
  3475. * Copy a quaternion to the current one
  3476. * @param other defines the other quaternion
  3477. * @returns the updated current quaternion
  3478. */
  3479. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3480. /**
  3481. * Updates the current quaternion with the given float coordinates
  3482. * @param x defines the x coordinate
  3483. * @param y defines the y coordinate
  3484. * @param z defines the z coordinate
  3485. * @param w defines the w coordinate
  3486. * @returns the updated current quaternion
  3487. */
  3488. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3489. /**
  3490. * Updates the current quaternion from the given float coordinates
  3491. * @param x defines the x coordinate
  3492. * @param y defines the y coordinate
  3493. * @param z defines the z coordinate
  3494. * @param w defines the w coordinate
  3495. * @returns the updated current quaternion
  3496. */
  3497. set(x: number, y: number, z: number, w: number): Quaternion;
  3498. /**
  3499. * Adds two quaternions
  3500. * @param other defines the second operand
  3501. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3502. */
  3503. add(other: DeepImmutable<Quaternion>): Quaternion;
  3504. /**
  3505. * Add a quaternion to the current one
  3506. * @param other defines the quaternion to add
  3507. * @returns the current quaternion
  3508. */
  3509. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3510. /**
  3511. * Subtract two quaternions
  3512. * @param other defines the second operand
  3513. * @returns a new quaternion as the subtraction result of the given one from the current one
  3514. */
  3515. subtract(other: Quaternion): Quaternion;
  3516. /**
  3517. * Multiplies the current quaternion by a scale factor
  3518. * @param value defines the scale factor
  3519. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3520. */
  3521. scale(value: number): Quaternion;
  3522. /**
  3523. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3524. * @param scale defines the scale factor
  3525. * @param result defines the Quaternion object where to store the result
  3526. * @returns the unmodified current quaternion
  3527. */
  3528. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3529. /**
  3530. * Multiplies in place the current quaternion by a scale factor
  3531. * @param value defines the scale factor
  3532. * @returns the current modified quaternion
  3533. */
  3534. scaleInPlace(value: number): Quaternion;
  3535. /**
  3536. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3537. * @param scale defines the scale factor
  3538. * @param result defines the Quaternion object where to store the result
  3539. * @returns the unmodified current quaternion
  3540. */
  3541. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3542. /**
  3543. * Multiplies two quaternions
  3544. * @param q1 defines the second operand
  3545. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3546. */
  3547. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3548. /**
  3549. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3550. * @param q1 defines the second operand
  3551. * @param result defines the target quaternion
  3552. * @returns the current quaternion
  3553. */
  3554. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3555. /**
  3556. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3557. * @param q1 defines the second operand
  3558. * @returns the currentupdated quaternion
  3559. */
  3560. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3561. /**
  3562. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3563. * @param ref defines the target quaternion
  3564. * @returns the current quaternion
  3565. */
  3566. conjugateToRef(ref: Quaternion): Quaternion;
  3567. /**
  3568. * Conjugates in place (1-q) the current quaternion
  3569. * @returns the current updated quaternion
  3570. */
  3571. conjugateInPlace(): Quaternion;
  3572. /**
  3573. * Conjugates in place (1-q) the current quaternion
  3574. * @returns a new quaternion
  3575. */
  3576. conjugate(): Quaternion;
  3577. /**
  3578. * Gets length of current quaternion
  3579. * @returns the quaternion length (float)
  3580. */
  3581. length(): number;
  3582. /**
  3583. * Normalize in place the current quaternion
  3584. * @returns the current updated quaternion
  3585. */
  3586. normalize(): Quaternion;
  3587. /**
  3588. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3589. * @param order is a reserved parameter and is ignore for now
  3590. * @returns a new Vector3 containing the Euler angles
  3591. */
  3592. toEulerAngles(order?: string): Vector3;
  3593. /**
  3594. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3595. * @param result defines the vector which will be filled with the Euler angles
  3596. * @param order is a reserved parameter and is ignore for now
  3597. * @returns the current unchanged quaternion
  3598. */
  3599. toEulerAnglesToRef(result: Vector3): Quaternion;
  3600. /**
  3601. * Updates the given rotation matrix with the current quaternion values
  3602. * @param result defines the target matrix
  3603. * @returns the current unchanged quaternion
  3604. */
  3605. toRotationMatrix(result: Matrix): Quaternion;
  3606. /**
  3607. * Updates the current quaternion from the given rotation matrix values
  3608. * @param matrix defines the source matrix
  3609. * @returns the current updated quaternion
  3610. */
  3611. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3612. /**
  3613. * Creates a new quaternion from a rotation matrix
  3614. * @param matrix defines the source matrix
  3615. * @returns a new quaternion created from the given rotation matrix values
  3616. */
  3617. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3618. /**
  3619. * Updates the given quaternion with the given rotation matrix values
  3620. * @param matrix defines the source matrix
  3621. * @param result defines the target quaternion
  3622. */
  3623. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3624. /**
  3625. * Returns the dot product (float) between the quaternions "left" and "right"
  3626. * @param left defines the left operand
  3627. * @param right defines the right operand
  3628. * @returns the dot product
  3629. */
  3630. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3631. /**
  3632. * Checks if the two quaternions are close to each other
  3633. * @param quat0 defines the first quaternion to check
  3634. * @param quat1 defines the second quaternion to check
  3635. * @returns true if the two quaternions are close to each other
  3636. */
  3637. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3638. /**
  3639. * Creates an empty quaternion
  3640. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3641. */
  3642. static Zero(): Quaternion;
  3643. /**
  3644. * Inverse a given quaternion
  3645. * @param q defines the source quaternion
  3646. * @returns a new quaternion as the inverted current quaternion
  3647. */
  3648. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3649. /**
  3650. * Inverse a given quaternion
  3651. * @param q defines the source quaternion
  3652. * @param result the quaternion the result will be stored in
  3653. * @returns the result quaternion
  3654. */
  3655. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3656. /**
  3657. * Creates an identity quaternion
  3658. * @returns the identity quaternion
  3659. */
  3660. static Identity(): Quaternion;
  3661. /**
  3662. * Gets a boolean indicating if the given quaternion is identity
  3663. * @param quaternion defines the quaternion to check
  3664. * @returns true if the quaternion is identity
  3665. */
  3666. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3667. /**
  3668. * Creates a quaternion from a rotation around an axis
  3669. * @param axis defines the axis to use
  3670. * @param angle defines the angle to use
  3671. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3672. */
  3673. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3674. /**
  3675. * Creates a rotation around an axis and stores it into the given quaternion
  3676. * @param axis defines the axis to use
  3677. * @param angle defines the angle to use
  3678. * @param result defines the target quaternion
  3679. * @returns the target quaternion
  3680. */
  3681. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3682. /**
  3683. * Creates a new quaternion from data stored into an array
  3684. * @param array defines the data source
  3685. * @param offset defines the offset in the source array where the data starts
  3686. * @returns a new quaternion
  3687. */
  3688. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3689. /**
  3690. * Create a quaternion from Euler rotation angles
  3691. * @param x Pitch
  3692. * @param y Yaw
  3693. * @param z Roll
  3694. * @returns the new Quaternion
  3695. */
  3696. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3697. /**
  3698. * Updates a quaternion from Euler rotation angles
  3699. * @param x Pitch
  3700. * @param y Yaw
  3701. * @param z Roll
  3702. * @param result the quaternion to store the result
  3703. * @returns the updated quaternion
  3704. */
  3705. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3706. /**
  3707. * Create a quaternion from Euler rotation vector
  3708. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3709. * @returns the new Quaternion
  3710. */
  3711. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3712. /**
  3713. * Updates a quaternion from Euler rotation vector
  3714. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3715. * @param result the quaternion to store the result
  3716. * @returns the updated quaternion
  3717. */
  3718. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3719. /**
  3720. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3721. * @param yaw defines the rotation around Y axis
  3722. * @param pitch defines the rotation around X axis
  3723. * @param roll defines the rotation around Z axis
  3724. * @returns the new quaternion
  3725. */
  3726. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3727. /**
  3728. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3729. * @param yaw defines the rotation around Y axis
  3730. * @param pitch defines the rotation around X axis
  3731. * @param roll defines the rotation around Z axis
  3732. * @param result defines the target quaternion
  3733. */
  3734. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3735. /**
  3736. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3737. * @param alpha defines the rotation around first axis
  3738. * @param beta defines the rotation around second axis
  3739. * @param gamma defines the rotation around third axis
  3740. * @returns the new quaternion
  3741. */
  3742. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3743. /**
  3744. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3745. * @param alpha defines the rotation around first axis
  3746. * @param beta defines the rotation around second axis
  3747. * @param gamma defines the rotation around third axis
  3748. * @param result defines the target quaternion
  3749. */
  3750. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3751. /**
  3752. * 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)
  3753. * @param axis1 defines the first axis
  3754. * @param axis2 defines the second axis
  3755. * @param axis3 defines the third axis
  3756. * @returns the new quaternion
  3757. */
  3758. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3759. /**
  3760. * 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
  3761. * @param axis1 defines the first axis
  3762. * @param axis2 defines the second axis
  3763. * @param axis3 defines the third axis
  3764. * @param ref defines the target quaternion
  3765. */
  3766. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3767. /**
  3768. * Interpolates between two quaternions
  3769. * @param left defines first quaternion
  3770. * @param right defines second quaternion
  3771. * @param amount defines the gradient to use
  3772. * @returns the new interpolated quaternion
  3773. */
  3774. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3775. /**
  3776. * Interpolates between two quaternions and stores it into a target quaternion
  3777. * @param left defines first quaternion
  3778. * @param right defines second quaternion
  3779. * @param amount defines the gradient to use
  3780. * @param result defines the target quaternion
  3781. */
  3782. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3783. /**
  3784. * Interpolate between two quaternions using Hermite interpolation
  3785. * @param value1 defines first quaternion
  3786. * @param tangent1 defines the incoming tangent
  3787. * @param value2 defines second quaternion
  3788. * @param tangent2 defines the outgoing tangent
  3789. * @param amount defines the target quaternion
  3790. * @returns the new interpolated quaternion
  3791. */
  3792. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3793. }
  3794. /**
  3795. * Class used to store matrix data (4x4)
  3796. */
  3797. export class Matrix {
  3798. private static _updateFlagSeed;
  3799. private static _identityReadOnly;
  3800. private _isIdentity;
  3801. private _isIdentityDirty;
  3802. private _isIdentity3x2;
  3803. private _isIdentity3x2Dirty;
  3804. /**
  3805. * Gets the update flag of the matrix which is an unique number for the matrix.
  3806. * It will be incremented every time the matrix data change.
  3807. * You can use it to speed the comparison between two versions of the same matrix.
  3808. */
  3809. updateFlag: number;
  3810. private readonly _m;
  3811. /**
  3812. * Gets the internal data of the matrix
  3813. */
  3814. readonly m: DeepImmutable<Float32Array>;
  3815. /** @hidden */ private _markAsUpdated(): void;
  3816. /** @hidden */
  3817. private _updateIdentityStatus;
  3818. /**
  3819. * Creates an empty matrix (filled with zeros)
  3820. */
  3821. constructor();
  3822. /**
  3823. * Check if the current matrix is identity
  3824. * @returns true is the matrix is the identity matrix
  3825. */
  3826. isIdentity(): boolean;
  3827. /**
  3828. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3829. * @returns true is the matrix is the identity matrix
  3830. */
  3831. isIdentityAs3x2(): boolean;
  3832. /**
  3833. * Gets the determinant of the matrix
  3834. * @returns the matrix determinant
  3835. */
  3836. determinant(): number;
  3837. /**
  3838. * Returns the matrix as a Float32Array
  3839. * @returns the matrix underlying array
  3840. */
  3841. toArray(): DeepImmutable<Float32Array>;
  3842. /**
  3843. * Returns the matrix as a Float32Array
  3844. * @returns the matrix underlying array.
  3845. */
  3846. asArray(): DeepImmutable<Float32Array>;
  3847. /**
  3848. * Inverts the current matrix in place
  3849. * @returns the current inverted matrix
  3850. */
  3851. invert(): Matrix;
  3852. /**
  3853. * Sets all the matrix elements to zero
  3854. * @returns the current matrix
  3855. */
  3856. reset(): Matrix;
  3857. /**
  3858. * Adds the current matrix with a second one
  3859. * @param other defines the matrix to add
  3860. * @returns a new matrix as the addition of the current matrix and the given one
  3861. */
  3862. add(other: DeepImmutable<Matrix>): Matrix;
  3863. /**
  3864. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3865. * @param other defines the matrix to add
  3866. * @param result defines the target matrix
  3867. * @returns the current matrix
  3868. */
  3869. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3870. /**
  3871. * Adds in place the given matrix to the current matrix
  3872. * @param other defines the second operand
  3873. * @returns the current updated matrix
  3874. */
  3875. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3876. /**
  3877. * Sets the given matrix to the current inverted Matrix
  3878. * @param other defines the target matrix
  3879. * @returns the unmodified current matrix
  3880. */
  3881. invertToRef(other: Matrix): Matrix;
  3882. /**
  3883. * add a value at the specified position in the current Matrix
  3884. * @param index the index of the value within the matrix. between 0 and 15.
  3885. * @param value the value to be added
  3886. * @returns the current updated matrix
  3887. */
  3888. addAtIndex(index: number, value: number): Matrix;
  3889. /**
  3890. * mutiply the specified position in the current Matrix by a value
  3891. * @param index the index of the value within the matrix. between 0 and 15.
  3892. * @param value the value to be added
  3893. * @returns the current updated matrix
  3894. */
  3895. multiplyAtIndex(index: number, value: number): Matrix;
  3896. /**
  3897. * Inserts the translation vector (using 3 floats) in the current matrix
  3898. * @param x defines the 1st component of the translation
  3899. * @param y defines the 2nd component of the translation
  3900. * @param z defines the 3rd component of the translation
  3901. * @returns the current updated matrix
  3902. */
  3903. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3904. /**
  3905. * Adds the translation vector (using 3 floats) in the current matrix
  3906. * @param x defines the 1st component of the translation
  3907. * @param y defines the 2nd component of the translation
  3908. * @param z defines the 3rd component of the translation
  3909. * @returns the current updated matrix
  3910. */
  3911. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3912. /**
  3913. * Inserts the translation vector in the current matrix
  3914. * @param vector3 defines the translation to insert
  3915. * @returns the current updated matrix
  3916. */
  3917. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3918. /**
  3919. * Gets the translation value of the current matrix
  3920. * @returns a new Vector3 as the extracted translation from the matrix
  3921. */
  3922. getTranslation(): Vector3;
  3923. /**
  3924. * Fill a Vector3 with the extracted translation from the matrix
  3925. * @param result defines the Vector3 where to store the translation
  3926. * @returns the current matrix
  3927. */
  3928. getTranslationToRef(result: Vector3): Matrix;
  3929. /**
  3930. * Remove rotation and scaling part from the matrix
  3931. * @returns the updated matrix
  3932. */
  3933. removeRotationAndScaling(): Matrix;
  3934. /**
  3935. * Multiply two matrices
  3936. * @param other defines the second operand
  3937. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3938. */
  3939. multiply(other: DeepImmutable<Matrix>): Matrix;
  3940. /**
  3941. * Copy the current matrix from the given one
  3942. * @param other defines the source matrix
  3943. * @returns the current updated matrix
  3944. */
  3945. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3946. /**
  3947. * Populates the given array from the starting index with the current matrix values
  3948. * @param array defines the target array
  3949. * @param offset defines the offset in the target array where to start storing values
  3950. * @returns the current matrix
  3951. */
  3952. copyToArray(array: Float32Array, offset?: number): Matrix;
  3953. /**
  3954. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3955. * @param other defines the second operand
  3956. * @param result defines the matrix where to store the multiplication
  3957. * @returns the current matrix
  3958. */
  3959. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3960. /**
  3961. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3962. * @param other defines the second operand
  3963. * @param result defines the array where to store the multiplication
  3964. * @param offset defines the offset in the target array where to start storing values
  3965. * @returns the current matrix
  3966. */
  3967. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3968. /**
  3969. * Check equality between this matrix and a second one
  3970. * @param value defines the second matrix to compare
  3971. * @returns true is the current matrix and the given one values are strictly equal
  3972. */
  3973. equals(value: DeepImmutable<Matrix>): boolean;
  3974. /**
  3975. * Clone the current matrix
  3976. * @returns a new matrix from the current matrix
  3977. */
  3978. clone(): Matrix;
  3979. /**
  3980. * Returns the name of the current matrix class
  3981. * @returns the string "Matrix"
  3982. */
  3983. getClassName(): string;
  3984. /**
  3985. * Gets the hash code of the current matrix
  3986. * @returns the hash code
  3987. */
  3988. getHashCode(): number;
  3989. /**
  3990. * Decomposes the current Matrix into a translation, rotation and scaling components
  3991. * @param scale defines the scale vector3 given as a reference to update
  3992. * @param rotation defines the rotation quaternion given as a reference to update
  3993. * @param translation defines the translation vector3 given as a reference to update
  3994. * @returns true if operation was successful
  3995. */
  3996. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3997. /**
  3998. * Gets specific row of the matrix
  3999. * @param index defines the number of the row to get
  4000. * @returns the index-th row of the current matrix as a new Vector4
  4001. */
  4002. getRow(index: number): Nullable<Vector4>;
  4003. /**
  4004. * Sets the index-th row of the current matrix to the vector4 values
  4005. * @param index defines the number of the row to set
  4006. * @param row defines the target vector4
  4007. * @returns the updated current matrix
  4008. */
  4009. setRow(index: number, row: Vector4): Matrix;
  4010. /**
  4011. * Compute the transpose of the matrix
  4012. * @returns the new transposed matrix
  4013. */
  4014. transpose(): Matrix;
  4015. /**
  4016. * Compute the transpose of the matrix and store it in a given matrix
  4017. * @param result defines the target matrix
  4018. * @returns the current matrix
  4019. */
  4020. transposeToRef(result: Matrix): Matrix;
  4021. /**
  4022. * Sets the index-th row of the current matrix with the given 4 x float values
  4023. * @param index defines the row index
  4024. * @param x defines the x component to set
  4025. * @param y defines the y component to set
  4026. * @param z defines the z component to set
  4027. * @param w defines the w component to set
  4028. * @returns the updated current matrix
  4029. */
  4030. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4031. /**
  4032. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4033. * @param scale defines the scale factor
  4034. * @returns a new matrix
  4035. */
  4036. scale(scale: number): Matrix;
  4037. /**
  4038. * Scale the current matrix values by a factor to a given result matrix
  4039. * @param scale defines the scale factor
  4040. * @param result defines the matrix to store the result
  4041. * @returns the current matrix
  4042. */
  4043. scaleToRef(scale: number, result: Matrix): Matrix;
  4044. /**
  4045. * Scale the current matrix values by a factor and add the result to a given matrix
  4046. * @param scale defines the scale factor
  4047. * @param result defines the Matrix to store the result
  4048. * @returns the current matrix
  4049. */
  4050. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4051. /**
  4052. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4053. * @param ref matrix to store the result
  4054. */
  4055. toNormalMatrix(ref: Matrix): void;
  4056. /**
  4057. * Gets only rotation part of the current matrix
  4058. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4059. */
  4060. getRotationMatrix(): Matrix;
  4061. /**
  4062. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4063. * @param result defines the target matrix to store data to
  4064. * @returns the current matrix
  4065. */
  4066. getRotationMatrixToRef(result: Matrix): Matrix;
  4067. /**
  4068. * Toggles model matrix from being right handed to left handed in place and vice versa
  4069. */
  4070. toggleModelMatrixHandInPlace(): void;
  4071. /**
  4072. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4073. */
  4074. toggleProjectionMatrixHandInPlace(): void;
  4075. /**
  4076. * Creates a matrix from an array
  4077. * @param array defines the source array
  4078. * @param offset defines an offset in the source array
  4079. * @returns a new Matrix set from the starting index of the given array
  4080. */
  4081. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4082. /**
  4083. * Copy the content of an array into a given matrix
  4084. * @param array defines the source array
  4085. * @param offset defines an offset in the source array
  4086. * @param result defines the target matrix
  4087. */
  4088. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4089. /**
  4090. * Stores an array into a matrix after having multiplied each component by a given factor
  4091. * @param array defines the source array
  4092. * @param offset defines the offset in the source array
  4093. * @param scale defines the scaling factor
  4094. * @param result defines the target matrix
  4095. */
  4096. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4097. /**
  4098. * Gets an identity matrix that must not be updated
  4099. */
  4100. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4101. /**
  4102. * Stores a list of values (16) inside a given matrix
  4103. * @param initialM11 defines 1st value of 1st row
  4104. * @param initialM12 defines 2nd value of 1st row
  4105. * @param initialM13 defines 3rd value of 1st row
  4106. * @param initialM14 defines 4th value of 1st row
  4107. * @param initialM21 defines 1st value of 2nd row
  4108. * @param initialM22 defines 2nd value of 2nd row
  4109. * @param initialM23 defines 3rd value of 2nd row
  4110. * @param initialM24 defines 4th value of 2nd row
  4111. * @param initialM31 defines 1st value of 3rd row
  4112. * @param initialM32 defines 2nd value of 3rd row
  4113. * @param initialM33 defines 3rd value of 3rd row
  4114. * @param initialM34 defines 4th value of 3rd row
  4115. * @param initialM41 defines 1st value of 4th row
  4116. * @param initialM42 defines 2nd value of 4th row
  4117. * @param initialM43 defines 3rd value of 4th row
  4118. * @param initialM44 defines 4th value of 4th row
  4119. * @param result defines the target matrix
  4120. */
  4121. 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;
  4122. /**
  4123. * Creates new matrix from a list of values (16)
  4124. * @param initialM11 defines 1st value of 1st row
  4125. * @param initialM12 defines 2nd value of 1st row
  4126. * @param initialM13 defines 3rd value of 1st row
  4127. * @param initialM14 defines 4th value of 1st row
  4128. * @param initialM21 defines 1st value of 2nd row
  4129. * @param initialM22 defines 2nd value of 2nd row
  4130. * @param initialM23 defines 3rd value of 2nd row
  4131. * @param initialM24 defines 4th value of 2nd row
  4132. * @param initialM31 defines 1st value of 3rd row
  4133. * @param initialM32 defines 2nd value of 3rd row
  4134. * @param initialM33 defines 3rd value of 3rd row
  4135. * @param initialM34 defines 4th value of 3rd row
  4136. * @param initialM41 defines 1st value of 4th row
  4137. * @param initialM42 defines 2nd value of 4th row
  4138. * @param initialM43 defines 3rd value of 4th row
  4139. * @param initialM44 defines 4th value of 4th row
  4140. * @returns the new matrix
  4141. */
  4142. 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;
  4143. /**
  4144. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4145. * @param scale defines the scale vector3
  4146. * @param rotation defines the rotation quaternion
  4147. * @param translation defines the translation vector3
  4148. * @returns a new matrix
  4149. */
  4150. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4151. /**
  4152. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4153. * @param scale defines the scale vector3
  4154. * @param rotation defines the rotation quaternion
  4155. * @param translation defines the translation vector3
  4156. * @param result defines the target matrix
  4157. */
  4158. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4159. /**
  4160. * Creates a new identity matrix
  4161. * @returns a new identity matrix
  4162. */
  4163. static Identity(): Matrix;
  4164. /**
  4165. * Creates a new identity matrix and stores the result in a given matrix
  4166. * @param result defines the target matrix
  4167. */
  4168. static IdentityToRef(result: Matrix): void;
  4169. /**
  4170. * Creates a new zero matrix
  4171. * @returns a new zero matrix
  4172. */
  4173. static Zero(): Matrix;
  4174. /**
  4175. * Creates a new rotation matrix for "angle" radians around the X axis
  4176. * @param angle defines the angle (in radians) to use
  4177. * @return the new matrix
  4178. */
  4179. static RotationX(angle: number): Matrix;
  4180. /**
  4181. * Creates a new matrix as the invert of a given matrix
  4182. * @param source defines the source matrix
  4183. * @returns the new matrix
  4184. */
  4185. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4186. /**
  4187. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4188. * @param angle defines the angle (in radians) to use
  4189. * @param result defines the target matrix
  4190. */
  4191. static RotationXToRef(angle: number, result: Matrix): void;
  4192. /**
  4193. * Creates a new rotation matrix for "angle" radians around the Y axis
  4194. * @param angle defines the angle (in radians) to use
  4195. * @return the new matrix
  4196. */
  4197. static RotationY(angle: number): Matrix;
  4198. /**
  4199. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4200. * @param angle defines the angle (in radians) to use
  4201. * @param result defines the target matrix
  4202. */
  4203. static RotationYToRef(angle: number, result: Matrix): void;
  4204. /**
  4205. * Creates a new rotation matrix for "angle" radians around the Z axis
  4206. * @param angle defines the angle (in radians) to use
  4207. * @return the new matrix
  4208. */
  4209. static RotationZ(angle: number): Matrix;
  4210. /**
  4211. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4212. * @param angle defines the angle (in radians) to use
  4213. * @param result defines the target matrix
  4214. */
  4215. static RotationZToRef(angle: number, result: Matrix): void;
  4216. /**
  4217. * Creates a new rotation matrix for "angle" radians around the given axis
  4218. * @param axis defines the axis to use
  4219. * @param angle defines the angle (in radians) to use
  4220. * @return the new matrix
  4221. */
  4222. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4223. /**
  4224. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4225. * @param axis defines the axis to use
  4226. * @param angle defines the angle (in radians) to use
  4227. * @param result defines the target matrix
  4228. */
  4229. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4230. /**
  4231. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4232. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4233. * @param from defines the vector to align
  4234. * @param to defines the vector to align to
  4235. * @param result defines the target matrix
  4236. */
  4237. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4238. /**
  4239. * Creates a rotation matrix
  4240. * @param yaw defines the yaw angle in radians (Y axis)
  4241. * @param pitch defines the pitch angle in radians (X axis)
  4242. * @param roll defines the roll angle in radians (X axis)
  4243. * @returns the new rotation matrix
  4244. */
  4245. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4246. /**
  4247. * Creates a rotation matrix and stores it in a given matrix
  4248. * @param yaw defines the yaw angle in radians (Y axis)
  4249. * @param pitch defines the pitch angle in radians (X axis)
  4250. * @param roll defines the roll angle in radians (X axis)
  4251. * @param result defines the target matrix
  4252. */
  4253. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4254. /**
  4255. * Creates a scaling matrix
  4256. * @param x defines the scale factor on X axis
  4257. * @param y defines the scale factor on Y axis
  4258. * @param z defines the scale factor on Z axis
  4259. * @returns the new matrix
  4260. */
  4261. static Scaling(x: number, y: number, z: number): Matrix;
  4262. /**
  4263. * Creates a scaling matrix and stores it in a given matrix
  4264. * @param x defines the scale factor on X axis
  4265. * @param y defines the scale factor on Y axis
  4266. * @param z defines the scale factor on Z axis
  4267. * @param result defines the target matrix
  4268. */
  4269. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4270. /**
  4271. * Creates a translation matrix
  4272. * @param x defines the translation on X axis
  4273. * @param y defines the translation on Y axis
  4274. * @param z defines the translationon Z axis
  4275. * @returns the new matrix
  4276. */
  4277. static Translation(x: number, y: number, z: number): Matrix;
  4278. /**
  4279. * Creates a translation matrix and stores it in a given matrix
  4280. * @param x defines the translation on X axis
  4281. * @param y defines the translation on Y axis
  4282. * @param z defines the translationon Z axis
  4283. * @param result defines the target matrix
  4284. */
  4285. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4286. /**
  4287. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4288. * @param startValue defines the start value
  4289. * @param endValue defines the end value
  4290. * @param gradient defines the gradient factor
  4291. * @returns the new matrix
  4292. */
  4293. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4294. /**
  4295. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4296. * @param startValue defines the start value
  4297. * @param endValue defines the end value
  4298. * @param gradient defines the gradient factor
  4299. * @param result defines the Matrix object where to store data
  4300. */
  4301. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4302. /**
  4303. * Builds a new matrix whose values are computed by:
  4304. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4305. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4306. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4307. * @param startValue defines the first matrix
  4308. * @param endValue defines the second matrix
  4309. * @param gradient defines the gradient between the two matrices
  4310. * @returns the new matrix
  4311. */
  4312. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4313. /**
  4314. * Update a matrix to values which are computed by:
  4315. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4316. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4317. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4318. * @param startValue defines the first matrix
  4319. * @param endValue defines the second matrix
  4320. * @param gradient defines the gradient between the two matrices
  4321. * @param result defines the target matrix
  4322. */
  4323. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4324. /**
  4325. * 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"
  4326. * This function works in left handed mode
  4327. * @param eye defines the final position of the entity
  4328. * @param target defines where the entity should look at
  4329. * @param up defines the up vector for the entity
  4330. * @returns the new matrix
  4331. */
  4332. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4333. /**
  4334. * 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".
  4335. * This function works in left handed mode
  4336. * @param eye defines the final position of the entity
  4337. * @param target defines where the entity should look at
  4338. * @param up defines the up vector for the entity
  4339. * @param result defines the target matrix
  4340. */
  4341. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4342. /**
  4343. * 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"
  4344. * This function works in right handed mode
  4345. * @param eye defines the final position of the entity
  4346. * @param target defines where the entity should look at
  4347. * @param up defines the up vector for the entity
  4348. * @returns the new matrix
  4349. */
  4350. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4351. /**
  4352. * 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".
  4353. * This function works in right handed mode
  4354. * @param eye defines the final position of the entity
  4355. * @param target defines where the entity should look at
  4356. * @param up defines the up vector for the entity
  4357. * @param result defines the target matrix
  4358. */
  4359. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4360. /**
  4361. * Create a left-handed orthographic projection matrix
  4362. * @param width defines the viewport width
  4363. * @param height defines the viewport height
  4364. * @param znear defines the near clip plane
  4365. * @param zfar defines the far clip plane
  4366. * @returns a new matrix as a left-handed orthographic projection matrix
  4367. */
  4368. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4369. /**
  4370. * Store a left-handed orthographic projection to a given matrix
  4371. * @param width defines the viewport width
  4372. * @param height defines the viewport height
  4373. * @param znear defines the near clip plane
  4374. * @param zfar defines the far clip plane
  4375. * @param result defines the target matrix
  4376. */
  4377. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4378. /**
  4379. * Create a left-handed orthographic projection matrix
  4380. * @param left defines the viewport left coordinate
  4381. * @param right defines the viewport right coordinate
  4382. * @param bottom defines the viewport bottom coordinate
  4383. * @param top defines the viewport top coordinate
  4384. * @param znear defines the near clip plane
  4385. * @param zfar defines the far clip plane
  4386. * @returns a new matrix as a left-handed orthographic projection matrix
  4387. */
  4388. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4389. /**
  4390. * Stores a left-handed orthographic projection into a given matrix
  4391. * @param left defines the viewport left coordinate
  4392. * @param right defines the viewport right coordinate
  4393. * @param bottom defines the viewport bottom coordinate
  4394. * @param top defines the viewport top coordinate
  4395. * @param znear defines the near clip plane
  4396. * @param zfar defines the far clip plane
  4397. * @param result defines the target matrix
  4398. */
  4399. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4400. /**
  4401. * Creates a right-handed orthographic projection matrix
  4402. * @param left defines the viewport left coordinate
  4403. * @param right defines the viewport right coordinate
  4404. * @param bottom defines the viewport bottom coordinate
  4405. * @param top defines the viewport top coordinate
  4406. * @param znear defines the near clip plane
  4407. * @param zfar defines the far clip plane
  4408. * @returns a new matrix as a right-handed orthographic projection matrix
  4409. */
  4410. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4411. /**
  4412. * Stores a right-handed orthographic projection into a given matrix
  4413. * @param left defines the viewport left coordinate
  4414. * @param right defines the viewport right coordinate
  4415. * @param bottom defines the viewport bottom coordinate
  4416. * @param top defines the viewport top coordinate
  4417. * @param znear defines the near clip plane
  4418. * @param zfar defines the far clip plane
  4419. * @param result defines the target matrix
  4420. */
  4421. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4422. /**
  4423. * Creates a left-handed perspective projection matrix
  4424. * @param width defines the viewport width
  4425. * @param height defines the viewport height
  4426. * @param znear defines the near clip plane
  4427. * @param zfar defines the far clip plane
  4428. * @returns a new matrix as a left-handed perspective projection matrix
  4429. */
  4430. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4431. /**
  4432. * Creates a left-handed perspective projection matrix
  4433. * @param fov defines the horizontal field of view
  4434. * @param aspect defines the aspect ratio
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @returns a new matrix as a left-handed perspective projection matrix
  4438. */
  4439. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4440. /**
  4441. * Stores a left-handed perspective projection into a given matrix
  4442. * @param fov defines the horizontal field of view
  4443. * @param aspect defines the aspect ratio
  4444. * @param znear defines the near clip plane
  4445. * @param zfar defines the far clip plane
  4446. * @param result defines the target matrix
  4447. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4448. */
  4449. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4450. /**
  4451. * Creates a right-handed perspective projection matrix
  4452. * @param fov defines the horizontal field of view
  4453. * @param aspect defines the aspect ratio
  4454. * @param znear defines the near clip plane
  4455. * @param zfar defines the far clip plane
  4456. * @returns a new matrix as a right-handed perspective projection matrix
  4457. */
  4458. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4459. /**
  4460. * Stores a right-handed perspective projection into a given matrix
  4461. * @param fov defines the horizontal field of view
  4462. * @param aspect defines the aspect ratio
  4463. * @param znear defines the near clip plane
  4464. * @param zfar defines the far clip plane
  4465. * @param result defines the target matrix
  4466. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4467. */
  4468. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4469. /**
  4470. * Stores a perspective projection for WebVR info a given matrix
  4471. * @param fov defines the field of view
  4472. * @param znear defines the near clip plane
  4473. * @param zfar defines the far clip plane
  4474. * @param result defines the target matrix
  4475. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4476. */
  4477. static PerspectiveFovWebVRToRef(fov: {
  4478. upDegrees: number;
  4479. downDegrees: number;
  4480. leftDegrees: number;
  4481. rightDegrees: number;
  4482. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4483. /**
  4484. * Computes a complete transformation matrix
  4485. * @param viewport defines the viewport to use
  4486. * @param world defines the world matrix
  4487. * @param view defines the view matrix
  4488. * @param projection defines the projection matrix
  4489. * @param zmin defines the near clip plane
  4490. * @param zmax defines the far clip plane
  4491. * @returns the transformation matrix
  4492. */
  4493. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4494. /**
  4495. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4496. * @param matrix defines the matrix to use
  4497. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4498. */
  4499. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4500. /**
  4501. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4502. * @param matrix defines the matrix to use
  4503. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4504. */
  4505. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4506. /**
  4507. * Compute the transpose of a given matrix
  4508. * @param matrix defines the matrix to transpose
  4509. * @returns the new matrix
  4510. */
  4511. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4512. /**
  4513. * Compute the transpose of a matrix and store it in a target matrix
  4514. * @param matrix defines the matrix to transpose
  4515. * @param result defines the target matrix
  4516. */
  4517. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4518. /**
  4519. * Computes a reflection matrix from a plane
  4520. * @param plane defines the reflection plane
  4521. * @returns a new matrix
  4522. */
  4523. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4524. /**
  4525. * Computes a reflection matrix from a plane
  4526. * @param plane defines the reflection plane
  4527. * @param result defines the target matrix
  4528. */
  4529. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4530. /**
  4531. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4532. * @param xaxis defines the value of the 1st axis
  4533. * @param yaxis defines the value of the 2nd axis
  4534. * @param zaxis defines the value of the 3rd axis
  4535. * @param result defines the target matrix
  4536. */
  4537. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4538. /**
  4539. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4540. * @param quat defines the quaternion to use
  4541. * @param result defines the target matrix
  4542. */
  4543. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4544. }
  4545. /**
  4546. * @hidden
  4547. */
  4548. export class TmpVectors {
  4549. static Vector2: Vector2[];
  4550. static Vector3: Vector3[];
  4551. static Vector4: Vector4[];
  4552. static Quaternion: Quaternion[];
  4553. static Matrix: Matrix[];
  4554. }
  4555. }
  4556. declare module BABYLON {
  4557. /**
  4558. * Defines potential orientation for back face culling
  4559. */
  4560. export enum Orientation {
  4561. /**
  4562. * Clockwise
  4563. */
  4564. CW = 0,
  4565. /** Counter clockwise */
  4566. CCW = 1
  4567. }
  4568. /** Class used to represent a Bezier curve */
  4569. export class BezierCurve {
  4570. /**
  4571. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4572. * @param t defines the time
  4573. * @param x1 defines the left coordinate on X axis
  4574. * @param y1 defines the left coordinate on Y axis
  4575. * @param x2 defines the right coordinate on X axis
  4576. * @param y2 defines the right coordinate on Y axis
  4577. * @returns the interpolated value
  4578. */
  4579. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4580. }
  4581. /**
  4582. * Defines angle representation
  4583. */
  4584. export class Angle {
  4585. private _radians;
  4586. /**
  4587. * Creates an Angle object of "radians" radians (float).
  4588. * @param radians the angle in radians
  4589. */
  4590. constructor(radians: number);
  4591. /**
  4592. * Get value in degrees
  4593. * @returns the Angle value in degrees (float)
  4594. */
  4595. degrees(): number;
  4596. /**
  4597. * Get value in radians
  4598. * @returns the Angle value in radians (float)
  4599. */
  4600. radians(): number;
  4601. /**
  4602. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4603. * @param a defines first vector
  4604. * @param b defines second vector
  4605. * @returns a new Angle
  4606. */
  4607. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4608. /**
  4609. * Gets a new Angle object from the given float in radians
  4610. * @param radians defines the angle value in radians
  4611. * @returns a new Angle
  4612. */
  4613. static FromRadians(radians: number): Angle;
  4614. /**
  4615. * Gets a new Angle object from the given float in degrees
  4616. * @param degrees defines the angle value in degrees
  4617. * @returns a new Angle
  4618. */
  4619. static FromDegrees(degrees: number): Angle;
  4620. }
  4621. /**
  4622. * This represents an arc in a 2d space.
  4623. */
  4624. export class Arc2 {
  4625. /** Defines the start point of the arc */
  4626. startPoint: Vector2;
  4627. /** Defines the mid point of the arc */
  4628. midPoint: Vector2;
  4629. /** Defines the end point of the arc */
  4630. endPoint: Vector2;
  4631. /**
  4632. * Defines the center point of the arc.
  4633. */
  4634. centerPoint: Vector2;
  4635. /**
  4636. * Defines the radius of the arc.
  4637. */
  4638. radius: number;
  4639. /**
  4640. * Defines the angle of the arc (from mid point to end point).
  4641. */
  4642. angle: Angle;
  4643. /**
  4644. * Defines the start angle of the arc (from start point to middle point).
  4645. */
  4646. startAngle: Angle;
  4647. /**
  4648. * Defines the orientation of the arc (clock wise/counter clock wise).
  4649. */
  4650. orientation: Orientation;
  4651. /**
  4652. * Creates an Arc object from the three given points : start, middle and end.
  4653. * @param startPoint Defines the start point of the arc
  4654. * @param midPoint Defines the midlle point of the arc
  4655. * @param endPoint Defines the end point of the arc
  4656. */
  4657. constructor(
  4658. /** Defines the start point of the arc */
  4659. startPoint: Vector2,
  4660. /** Defines the mid point of the arc */
  4661. midPoint: Vector2,
  4662. /** Defines the end point of the arc */
  4663. endPoint: Vector2);
  4664. }
  4665. /**
  4666. * Represents a 2D path made up of multiple 2D points
  4667. */
  4668. export class Path2 {
  4669. private _points;
  4670. private _length;
  4671. /**
  4672. * If the path start and end point are the same
  4673. */
  4674. closed: boolean;
  4675. /**
  4676. * Creates a Path2 object from the starting 2D coordinates x and y.
  4677. * @param x the starting points x value
  4678. * @param y the starting points y value
  4679. */
  4680. constructor(x: number, y: number);
  4681. /**
  4682. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4683. * @param x the added points x value
  4684. * @param y the added points y value
  4685. * @returns the updated Path2.
  4686. */
  4687. addLineTo(x: number, y: number): Path2;
  4688. /**
  4689. * 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.
  4690. * @param midX middle point x value
  4691. * @param midY middle point y value
  4692. * @param endX end point x value
  4693. * @param endY end point y value
  4694. * @param numberOfSegments (default: 36)
  4695. * @returns the updated Path2.
  4696. */
  4697. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4698. /**
  4699. * Closes the Path2.
  4700. * @returns the Path2.
  4701. */
  4702. close(): Path2;
  4703. /**
  4704. * Gets the sum of the distance between each sequential point in the path
  4705. * @returns the Path2 total length (float).
  4706. */
  4707. length(): number;
  4708. /**
  4709. * Gets the points which construct the path
  4710. * @returns the Path2 internal array of points.
  4711. */
  4712. getPoints(): Vector2[];
  4713. /**
  4714. * Retreives the point at the distance aways from the starting point
  4715. * @param normalizedLengthPosition the length along the path to retreive the point from
  4716. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4717. */
  4718. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4719. /**
  4720. * Creates a new path starting from an x and y position
  4721. * @param x starting x value
  4722. * @param y starting y value
  4723. * @returns a new Path2 starting at the coordinates (x, y).
  4724. */
  4725. static StartingAt(x: number, y: number): Path2;
  4726. }
  4727. /**
  4728. * Represents a 3D path made up of multiple 3D points
  4729. */
  4730. export class Path3D {
  4731. /**
  4732. * an array of Vector3, the curve axis of the Path3D
  4733. */
  4734. path: Vector3[];
  4735. private _curve;
  4736. private _distances;
  4737. private _tangents;
  4738. private _normals;
  4739. private _binormals;
  4740. private _raw;
  4741. /**
  4742. * new Path3D(path, normal, raw)
  4743. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4744. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4745. * @param path an array of Vector3, the curve axis of the Path3D
  4746. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4747. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4748. */
  4749. constructor(
  4750. /**
  4751. * an array of Vector3, the curve axis of the Path3D
  4752. */
  4753. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4754. /**
  4755. * Returns the Path3D array of successive Vector3 designing its curve.
  4756. * @returns the Path3D array of successive Vector3 designing its curve.
  4757. */
  4758. getCurve(): Vector3[];
  4759. /**
  4760. * Returns an array populated with tangent vectors on each Path3D curve point.
  4761. * @returns an array populated with tangent vectors on each Path3D curve point.
  4762. */
  4763. getTangents(): Vector3[];
  4764. /**
  4765. * Returns an array populated with normal vectors on each Path3D curve point.
  4766. * @returns an array populated with normal vectors on each Path3D curve point.
  4767. */
  4768. getNormals(): Vector3[];
  4769. /**
  4770. * Returns an array populated with binormal vectors on each Path3D curve point.
  4771. * @returns an array populated with binormal vectors on each Path3D curve point.
  4772. */
  4773. getBinormals(): Vector3[];
  4774. /**
  4775. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4776. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4777. */
  4778. getDistances(): number[];
  4779. /**
  4780. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4781. * @param path path which all values are copied into the curves points
  4782. * @param firstNormal which should be projected onto the curve
  4783. * @returns the same object updated.
  4784. */
  4785. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4786. private _compute;
  4787. private _getFirstNonNullVector;
  4788. private _getLastNonNullVector;
  4789. private _normalVector;
  4790. }
  4791. /**
  4792. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4793. * A Curve3 is designed from a series of successive Vector3.
  4794. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4795. */
  4796. export class Curve3 {
  4797. private _points;
  4798. private _length;
  4799. /**
  4800. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4801. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4802. * @param v1 (Vector3) the control point
  4803. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4804. * @param nbPoints (integer) the wanted number of points in the curve
  4805. * @returns the created Curve3
  4806. */
  4807. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4808. /**
  4809. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4810. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4811. * @param v1 (Vector3) the first control point
  4812. * @param v2 (Vector3) the second control point
  4813. * @param v3 (Vector3) the end point of the Cubic Bezier
  4814. * @param nbPoints (integer) the wanted number of points in the curve
  4815. * @returns the created Curve3
  4816. */
  4817. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4818. /**
  4819. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4820. * @param p1 (Vector3) the origin point of the Hermite Spline
  4821. * @param t1 (Vector3) the tangent vector at the origin point
  4822. * @param p2 (Vector3) the end point of the Hermite Spline
  4823. * @param t2 (Vector3) the tangent vector at the end point
  4824. * @param nbPoints (integer) the wanted number of points in the curve
  4825. * @returns the created Curve3
  4826. */
  4827. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4828. /**
  4829. * Returns a Curve3 object along a CatmullRom Spline curve :
  4830. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4831. * @param nbPoints (integer) the wanted number of points between each curve control points
  4832. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4833. * @returns the created Curve3
  4834. */
  4835. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4836. /**
  4837. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4838. * A Curve3 is designed from a series of successive Vector3.
  4839. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4840. * @param points points which make up the curve
  4841. */
  4842. constructor(points: Vector3[]);
  4843. /**
  4844. * @returns the Curve3 stored array of successive Vector3
  4845. */
  4846. getPoints(): Vector3[];
  4847. /**
  4848. * @returns the computed length (float) of the curve.
  4849. */
  4850. length(): number;
  4851. /**
  4852. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4853. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4854. * curveA and curveB keep unchanged.
  4855. * @param curve the curve to continue from this curve
  4856. * @returns the newly constructed curve
  4857. */
  4858. continue(curve: DeepImmutable<Curve3>): Curve3;
  4859. private _computeLength;
  4860. }
  4861. }
  4862. declare module BABYLON {
  4863. /**
  4864. * This represents the main contract an easing function should follow.
  4865. * Easing functions are used throughout the animation system.
  4866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4867. */
  4868. export interface IEasingFunction {
  4869. /**
  4870. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4871. * of the easing function.
  4872. * The link below provides some of the most common examples of easing functions.
  4873. * @see https://easings.net/
  4874. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4875. * @returns the corresponding value on the curve defined by the easing function
  4876. */
  4877. ease(gradient: number): number;
  4878. }
  4879. /**
  4880. * Base class used for every default easing function.
  4881. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4882. */
  4883. export class EasingFunction implements IEasingFunction {
  4884. /**
  4885. * Interpolation follows the mathematical formula associated with the easing function.
  4886. */
  4887. static readonly EASINGMODE_EASEIN: number;
  4888. /**
  4889. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4890. */
  4891. static readonly EASINGMODE_EASEOUT: number;
  4892. /**
  4893. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4894. */
  4895. static readonly EASINGMODE_EASEINOUT: number;
  4896. private _easingMode;
  4897. /**
  4898. * Sets the easing mode of the current function.
  4899. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4900. */
  4901. setEasingMode(easingMode: number): void;
  4902. /**
  4903. * Gets the current easing mode.
  4904. * @returns the easing mode
  4905. */
  4906. getEasingMode(): number;
  4907. /**
  4908. * @hidden
  4909. */
  4910. easeInCore(gradient: number): number;
  4911. /**
  4912. * Given an input gradient between 0 and 1, this returns the corresponding value
  4913. * of the easing function.
  4914. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4915. * @returns the corresponding value on the curve defined by the easing function
  4916. */
  4917. ease(gradient: number): number;
  4918. }
  4919. /**
  4920. * Easing function with a circle shape (see link below).
  4921. * @see https://easings.net/#easeInCirc
  4922. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4923. */
  4924. export class CircleEase extends EasingFunction implements IEasingFunction {
  4925. /** @hidden */
  4926. easeInCore(gradient: number): number;
  4927. }
  4928. /**
  4929. * Easing function with a ease back shape (see link below).
  4930. * @see https://easings.net/#easeInBack
  4931. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4932. */
  4933. export class BackEase extends EasingFunction implements IEasingFunction {
  4934. /** Defines the amplitude of the function */
  4935. amplitude: number;
  4936. /**
  4937. * Instantiates a back ease easing
  4938. * @see https://easings.net/#easeInBack
  4939. * @param amplitude Defines the amplitude of the function
  4940. */
  4941. constructor(
  4942. /** Defines the amplitude of the function */
  4943. amplitude?: number);
  4944. /** @hidden */
  4945. easeInCore(gradient: number): number;
  4946. }
  4947. /**
  4948. * Easing function with a bouncing shape (see link below).
  4949. * @see https://easings.net/#easeInBounce
  4950. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4951. */
  4952. export class BounceEase extends EasingFunction implements IEasingFunction {
  4953. /** Defines the number of bounces */
  4954. bounces: number;
  4955. /** Defines the amplitude of the bounce */
  4956. bounciness: number;
  4957. /**
  4958. * Instantiates a bounce easing
  4959. * @see https://easings.net/#easeInBounce
  4960. * @param bounces Defines the number of bounces
  4961. * @param bounciness Defines the amplitude of the bounce
  4962. */
  4963. constructor(
  4964. /** Defines the number of bounces */
  4965. bounces?: number,
  4966. /** Defines the amplitude of the bounce */
  4967. bounciness?: number);
  4968. /** @hidden */
  4969. easeInCore(gradient: number): number;
  4970. }
  4971. /**
  4972. * Easing function with a power of 3 shape (see link below).
  4973. * @see https://easings.net/#easeInCubic
  4974. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4975. */
  4976. export class CubicEase extends EasingFunction implements IEasingFunction {
  4977. /** @hidden */
  4978. easeInCore(gradient: number): number;
  4979. }
  4980. /**
  4981. * Easing function with an elastic shape (see link below).
  4982. * @see https://easings.net/#easeInElastic
  4983. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4984. */
  4985. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4986. /** Defines the number of oscillations*/
  4987. oscillations: number;
  4988. /** Defines the amplitude of the oscillations*/
  4989. springiness: number;
  4990. /**
  4991. * Instantiates an elastic easing function
  4992. * @see https://easings.net/#easeInElastic
  4993. * @param oscillations Defines the number of oscillations
  4994. * @param springiness Defines the amplitude of the oscillations
  4995. */
  4996. constructor(
  4997. /** Defines the number of oscillations*/
  4998. oscillations?: number,
  4999. /** Defines the amplitude of the oscillations*/
  5000. springiness?: number);
  5001. /** @hidden */
  5002. easeInCore(gradient: number): number;
  5003. }
  5004. /**
  5005. * Easing function with an exponential shape (see link below).
  5006. * @see https://easings.net/#easeInExpo
  5007. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5008. */
  5009. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5010. /** Defines the exponent of the function */
  5011. exponent: number;
  5012. /**
  5013. * Instantiates an exponential easing function
  5014. * @see https://easings.net/#easeInExpo
  5015. * @param exponent Defines the exponent of the function
  5016. */
  5017. constructor(
  5018. /** Defines the exponent of the function */
  5019. exponent?: number);
  5020. /** @hidden */
  5021. easeInCore(gradient: number): number;
  5022. }
  5023. /**
  5024. * Easing function with a power shape (see link below).
  5025. * @see https://easings.net/#easeInQuad
  5026. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5027. */
  5028. export class PowerEase extends EasingFunction implements IEasingFunction {
  5029. /** Defines the power of the function */
  5030. power: number;
  5031. /**
  5032. * Instantiates an power base easing function
  5033. * @see https://easings.net/#easeInQuad
  5034. * @param power Defines the power of the function
  5035. */
  5036. constructor(
  5037. /** Defines the power of the function */
  5038. power?: number);
  5039. /** @hidden */
  5040. easeInCore(gradient: number): number;
  5041. }
  5042. /**
  5043. * Easing function with a power of 2 shape (see link below).
  5044. * @see https://easings.net/#easeInQuad
  5045. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5046. */
  5047. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5048. /** @hidden */
  5049. easeInCore(gradient: number): number;
  5050. }
  5051. /**
  5052. * Easing function with a power of 4 shape (see link below).
  5053. * @see https://easings.net/#easeInQuart
  5054. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5055. */
  5056. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5057. /** @hidden */
  5058. easeInCore(gradient: number): number;
  5059. }
  5060. /**
  5061. * Easing function with a power of 5 shape (see link below).
  5062. * @see https://easings.net/#easeInQuint
  5063. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5064. */
  5065. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5066. /** @hidden */
  5067. easeInCore(gradient: number): number;
  5068. }
  5069. /**
  5070. * Easing function with a sin shape (see link below).
  5071. * @see https://easings.net/#easeInSine
  5072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5073. */
  5074. export class SineEase extends EasingFunction implements IEasingFunction {
  5075. /** @hidden */
  5076. easeInCore(gradient: number): number;
  5077. }
  5078. /**
  5079. * Easing function with a bezier shape (see link below).
  5080. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5082. */
  5083. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5084. /** Defines the x component of the start tangent in the bezier curve */
  5085. x1: number;
  5086. /** Defines the y component of the start tangent in the bezier curve */
  5087. y1: number;
  5088. /** Defines the x component of the end tangent in the bezier curve */
  5089. x2: number;
  5090. /** Defines the y component of the end tangent in the bezier curve */
  5091. y2: number;
  5092. /**
  5093. * Instantiates a bezier function
  5094. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5095. * @param x1 Defines the x component of the start tangent in the bezier curve
  5096. * @param y1 Defines the y component of the start tangent in the bezier curve
  5097. * @param x2 Defines the x component of the end tangent in the bezier curve
  5098. * @param y2 Defines the y component of the end tangent in the bezier curve
  5099. */
  5100. constructor(
  5101. /** Defines the x component of the start tangent in the bezier curve */
  5102. x1?: number,
  5103. /** Defines the y component of the start tangent in the bezier curve */
  5104. y1?: number,
  5105. /** Defines the x component of the end tangent in the bezier curve */
  5106. x2?: number,
  5107. /** Defines the y component of the end tangent in the bezier curve */
  5108. y2?: number);
  5109. /** @hidden */
  5110. easeInCore(gradient: number): number;
  5111. }
  5112. }
  5113. declare module BABYLON {
  5114. /**
  5115. * Class used to hold a RBG color
  5116. */
  5117. export class Color3 {
  5118. /**
  5119. * Defines the red component (between 0 and 1, default is 0)
  5120. */
  5121. r: number;
  5122. /**
  5123. * Defines the green component (between 0 and 1, default is 0)
  5124. */
  5125. g: number;
  5126. /**
  5127. * Defines the blue component (between 0 and 1, default is 0)
  5128. */
  5129. b: number;
  5130. /**
  5131. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5132. * @param r defines the red component (between 0 and 1, default is 0)
  5133. * @param g defines the green component (between 0 and 1, default is 0)
  5134. * @param b defines the blue component (between 0 and 1, default is 0)
  5135. */
  5136. constructor(
  5137. /**
  5138. * Defines the red component (between 0 and 1, default is 0)
  5139. */
  5140. r?: number,
  5141. /**
  5142. * Defines the green component (between 0 and 1, default is 0)
  5143. */
  5144. g?: number,
  5145. /**
  5146. * Defines the blue component (between 0 and 1, default is 0)
  5147. */
  5148. b?: number);
  5149. /**
  5150. * Creates a string with the Color3 current values
  5151. * @returns the string representation of the Color3 object
  5152. */
  5153. toString(): string;
  5154. /**
  5155. * Returns the string "Color3"
  5156. * @returns "Color3"
  5157. */
  5158. getClassName(): string;
  5159. /**
  5160. * Compute the Color3 hash code
  5161. * @returns an unique number that can be used to hash Color3 objects
  5162. */
  5163. getHashCode(): number;
  5164. /**
  5165. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5166. * @param array defines the array where to store the r,g,b components
  5167. * @param index defines an optional index in the target array to define where to start storing values
  5168. * @returns the current Color3 object
  5169. */
  5170. toArray(array: FloatArray, index?: number): Color3;
  5171. /**
  5172. * Returns a new Color4 object from the current Color3 and the given alpha
  5173. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5174. * @returns a new Color4 object
  5175. */
  5176. toColor4(alpha?: number): Color4;
  5177. /**
  5178. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5179. * @returns the new array
  5180. */
  5181. asArray(): number[];
  5182. /**
  5183. * Returns the luminance value
  5184. * @returns a float value
  5185. */
  5186. toLuminance(): number;
  5187. /**
  5188. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5189. * @param otherColor defines the second operand
  5190. * @returns the new Color3 object
  5191. */
  5192. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5193. /**
  5194. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5195. * @param otherColor defines the second operand
  5196. * @param result defines the Color3 object where to store the result
  5197. * @returns the current Color3
  5198. */
  5199. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5200. /**
  5201. * Determines equality between Color3 objects
  5202. * @param otherColor defines the second operand
  5203. * @returns true if the rgb values are equal to the given ones
  5204. */
  5205. equals(otherColor: DeepImmutable<Color3>): boolean;
  5206. /**
  5207. * Determines equality between the current Color3 object and a set of r,b,g values
  5208. * @param r defines the red component to check
  5209. * @param g defines the green component to check
  5210. * @param b defines the blue component to check
  5211. * @returns true if the rgb values are equal to the given ones
  5212. */
  5213. equalsFloats(r: number, g: number, b: number): boolean;
  5214. /**
  5215. * Multiplies in place each rgb value by scale
  5216. * @param scale defines the scaling factor
  5217. * @returns the updated Color3
  5218. */
  5219. scale(scale: number): Color3;
  5220. /**
  5221. * Multiplies the rgb values by scale and stores the result into "result"
  5222. * @param scale defines the scaling factor
  5223. * @param result defines the Color3 object where to store the result
  5224. * @returns the unmodified current Color3
  5225. */
  5226. scaleToRef(scale: number, result: Color3): Color3;
  5227. /**
  5228. * Scale the current Color3 values by a factor and add the result to a given Color3
  5229. * @param scale defines the scale factor
  5230. * @param result defines color to store the result into
  5231. * @returns the unmodified current Color3
  5232. */
  5233. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5234. /**
  5235. * Clamps the rgb values by the min and max values and stores the result into "result"
  5236. * @param min defines minimum clamping value (default is 0)
  5237. * @param max defines maximum clamping value (default is 1)
  5238. * @param result defines color to store the result into
  5239. * @returns the original Color3
  5240. */
  5241. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5242. /**
  5243. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5244. * @param otherColor defines the second operand
  5245. * @returns the new Color3
  5246. */
  5247. add(otherColor: DeepImmutable<Color3>): Color3;
  5248. /**
  5249. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5250. * @param otherColor defines the second operand
  5251. * @param result defines Color3 object to store the result into
  5252. * @returns the unmodified current Color3
  5253. */
  5254. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5255. /**
  5256. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5257. * @param otherColor defines the second operand
  5258. * @returns the new Color3
  5259. */
  5260. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5261. /**
  5262. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5263. * @param otherColor defines the second operand
  5264. * @param result defines Color3 object to store the result into
  5265. * @returns the unmodified current Color3
  5266. */
  5267. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5268. /**
  5269. * Copy the current object
  5270. * @returns a new Color3 copied the current one
  5271. */
  5272. clone(): Color3;
  5273. /**
  5274. * Copies the rgb values from the source in the current Color3
  5275. * @param source defines the source Color3 object
  5276. * @returns the updated Color3 object
  5277. */
  5278. copyFrom(source: DeepImmutable<Color3>): Color3;
  5279. /**
  5280. * Updates the Color3 rgb values from the given floats
  5281. * @param r defines the red component to read from
  5282. * @param g defines the green component to read from
  5283. * @param b defines the blue component to read from
  5284. * @returns the current Color3 object
  5285. */
  5286. copyFromFloats(r: number, g: number, b: number): Color3;
  5287. /**
  5288. * Updates the Color3 rgb values from the given floats
  5289. * @param r defines the red component to read from
  5290. * @param g defines the green component to read from
  5291. * @param b defines the blue component to read from
  5292. * @returns the current Color3 object
  5293. */
  5294. set(r: number, g: number, b: number): Color3;
  5295. /**
  5296. * Compute the Color3 hexadecimal code as a string
  5297. * @returns a string containing the hexadecimal representation of the Color3 object
  5298. */
  5299. toHexString(): string;
  5300. /**
  5301. * Computes a new Color3 converted from the current one to linear space
  5302. * @returns a new Color3 object
  5303. */
  5304. toLinearSpace(): Color3;
  5305. /**
  5306. * Converts current color in rgb space to HSV values
  5307. * @returns a new color3 representing the HSV values
  5308. */
  5309. toHSV(): Color3;
  5310. /**
  5311. * Converts current color in rgb space to HSV values
  5312. * @param result defines the Color3 where to store the HSV values
  5313. */
  5314. toHSVToRef(result: Color3): void;
  5315. /**
  5316. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5317. * @param convertedColor defines the Color3 object where to store the linear space version
  5318. * @returns the unmodified Color3
  5319. */
  5320. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5321. /**
  5322. * Computes a new Color3 converted from the current one to gamma space
  5323. * @returns a new Color3 object
  5324. */
  5325. toGammaSpace(): Color3;
  5326. /**
  5327. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5328. * @param convertedColor defines the Color3 object where to store the gamma space version
  5329. * @returns the unmodified Color3
  5330. */
  5331. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5332. private static _BlackReadOnly;
  5333. /**
  5334. * Convert Hue, saturation and value to a Color3 (RGB)
  5335. * @param hue defines the hue
  5336. * @param saturation defines the saturation
  5337. * @param value defines the value
  5338. * @param result defines the Color3 where to store the RGB values
  5339. */
  5340. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5341. /**
  5342. * Creates a new Color3 from the string containing valid hexadecimal values
  5343. * @param hex defines a string containing valid hexadecimal values
  5344. * @returns a new Color3 object
  5345. */
  5346. static FromHexString(hex: string): Color3;
  5347. /**
  5348. * Creates a new Color3 from the starting index of the given array
  5349. * @param array defines the source array
  5350. * @param offset defines an offset in the source array
  5351. * @returns a new Color3 object
  5352. */
  5353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5354. /**
  5355. * Creates a new Color3 from integer values (< 256)
  5356. * @param r defines the red component to read from (value between 0 and 255)
  5357. * @param g defines the green component to read from (value between 0 and 255)
  5358. * @param b defines the blue component to read from (value between 0 and 255)
  5359. * @returns a new Color3 object
  5360. */
  5361. static FromInts(r: number, g: number, b: number): Color3;
  5362. /**
  5363. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5364. * @param start defines the start Color3 value
  5365. * @param end defines the end Color3 value
  5366. * @param amount defines the gradient value between start and end
  5367. * @returns a new Color3 object
  5368. */
  5369. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5370. /**
  5371. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5372. * @param left defines the start value
  5373. * @param right defines the end value
  5374. * @param amount defines the gradient factor
  5375. * @param result defines the Color3 object where to store the result
  5376. */
  5377. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5378. /**
  5379. * Returns a Color3 value containing a red color
  5380. * @returns a new Color3 object
  5381. */
  5382. static Red(): Color3;
  5383. /**
  5384. * Returns a Color3 value containing a green color
  5385. * @returns a new Color3 object
  5386. */
  5387. static Green(): Color3;
  5388. /**
  5389. * Returns a Color3 value containing a blue color
  5390. * @returns a new Color3 object
  5391. */
  5392. static Blue(): Color3;
  5393. /**
  5394. * Returns a Color3 value containing a black color
  5395. * @returns a new Color3 object
  5396. */
  5397. static Black(): Color3;
  5398. /**
  5399. * Gets a Color3 value containing a black color that must not be updated
  5400. */
  5401. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5402. /**
  5403. * Returns a Color3 value containing a white color
  5404. * @returns a new Color3 object
  5405. */
  5406. static White(): Color3;
  5407. /**
  5408. * Returns a Color3 value containing a purple color
  5409. * @returns a new Color3 object
  5410. */
  5411. static Purple(): Color3;
  5412. /**
  5413. * Returns a Color3 value containing a magenta color
  5414. * @returns a new Color3 object
  5415. */
  5416. static Magenta(): Color3;
  5417. /**
  5418. * Returns a Color3 value containing a yellow color
  5419. * @returns a new Color3 object
  5420. */
  5421. static Yellow(): Color3;
  5422. /**
  5423. * Returns a Color3 value containing a gray color
  5424. * @returns a new Color3 object
  5425. */
  5426. static Gray(): Color3;
  5427. /**
  5428. * Returns a Color3 value containing a teal color
  5429. * @returns a new Color3 object
  5430. */
  5431. static Teal(): Color3;
  5432. /**
  5433. * Returns a Color3 value containing a random color
  5434. * @returns a new Color3 object
  5435. */
  5436. static Random(): Color3;
  5437. }
  5438. /**
  5439. * Class used to hold a RBGA color
  5440. */
  5441. export class Color4 {
  5442. /**
  5443. * Defines the red component (between 0 and 1, default is 0)
  5444. */
  5445. r: number;
  5446. /**
  5447. * Defines the green component (between 0 and 1, default is 0)
  5448. */
  5449. g: number;
  5450. /**
  5451. * Defines the blue component (between 0 and 1, default is 0)
  5452. */
  5453. b: number;
  5454. /**
  5455. * Defines the alpha component (between 0 and 1, default is 1)
  5456. */
  5457. a: number;
  5458. /**
  5459. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5460. * @param r defines the red component (between 0 and 1, default is 0)
  5461. * @param g defines the green component (between 0 and 1, default is 0)
  5462. * @param b defines the blue component (between 0 and 1, default is 0)
  5463. * @param a defines the alpha component (between 0 and 1, default is 1)
  5464. */
  5465. constructor(
  5466. /**
  5467. * Defines the red component (between 0 and 1, default is 0)
  5468. */
  5469. r?: number,
  5470. /**
  5471. * Defines the green component (between 0 and 1, default is 0)
  5472. */
  5473. g?: number,
  5474. /**
  5475. * Defines the blue component (between 0 and 1, default is 0)
  5476. */
  5477. b?: number,
  5478. /**
  5479. * Defines the alpha component (between 0 and 1, default is 1)
  5480. */
  5481. a?: number);
  5482. /**
  5483. * Adds in place the given Color4 values to the current Color4 object
  5484. * @param right defines the second operand
  5485. * @returns the current updated Color4 object
  5486. */
  5487. addInPlace(right: DeepImmutable<Color4>): Color4;
  5488. /**
  5489. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5490. * @returns the new array
  5491. */
  5492. asArray(): number[];
  5493. /**
  5494. * Stores from the starting index in the given array the Color4 successive values
  5495. * @param array defines the array where to store the r,g,b components
  5496. * @param index defines an optional index in the target array to define where to start storing values
  5497. * @returns the current Color4 object
  5498. */
  5499. toArray(array: number[], index?: number): Color4;
  5500. /**
  5501. * Determines equality between Color4 objects
  5502. * @param otherColor defines the second operand
  5503. * @returns true if the rgba values are equal to the given ones
  5504. */
  5505. equals(otherColor: DeepImmutable<Color4>): boolean;
  5506. /**
  5507. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5508. * @param right defines the second operand
  5509. * @returns a new Color4 object
  5510. */
  5511. add(right: DeepImmutable<Color4>): Color4;
  5512. /**
  5513. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5514. * @param right defines the second operand
  5515. * @returns a new Color4 object
  5516. */
  5517. subtract(right: DeepImmutable<Color4>): Color4;
  5518. /**
  5519. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5520. * @param right defines the second operand
  5521. * @param result defines the Color4 object where to store the result
  5522. * @returns the current Color4 object
  5523. */
  5524. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5525. /**
  5526. * Creates a new Color4 with the current Color4 values multiplied by scale
  5527. * @param scale defines the scaling factor to apply
  5528. * @returns a new Color4 object
  5529. */
  5530. scale(scale: number): Color4;
  5531. /**
  5532. * Multiplies the current Color4 values by scale and stores the result in "result"
  5533. * @param scale defines the scaling factor to apply
  5534. * @param result defines the Color4 object where to store the result
  5535. * @returns the current unmodified Color4
  5536. */
  5537. scaleToRef(scale: number, result: Color4): Color4;
  5538. /**
  5539. * Scale the current Color4 values by a factor and add the result to a given Color4
  5540. * @param scale defines the scale factor
  5541. * @param result defines the Color4 object where to store the result
  5542. * @returns the unmodified current Color4
  5543. */
  5544. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5545. /**
  5546. * Clamps the rgb values by the min and max values and stores the result into "result"
  5547. * @param min defines minimum clamping value (default is 0)
  5548. * @param max defines maximum clamping value (default is 1)
  5549. * @param result defines color to store the result into.
  5550. * @returns the cuurent Color4
  5551. */
  5552. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5553. /**
  5554. * Multipy an Color4 value by another and return a new Color4 object
  5555. * @param color defines the Color4 value to multiply by
  5556. * @returns a new Color4 object
  5557. */
  5558. multiply(color: Color4): Color4;
  5559. /**
  5560. * Multipy a Color4 value by another and push the result in a reference value
  5561. * @param color defines the Color4 value to multiply by
  5562. * @param result defines the Color4 to fill the result in
  5563. * @returns the result Color4
  5564. */
  5565. multiplyToRef(color: Color4, result: Color4): Color4;
  5566. /**
  5567. * Creates a string with the Color4 current values
  5568. * @returns the string representation of the Color4 object
  5569. */
  5570. toString(): string;
  5571. /**
  5572. * Returns the string "Color4"
  5573. * @returns "Color4"
  5574. */
  5575. getClassName(): string;
  5576. /**
  5577. * Compute the Color4 hash code
  5578. * @returns an unique number that can be used to hash Color4 objects
  5579. */
  5580. getHashCode(): number;
  5581. /**
  5582. * Creates a new Color4 copied from the current one
  5583. * @returns a new Color4 object
  5584. */
  5585. clone(): Color4;
  5586. /**
  5587. * Copies the given Color4 values into the current one
  5588. * @param source defines the source Color4 object
  5589. * @returns the current updated Color4 object
  5590. */
  5591. copyFrom(source: Color4): Color4;
  5592. /**
  5593. * Copies the given float values into the current one
  5594. * @param r defines the red component to read from
  5595. * @param g defines the green component to read from
  5596. * @param b defines the blue component to read from
  5597. * @param a defines the alpha component to read from
  5598. * @returns the current updated Color4 object
  5599. */
  5600. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5601. /**
  5602. * Copies the given float values into the current one
  5603. * @param r defines the red component to read from
  5604. * @param g defines the green component to read from
  5605. * @param b defines the blue component to read from
  5606. * @param a defines the alpha component to read from
  5607. * @returns the current updated Color4 object
  5608. */
  5609. set(r: number, g: number, b: number, a: number): Color4;
  5610. /**
  5611. * Compute the Color4 hexadecimal code as a string
  5612. * @returns a string containing the hexadecimal representation of the Color4 object
  5613. */
  5614. toHexString(): string;
  5615. /**
  5616. * Computes a new Color4 converted from the current one to linear space
  5617. * @returns a new Color4 object
  5618. */
  5619. toLinearSpace(): Color4;
  5620. /**
  5621. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5622. * @param convertedColor defines the Color4 object where to store the linear space version
  5623. * @returns the unmodified Color4
  5624. */
  5625. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5626. /**
  5627. * Computes a new Color4 converted from the current one to gamma space
  5628. * @returns a new Color4 object
  5629. */
  5630. toGammaSpace(): Color4;
  5631. /**
  5632. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5633. * @param convertedColor defines the Color4 object where to store the gamma space version
  5634. * @returns the unmodified Color4
  5635. */
  5636. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5637. /**
  5638. * Creates a new Color4 from the string containing valid hexadecimal values
  5639. * @param hex defines a string containing valid hexadecimal values
  5640. * @returns a new Color4 object
  5641. */
  5642. static FromHexString(hex: string): Color4;
  5643. /**
  5644. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5645. * @param left defines the start value
  5646. * @param right defines the end value
  5647. * @param amount defines the gradient factor
  5648. * @returns a new Color4 object
  5649. */
  5650. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5651. /**
  5652. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5653. * @param left defines the start value
  5654. * @param right defines the end value
  5655. * @param amount defines the gradient factor
  5656. * @param result defines the Color4 object where to store data
  5657. */
  5658. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5659. /**
  5660. * Creates a new Color4 from a Color3 and an alpha value
  5661. * @param color3 defines the source Color3 to read from
  5662. * @param alpha defines the alpha component (1.0 by default)
  5663. * @returns a new Color4 object
  5664. */
  5665. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5666. /**
  5667. * Creates a new Color4 from the starting index element of the given array
  5668. * @param array defines the source array to read from
  5669. * @param offset defines the offset in the source array
  5670. * @returns a new Color4 object
  5671. */
  5672. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5673. /**
  5674. * Creates a new Color3 from integer values (< 256)
  5675. * @param r defines the red component to read from (value between 0 and 255)
  5676. * @param g defines the green component to read from (value between 0 and 255)
  5677. * @param b defines the blue component to read from (value between 0 and 255)
  5678. * @param a defines the alpha component to read from (value between 0 and 255)
  5679. * @returns a new Color3 object
  5680. */
  5681. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5682. /**
  5683. * Check the content of a given array and convert it to an array containing RGBA data
  5684. * If the original array was already containing count * 4 values then it is returned directly
  5685. * @param colors defines the array to check
  5686. * @param count defines the number of RGBA data to expect
  5687. * @returns an array containing count * 4 values (RGBA)
  5688. */
  5689. static CheckColors4(colors: number[], count: number): number[];
  5690. }
  5691. /**
  5692. * @hidden
  5693. */
  5694. export class TmpColors {
  5695. static Color3: Color3[];
  5696. static Color4: Color4[];
  5697. }
  5698. }
  5699. declare module BABYLON {
  5700. /**
  5701. * Defines an interface which represents an animation key frame
  5702. */
  5703. export interface IAnimationKey {
  5704. /**
  5705. * Frame of the key frame
  5706. */
  5707. frame: number;
  5708. /**
  5709. * Value at the specifies key frame
  5710. */
  5711. value: any;
  5712. /**
  5713. * The input tangent for the cubic hermite spline
  5714. */
  5715. inTangent?: any;
  5716. /**
  5717. * The output tangent for the cubic hermite spline
  5718. */
  5719. outTangent?: any;
  5720. /**
  5721. * The animation interpolation type
  5722. */
  5723. interpolation?: AnimationKeyInterpolation;
  5724. }
  5725. /**
  5726. * Enum for the animation key frame interpolation type
  5727. */
  5728. export enum AnimationKeyInterpolation {
  5729. /**
  5730. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5731. */
  5732. STEP = 1
  5733. }
  5734. }
  5735. declare module BABYLON {
  5736. /**
  5737. * Represents the range of an animation
  5738. */
  5739. export class AnimationRange {
  5740. /**The name of the animation range**/
  5741. name: string;
  5742. /**The starting frame of the animation */
  5743. from: number;
  5744. /**The ending frame of the animation*/
  5745. to: number;
  5746. /**
  5747. * Initializes the range of an animation
  5748. * @param name The name of the animation range
  5749. * @param from The starting frame of the animation
  5750. * @param to The ending frame of the animation
  5751. */
  5752. constructor(
  5753. /**The name of the animation range**/
  5754. name: string,
  5755. /**The starting frame of the animation */
  5756. from: number,
  5757. /**The ending frame of the animation*/
  5758. to: number);
  5759. /**
  5760. * Makes a copy of the animation range
  5761. * @returns A copy of the animation range
  5762. */
  5763. clone(): AnimationRange;
  5764. }
  5765. }
  5766. declare module BABYLON {
  5767. /**
  5768. * Composed of a frame, and an action function
  5769. */
  5770. export class AnimationEvent {
  5771. /** The frame for which the event is triggered **/
  5772. frame: number;
  5773. /** The event to perform when triggered **/
  5774. action: (currentFrame: number) => void;
  5775. /** Specifies if the event should be triggered only once**/
  5776. onlyOnce?: boolean | undefined;
  5777. /**
  5778. * Specifies if the animation event is done
  5779. */
  5780. isDone: boolean;
  5781. /**
  5782. * Initializes the animation event
  5783. * @param frame The frame for which the event is triggered
  5784. * @param action The event to perform when triggered
  5785. * @param onlyOnce Specifies if the event should be triggered only once
  5786. */
  5787. constructor(
  5788. /** The frame for which the event is triggered **/
  5789. frame: number,
  5790. /** The event to perform when triggered **/
  5791. action: (currentFrame: number) => void,
  5792. /** Specifies if the event should be triggered only once**/
  5793. onlyOnce?: boolean | undefined);
  5794. /** @hidden */ private _clone(): AnimationEvent;
  5795. }
  5796. }
  5797. declare module BABYLON {
  5798. /**
  5799. * Interface used to define a behavior
  5800. */
  5801. export interface Behavior<T> {
  5802. /** gets or sets behavior's name */
  5803. name: string;
  5804. /**
  5805. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5806. */
  5807. init(): void;
  5808. /**
  5809. * Called when the behavior is attached to a target
  5810. * @param target defines the target where the behavior is attached to
  5811. */
  5812. attach(target: T): void;
  5813. /**
  5814. * Called when the behavior is detached from its target
  5815. */
  5816. detach(): void;
  5817. }
  5818. /**
  5819. * Interface implemented by classes supporting behaviors
  5820. */
  5821. export interface IBehaviorAware<T> {
  5822. /**
  5823. * Attach a behavior
  5824. * @param behavior defines the behavior to attach
  5825. * @returns the current host
  5826. */
  5827. addBehavior(behavior: Behavior<T>): T;
  5828. /**
  5829. * Remove a behavior from the current object
  5830. * @param behavior defines the behavior to detach
  5831. * @returns the current host
  5832. */
  5833. removeBehavior(behavior: Behavior<T>): T;
  5834. /**
  5835. * Gets a behavior using its name to search
  5836. * @param name defines the name to search
  5837. * @returns the behavior or null if not found
  5838. */
  5839. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5840. }
  5841. }
  5842. declare module BABYLON {
  5843. /**
  5844. * Defines an array and its length.
  5845. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5846. */
  5847. export interface ISmartArrayLike<T> {
  5848. /**
  5849. * The data of the array.
  5850. */
  5851. data: Array<T>;
  5852. /**
  5853. * The active length of the array.
  5854. */
  5855. length: number;
  5856. }
  5857. /**
  5858. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5859. */
  5860. export class SmartArray<T> implements ISmartArrayLike<T> {
  5861. /**
  5862. * The full set of data from the array.
  5863. */
  5864. data: Array<T>;
  5865. /**
  5866. * The active length of the array.
  5867. */
  5868. length: number;
  5869. protected _id: number;
  5870. /**
  5871. * Instantiates a Smart Array.
  5872. * @param capacity defines the default capacity of the array.
  5873. */
  5874. constructor(capacity: number);
  5875. /**
  5876. * Pushes a value at the end of the active data.
  5877. * @param value defines the object to push in the array.
  5878. */
  5879. push(value: T): void;
  5880. /**
  5881. * Iterates over the active data and apply the lambda to them.
  5882. * @param func defines the action to apply on each value.
  5883. */
  5884. forEach(func: (content: T) => void): void;
  5885. /**
  5886. * Sorts the full sets of data.
  5887. * @param compareFn defines the comparison function to apply.
  5888. */
  5889. sort(compareFn: (a: T, b: T) => number): void;
  5890. /**
  5891. * Resets the active data to an empty array.
  5892. */
  5893. reset(): void;
  5894. /**
  5895. * Releases all the data from the array as well as the array.
  5896. */
  5897. dispose(): void;
  5898. /**
  5899. * Concats the active data with a given array.
  5900. * @param array defines the data to concatenate with.
  5901. */
  5902. concat(array: any): void;
  5903. /**
  5904. * Returns the position of a value in the active data.
  5905. * @param value defines the value to find the index for
  5906. * @returns the index if found in the active data otherwise -1
  5907. */
  5908. indexOf(value: T): number;
  5909. /**
  5910. * Returns whether an element is part of the active data.
  5911. * @param value defines the value to look for
  5912. * @returns true if found in the active data otherwise false
  5913. */
  5914. contains(value: T): boolean;
  5915. private static _GlobalId;
  5916. }
  5917. /**
  5918. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5919. * The data in this array can only be present once
  5920. */
  5921. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5922. private _duplicateId;
  5923. /**
  5924. * Pushes a value at the end of the active data.
  5925. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5926. * @param value defines the object to push in the array.
  5927. */
  5928. push(value: T): void;
  5929. /**
  5930. * Pushes a value at the end of the active data.
  5931. * If the data is already present, it won t be added again
  5932. * @param value defines the object to push in the array.
  5933. * @returns true if added false if it was already present
  5934. */
  5935. pushNoDuplicate(value: T): boolean;
  5936. /**
  5937. * Resets the active data to an empty array.
  5938. */
  5939. reset(): void;
  5940. /**
  5941. * Concats the active data with a given array.
  5942. * This ensures no dupplicate will be present in the result.
  5943. * @param array defines the data to concatenate with.
  5944. */
  5945. concatWithNoDuplicate(array: any): void;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * @ignore
  5951. * This is a list of all the different input types that are available in the application.
  5952. * Fo instance: ArcRotateCameraGamepadInput...
  5953. */
  5954. export var CameraInputTypes: {};
  5955. /**
  5956. * This is the contract to implement in order to create a new input class.
  5957. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5958. */
  5959. export interface ICameraInput<TCamera extends Camera> {
  5960. /**
  5961. * Defines the camera the input is attached to.
  5962. */
  5963. camera: Nullable<TCamera>;
  5964. /**
  5965. * Gets the class name of the current intput.
  5966. * @returns the class name
  5967. */
  5968. getClassName(): string;
  5969. /**
  5970. * Get the friendly name associated with the input class.
  5971. * @returns the input friendly name
  5972. */
  5973. getSimpleName(): string;
  5974. /**
  5975. * Attach the input controls to a specific dom element to get the input from.
  5976. * @param element Defines the element the controls should be listened from
  5977. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5978. */
  5979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5980. /**
  5981. * Detach the current controls from the specified dom element.
  5982. * @param element Defines the element to stop listening the inputs from
  5983. */
  5984. detachControl(element: Nullable<HTMLElement>): void;
  5985. /**
  5986. * Update the current camera state depending on the inputs that have been used this frame.
  5987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5988. */
  5989. checkInputs?: () => void;
  5990. }
  5991. /**
  5992. * Represents a map of input types to input instance or input index to input instance.
  5993. */
  5994. export interface CameraInputsMap<TCamera extends Camera> {
  5995. /**
  5996. * Accessor to the input by input type.
  5997. */
  5998. [name: string]: ICameraInput<TCamera>;
  5999. /**
  6000. * Accessor to the input by input index.
  6001. */
  6002. [idx: number]: ICameraInput<TCamera>;
  6003. }
  6004. /**
  6005. * This represents the input manager used within a camera.
  6006. * It helps dealing with all the different kind of input attached to a camera.
  6007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6008. */
  6009. export class CameraInputsManager<TCamera extends Camera> {
  6010. /**
  6011. * Defines the list of inputs attahed to the camera.
  6012. */
  6013. attached: CameraInputsMap<TCamera>;
  6014. /**
  6015. * Defines the dom element the camera is collecting inputs from.
  6016. * This is null if the controls have not been attached.
  6017. */
  6018. attachedElement: Nullable<HTMLElement>;
  6019. /**
  6020. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6021. */
  6022. noPreventDefault: boolean;
  6023. /**
  6024. * Defined the camera the input manager belongs to.
  6025. */
  6026. camera: TCamera;
  6027. /**
  6028. * Update the current camera state depending on the inputs that have been used this frame.
  6029. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6030. */
  6031. checkInputs: () => void;
  6032. /**
  6033. * Instantiate a new Camera Input Manager.
  6034. * @param camera Defines the camera the input manager blongs to
  6035. */
  6036. constructor(camera: TCamera);
  6037. /**
  6038. * Add an input method to a camera
  6039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6040. * @param input camera input method
  6041. */
  6042. add(input: ICameraInput<TCamera>): void;
  6043. /**
  6044. * Remove a specific input method from a camera
  6045. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6046. * @param inputToRemove camera input method
  6047. */
  6048. remove(inputToRemove: ICameraInput<TCamera>): void;
  6049. /**
  6050. * Remove a specific input type from a camera
  6051. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6052. * @param inputType the type of the input to remove
  6053. */
  6054. removeByType(inputType: string): void;
  6055. private _addCheckInputs;
  6056. /**
  6057. * Attach the input controls to the currently attached dom element to listen the events from.
  6058. * @param input Defines the input to attach
  6059. */
  6060. attachInput(input: ICameraInput<TCamera>): void;
  6061. /**
  6062. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6063. * @param element Defines the dom element to collect the events from
  6064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6065. */
  6066. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6067. /**
  6068. * Detach the current manager inputs controls from a specific dom element.
  6069. * @param element Defines the dom element to collect the events from
  6070. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6071. */
  6072. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6073. /**
  6074. * Rebuild the dynamic inputCheck function from the current list of
  6075. * defined inputs in the manager.
  6076. */
  6077. rebuildInputCheck(): void;
  6078. /**
  6079. * Remove all attached input methods from a camera
  6080. */
  6081. clear(): void;
  6082. /**
  6083. * Serialize the current input manager attached to a camera.
  6084. * This ensures than once parsed,
  6085. * the input associated to the camera will be identical to the current ones
  6086. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6087. */
  6088. serialize(serializedCamera: any): void;
  6089. /**
  6090. * Parses an input manager serialized JSON to restore the previous list of inputs
  6091. * and states associated to a camera.
  6092. * @param parsedCamera Defines the JSON to parse
  6093. */
  6094. parse(parsedCamera: any): void;
  6095. }
  6096. }
  6097. declare module BABYLON {
  6098. /**
  6099. * Class used to store data that will be store in GPU memory
  6100. */
  6101. export class Buffer {
  6102. private _engine;
  6103. private _buffer;
  6104. /** @hidden */ private _data: Nullable<DataArray>;
  6105. private _updatable;
  6106. private _instanced;
  6107. private _divisor;
  6108. /**
  6109. * Gets the byte stride.
  6110. */
  6111. readonly byteStride: number;
  6112. /**
  6113. * Constructor
  6114. * @param engine the engine
  6115. * @param data the data to use for this buffer
  6116. * @param updatable whether the data is updatable
  6117. * @param stride the stride (optional)
  6118. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6119. * @param instanced whether the buffer is instanced (optional)
  6120. * @param useBytes set to true if the stride in in bytes (optional)
  6121. * @param divisor sets an optional divisor for instances (1 by default)
  6122. */
  6123. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6124. /**
  6125. * Create a new VertexBuffer based on the current buffer
  6126. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6127. * @param offset defines offset in the buffer (0 by default)
  6128. * @param size defines the size in floats of attributes (position is 3 for instance)
  6129. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6130. * @param instanced defines if the vertex buffer contains indexed data
  6131. * @param useBytes defines if the offset and stride are in bytes *
  6132. * @param divisor sets an optional divisor for instances (1 by default)
  6133. * @returns the new vertex buffer
  6134. */
  6135. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6136. /**
  6137. * Gets a boolean indicating if the Buffer is updatable?
  6138. * @returns true if the buffer is updatable
  6139. */
  6140. isUpdatable(): boolean;
  6141. /**
  6142. * Gets current buffer's data
  6143. * @returns a DataArray or null
  6144. */
  6145. getData(): Nullable<DataArray>;
  6146. /**
  6147. * Gets underlying native buffer
  6148. * @returns underlying native buffer
  6149. */
  6150. getBuffer(): Nullable<DataBuffer>;
  6151. /**
  6152. * Gets the stride in float32 units (i.e. byte stride / 4).
  6153. * May not be an integer if the byte stride is not divisible by 4.
  6154. * DEPRECATED. Use byteStride instead.
  6155. * @returns the stride in float32 units
  6156. */
  6157. getStrideSize(): number;
  6158. /**
  6159. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6160. * @param data defines the data to store
  6161. */
  6162. create(data?: Nullable<DataArray>): void;
  6163. /** @hidden */ private _rebuild(): void;
  6164. /**
  6165. * Update current buffer data
  6166. * @param data defines the data to store
  6167. */
  6168. update(data: DataArray): void;
  6169. /**
  6170. * Updates the data directly.
  6171. * @param data the new data
  6172. * @param offset the new offset
  6173. * @param vertexCount the vertex count (optional)
  6174. * @param useBytes set to true if the offset is in bytes
  6175. */
  6176. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6177. /**
  6178. * Release all resources
  6179. */
  6180. dispose(): void;
  6181. }
  6182. /**
  6183. * Specialized buffer used to store vertex data
  6184. */
  6185. export class VertexBuffer {
  6186. /** @hidden */ private _buffer: Buffer;
  6187. private _kind;
  6188. private _size;
  6189. private _ownsBuffer;
  6190. private _instanced;
  6191. private _instanceDivisor;
  6192. /**
  6193. * The byte type.
  6194. */
  6195. static readonly BYTE: number;
  6196. /**
  6197. * The unsigned byte type.
  6198. */
  6199. static readonly UNSIGNED_BYTE: number;
  6200. /**
  6201. * The short type.
  6202. */
  6203. static readonly SHORT: number;
  6204. /**
  6205. * The unsigned short type.
  6206. */
  6207. static readonly UNSIGNED_SHORT: number;
  6208. /**
  6209. * The integer type.
  6210. */
  6211. static readonly INT: number;
  6212. /**
  6213. * The unsigned integer type.
  6214. */
  6215. static readonly UNSIGNED_INT: number;
  6216. /**
  6217. * The float type.
  6218. */
  6219. static readonly FLOAT: number;
  6220. /**
  6221. * Gets or sets the instance divisor when in instanced mode
  6222. */
  6223. instanceDivisor: number;
  6224. /**
  6225. * Gets the byte stride.
  6226. */
  6227. readonly byteStride: number;
  6228. /**
  6229. * Gets the byte offset.
  6230. */
  6231. readonly byteOffset: number;
  6232. /**
  6233. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6234. */
  6235. readonly normalized: boolean;
  6236. /**
  6237. * Gets the data type of each component in the array.
  6238. */
  6239. readonly type: number;
  6240. /**
  6241. * Constructor
  6242. * @param engine the engine
  6243. * @param data the data to use for this vertex buffer
  6244. * @param kind the vertex buffer kind
  6245. * @param updatable whether the data is updatable
  6246. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6247. * @param stride the stride (optional)
  6248. * @param instanced whether the buffer is instanced (optional)
  6249. * @param offset the offset of the data (optional)
  6250. * @param size the number of components (optional)
  6251. * @param type the type of the component (optional)
  6252. * @param normalized whether the data contains normalized data (optional)
  6253. * @param useBytes set to true if stride and offset are in bytes (optional)
  6254. * @param divisor defines the instance divisor to use (1 by default)
  6255. */
  6256. 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, divisor?: number);
  6257. /** @hidden */ private _rebuild(): void;
  6258. /**
  6259. * Returns the kind of the VertexBuffer (string)
  6260. * @returns a string
  6261. */
  6262. getKind(): string;
  6263. /**
  6264. * Gets a boolean indicating if the VertexBuffer is updatable?
  6265. * @returns true if the buffer is updatable
  6266. */
  6267. isUpdatable(): boolean;
  6268. /**
  6269. * Gets current buffer's data
  6270. * @returns a DataArray or null
  6271. */
  6272. getData(): Nullable<DataArray>;
  6273. /**
  6274. * Gets underlying native buffer
  6275. * @returns underlying native buffer
  6276. */
  6277. getBuffer(): Nullable<DataBuffer>;
  6278. /**
  6279. * Gets the stride in float32 units (i.e. byte stride / 4).
  6280. * May not be an integer if the byte stride is not divisible by 4.
  6281. * DEPRECATED. Use byteStride instead.
  6282. * @returns the stride in float32 units
  6283. */
  6284. getStrideSize(): number;
  6285. /**
  6286. * Returns the offset as a multiple of the type byte length.
  6287. * DEPRECATED. Use byteOffset instead.
  6288. * @returns the offset in bytes
  6289. */
  6290. getOffset(): number;
  6291. /**
  6292. * Returns the number of components per vertex attribute (integer)
  6293. * @returns the size in float
  6294. */
  6295. getSize(): number;
  6296. /**
  6297. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6298. * @returns true if this buffer is instanced
  6299. */
  6300. getIsInstanced(): boolean;
  6301. /**
  6302. * Returns the instancing divisor, zero for non-instanced (integer).
  6303. * @returns a number
  6304. */
  6305. getInstanceDivisor(): number;
  6306. /**
  6307. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6308. * @param data defines the data to store
  6309. */
  6310. create(data?: DataArray): void;
  6311. /**
  6312. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6313. * This function will create a new buffer if the current one is not updatable
  6314. * @param data defines the data to store
  6315. */
  6316. update(data: DataArray): void;
  6317. /**
  6318. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6319. * Returns the directly updated WebGLBuffer.
  6320. * @param data the new data
  6321. * @param offset the new offset
  6322. * @param useBytes set to true if the offset is in bytes
  6323. */
  6324. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6325. /**
  6326. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6327. */
  6328. dispose(): void;
  6329. /**
  6330. * Enumerates each value of this vertex buffer as numbers.
  6331. * @param count the number of values to enumerate
  6332. * @param callback the callback function called for each value
  6333. */
  6334. forEach(count: number, callback: (value: number, index: number) => void): void;
  6335. /**
  6336. * Positions
  6337. */
  6338. static readonly PositionKind: string;
  6339. /**
  6340. * Normals
  6341. */
  6342. static readonly NormalKind: string;
  6343. /**
  6344. * Tangents
  6345. */
  6346. static readonly TangentKind: string;
  6347. /**
  6348. * Texture coordinates
  6349. */
  6350. static readonly UVKind: string;
  6351. /**
  6352. * Texture coordinates 2
  6353. */
  6354. static readonly UV2Kind: string;
  6355. /**
  6356. * Texture coordinates 3
  6357. */
  6358. static readonly UV3Kind: string;
  6359. /**
  6360. * Texture coordinates 4
  6361. */
  6362. static readonly UV4Kind: string;
  6363. /**
  6364. * Texture coordinates 5
  6365. */
  6366. static readonly UV5Kind: string;
  6367. /**
  6368. * Texture coordinates 6
  6369. */
  6370. static readonly UV6Kind: string;
  6371. /**
  6372. * Colors
  6373. */
  6374. static readonly ColorKind: string;
  6375. /**
  6376. * Matrix indices (for bones)
  6377. */
  6378. static readonly MatricesIndicesKind: string;
  6379. /**
  6380. * Matrix weights (for bones)
  6381. */
  6382. static readonly MatricesWeightsKind: string;
  6383. /**
  6384. * Additional matrix indices (for bones)
  6385. */
  6386. static readonly MatricesIndicesExtraKind: string;
  6387. /**
  6388. * Additional matrix weights (for bones)
  6389. */
  6390. static readonly MatricesWeightsExtraKind: string;
  6391. /**
  6392. * Deduces the stride given a kind.
  6393. * @param kind The kind string to deduce
  6394. * @returns The deduced stride
  6395. */
  6396. static DeduceStride(kind: string): number;
  6397. /**
  6398. * Gets the byte length of the given type.
  6399. * @param type the type
  6400. * @returns the number of bytes
  6401. */
  6402. static GetTypeByteLength(type: number): number;
  6403. /**
  6404. * Enumerates each value of the given parameters as numbers.
  6405. * @param data the data to enumerate
  6406. * @param byteOffset the byte offset of the data
  6407. * @param byteStride the byte stride of the data
  6408. * @param componentCount the number of components per element
  6409. * @param componentType the type of the component
  6410. * @param count the number of values to enumerate
  6411. * @param normalized whether the data is normalized
  6412. * @param callback the callback function called for each value
  6413. */
  6414. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6415. private static _GetFloatValue;
  6416. }
  6417. }
  6418. declare module BABYLON {
  6419. /**
  6420. * @hidden
  6421. */
  6422. export class IntersectionInfo {
  6423. bu: Nullable<number>;
  6424. bv: Nullable<number>;
  6425. distance: number;
  6426. faceId: number;
  6427. subMeshId: number;
  6428. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6429. }
  6430. }
  6431. declare module BABYLON {
  6432. /**
  6433. * Represens a plane by the equation ax + by + cz + d = 0
  6434. */
  6435. export class Plane {
  6436. private static _TmpMatrix;
  6437. /**
  6438. * Normal of the plane (a,b,c)
  6439. */
  6440. normal: Vector3;
  6441. /**
  6442. * d component of the plane
  6443. */
  6444. d: number;
  6445. /**
  6446. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6447. * @param a a component of the plane
  6448. * @param b b component of the plane
  6449. * @param c c component of the plane
  6450. * @param d d component of the plane
  6451. */
  6452. constructor(a: number, b: number, c: number, d: number);
  6453. /**
  6454. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6455. */
  6456. asArray(): number[];
  6457. /**
  6458. * @returns a new plane copied from the current Plane.
  6459. */
  6460. clone(): Plane;
  6461. /**
  6462. * @returns the string "Plane".
  6463. */
  6464. getClassName(): string;
  6465. /**
  6466. * @returns the Plane hash code.
  6467. */
  6468. getHashCode(): number;
  6469. /**
  6470. * Normalize the current Plane in place.
  6471. * @returns the updated Plane.
  6472. */
  6473. normalize(): Plane;
  6474. /**
  6475. * Applies a transformation the plane and returns the result
  6476. * @param transformation the transformation matrix to be applied to the plane
  6477. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6478. */
  6479. transform(transformation: DeepImmutable<Matrix>): Plane;
  6480. /**
  6481. * Calcualtte the dot product between the point and the plane normal
  6482. * @param point point to calculate the dot product with
  6483. * @returns the dot product (float) of the point coordinates and the plane normal.
  6484. */
  6485. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6486. /**
  6487. * Updates the current Plane from the plane defined by the three given points.
  6488. * @param point1 one of the points used to contruct the plane
  6489. * @param point2 one of the points used to contruct the plane
  6490. * @param point3 one of the points used to contruct the plane
  6491. * @returns the updated Plane.
  6492. */
  6493. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6494. /**
  6495. * Checks if the plane is facing a given direction
  6496. * @param direction the direction to check if the plane is facing
  6497. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6498. * @returns True is the vector "direction" is the same side than the plane normal.
  6499. */
  6500. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6501. /**
  6502. * Calculates the distance to a point
  6503. * @param point point to calculate distance to
  6504. * @returns the signed distance (float) from the given point to the Plane.
  6505. */
  6506. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6507. /**
  6508. * Creates a plane from an array
  6509. * @param array the array to create a plane from
  6510. * @returns a new Plane from the given array.
  6511. */
  6512. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6513. /**
  6514. * Creates a plane from three points
  6515. * @param point1 point used to create the plane
  6516. * @param point2 point used to create the plane
  6517. * @param point3 point used to create the plane
  6518. * @returns a new Plane defined by the three given points.
  6519. */
  6520. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6521. /**
  6522. * Creates a plane from an origin point and a normal
  6523. * @param origin origin of the plane to be constructed
  6524. * @param normal normal of the plane to be constructed
  6525. * @returns a new Plane the normal vector to this plane at the given origin point.
  6526. * Note : the vector "normal" is updated because normalized.
  6527. */
  6528. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6529. /**
  6530. * Calculates the distance from a plane and a point
  6531. * @param origin origin of the plane to be constructed
  6532. * @param normal normal of the plane to be constructed
  6533. * @param point point to calculate distance to
  6534. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6535. */
  6536. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6537. }
  6538. }
  6539. declare module BABYLON {
  6540. /**
  6541. * Class used to store bounding sphere information
  6542. */
  6543. export class BoundingSphere {
  6544. /**
  6545. * Gets the center of the bounding sphere in local space
  6546. */
  6547. readonly center: Vector3;
  6548. /**
  6549. * Radius of the bounding sphere in local space
  6550. */
  6551. radius: number;
  6552. /**
  6553. * Gets the center of the bounding sphere in world space
  6554. */
  6555. readonly centerWorld: Vector3;
  6556. /**
  6557. * Radius of the bounding sphere in world space
  6558. */
  6559. radiusWorld: number;
  6560. /**
  6561. * Gets the minimum vector in local space
  6562. */
  6563. readonly minimum: Vector3;
  6564. /**
  6565. * Gets the maximum vector in local space
  6566. */
  6567. readonly maximum: Vector3;
  6568. private _worldMatrix;
  6569. private static readonly TmpVector3;
  6570. /**
  6571. * Creates a new bounding sphere
  6572. * @param min defines the minimum vector (in local space)
  6573. * @param max defines the maximum vector (in local space)
  6574. * @param worldMatrix defines the new world matrix
  6575. */
  6576. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6577. /**
  6578. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6579. * @param min defines the new minimum vector (in local space)
  6580. * @param max defines the new maximum vector (in local space)
  6581. * @param worldMatrix defines the new world matrix
  6582. */
  6583. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6584. /**
  6585. * Scale the current bounding sphere by applying a scale factor
  6586. * @param factor defines the scale factor to apply
  6587. * @returns the current bounding box
  6588. */
  6589. scale(factor: number): BoundingSphere;
  6590. /**
  6591. * Gets the world matrix of the bounding box
  6592. * @returns a matrix
  6593. */
  6594. getWorldMatrix(): DeepImmutable<Matrix>;
  6595. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6596. /**
  6597. * Tests if the bounding sphere is intersecting the frustum planes
  6598. * @param frustumPlanes defines the frustum planes to test
  6599. * @returns true if there is an intersection
  6600. */
  6601. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6602. /**
  6603. * Tests if the bounding sphere center is in between the frustum planes.
  6604. * Used for optimistic fast inclusion.
  6605. * @param frustumPlanes defines the frustum planes to test
  6606. * @returns true if the sphere center is in between the frustum planes
  6607. */
  6608. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6609. /**
  6610. * Tests if a point is inside the bounding sphere
  6611. * @param point defines the point to test
  6612. * @returns true if the point is inside the bounding sphere
  6613. */
  6614. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6615. /**
  6616. * Checks if two sphere intersct
  6617. * @param sphere0 sphere 0
  6618. * @param sphere1 sphere 1
  6619. * @returns true if the speres intersect
  6620. */
  6621. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6622. }
  6623. }
  6624. declare module BABYLON {
  6625. /**
  6626. * Class used to store bounding box information
  6627. */
  6628. export class BoundingBox implements ICullable {
  6629. /**
  6630. * Gets the 8 vectors representing the bounding box in local space
  6631. */
  6632. readonly vectors: Vector3[];
  6633. /**
  6634. * Gets the center of the bounding box in local space
  6635. */
  6636. readonly center: Vector3;
  6637. /**
  6638. * Gets the center of the bounding box in world space
  6639. */
  6640. readonly centerWorld: Vector3;
  6641. /**
  6642. * Gets the extend size in local space
  6643. */
  6644. readonly extendSize: Vector3;
  6645. /**
  6646. * Gets the extend size in world space
  6647. */
  6648. readonly extendSizeWorld: Vector3;
  6649. /**
  6650. * Gets the OBB (object bounding box) directions
  6651. */
  6652. readonly directions: Vector3[];
  6653. /**
  6654. * Gets the 8 vectors representing the bounding box in world space
  6655. */
  6656. readonly vectorsWorld: Vector3[];
  6657. /**
  6658. * Gets the minimum vector in world space
  6659. */
  6660. readonly minimumWorld: Vector3;
  6661. /**
  6662. * Gets the maximum vector in world space
  6663. */
  6664. readonly maximumWorld: Vector3;
  6665. /**
  6666. * Gets the minimum vector in local space
  6667. */
  6668. readonly minimum: Vector3;
  6669. /**
  6670. * Gets the maximum vector in local space
  6671. */
  6672. readonly maximum: Vector3;
  6673. private _worldMatrix;
  6674. private static readonly TmpVector3;
  6675. /**
  6676. * @hidden
  6677. */ private _tag: number;
  6678. /**
  6679. * Creates a new bounding box
  6680. * @param min defines the minimum vector (in local space)
  6681. * @param max defines the maximum vector (in local space)
  6682. * @param worldMatrix defines the new world matrix
  6683. */
  6684. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6685. /**
  6686. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6687. * @param min defines the new minimum vector (in local space)
  6688. * @param max defines the new maximum vector (in local space)
  6689. * @param worldMatrix defines the new world matrix
  6690. */
  6691. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6692. /**
  6693. * Scale the current bounding box by applying a scale factor
  6694. * @param factor defines the scale factor to apply
  6695. * @returns the current bounding box
  6696. */
  6697. scale(factor: number): BoundingBox;
  6698. /**
  6699. * Gets the world matrix of the bounding box
  6700. * @returns a matrix
  6701. */
  6702. getWorldMatrix(): DeepImmutable<Matrix>;
  6703. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6704. /**
  6705. * Tests if the bounding box is intersecting the frustum planes
  6706. * @param frustumPlanes defines the frustum planes to test
  6707. * @returns true if there is an intersection
  6708. */
  6709. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6710. /**
  6711. * Tests if the bounding box is entirely inside the frustum planes
  6712. * @param frustumPlanes defines the frustum planes to test
  6713. * @returns true if there is an inclusion
  6714. */
  6715. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6716. /**
  6717. * Tests if a point is inside the bounding box
  6718. * @param point defines the point to test
  6719. * @returns true if the point is inside the bounding box
  6720. */
  6721. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6722. /**
  6723. * Tests if the bounding box intersects with a bounding sphere
  6724. * @param sphere defines the sphere to test
  6725. * @returns true if there is an intersection
  6726. */
  6727. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6728. /**
  6729. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6730. * @param min defines the min vector to use
  6731. * @param max defines the max vector to use
  6732. * @returns true if there is an intersection
  6733. */
  6734. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6735. /**
  6736. * Tests if two bounding boxes are intersections
  6737. * @param box0 defines the first box to test
  6738. * @param box1 defines the second box to test
  6739. * @returns true if there is an intersection
  6740. */
  6741. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6742. /**
  6743. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6744. * @param minPoint defines the minimum vector of the bounding box
  6745. * @param maxPoint defines the maximum vector of the bounding box
  6746. * @param sphereCenter defines the sphere center
  6747. * @param sphereRadius defines the sphere radius
  6748. * @returns true if there is an intersection
  6749. */
  6750. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6751. /**
  6752. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6753. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6754. * @param frustumPlanes defines the frustum planes to test
  6755. * @return true if there is an inclusion
  6756. */
  6757. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6758. /**
  6759. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6760. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6761. * @param frustumPlanes defines the frustum planes to test
  6762. * @return true if there is an intersection
  6763. */
  6764. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6765. }
  6766. }
  6767. declare module BABYLON {
  6768. /** @hidden */
  6769. export class Collider {
  6770. /** Define if a collision was found */
  6771. collisionFound: boolean;
  6772. /**
  6773. * Define last intersection point in local space
  6774. */
  6775. intersectionPoint: Vector3;
  6776. /**
  6777. * Define last collided mesh
  6778. */
  6779. collidedMesh: Nullable<AbstractMesh>;
  6780. private _collisionPoint;
  6781. private _planeIntersectionPoint;
  6782. private _tempVector;
  6783. private _tempVector2;
  6784. private _tempVector3;
  6785. private _tempVector4;
  6786. private _edge;
  6787. private _baseToVertex;
  6788. private _destinationPoint;
  6789. private _slidePlaneNormal;
  6790. private _displacementVector;
  6791. /** @hidden */ private _radius: Vector3;
  6792. /** @hidden */ private _retry: number;
  6793. private _velocity;
  6794. private _basePoint;
  6795. private _epsilon;
  6796. /** @hidden */ private _velocityWorldLength: number;
  6797. /** @hidden */ private _basePointWorld: Vector3;
  6798. private _velocityWorld;
  6799. private _normalizedVelocity;
  6800. /** @hidden */ private _initialVelocity: Vector3;
  6801. /** @hidden */ private _initialPosition: Vector3;
  6802. private _nearestDistance;
  6803. private _collisionMask;
  6804. collisionMask: number;
  6805. /**
  6806. * Gets the plane normal used to compute the sliding response (in local space)
  6807. */
  6808. readonly slidePlaneNormal: Vector3;
  6809. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  6810. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6811. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6812. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6813. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6814. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * Interface for cullable objects
  6820. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6821. */
  6822. export interface ICullable {
  6823. /**
  6824. * Checks if the object or part of the object is in the frustum
  6825. * @param frustumPlanes Camera near/planes
  6826. * @returns true if the object is in frustum otherwise false
  6827. */
  6828. isInFrustum(frustumPlanes: Plane[]): boolean;
  6829. /**
  6830. * Checks if a cullable object (mesh...) is in the camera frustum
  6831. * Unlike isInFrustum this cheks the full bounding box
  6832. * @param frustumPlanes Camera near/planes
  6833. * @returns true if the object is in frustum otherwise false
  6834. */
  6835. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6836. }
  6837. /**
  6838. * Info for a bounding data of a mesh
  6839. */
  6840. export class BoundingInfo implements ICullable {
  6841. /**
  6842. * Bounding box for the mesh
  6843. */
  6844. readonly boundingBox: BoundingBox;
  6845. /**
  6846. * Bounding sphere for the mesh
  6847. */
  6848. readonly boundingSphere: BoundingSphere;
  6849. private _isLocked;
  6850. private static readonly TmpVector3;
  6851. /**
  6852. * Constructs bounding info
  6853. * @param minimum min vector of the bounding box/sphere
  6854. * @param maximum max vector of the bounding box/sphere
  6855. * @param worldMatrix defines the new world matrix
  6856. */
  6857. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6858. /**
  6859. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6860. * @param min defines the new minimum vector (in local space)
  6861. * @param max defines the new maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6865. /**
  6866. * min vector of the bounding box/sphere
  6867. */
  6868. readonly minimum: Vector3;
  6869. /**
  6870. * max vector of the bounding box/sphere
  6871. */
  6872. readonly maximum: Vector3;
  6873. /**
  6874. * If the info is locked and won't be updated to avoid perf overhead
  6875. */
  6876. isLocked: boolean;
  6877. /**
  6878. * Updates the bounding sphere and box
  6879. * @param world world matrix to be used to update
  6880. */
  6881. update(world: DeepImmutable<Matrix>): void;
  6882. /**
  6883. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6884. * @param center New center of the bounding info
  6885. * @param extend New extend of the bounding info
  6886. * @returns the current bounding info
  6887. */
  6888. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6889. /**
  6890. * Scale the current bounding info by applying a scale factor
  6891. * @param factor defines the scale factor to apply
  6892. * @returns the current bounding info
  6893. */
  6894. scale(factor: number): BoundingInfo;
  6895. /**
  6896. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6897. * @param frustumPlanes defines the frustum to test
  6898. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6899. * @returns true if the bounding info is in the frustum planes
  6900. */
  6901. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6902. /**
  6903. * Gets the world distance between the min and max points of the bounding box
  6904. */
  6905. readonly diagonalLength: number;
  6906. /**
  6907. * Checks if a cullable object (mesh...) is in the camera frustum
  6908. * Unlike isInFrustum this cheks the full bounding box
  6909. * @param frustumPlanes Camera near/planes
  6910. * @returns true if the object is in frustum otherwise false
  6911. */
  6912. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6913. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  6914. /**
  6915. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6916. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6917. * @param point the point to check intersection with
  6918. * @returns if the point intersects
  6919. */
  6920. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6921. /**
  6922. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6923. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6924. * @param boundingInfo the bounding info to check intersection with
  6925. * @param precise if the intersection should be done using OBB
  6926. * @returns if the bounding info intersects
  6927. */
  6928. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6929. }
  6930. }
  6931. declare module BABYLON {
  6932. /**
  6933. * Extracts minimum and maximum values from a list of indexed positions
  6934. * @param positions defines the positions to use
  6935. * @param indices defines the indices to the positions
  6936. * @param indexStart defines the start index
  6937. * @param indexCount defines the end index
  6938. * @param bias defines bias value to add to the result
  6939. * @return minimum and maximum values
  6940. */
  6941. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6942. minimum: Vector3;
  6943. maximum: Vector3;
  6944. };
  6945. /**
  6946. * Extracts minimum and maximum values from a list of positions
  6947. * @param positions defines the positions to use
  6948. * @param start defines the start index in the positions array
  6949. * @param count defines the number of positions to handle
  6950. * @param bias defines bias value to add to the result
  6951. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6952. * @return minimum and maximum values
  6953. */
  6954. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6955. minimum: Vector3;
  6956. maximum: Vector3;
  6957. };
  6958. }
  6959. declare module BABYLON {
  6960. /** @hidden */
  6961. export class WebGLDataBuffer extends DataBuffer {
  6962. private _buffer;
  6963. constructor(resource: WebGLBuffer);
  6964. readonly underlyingResource: any;
  6965. }
  6966. }
  6967. declare module BABYLON {
  6968. /** @hidden */
  6969. export class WebGLPipelineContext implements IPipelineContext {
  6970. engine: ThinEngine;
  6971. program: Nullable<WebGLProgram>;
  6972. context?: WebGLRenderingContext;
  6973. vertexShader?: WebGLShader;
  6974. fragmentShader?: WebGLShader;
  6975. isParallelCompiled: boolean;
  6976. onCompiled?: () => void;
  6977. transformFeedback?: WebGLTransformFeedback | null;
  6978. readonly isAsync: boolean;
  6979. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  6980. }
  6981. }
  6982. declare module BABYLON {
  6983. interface ThinEngine {
  6984. /**
  6985. * Create an uniform buffer
  6986. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6987. * @param elements defines the content of the uniform buffer
  6988. * @returns the webGL uniform buffer
  6989. */
  6990. createUniformBuffer(elements: FloatArray): DataBuffer;
  6991. /**
  6992. * Create a dynamic uniform buffer
  6993. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6994. * @param elements defines the content of the uniform buffer
  6995. * @returns the webGL uniform buffer
  6996. */
  6997. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  6998. /**
  6999. * Update an existing uniform buffer
  7000. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7001. * @param uniformBuffer defines the target uniform buffer
  7002. * @param elements defines the content to update
  7003. * @param offset defines the offset in the uniform buffer where update should start
  7004. * @param count defines the size of the data to update
  7005. */
  7006. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7007. /**
  7008. * Bind an uniform buffer to the current webGL context
  7009. * @param buffer defines the buffer to bind
  7010. */
  7011. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7012. /**
  7013. * Bind a buffer to the current webGL context at a given location
  7014. * @param buffer defines the buffer to bind
  7015. * @param location defines the index where to bind the buffer
  7016. */
  7017. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7018. /**
  7019. * Bind a specific block at a given index in a specific shader program
  7020. * @param pipelineContext defines the pipeline context to use
  7021. * @param blockName defines the block name
  7022. * @param index defines the index where to bind the block
  7023. */
  7024. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7025. }
  7026. }
  7027. declare module BABYLON {
  7028. /**
  7029. * Uniform buffer objects.
  7030. *
  7031. * Handles blocks of uniform on the GPU.
  7032. *
  7033. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7034. *
  7035. * For more information, please refer to :
  7036. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7037. */
  7038. export class UniformBuffer {
  7039. private _engine;
  7040. private _buffer;
  7041. private _data;
  7042. private _bufferData;
  7043. private _dynamic?;
  7044. private _uniformLocations;
  7045. private _uniformSizes;
  7046. private _uniformLocationPointer;
  7047. private _needSync;
  7048. private _noUBO;
  7049. private _currentEffect;
  7050. /** @hidden */ private _alreadyBound: boolean;
  7051. private static _MAX_UNIFORM_SIZE;
  7052. private static _tempBuffer;
  7053. /**
  7054. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7055. * This is dynamic to allow compat with webgl 1 and 2.
  7056. * You will need to pass the name of the uniform as well as the value.
  7057. */
  7058. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7059. /**
  7060. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7061. * This is dynamic to allow compat with webgl 1 and 2.
  7062. * You will need to pass the name of the uniform as well as the value.
  7063. */
  7064. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7065. /**
  7066. * Lambda to Update a single float in a uniform buffer.
  7067. * This is dynamic to allow compat with webgl 1 and 2.
  7068. * You will need to pass the name of the uniform as well as the value.
  7069. */
  7070. updateFloat: (name: string, x: number) => void;
  7071. /**
  7072. * Lambda to Update a vec2 of float in a uniform buffer.
  7073. * This is dynamic to allow compat with webgl 1 and 2.
  7074. * You will need to pass the name of the uniform as well as the value.
  7075. */
  7076. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7077. /**
  7078. * Lambda to Update a vec3 of float in a uniform buffer.
  7079. * This is dynamic to allow compat with webgl 1 and 2.
  7080. * You will need to pass the name of the uniform as well as the value.
  7081. */
  7082. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7083. /**
  7084. * Lambda to Update a vec4 of float in a uniform buffer.
  7085. * This is dynamic to allow compat with webgl 1 and 2.
  7086. * You will need to pass the name of the uniform as well as the value.
  7087. */
  7088. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7089. /**
  7090. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7091. * This is dynamic to allow compat with webgl 1 and 2.
  7092. * You will need to pass the name of the uniform as well as the value.
  7093. */
  7094. updateMatrix: (name: string, mat: Matrix) => void;
  7095. /**
  7096. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7097. * This is dynamic to allow compat with webgl 1 and 2.
  7098. * You will need to pass the name of the uniform as well as the value.
  7099. */
  7100. updateVector3: (name: string, vector: Vector3) => void;
  7101. /**
  7102. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7103. * This is dynamic to allow compat with webgl 1 and 2.
  7104. * You will need to pass the name of the uniform as well as the value.
  7105. */
  7106. updateVector4: (name: string, vector: Vector4) => void;
  7107. /**
  7108. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7109. * This is dynamic to allow compat with webgl 1 and 2.
  7110. * You will need to pass the name of the uniform as well as the value.
  7111. */
  7112. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7113. /**
  7114. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7115. * This is dynamic to allow compat with webgl 1 and 2.
  7116. * You will need to pass the name of the uniform as well as the value.
  7117. */
  7118. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7119. /**
  7120. * Instantiates a new Uniform buffer objects.
  7121. *
  7122. * Handles blocks of uniform on the GPU.
  7123. *
  7124. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7125. *
  7126. * For more information, please refer to :
  7127. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7128. * @param engine Define the engine the buffer is associated with
  7129. * @param data Define the data contained in the buffer
  7130. * @param dynamic Define if the buffer is updatable
  7131. */
  7132. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7133. /**
  7134. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7135. * or just falling back on setUniformXXX calls.
  7136. */
  7137. readonly useUbo: boolean;
  7138. /**
  7139. * Indicates if the WebGL underlying uniform buffer is in sync
  7140. * with the javascript cache data.
  7141. */
  7142. readonly isSync: boolean;
  7143. /**
  7144. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7145. * Also, a dynamic UniformBuffer will disable cache verification and always
  7146. * update the underlying WebGL uniform buffer to the GPU.
  7147. * @returns if Dynamic, otherwise false
  7148. */
  7149. isDynamic(): boolean;
  7150. /**
  7151. * The data cache on JS side.
  7152. * @returns the underlying data as a float array
  7153. */
  7154. getData(): Float32Array;
  7155. /**
  7156. * The underlying WebGL Uniform buffer.
  7157. * @returns the webgl buffer
  7158. */
  7159. getBuffer(): Nullable<DataBuffer>;
  7160. /**
  7161. * std140 layout specifies how to align data within an UBO structure.
  7162. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7163. * for specs.
  7164. */
  7165. private _fillAlignment;
  7166. /**
  7167. * Adds an uniform in the buffer.
  7168. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7169. * for the layout to be correct !
  7170. * @param name Name of the uniform, as used in the uniform block in the shader.
  7171. * @param size Data size, or data directly.
  7172. */
  7173. addUniform(name: string, size: number | number[]): void;
  7174. /**
  7175. * Adds a Matrix 4x4 to the uniform buffer.
  7176. * @param name Name of the uniform, as used in the uniform block in the shader.
  7177. * @param mat A 4x4 matrix.
  7178. */
  7179. addMatrix(name: string, mat: Matrix): void;
  7180. /**
  7181. * Adds a vec2 to the uniform buffer.
  7182. * @param name Name of the uniform, as used in the uniform block in the shader.
  7183. * @param x Define the x component value of the vec2
  7184. * @param y Define the y component value of the vec2
  7185. */
  7186. addFloat2(name: string, x: number, y: number): void;
  7187. /**
  7188. * Adds a vec3 to the uniform buffer.
  7189. * @param name Name of the uniform, as used in the uniform block in the shader.
  7190. * @param x Define the x component value of the vec3
  7191. * @param y Define the y component value of the vec3
  7192. * @param z Define the z component value of the vec3
  7193. */
  7194. addFloat3(name: string, x: number, y: number, z: number): void;
  7195. /**
  7196. * Adds a vec3 to the uniform buffer.
  7197. * @param name Name of the uniform, as used in the uniform block in the shader.
  7198. * @param color Define the vec3 from a Color
  7199. */
  7200. addColor3(name: string, color: Color3): void;
  7201. /**
  7202. * Adds a vec4 to the uniform buffer.
  7203. * @param name Name of the uniform, as used in the uniform block in the shader.
  7204. * @param color Define the rgb components from a Color
  7205. * @param alpha Define the a component of the vec4
  7206. */
  7207. addColor4(name: string, color: Color3, alpha: number): void;
  7208. /**
  7209. * Adds a vec3 to the uniform buffer.
  7210. * @param name Name of the uniform, as used in the uniform block in the shader.
  7211. * @param vector Define the vec3 components from a Vector
  7212. */
  7213. addVector3(name: string, vector: Vector3): void;
  7214. /**
  7215. * Adds a Matrix 3x3 to the uniform buffer.
  7216. * @param name Name of the uniform, as used in the uniform block in the shader.
  7217. */
  7218. addMatrix3x3(name: string): void;
  7219. /**
  7220. * Adds a Matrix 2x2 to the uniform buffer.
  7221. * @param name Name of the uniform, as used in the uniform block in the shader.
  7222. */
  7223. addMatrix2x2(name: string): void;
  7224. /**
  7225. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7226. */
  7227. create(): void;
  7228. /** @hidden */ private _rebuild(): void;
  7229. /**
  7230. * Updates the WebGL Uniform Buffer on the GPU.
  7231. * If the `dynamic` flag is set to true, no cache comparison is done.
  7232. * Otherwise, the buffer will be updated only if the cache differs.
  7233. */
  7234. update(): void;
  7235. /**
  7236. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7237. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7238. * @param data Define the flattened data
  7239. * @param size Define the size of the data.
  7240. */
  7241. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7242. private _valueCache;
  7243. private _cacheMatrix;
  7244. private _updateMatrix3x3ForUniform;
  7245. private _updateMatrix3x3ForEffect;
  7246. private _updateMatrix2x2ForEffect;
  7247. private _updateMatrix2x2ForUniform;
  7248. private _updateFloatForEffect;
  7249. private _updateFloatForUniform;
  7250. private _updateFloat2ForEffect;
  7251. private _updateFloat2ForUniform;
  7252. private _updateFloat3ForEffect;
  7253. private _updateFloat3ForUniform;
  7254. private _updateFloat4ForEffect;
  7255. private _updateFloat4ForUniform;
  7256. private _updateMatrixForEffect;
  7257. private _updateMatrixForUniform;
  7258. private _updateVector3ForEffect;
  7259. private _updateVector3ForUniform;
  7260. private _updateVector4ForEffect;
  7261. private _updateVector4ForUniform;
  7262. private _updateColor3ForEffect;
  7263. private _updateColor3ForUniform;
  7264. private _updateColor4ForEffect;
  7265. private _updateColor4ForUniform;
  7266. /**
  7267. * Sets a sampler uniform on the effect.
  7268. * @param name Define the name of the sampler.
  7269. * @param texture Define the texture to set in the sampler
  7270. */
  7271. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7272. /**
  7273. * Directly updates the value of the uniform in the cache AND on the GPU.
  7274. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7275. * @param data Define the flattened data
  7276. */
  7277. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7278. /**
  7279. * Binds this uniform buffer to an effect.
  7280. * @param effect Define the effect to bind the buffer to
  7281. * @param name Name of the uniform block in the shader.
  7282. */
  7283. bindToEffect(effect: Effect, name: string): void;
  7284. /**
  7285. * Disposes the uniform buffer.
  7286. */
  7287. dispose(): void;
  7288. }
  7289. }
  7290. declare module BABYLON {
  7291. /**
  7292. * Enum that determines the text-wrapping mode to use.
  7293. */
  7294. export enum InspectableType {
  7295. /**
  7296. * Checkbox for booleans
  7297. */
  7298. Checkbox = 0,
  7299. /**
  7300. * Sliders for numbers
  7301. */
  7302. Slider = 1,
  7303. /**
  7304. * Vector3
  7305. */
  7306. Vector3 = 2,
  7307. /**
  7308. * Quaternions
  7309. */
  7310. Quaternion = 3,
  7311. /**
  7312. * Color3
  7313. */
  7314. Color3 = 4,
  7315. /**
  7316. * String
  7317. */
  7318. String = 5
  7319. }
  7320. /**
  7321. * Interface used to define custom inspectable properties.
  7322. * This interface is used by the inspector to display custom property grids
  7323. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7324. */
  7325. export interface IInspectable {
  7326. /**
  7327. * Gets the label to display
  7328. */
  7329. label: string;
  7330. /**
  7331. * Gets the name of the property to edit
  7332. */
  7333. propertyName: string;
  7334. /**
  7335. * Gets the type of the editor to use
  7336. */
  7337. type: InspectableType;
  7338. /**
  7339. * Gets the minimum value of the property when using in "slider" mode
  7340. */
  7341. min?: number;
  7342. /**
  7343. * Gets the maximum value of the property when using in "slider" mode
  7344. */
  7345. max?: number;
  7346. /**
  7347. * Gets the setp to use when using in "slider" mode
  7348. */
  7349. step?: number;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * Class used to provide helper for timing
  7355. */
  7356. export class TimingTools {
  7357. /**
  7358. * Polyfill for setImmediate
  7359. * @param action defines the action to execute after the current execution block
  7360. */
  7361. static SetImmediate(action: () => void): void;
  7362. }
  7363. }
  7364. declare module BABYLON {
  7365. /**
  7366. * Class used to enable instatition of objects by class name
  7367. */
  7368. export class InstantiationTools {
  7369. /**
  7370. * Use this object to register external classes like custom textures or material
  7371. * to allow the laoders to instantiate them
  7372. */
  7373. static RegisteredExternalClasses: {
  7374. [key: string]: Object;
  7375. };
  7376. /**
  7377. * Tries to instantiate a new object from a given class name
  7378. * @param className defines the class name to instantiate
  7379. * @returns the new object or null if the system was not able to do the instantiation
  7380. */
  7381. static Instantiate(className: string): any;
  7382. }
  7383. }
  7384. declare module BABYLON {
  7385. /**
  7386. * Define options used to create a depth texture
  7387. */
  7388. export class DepthTextureCreationOptions {
  7389. /** Specifies whether or not a stencil should be allocated in the texture */
  7390. generateStencil?: boolean;
  7391. /** Specifies whether or not bilinear filtering is enable on the texture */
  7392. bilinearFiltering?: boolean;
  7393. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7394. comparisonFunction?: number;
  7395. /** Specifies if the created texture is a cube texture */
  7396. isCube?: boolean;
  7397. }
  7398. }
  7399. declare module BABYLON {
  7400. interface ThinEngine {
  7401. /**
  7402. * Creates a depth stencil cube texture.
  7403. * This is only available in WebGL 2.
  7404. * @param size The size of face edge in the cube texture.
  7405. * @param options The options defining the cube texture.
  7406. * @returns The cube texture
  7407. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7408. /**
  7409. * Creates a cube texture
  7410. * @param rootUrl defines the url where the files to load is located
  7411. * @param scene defines the current scene
  7412. * @param files defines the list of files to load (1 per face)
  7413. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7414. * @param onLoad defines an optional callback raised when the texture is loaded
  7415. * @param onError defines an optional callback raised if there is an issue to load the texture
  7416. * @param format defines the format of the data
  7417. * @param forcedExtension defines the extension to use to pick the right loader
  7418. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7419. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7420. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7421. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7422. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7423. * @returns the cube texture as an InternalTexture
  7424. */
  7425. 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;
  7426. /**
  7427. * Creates a cube texture
  7428. * @param rootUrl defines the url where the files to load is located
  7429. * @param scene defines the current scene
  7430. * @param files defines the list of files to load (1 per face)
  7431. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7432. * @param onLoad defines an optional callback raised when the texture is loaded
  7433. * @param onError defines an optional callback raised if there is an issue to load the texture
  7434. * @param format defines the format of the data
  7435. * @param forcedExtension defines the extension to use to pick the right loader
  7436. * @returns the cube texture as an InternalTexture
  7437. */
  7438. 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;
  7439. /**
  7440. * Creates a cube texture
  7441. * @param rootUrl defines the url where the files to load is located
  7442. * @param scene defines the current scene
  7443. * @param files defines the list of files to load (1 per face)
  7444. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7445. * @param onLoad defines an optional callback raised when the texture is loaded
  7446. * @param onError defines an optional callback raised if there is an issue to load the texture
  7447. * @param format defines the format of the data
  7448. * @param forcedExtension defines the extension to use to pick the right loader
  7449. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7450. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7451. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7452. * @returns the cube texture as an InternalTexture
  7453. */
  7454. 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;
  7455. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7456. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7457. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7458. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7459. /**
  7460. * @hidden
  7461. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  7462. }
  7463. }
  7464. declare module BABYLON {
  7465. /**
  7466. * Class for creating a cube texture
  7467. */
  7468. export class CubeTexture extends BaseTexture {
  7469. private _delayedOnLoad;
  7470. /**
  7471. * The url of the texture
  7472. */
  7473. url: string;
  7474. /**
  7475. * Gets or sets the center of the bounding box associated with the cube texture.
  7476. * It must define where the camera used to render the texture was set
  7477. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7478. */
  7479. boundingBoxPosition: Vector3;
  7480. private _boundingBoxSize;
  7481. /**
  7482. * Gets or sets the size of the bounding box associated with the cube texture
  7483. * When defined, the cubemap will switch to local mode
  7484. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7485. * @example https://www.babylonjs-playground.com/#RNASML
  7486. */
  7487. /**
  7488. * Returns the bounding box size
  7489. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7490. */
  7491. boundingBoxSize: Vector3;
  7492. protected _rotationY: number;
  7493. /**
  7494. * Sets texture matrix rotation angle around Y axis in radians.
  7495. */
  7496. /**
  7497. * Gets texture matrix rotation angle around Y axis radians.
  7498. */
  7499. rotationY: number;
  7500. /**
  7501. * Are mip maps generated for this texture or not.
  7502. */
  7503. readonly noMipmap: boolean;
  7504. private _noMipmap;
  7505. private _files;
  7506. protected _forcedExtension: Nullable<string>;
  7507. private _extensions;
  7508. private _textureMatrix;
  7509. private _format;
  7510. private _createPolynomials;
  7511. /** @hidden */ private _prefiltered: boolean;
  7512. /**
  7513. * Creates a cube texture from an array of image urls
  7514. * @param files defines an array of image urls
  7515. * @param scene defines the hosting scene
  7516. * @param noMipmap specifies if mip maps are not used
  7517. * @returns a cube texture
  7518. */
  7519. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7520. /**
  7521. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7522. * @param url defines the url of the prefiltered texture
  7523. * @param scene defines the scene the texture is attached to
  7524. * @param forcedExtension defines the extension of the file if different from the url
  7525. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7526. * @return the prefiltered texture
  7527. */
  7528. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7529. /**
  7530. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7531. * as prefiltered data.
  7532. * @param rootUrl defines the url of the texture or the root name of the six images
  7533. * @param scene defines the scene the texture is attached to
  7534. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7535. * @param noMipmap defines if mipmaps should be created or not
  7536. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7537. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7538. * @param onError defines a callback triggered in case of error during load
  7539. * @param format defines the internal format to use for the texture once loaded
  7540. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7541. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7542. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7543. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7544. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7545. * @return the cube texture
  7546. */
  7547. 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);
  7548. /**
  7549. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7550. */
  7551. readonly isPrefiltered: boolean;
  7552. /**
  7553. * Get the current class name of the texture useful for serialization or dynamic coding.
  7554. * @returns "CubeTexture"
  7555. */
  7556. getClassName(): string;
  7557. /**
  7558. * Update the url (and optional buffer) of this texture if url was null during construction.
  7559. * @param url the url of the texture
  7560. * @param forcedExtension defines the extension to use
  7561. * @param onLoad callback called when the texture is loaded (defaults to null)
  7562. */
  7563. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7564. /**
  7565. * Delays loading of the cube texture
  7566. * @param forcedExtension defines the extension to use
  7567. */
  7568. delayLoad(forcedExtension?: string): void;
  7569. /**
  7570. * Returns the reflection texture matrix
  7571. * @returns the reflection texture matrix
  7572. */
  7573. getReflectionTextureMatrix(): Matrix;
  7574. /**
  7575. * Sets the reflection texture matrix
  7576. * @param value Reflection texture matrix
  7577. */
  7578. setReflectionTextureMatrix(value: Matrix): void;
  7579. /**
  7580. * Parses text to create a cube texture
  7581. * @param parsedTexture define the serialized text to read from
  7582. * @param scene defines the hosting scene
  7583. * @param rootUrl defines the root url of the cube texture
  7584. * @returns a cube texture
  7585. */
  7586. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7587. /**
  7588. * Makes a clone, or deep copy, of the cube texture
  7589. * @returns a new cube texture
  7590. */
  7591. clone(): CubeTexture;
  7592. }
  7593. }
  7594. declare module BABYLON {
  7595. /**
  7596. * Manages the defines for the Material
  7597. */
  7598. export class MaterialDefines {
  7599. /** @hidden */
  7600. protected _keys: string[];
  7601. private _isDirty;
  7602. /** @hidden */ private _renderId: number;
  7603. /** @hidden */ private _areLightsDirty: boolean;
  7604. /** @hidden */ private _areLightsDisposed: boolean;
  7605. /** @hidden */ private _areAttributesDirty: boolean;
  7606. /** @hidden */ private _areTexturesDirty: boolean;
  7607. /** @hidden */ private _areFresnelDirty: boolean;
  7608. /** @hidden */ private _areMiscDirty: boolean;
  7609. /** @hidden */ private _areImageProcessingDirty: boolean;
  7610. /** @hidden */ private _normals: boolean;
  7611. /** @hidden */ private _uvs: boolean;
  7612. /** @hidden */ private _needNormals: boolean;
  7613. /** @hidden */ private _needUVs: boolean;
  7614. [id: string]: any;
  7615. /**
  7616. * Specifies if the material needs to be re-calculated
  7617. */
  7618. readonly isDirty: boolean;
  7619. /**
  7620. * Marks the material to indicate that it has been re-calculated
  7621. */
  7622. markAsProcessed(): void;
  7623. /**
  7624. * Marks the material to indicate that it needs to be re-calculated
  7625. */
  7626. markAsUnprocessed(): void;
  7627. /**
  7628. * Marks the material to indicate all of its defines need to be re-calculated
  7629. */
  7630. markAllAsDirty(): void;
  7631. /**
  7632. * Marks the material to indicate that image processing needs to be re-calculated
  7633. */
  7634. markAsImageProcessingDirty(): void;
  7635. /**
  7636. * Marks the material to indicate the lights need to be re-calculated
  7637. * @param disposed Defines whether the light is dirty due to dispose or not
  7638. */
  7639. markAsLightDirty(disposed?: boolean): void;
  7640. /**
  7641. * Marks the attribute state as changed
  7642. */
  7643. markAsAttributesDirty(): void;
  7644. /**
  7645. * Marks the texture state as changed
  7646. */
  7647. markAsTexturesDirty(): void;
  7648. /**
  7649. * Marks the fresnel state as changed
  7650. */
  7651. markAsFresnelDirty(): void;
  7652. /**
  7653. * Marks the misc state as changed
  7654. */
  7655. markAsMiscDirty(): void;
  7656. /**
  7657. * Rebuilds the material defines
  7658. */
  7659. rebuild(): void;
  7660. /**
  7661. * Specifies if two material defines are equal
  7662. * @param other - A material define instance to compare to
  7663. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7664. */
  7665. isEqual(other: MaterialDefines): boolean;
  7666. /**
  7667. * Clones this instance's defines to another instance
  7668. * @param other - material defines to clone values to
  7669. */
  7670. cloneTo(other: MaterialDefines): void;
  7671. /**
  7672. * Resets the material define values
  7673. */
  7674. reset(): void;
  7675. /**
  7676. * Converts the material define values to a string
  7677. * @returns - String of material define information
  7678. */
  7679. toString(): string;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7685. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7686. * 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;
  7687. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7688. */
  7689. export class ColorCurves {
  7690. private _dirty;
  7691. private _tempColor;
  7692. private _globalCurve;
  7693. private _highlightsCurve;
  7694. private _midtonesCurve;
  7695. private _shadowsCurve;
  7696. private _positiveCurve;
  7697. private _negativeCurve;
  7698. private _globalHue;
  7699. private _globalDensity;
  7700. private _globalSaturation;
  7701. private _globalExposure;
  7702. /**
  7703. * Gets the global Hue value.
  7704. * 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).
  7705. */
  7706. /**
  7707. * Sets the global Hue value.
  7708. * 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).
  7709. */
  7710. globalHue: number;
  7711. /**
  7712. * Gets the global Density value.
  7713. * 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.
  7714. * Values less than zero provide a filter of opposite hue.
  7715. */
  7716. /**
  7717. * Sets the global Density value.
  7718. * 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.
  7719. * Values less than zero provide a filter of opposite hue.
  7720. */
  7721. globalDensity: number;
  7722. /**
  7723. * Gets the global Saturation value.
  7724. * 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.
  7725. */
  7726. /**
  7727. * Sets the global Saturation value.
  7728. * 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.
  7729. */
  7730. globalSaturation: number;
  7731. /**
  7732. * Gets the global Exposure value.
  7733. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7734. */
  7735. /**
  7736. * Sets the global Exposure value.
  7737. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7738. */
  7739. globalExposure: number;
  7740. private _highlightsHue;
  7741. private _highlightsDensity;
  7742. private _highlightsSaturation;
  7743. private _highlightsExposure;
  7744. /**
  7745. * Gets the highlights Hue value.
  7746. * 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).
  7747. */
  7748. /**
  7749. * Sets the highlights Hue value.
  7750. * 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).
  7751. */
  7752. highlightsHue: number;
  7753. /**
  7754. * Gets the highlights Density value.
  7755. * 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.
  7756. * Values less than zero provide a filter of opposite hue.
  7757. */
  7758. /**
  7759. * Sets the highlights Density value.
  7760. * 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.
  7761. * Values less than zero provide a filter of opposite hue.
  7762. */
  7763. highlightsDensity: number;
  7764. /**
  7765. * Gets the highlights Saturation value.
  7766. * 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.
  7767. */
  7768. /**
  7769. * Sets the highlights Saturation value.
  7770. * 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.
  7771. */
  7772. highlightsSaturation: number;
  7773. /**
  7774. * Gets the highlights Exposure value.
  7775. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7776. */
  7777. /**
  7778. * Sets the highlights Exposure value.
  7779. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7780. */
  7781. highlightsExposure: number;
  7782. private _midtonesHue;
  7783. private _midtonesDensity;
  7784. private _midtonesSaturation;
  7785. private _midtonesExposure;
  7786. /**
  7787. * Gets the midtones Hue value.
  7788. * 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).
  7789. */
  7790. /**
  7791. * Sets the midtones Hue value.
  7792. * 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).
  7793. */
  7794. midtonesHue: number;
  7795. /**
  7796. * Gets the midtones Density value.
  7797. * 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.
  7798. * Values less than zero provide a filter of opposite hue.
  7799. */
  7800. /**
  7801. * Sets the midtones Density value.
  7802. * 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.
  7803. * Values less than zero provide a filter of opposite hue.
  7804. */
  7805. midtonesDensity: number;
  7806. /**
  7807. * Gets the midtones Saturation value.
  7808. * 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.
  7809. */
  7810. /**
  7811. * Sets the midtones Saturation value.
  7812. * 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.
  7813. */
  7814. midtonesSaturation: number;
  7815. /**
  7816. * Gets the midtones Exposure value.
  7817. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7818. */
  7819. /**
  7820. * Sets the midtones Exposure value.
  7821. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7822. */
  7823. midtonesExposure: number;
  7824. private _shadowsHue;
  7825. private _shadowsDensity;
  7826. private _shadowsSaturation;
  7827. private _shadowsExposure;
  7828. /**
  7829. * Gets the shadows Hue value.
  7830. * 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).
  7831. */
  7832. /**
  7833. * Sets the shadows Hue value.
  7834. * 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).
  7835. */
  7836. shadowsHue: number;
  7837. /**
  7838. * Gets the shadows Density value.
  7839. * 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.
  7840. * Values less than zero provide a filter of opposite hue.
  7841. */
  7842. /**
  7843. * Sets the shadows Density value.
  7844. * 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.
  7845. * Values less than zero provide a filter of opposite hue.
  7846. */
  7847. shadowsDensity: number;
  7848. /**
  7849. * Gets the shadows Saturation value.
  7850. * 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.
  7851. */
  7852. /**
  7853. * Sets the shadows Saturation value.
  7854. * 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.
  7855. */
  7856. shadowsSaturation: number;
  7857. /**
  7858. * Gets the shadows Exposure value.
  7859. * 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.
  7860. */
  7861. /**
  7862. * Sets the shadows Exposure value.
  7863. * 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.
  7864. */
  7865. shadowsExposure: number;
  7866. /**
  7867. * Returns the class name
  7868. * @returns The class name
  7869. */
  7870. getClassName(): string;
  7871. /**
  7872. * Binds the color curves to the shader.
  7873. * @param colorCurves The color curve to bind
  7874. * @param effect The effect to bind to
  7875. * @param positiveUniform The positive uniform shader parameter
  7876. * @param neutralUniform The neutral uniform shader parameter
  7877. * @param negativeUniform The negative uniform shader parameter
  7878. */
  7879. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7880. /**
  7881. * Prepare the list of uniforms associated with the ColorCurves effects.
  7882. * @param uniformsList The list of uniforms used in the effect
  7883. */
  7884. static PrepareUniforms(uniformsList: string[]): void;
  7885. /**
  7886. * Returns color grading data based on a hue, density, saturation and exposure value.
  7887. * @param filterHue The hue of the color filter.
  7888. * @param filterDensity The density of the color filter.
  7889. * @param saturation The saturation.
  7890. * @param exposure The exposure.
  7891. * @param result The result data container.
  7892. */
  7893. private getColorGradingDataToRef;
  7894. /**
  7895. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7896. * @param value The input slider value in range [-100,100].
  7897. * @returns Adjusted value.
  7898. */
  7899. private static applyColorGradingSliderNonlinear;
  7900. /**
  7901. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7902. * @param hue The hue (H) input.
  7903. * @param saturation The saturation (S) input.
  7904. * @param brightness The brightness (B) input.
  7905. * @result An RGBA color represented as Vector4.
  7906. */
  7907. private static fromHSBToRef;
  7908. /**
  7909. * Returns a value clamped between min and max
  7910. * @param value The value to clamp
  7911. * @param min The minimum of value
  7912. * @param max The maximum of value
  7913. * @returns The clamped value.
  7914. */
  7915. private static clamp;
  7916. /**
  7917. * Clones the current color curve instance.
  7918. * @return The cloned curves
  7919. */
  7920. clone(): ColorCurves;
  7921. /**
  7922. * Serializes the current color curve instance to a json representation.
  7923. * @return a JSON representation
  7924. */
  7925. serialize(): any;
  7926. /**
  7927. * Parses the color curve from a json representation.
  7928. * @param source the JSON source to parse
  7929. * @return The parsed curves
  7930. */
  7931. static Parse(source: any): ColorCurves;
  7932. }
  7933. }
  7934. declare module BABYLON {
  7935. /**
  7936. * Interface to follow in your material defines to integrate easily the
  7937. * Image proccessing functions.
  7938. * @hidden
  7939. */
  7940. export interface IImageProcessingConfigurationDefines {
  7941. IMAGEPROCESSING: boolean;
  7942. VIGNETTE: boolean;
  7943. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7944. VIGNETTEBLENDMODEOPAQUE: boolean;
  7945. TONEMAPPING: boolean;
  7946. TONEMAPPING_ACES: boolean;
  7947. CONTRAST: boolean;
  7948. EXPOSURE: boolean;
  7949. COLORCURVES: boolean;
  7950. COLORGRADING: boolean;
  7951. COLORGRADING3D: boolean;
  7952. SAMPLER3DGREENDEPTH: boolean;
  7953. SAMPLER3DBGRMAP: boolean;
  7954. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7955. }
  7956. /**
  7957. * @hidden
  7958. */
  7959. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7960. IMAGEPROCESSING: boolean;
  7961. VIGNETTE: boolean;
  7962. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7963. VIGNETTEBLENDMODEOPAQUE: boolean;
  7964. TONEMAPPING: boolean;
  7965. TONEMAPPING_ACES: boolean;
  7966. CONTRAST: boolean;
  7967. COLORCURVES: boolean;
  7968. COLORGRADING: boolean;
  7969. COLORGRADING3D: boolean;
  7970. SAMPLER3DGREENDEPTH: boolean;
  7971. SAMPLER3DBGRMAP: boolean;
  7972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7973. EXPOSURE: boolean;
  7974. constructor();
  7975. }
  7976. /**
  7977. * This groups together the common properties used for image processing either in direct forward pass
  7978. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7979. * or not.
  7980. */
  7981. export class ImageProcessingConfiguration {
  7982. /**
  7983. * Default tone mapping applied in BabylonJS.
  7984. */
  7985. static readonly TONEMAPPING_STANDARD: number;
  7986. /**
  7987. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7988. * to other engines rendering to increase portability.
  7989. */
  7990. static readonly TONEMAPPING_ACES: number;
  7991. /**
  7992. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7993. */
  7994. colorCurves: Nullable<ColorCurves>;
  7995. private _colorCurvesEnabled;
  7996. /**
  7997. * Gets wether the color curves effect is enabled.
  7998. */
  7999. /**
  8000. * Sets wether the color curves effect is enabled.
  8001. */
  8002. colorCurvesEnabled: boolean;
  8003. private _colorGradingTexture;
  8004. /**
  8005. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8006. */
  8007. /**
  8008. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8009. */
  8010. colorGradingTexture: Nullable<BaseTexture>;
  8011. private _colorGradingEnabled;
  8012. /**
  8013. * Gets wether the color grading effect is enabled.
  8014. */
  8015. /**
  8016. * Sets wether the color grading effect is enabled.
  8017. */
  8018. colorGradingEnabled: boolean;
  8019. private _colorGradingWithGreenDepth;
  8020. /**
  8021. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8022. */
  8023. /**
  8024. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8025. */
  8026. colorGradingWithGreenDepth: boolean;
  8027. private _colorGradingBGR;
  8028. /**
  8029. * Gets wether the color grading texture contains BGR values.
  8030. */
  8031. /**
  8032. * Sets wether the color grading texture contains BGR values.
  8033. */
  8034. colorGradingBGR: boolean;
  8035. /** @hidden */ private _exposure: number;
  8036. /**
  8037. * Gets the Exposure used in the effect.
  8038. */
  8039. /**
  8040. * Sets the Exposure used in the effect.
  8041. */
  8042. exposure: number;
  8043. private _toneMappingEnabled;
  8044. /**
  8045. * Gets wether the tone mapping effect is enabled.
  8046. */
  8047. /**
  8048. * Sets wether the tone mapping effect is enabled.
  8049. */
  8050. toneMappingEnabled: boolean;
  8051. private _toneMappingType;
  8052. /**
  8053. * Gets the type of tone mapping effect.
  8054. */
  8055. /**
  8056. * Sets the type of tone mapping effect used in BabylonJS.
  8057. */
  8058. toneMappingType: number;
  8059. protected _contrast: number;
  8060. /**
  8061. * Gets the contrast used in the effect.
  8062. */
  8063. /**
  8064. * Sets the contrast used in the effect.
  8065. */
  8066. contrast: number;
  8067. /**
  8068. * Vignette stretch size.
  8069. */
  8070. vignetteStretch: number;
  8071. /**
  8072. * Vignette centre X Offset.
  8073. */
  8074. vignetteCentreX: number;
  8075. /**
  8076. * Vignette centre Y Offset.
  8077. */
  8078. vignetteCentreY: number;
  8079. /**
  8080. * Vignette weight or intensity of the vignette effect.
  8081. */
  8082. vignetteWeight: number;
  8083. /**
  8084. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8085. * if vignetteEnabled is set to true.
  8086. */
  8087. vignetteColor: Color4;
  8088. /**
  8089. * Camera field of view used by the Vignette effect.
  8090. */
  8091. vignetteCameraFov: number;
  8092. private _vignetteBlendMode;
  8093. /**
  8094. * Gets the vignette blend mode allowing different kind of effect.
  8095. */
  8096. /**
  8097. * Sets the vignette blend mode allowing different kind of effect.
  8098. */
  8099. vignetteBlendMode: number;
  8100. private _vignetteEnabled;
  8101. /**
  8102. * Gets wether the vignette effect is enabled.
  8103. */
  8104. /**
  8105. * Sets wether the vignette effect is enabled.
  8106. */
  8107. vignetteEnabled: boolean;
  8108. private _applyByPostProcess;
  8109. /**
  8110. * Gets wether the image processing is applied through a post process or not.
  8111. */
  8112. /**
  8113. * Sets wether the image processing is applied through a post process or not.
  8114. */
  8115. applyByPostProcess: boolean;
  8116. private _isEnabled;
  8117. /**
  8118. * Gets wether the image processing is enabled or not.
  8119. */
  8120. /**
  8121. * Sets wether the image processing is enabled or not.
  8122. */
  8123. isEnabled: boolean;
  8124. /**
  8125. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8126. */
  8127. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8128. /**
  8129. * Method called each time the image processing information changes requires to recompile the effect.
  8130. */
  8131. protected _updateParameters(): void;
  8132. /**
  8133. * Gets the current class name.
  8134. * @return "ImageProcessingConfiguration"
  8135. */
  8136. getClassName(): string;
  8137. /**
  8138. * Prepare the list of uniforms associated with the Image Processing effects.
  8139. * @param uniforms The list of uniforms used in the effect
  8140. * @param defines the list of defines currently in use
  8141. */
  8142. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8143. /**
  8144. * Prepare the list of samplers associated with the Image Processing effects.
  8145. * @param samplersList The list of uniforms used in the effect
  8146. * @param defines the list of defines currently in use
  8147. */
  8148. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8149. /**
  8150. * Prepare the list of defines associated to the shader.
  8151. * @param defines the list of defines to complete
  8152. * @param forPostProcess Define if we are currently in post process mode or not
  8153. */
  8154. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8155. /**
  8156. * Returns true if all the image processing information are ready.
  8157. * @returns True if ready, otherwise, false
  8158. */
  8159. isReady(): boolean;
  8160. /**
  8161. * Binds the image processing to the shader.
  8162. * @param effect The effect to bind to
  8163. * @param overrideAspectRatio Override the aspect ratio of the effect
  8164. */
  8165. bind(effect: Effect, overrideAspectRatio?: number): void;
  8166. /**
  8167. * Clones the current image processing instance.
  8168. * @return The cloned image processing
  8169. */
  8170. clone(): ImageProcessingConfiguration;
  8171. /**
  8172. * Serializes the current image processing instance to a json representation.
  8173. * @return a JSON representation
  8174. */
  8175. serialize(): any;
  8176. /**
  8177. * Parses the image processing from a json representation.
  8178. * @param source the JSON source to parse
  8179. * @return The parsed image processing
  8180. */
  8181. static Parse(source: any): ImageProcessingConfiguration;
  8182. private static _VIGNETTEMODE_MULTIPLY;
  8183. private static _VIGNETTEMODE_OPAQUE;
  8184. /**
  8185. * Used to apply the vignette as a mix with the pixel color.
  8186. */
  8187. static readonly VIGNETTEMODE_MULTIPLY: number;
  8188. /**
  8189. * Used to apply the vignette as a replacement of the pixel color.
  8190. */
  8191. static readonly VIGNETTEMODE_OPAQUE: number;
  8192. }
  8193. }
  8194. declare module BABYLON {
  8195. /** @hidden */
  8196. export var postprocessVertexShader: {
  8197. name: string;
  8198. shader: string;
  8199. };
  8200. }
  8201. declare module BABYLON {
  8202. interface ThinEngine {
  8203. /**
  8204. * Creates a new render target texture
  8205. * @param size defines the size of the texture
  8206. * @param options defines the options used to create the texture
  8207. * @returns a new render target texture stored in an InternalTexture
  8208. */
  8209. createRenderTargetTexture(size: number | {
  8210. width: number;
  8211. height: number;
  8212. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8213. /**
  8214. * Creates a depth stencil texture.
  8215. * This is only available in WebGL 2 or with the depth texture extension available.
  8216. * @param size The size of face edge in the texture.
  8217. * @param options The options defining the texture.
  8218. * @returns The texture
  8219. */
  8220. createDepthStencilTexture(size: number | {
  8221. width: number;
  8222. height: number;
  8223. }, options: DepthTextureCreationOptions): InternalTexture;
  8224. /** @hidden */ private _createDepthStencilTexture(size: number | {
  8225. width: number;
  8226. height: number;
  8227. }, options: DepthTextureCreationOptions): InternalTexture;
  8228. }
  8229. }
  8230. declare module BABYLON {
  8231. /** Defines supported spaces */
  8232. export enum Space {
  8233. /** Local (object) space */
  8234. LOCAL = 0,
  8235. /** World space */
  8236. WORLD = 1,
  8237. /** Bone space */
  8238. BONE = 2
  8239. }
  8240. /** Defines the 3 main axes */
  8241. export class Axis {
  8242. /** X axis */
  8243. static X: Vector3;
  8244. /** Y axis */
  8245. static Y: Vector3;
  8246. /** Z axis */
  8247. static Z: Vector3;
  8248. }
  8249. }
  8250. declare module BABYLON {
  8251. /**
  8252. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8253. * This is the base of the follow, arc rotate cameras and Free camera
  8254. * @see http://doc.babylonjs.com/features/cameras
  8255. */
  8256. export class TargetCamera extends Camera {
  8257. private static _RigCamTransformMatrix;
  8258. private static _TargetTransformMatrix;
  8259. private static _TargetFocalPoint;
  8260. /**
  8261. * Define the current direction the camera is moving to
  8262. */
  8263. cameraDirection: Vector3;
  8264. /**
  8265. * Define the current rotation the camera is rotating to
  8266. */
  8267. cameraRotation: Vector2;
  8268. /**
  8269. * When set, the up vector of the camera will be updated by the rotation of the camera
  8270. */
  8271. updateUpVectorFromRotation: boolean;
  8272. private _tmpQuaternion;
  8273. /**
  8274. * Define the current rotation of the camera
  8275. */
  8276. rotation: Vector3;
  8277. /**
  8278. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8279. */
  8280. rotationQuaternion: Quaternion;
  8281. /**
  8282. * Define the current speed of the camera
  8283. */
  8284. speed: number;
  8285. /**
  8286. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8287. * around all axis.
  8288. */
  8289. noRotationConstraint: boolean;
  8290. /**
  8291. * Define the current target of the camera as an object or a position.
  8292. */
  8293. lockedTarget: any;
  8294. /** @hidden */ private _currentTarget: Vector3;
  8295. /** @hidden */ private _initialFocalDistance: number;
  8296. /** @hidden */ private _viewMatrix: Matrix;
  8297. /** @hidden */ private _camMatrix: Matrix;
  8298. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8299. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8300. /** @hidden */ private _referencePoint: Vector3;
  8301. /** @hidden */ private _transformedReferencePoint: Vector3;
  8302. protected _globalCurrentTarget: Vector3;
  8303. protected _globalCurrentUpVector: Vector3;
  8304. /** @hidden */ private _reset: () => void;
  8305. private _defaultUp;
  8306. /**
  8307. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8308. * This is the base of the follow, arc rotate cameras and Free camera
  8309. * @see http://doc.babylonjs.com/features/cameras
  8310. * @param name Defines the name of the camera in the scene
  8311. * @param position Defines the start position of the camera in the scene
  8312. * @param scene Defines the scene the camera belongs to
  8313. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8314. */
  8315. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8316. /**
  8317. * Gets the position in front of the camera at a given distance.
  8318. * @param distance The distance from the camera we want the position to be
  8319. * @returns the position
  8320. */
  8321. getFrontPosition(distance: number): Vector3;
  8322. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8323. private _storedPosition;
  8324. private _storedRotation;
  8325. private _storedRotationQuaternion;
  8326. /**
  8327. * Store current camera state of the camera (fov, position, rotation, etc..)
  8328. * @returns the camera
  8329. */
  8330. storeState(): Camera;
  8331. /**
  8332. * Restored camera state. You must call storeState() first
  8333. * @returns whether it was successful or not
  8334. * @hidden
  8335. */ private _restoreStateValues(): boolean;
  8336. /** @hidden */ private _initCache(): void;
  8337. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8338. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8339. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8340. /**
  8341. * Defines the target the camera should look at.
  8342. * @param target Defines the new target as a Vector or a mesh
  8343. */
  8344. setTarget(target: Vector3): void;
  8345. /**
  8346. * Return the current target position of the camera. This value is expressed in local space.
  8347. * @returns the target position
  8348. */
  8349. getTarget(): Vector3;
  8350. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8351. /** @hidden */ private _updatePosition(): void;
  8352. /** @hidden */ private _checkInputs(): void;
  8353. protected _updateCameraRotationMatrix(): void;
  8354. /**
  8355. * 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)
  8356. * @returns the current camera
  8357. */
  8358. private _rotateUpVectorWithCameraRotationMatrix;
  8359. private _cachedRotationZ;
  8360. private _cachedQuaternionRotationZ;
  8361. /** @hidden */ private _getViewMatrix(): Matrix;
  8362. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8363. /**
  8364. * @hidden
  8365. */
  8366. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8367. /**
  8368. * @hidden
  8369. */ private _updateRigCameras(): void;
  8370. private _getRigCamPositionAndTarget;
  8371. /**
  8372. * Gets the current object class name.
  8373. * @return the class name
  8374. */
  8375. getClassName(): string;
  8376. }
  8377. }
  8378. declare module BABYLON {
  8379. /**
  8380. * Gather the list of keyboard event types as constants.
  8381. */
  8382. export class KeyboardEventTypes {
  8383. /**
  8384. * The keydown event is fired when a key becomes active (pressed).
  8385. */
  8386. static readonly KEYDOWN: number;
  8387. /**
  8388. * The keyup event is fired when a key has been released.
  8389. */
  8390. static readonly KEYUP: number;
  8391. }
  8392. /**
  8393. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8394. */
  8395. export class KeyboardInfo {
  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. * Instantiates a new keyboard info.
  8406. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8407. * @param type Defines the type of event (KeyboardEventTypes)
  8408. * @param event Defines the related dom event
  8409. */
  8410. constructor(
  8411. /**
  8412. * Defines the type of event (KeyboardEventTypes)
  8413. */
  8414. type: number,
  8415. /**
  8416. * Defines the related dom event
  8417. */
  8418. event: KeyboardEvent);
  8419. }
  8420. /**
  8421. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8422. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8423. */
  8424. export class KeyboardInfoPre extends KeyboardInfo {
  8425. /**
  8426. * Defines the type of event (KeyboardEventTypes)
  8427. */
  8428. type: number;
  8429. /**
  8430. * Defines the related dom event
  8431. */
  8432. event: KeyboardEvent;
  8433. /**
  8434. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8435. */
  8436. skipOnPointerObservable: boolean;
  8437. /**
  8438. * Instantiates a new keyboard pre info.
  8439. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8440. * @param type Defines the type of event (KeyboardEventTypes)
  8441. * @param event Defines the related dom event
  8442. */
  8443. constructor(
  8444. /**
  8445. * Defines the type of event (KeyboardEventTypes)
  8446. */
  8447. type: number,
  8448. /**
  8449. * Defines the related dom event
  8450. */
  8451. event: KeyboardEvent);
  8452. }
  8453. }
  8454. declare module BABYLON {
  8455. /**
  8456. * Manage the keyboard inputs to control the movement of a free camera.
  8457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8458. */
  8459. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8460. /**
  8461. * Defines the camera the input is attached to.
  8462. */
  8463. camera: FreeCamera;
  8464. /**
  8465. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8466. */
  8467. keysUp: number[];
  8468. /**
  8469. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8470. */
  8471. keysDown: number[];
  8472. /**
  8473. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8474. */
  8475. keysLeft: number[];
  8476. /**
  8477. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8478. */
  8479. keysRight: number[];
  8480. private _keys;
  8481. private _onCanvasBlurObserver;
  8482. private _onKeyboardObserver;
  8483. private _engine;
  8484. private _scene;
  8485. /**
  8486. * Attach the input controls to a specific dom element to get the input from.
  8487. * @param element Defines the element the controls should be listened from
  8488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8489. */
  8490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8491. /**
  8492. * Detach the current controls from the specified dom element.
  8493. * @param element Defines the element to stop listening the inputs from
  8494. */
  8495. detachControl(element: Nullable<HTMLElement>): void;
  8496. /**
  8497. * Update the current camera state depending on the inputs that have been used this frame.
  8498. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8499. */
  8500. checkInputs(): void;
  8501. /**
  8502. * Gets the class name of the current intput.
  8503. * @returns the class name
  8504. */
  8505. getClassName(): string;
  8506. /** @hidden */ private _onLostFocus(): void;
  8507. /**
  8508. * Get the friendly name associated with the input class.
  8509. * @returns the input friendly name
  8510. */
  8511. getSimpleName(): string;
  8512. }
  8513. }
  8514. declare module BABYLON {
  8515. /**
  8516. * Interface describing all the common properties and methods a shadow light needs to implement.
  8517. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8518. * as well as binding the different shadow properties to the effects.
  8519. */
  8520. export interface IShadowLight extends Light {
  8521. /**
  8522. * The light id in the scene (used in scene.findLighById for instance)
  8523. */
  8524. id: string;
  8525. /**
  8526. * The position the shdow will be casted from.
  8527. */
  8528. position: Vector3;
  8529. /**
  8530. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8531. */
  8532. direction: Vector3;
  8533. /**
  8534. * The transformed position. Position of the light in world space taking parenting in account.
  8535. */
  8536. transformedPosition: Vector3;
  8537. /**
  8538. * The transformed direction. Direction of the light in world space taking parenting in account.
  8539. */
  8540. transformedDirection: Vector3;
  8541. /**
  8542. * The friendly name of the light in the scene.
  8543. */
  8544. name: string;
  8545. /**
  8546. * Defines the shadow projection clipping minimum z value.
  8547. */
  8548. shadowMinZ: number;
  8549. /**
  8550. * Defines the shadow projection clipping maximum z value.
  8551. */
  8552. shadowMaxZ: number;
  8553. /**
  8554. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8555. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8556. */
  8557. computeTransformedInformation(): boolean;
  8558. /**
  8559. * Gets the scene the light belongs to.
  8560. * @returns The scene
  8561. */
  8562. getScene(): Scene;
  8563. /**
  8564. * Callback defining a custom Projection Matrix Builder.
  8565. * This can be used to override the default projection matrix computation.
  8566. */
  8567. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8568. /**
  8569. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8570. * @param matrix The materix to updated with the projection information
  8571. * @param viewMatrix The transform matrix of the light
  8572. * @param renderList The list of mesh to render in the map
  8573. * @returns The current light
  8574. */
  8575. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8576. /**
  8577. * Gets the current depth scale used in ESM.
  8578. * @returns The scale
  8579. */
  8580. getDepthScale(): number;
  8581. /**
  8582. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8583. * @returns true if a cube texture needs to be use
  8584. */
  8585. needCube(): boolean;
  8586. /**
  8587. * Detects if the projection matrix requires to be recomputed this frame.
  8588. * @returns true if it requires to be recomputed otherwise, false.
  8589. */
  8590. needProjectionMatrixCompute(): boolean;
  8591. /**
  8592. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8593. */
  8594. forceProjectionMatrixCompute(): void;
  8595. /**
  8596. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8597. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8598. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8599. */
  8600. getShadowDirection(faceIndex?: number): Vector3;
  8601. /**
  8602. * Gets the minZ used for shadow according to both the scene and the light.
  8603. * @param activeCamera The camera we are returning the min for
  8604. * @returns the depth min z
  8605. */
  8606. getDepthMinZ(activeCamera: Camera): number;
  8607. /**
  8608. * Gets the maxZ used for shadow according to both the scene and the light.
  8609. * @param activeCamera The camera we are returning the max for
  8610. * @returns the depth max z
  8611. */
  8612. getDepthMaxZ(activeCamera: Camera): number;
  8613. }
  8614. /**
  8615. * Base implementation IShadowLight
  8616. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8617. */
  8618. export abstract class ShadowLight extends Light implements IShadowLight {
  8619. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8620. protected _position: Vector3;
  8621. protected _setPosition(value: Vector3): void;
  8622. /**
  8623. * Sets the position the shadow will be casted from. Also use as the light position for both
  8624. * point and spot lights.
  8625. */
  8626. /**
  8627. * Sets the position the shadow will be casted from. Also use as the light position for both
  8628. * point and spot lights.
  8629. */
  8630. position: Vector3;
  8631. protected _direction: Vector3;
  8632. protected _setDirection(value: Vector3): void;
  8633. /**
  8634. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8635. * Also use as the light direction on spot and directional lights.
  8636. */
  8637. /**
  8638. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8639. * Also use as the light direction on spot and directional lights.
  8640. */
  8641. direction: Vector3;
  8642. private _shadowMinZ;
  8643. /**
  8644. * Gets the shadow projection clipping minimum z value.
  8645. */
  8646. /**
  8647. * Sets the shadow projection clipping minimum z value.
  8648. */
  8649. shadowMinZ: number;
  8650. private _shadowMaxZ;
  8651. /**
  8652. * Sets the shadow projection clipping maximum z value.
  8653. */
  8654. /**
  8655. * Gets the shadow projection clipping maximum z value.
  8656. */
  8657. shadowMaxZ: number;
  8658. /**
  8659. * Callback defining a custom Projection Matrix Builder.
  8660. * This can be used to override the default projection matrix computation.
  8661. */
  8662. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8663. /**
  8664. * The transformed position. Position of the light in world space taking parenting in account.
  8665. */
  8666. transformedPosition: Vector3;
  8667. /**
  8668. * The transformed direction. Direction of the light in world space taking parenting in account.
  8669. */
  8670. transformedDirection: Vector3;
  8671. private _needProjectionMatrixCompute;
  8672. /**
  8673. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8674. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8675. */
  8676. computeTransformedInformation(): boolean;
  8677. /**
  8678. * Return the depth scale used for the shadow map.
  8679. * @returns the depth scale.
  8680. */
  8681. getDepthScale(): number;
  8682. /**
  8683. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8684. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8685. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8686. */
  8687. getShadowDirection(faceIndex?: number): Vector3;
  8688. /**
  8689. * Returns the ShadowLight absolute position in the World.
  8690. * @returns the position vector in world space
  8691. */
  8692. getAbsolutePosition(): Vector3;
  8693. /**
  8694. * Sets the ShadowLight direction toward the passed target.
  8695. * @param target The point to target in local space
  8696. * @returns the updated ShadowLight direction
  8697. */
  8698. setDirectionToTarget(target: Vector3): Vector3;
  8699. /**
  8700. * Returns the light rotation in euler definition.
  8701. * @returns the x y z rotation in local space.
  8702. */
  8703. getRotation(): Vector3;
  8704. /**
  8705. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8706. * @returns true if a cube texture needs to be use
  8707. */
  8708. needCube(): boolean;
  8709. /**
  8710. * Detects if the projection matrix requires to be recomputed this frame.
  8711. * @returns true if it requires to be recomputed otherwise, false.
  8712. */
  8713. needProjectionMatrixCompute(): boolean;
  8714. /**
  8715. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8716. */
  8717. forceProjectionMatrixCompute(): void;
  8718. /** @hidden */ private _initCache(): void;
  8719. /** @hidden */ private _isSynchronized(): boolean;
  8720. /**
  8721. * Computes the world matrix of the node
  8722. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8723. * @returns the world matrix
  8724. */
  8725. computeWorldMatrix(force?: boolean): Matrix;
  8726. /**
  8727. * Gets the minZ used for shadow according to both the scene and the light.
  8728. * @param activeCamera The camera we are returning the min for
  8729. * @returns the depth min z
  8730. */
  8731. getDepthMinZ(activeCamera: Camera): number;
  8732. /**
  8733. * Gets the maxZ used for shadow according to both the scene and the light.
  8734. * @param activeCamera The camera we are returning the max for
  8735. * @returns the depth max z
  8736. */
  8737. getDepthMaxZ(activeCamera: Camera): number;
  8738. /**
  8739. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8740. * @param matrix The materix to updated with the projection information
  8741. * @param viewMatrix The transform matrix of the light
  8742. * @param renderList The list of mesh to render in the map
  8743. * @returns The current light
  8744. */
  8745. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8746. }
  8747. }
  8748. declare module BABYLON {
  8749. /**
  8750. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8751. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8752. */
  8753. export class EffectFallbacks implements IEffectFallbacks {
  8754. private _defines;
  8755. private _currentRank;
  8756. private _maxRank;
  8757. private _mesh;
  8758. /**
  8759. * Removes the fallback from the bound mesh.
  8760. */
  8761. unBindMesh(): void;
  8762. /**
  8763. * Adds a fallback on the specified property.
  8764. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8765. * @param define The name of the define in the shader
  8766. */
  8767. addFallback(rank: number, define: string): void;
  8768. /**
  8769. * Sets the mesh to use CPU skinning when needing to fallback.
  8770. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8771. * @param mesh The mesh to use the fallbacks.
  8772. */
  8773. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8774. /**
  8775. * Checks to see if more fallbacks are still availible.
  8776. */
  8777. readonly hasMoreFallbacks: boolean;
  8778. /**
  8779. * Removes the defines that should be removed when falling back.
  8780. * @param currentDefines defines the current define statements for the shader.
  8781. * @param effect defines the current effect we try to compile
  8782. * @returns The resulting defines with defines of the current rank removed.
  8783. */
  8784. reduce(currentDefines: string, effect: Effect): string;
  8785. }
  8786. }
  8787. declare module BABYLON {
  8788. /**
  8789. * "Static Class" containing the most commonly used helper while dealing with material for
  8790. * rendering purpose.
  8791. *
  8792. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8793. *
  8794. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8795. */
  8796. export class MaterialHelper {
  8797. /**
  8798. * Bind the current view position to an effect.
  8799. * @param effect The effect to be bound
  8800. * @param scene The scene the eyes position is used from
  8801. */
  8802. static BindEyePosition(effect: Effect, scene: Scene): void;
  8803. /**
  8804. * Helps preparing the defines values about the UVs in used in the effect.
  8805. * UVs are shared as much as we can accross channels in the shaders.
  8806. * @param texture The texture we are preparing the UVs for
  8807. * @param defines The defines to update
  8808. * @param key The channel key "diffuse", "specular"... used in the shader
  8809. */
  8810. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8811. /**
  8812. * Binds a texture matrix value to its corrsponding uniform
  8813. * @param texture The texture to bind the matrix for
  8814. * @param uniformBuffer The uniform buffer receivin the data
  8815. * @param key The channel key "diffuse", "specular"... used in the shader
  8816. */
  8817. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8818. /**
  8819. * Gets the current status of the fog (should it be enabled?)
  8820. * @param mesh defines the mesh to evaluate for fog support
  8821. * @param scene defines the hosting scene
  8822. * @returns true if fog must be enabled
  8823. */
  8824. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8825. /**
  8826. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8827. * @param mesh defines the current mesh
  8828. * @param scene defines the current scene
  8829. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8830. * @param pointsCloud defines if point cloud rendering has to be turned on
  8831. * @param fogEnabled defines if fog has to be turned on
  8832. * @param alphaTest defines if alpha testing has to be turned on
  8833. * @param defines defines the current list of defines
  8834. */
  8835. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8836. /**
  8837. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8838. * @param scene defines the current scene
  8839. * @param engine defines the current engine
  8840. * @param defines specifies the list of active defines
  8841. * @param useInstances defines if instances have to be turned on
  8842. * @param useClipPlane defines if clip plane have to be turned on
  8843. */
  8844. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8845. /**
  8846. * Prepares the defines for bones
  8847. * @param mesh The mesh containing the geometry data we will draw
  8848. * @param defines The defines to update
  8849. */
  8850. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8851. /**
  8852. * Prepares the defines for morph targets
  8853. * @param mesh The mesh containing the geometry data we will draw
  8854. * @param defines The defines to update
  8855. */
  8856. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8857. /**
  8858. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8859. * @param mesh The mesh containing the geometry data we will draw
  8860. * @param defines The defines to update
  8861. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8862. * @param useBones Precise whether bones should be used or not (override mesh info)
  8863. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8864. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8865. * @returns false if defines are considered not dirty and have not been checked
  8866. */
  8867. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8868. /**
  8869. * Prepares the defines related to multiview
  8870. * @param scene The scene we are intending to draw
  8871. * @param defines The defines to update
  8872. */
  8873. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8874. /**
  8875. * Prepares the defines related to the light information passed in parameter
  8876. * @param scene The scene we are intending to draw
  8877. * @param mesh The mesh the effect is compiling for
  8878. * @param light The light the effect is compiling for
  8879. * @param lightIndex The index of the light
  8880. * @param defines The defines to update
  8881. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8882. * @param state Defines the current state regarding what is needed (normals, etc...)
  8883. */
  8884. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8885. needNormals: boolean;
  8886. needRebuild: boolean;
  8887. shadowEnabled: boolean;
  8888. specularEnabled: boolean;
  8889. lightmapMode: boolean;
  8890. }): void;
  8891. /**
  8892. * Prepares the defines related to the light information passed in parameter
  8893. * @param scene The scene we are intending to draw
  8894. * @param mesh The mesh the effect is compiling for
  8895. * @param defines The defines to update
  8896. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8897. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8898. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8899. * @returns true if normals will be required for the rest of the effect
  8900. */
  8901. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8902. /**
  8903. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8904. * @param lightIndex defines the light index
  8905. * @param uniformsList The uniform list
  8906. * @param samplersList The sampler list
  8907. * @param projectedLightTexture defines if projected texture must be used
  8908. * @param uniformBuffersList defines an optional list of uniform buffers
  8909. */
  8910. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8911. /**
  8912. * Prepares the uniforms and samplers list to be used in the effect
  8913. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8914. * @param samplersList The sampler list
  8915. * @param defines The defines helping in the list generation
  8916. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8917. */
  8918. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8919. /**
  8920. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8921. * @param defines The defines to update while falling back
  8922. * @param fallbacks The authorized effect fallbacks
  8923. * @param maxSimultaneousLights The maximum number of lights allowed
  8924. * @param rank the current rank of the Effect
  8925. * @returns The newly affected rank
  8926. */
  8927. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8928. private static _TmpMorphInfluencers;
  8929. /**
  8930. * Prepares the list of attributes required for morph targets according to the effect defines.
  8931. * @param attribs The current list of supported attribs
  8932. * @param mesh The mesh to prepare the morph targets attributes for
  8933. * @param influencers The number of influencers
  8934. */
  8935. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8936. /**
  8937. * Prepares the list of attributes required for morph targets according to the effect defines.
  8938. * @param attribs The current list of supported attribs
  8939. * @param mesh The mesh to prepare the morph targets attributes for
  8940. * @param defines The current Defines of the effect
  8941. */
  8942. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8943. /**
  8944. * Prepares the list of attributes required for bones according to the effect defines.
  8945. * @param attribs The current list of supported attribs
  8946. * @param mesh The mesh to prepare the bones attributes for
  8947. * @param defines The current Defines of the effect
  8948. * @param fallbacks The current efffect fallback strategy
  8949. */
  8950. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8951. /**
  8952. * Check and prepare the list of attributes required for instances according to the effect defines.
  8953. * @param attribs The current list of supported attribs
  8954. * @param defines The current MaterialDefines of the effect
  8955. */
  8956. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8957. /**
  8958. * Add the list of attributes required for instances to the attribs array.
  8959. * @param attribs The current list of supported attribs
  8960. */
  8961. static PushAttributesForInstances(attribs: string[]): void;
  8962. /**
  8963. * Binds the light information to the effect.
  8964. * @param light The light containing the generator
  8965. * @param effect The effect we are binding the data to
  8966. * @param lightIndex The light index in the effect used to render
  8967. */
  8968. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8969. /**
  8970. * Binds the lights information from the scene to the effect for the given mesh.
  8971. * @param light Light to bind
  8972. * @param lightIndex Light index
  8973. * @param scene The scene where the light belongs to
  8974. * @param effect The effect we are binding the data to
  8975. * @param useSpecular Defines if specular is supported
  8976. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8977. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8978. */
  8979. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8980. /**
  8981. * Binds the lights information from the scene to the effect for the given mesh.
  8982. * @param scene The scene the lights belongs to
  8983. * @param mesh The mesh we are binding the information to render
  8984. * @param effect The effect we are binding the data to
  8985. * @param defines The generated defines for the effect
  8986. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8987. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8988. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8989. */
  8990. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8991. private static _tempFogColor;
  8992. /**
  8993. * Binds the fog information from the scene to the effect for the given mesh.
  8994. * @param scene The scene the lights belongs to
  8995. * @param mesh The mesh we are binding the information to render
  8996. * @param effect The effect we are binding the data to
  8997. * @param linearSpace Defines if the fog effect is applied in linear space
  8998. */
  8999. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9000. /**
  9001. * Binds the bones information from the mesh to the effect.
  9002. * @param mesh The mesh we are binding the information to render
  9003. * @param effect The effect we are binding the data to
  9004. */
  9005. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9006. /**
  9007. * Binds the morph targets information from the mesh to the effect.
  9008. * @param abstractMesh The mesh we are binding the information to render
  9009. * @param effect The effect we are binding the data to
  9010. */
  9011. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9012. /**
  9013. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9014. * @param defines The generated defines used in the effect
  9015. * @param effect The effect we are binding the data to
  9016. * @param scene The scene we are willing to render with logarithmic scale for
  9017. */
  9018. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9019. /**
  9020. * Binds the clip plane information from the scene to the effect.
  9021. * @param scene The scene the clip plane information are extracted from
  9022. * @param effect The effect we are binding the data to
  9023. */
  9024. static BindClipPlane(effect: Effect, scene: Scene): void;
  9025. }
  9026. }
  9027. declare module BABYLON {
  9028. /** @hidden */
  9029. export var packingFunctions: {
  9030. name: string;
  9031. shader: string;
  9032. };
  9033. }
  9034. declare module BABYLON {
  9035. /** @hidden */
  9036. export var shadowMapPixelShader: {
  9037. name: string;
  9038. shader: string;
  9039. };
  9040. }
  9041. declare module BABYLON {
  9042. /** @hidden */
  9043. export var bonesDeclaration: {
  9044. name: string;
  9045. shader: string;
  9046. };
  9047. }
  9048. declare module BABYLON {
  9049. /** @hidden */
  9050. export var morphTargetsVertexGlobalDeclaration: {
  9051. name: string;
  9052. shader: string;
  9053. };
  9054. }
  9055. declare module BABYLON {
  9056. /** @hidden */
  9057. export var morphTargetsVertexDeclaration: {
  9058. name: string;
  9059. shader: string;
  9060. };
  9061. }
  9062. declare module BABYLON {
  9063. /** @hidden */
  9064. export var instancesDeclaration: {
  9065. name: string;
  9066. shader: string;
  9067. };
  9068. }
  9069. declare module BABYLON {
  9070. /** @hidden */
  9071. export var helperFunctions: {
  9072. name: string;
  9073. shader: string;
  9074. };
  9075. }
  9076. declare module BABYLON {
  9077. /** @hidden */
  9078. export var morphTargetsVertex: {
  9079. name: string;
  9080. shader: string;
  9081. };
  9082. }
  9083. declare module BABYLON {
  9084. /** @hidden */
  9085. export var instancesVertex: {
  9086. name: string;
  9087. shader: string;
  9088. };
  9089. }
  9090. declare module BABYLON {
  9091. /** @hidden */
  9092. export var bonesVertex: {
  9093. name: string;
  9094. shader: string;
  9095. };
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var shadowMapVertexShader: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var depthBoxBlurPixelShader: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /**
  9113. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9114. */
  9115. export interface ICustomShaderOptions {
  9116. /**
  9117. * Gets or sets the custom shader name to use
  9118. */
  9119. shaderName: string;
  9120. /**
  9121. * The list of attribute names used in the shader
  9122. */
  9123. attributes?: string[];
  9124. /**
  9125. * The list of unifrom names used in the shader
  9126. */
  9127. uniforms?: string[];
  9128. /**
  9129. * The list of sampler names used in the shader
  9130. */
  9131. samplers?: string[];
  9132. /**
  9133. * The list of defines used in the shader
  9134. */
  9135. defines?: string[];
  9136. }
  9137. /**
  9138. * Interface to implement to create a shadow generator compatible with BJS.
  9139. */
  9140. export interface IShadowGenerator {
  9141. /**
  9142. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9143. * @returns The render target texture if present otherwise, null
  9144. */
  9145. getShadowMap(): Nullable<RenderTargetTexture>;
  9146. /**
  9147. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9148. * @returns The render target texture if the shadow map is present otherwise, null
  9149. */
  9150. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9151. /**
  9152. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9153. * @param subMesh The submesh we want to render in the shadow map
  9154. * @param useInstances Defines wether will draw in the map using instances
  9155. * @returns true if ready otherwise, false
  9156. */
  9157. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9158. /**
  9159. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9160. * @param defines Defines of the material we want to update
  9161. * @param lightIndex Index of the light in the enabled light list of the material
  9162. */
  9163. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9164. /**
  9165. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9166. * defined in the generator but impacting the effect).
  9167. * It implies the unifroms available on the materials are the standard BJS ones.
  9168. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9169. * @param effect The effect we are binfing the information for
  9170. */
  9171. bindShadowLight(lightIndex: string, effect: Effect): void;
  9172. /**
  9173. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9174. * (eq to shadow prjection matrix * light transform matrix)
  9175. * @returns The transform matrix used to create the shadow map
  9176. */
  9177. getTransformMatrix(): Matrix;
  9178. /**
  9179. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9180. * Cube and 2D textures for instance.
  9181. */
  9182. recreateShadowMap(): void;
  9183. /**
  9184. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9185. * @param onCompiled Callback triggered at the and of the effects compilation
  9186. * @param options Sets of optional options forcing the compilation with different modes
  9187. */
  9188. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9189. useInstances: boolean;
  9190. }>): void;
  9191. /**
  9192. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9193. * @param options Sets of optional options forcing the compilation with different modes
  9194. * @returns A promise that resolves when the compilation completes
  9195. */
  9196. forceCompilationAsync(options?: Partial<{
  9197. useInstances: boolean;
  9198. }>): Promise<void>;
  9199. /**
  9200. * Serializes the shadow generator setup to a json object.
  9201. * @returns The serialized JSON object
  9202. */
  9203. serialize(): any;
  9204. /**
  9205. * Disposes the Shadow map and related Textures and effects.
  9206. */
  9207. dispose(): void;
  9208. }
  9209. /**
  9210. * Default implementation IShadowGenerator.
  9211. * This is the main object responsible of generating shadows in the framework.
  9212. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9213. */
  9214. export class ShadowGenerator implements IShadowGenerator {
  9215. /**
  9216. * Shadow generator mode None: no filtering applied.
  9217. */
  9218. static readonly FILTER_NONE: number;
  9219. /**
  9220. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9221. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9222. */
  9223. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9224. /**
  9225. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9226. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9227. */
  9228. static readonly FILTER_POISSONSAMPLING: number;
  9229. /**
  9230. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9231. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9232. */
  9233. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9234. /**
  9235. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9236. * edge artifacts on steep falloff.
  9237. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9238. */
  9239. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9240. /**
  9241. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9242. * edge artifacts on steep falloff.
  9243. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9244. */
  9245. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9246. /**
  9247. * Shadow generator mode PCF: Percentage Closer Filtering
  9248. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9249. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9250. */
  9251. static readonly FILTER_PCF: number;
  9252. /**
  9253. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9254. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9255. * Contact Hardening
  9256. */
  9257. static readonly FILTER_PCSS: number;
  9258. /**
  9259. * Reserved for PCF and PCSS
  9260. * Highest Quality.
  9261. *
  9262. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9263. *
  9264. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9265. */
  9266. static readonly QUALITY_HIGH: number;
  9267. /**
  9268. * Reserved for PCF and PCSS
  9269. * Good tradeoff for quality/perf cross devices
  9270. *
  9271. * Execute PCF on a 3*3 kernel.
  9272. *
  9273. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9274. */
  9275. static readonly QUALITY_MEDIUM: number;
  9276. /**
  9277. * Reserved for PCF and PCSS
  9278. * The lowest quality but the fastest.
  9279. *
  9280. * Execute PCF on a 1*1 kernel.
  9281. *
  9282. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9283. */
  9284. static readonly QUALITY_LOW: number;
  9285. /** Gets or sets the custom shader name to use */
  9286. customShaderOptions: ICustomShaderOptions;
  9287. /**
  9288. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9289. */
  9290. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9291. /**
  9292. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9293. */
  9294. onAfterShadowMapRenderObservable: Observable<Effect>;
  9295. /**
  9296. * Observable triggered before a mesh is rendered in the shadow map.
  9297. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9298. */
  9299. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9300. /**
  9301. * Observable triggered after a mesh is rendered in the shadow map.
  9302. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9303. */
  9304. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9305. private _bias;
  9306. /**
  9307. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9308. */
  9309. /**
  9310. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9311. */
  9312. bias: number;
  9313. private _normalBias;
  9314. /**
  9315. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9316. */
  9317. /**
  9318. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9319. */
  9320. normalBias: number;
  9321. private _blurBoxOffset;
  9322. /**
  9323. * Gets the blur box offset: offset applied during the blur pass.
  9324. * Only useful if useKernelBlur = false
  9325. */
  9326. /**
  9327. * Sets the blur box offset: offset applied during the blur pass.
  9328. * Only useful if useKernelBlur = false
  9329. */
  9330. blurBoxOffset: number;
  9331. private _blurScale;
  9332. /**
  9333. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9334. * 2 means half of the size.
  9335. */
  9336. /**
  9337. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9338. * 2 means half of the size.
  9339. */
  9340. blurScale: number;
  9341. private _blurKernel;
  9342. /**
  9343. * Gets the blur kernel: kernel size of the blur pass.
  9344. * Only useful if useKernelBlur = true
  9345. */
  9346. /**
  9347. * Sets the blur kernel: kernel size of the blur pass.
  9348. * Only useful if useKernelBlur = true
  9349. */
  9350. blurKernel: number;
  9351. private _useKernelBlur;
  9352. /**
  9353. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9354. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9355. */
  9356. /**
  9357. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9358. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9359. */
  9360. useKernelBlur: boolean;
  9361. private _depthScale;
  9362. /**
  9363. * Gets the depth scale used in ESM mode.
  9364. */
  9365. /**
  9366. * Sets the depth scale used in ESM mode.
  9367. * This can override the scale stored on the light.
  9368. */
  9369. depthScale: number;
  9370. private _filter;
  9371. /**
  9372. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9373. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9374. */
  9375. /**
  9376. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9377. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9378. */
  9379. filter: number;
  9380. /**
  9381. * Gets if the current filter is set to Poisson Sampling.
  9382. */
  9383. /**
  9384. * Sets the current filter to Poisson Sampling.
  9385. */
  9386. usePoissonSampling: boolean;
  9387. /**
  9388. * Gets if the current filter is set to ESM.
  9389. */
  9390. /**
  9391. * Sets the current filter is to ESM.
  9392. */
  9393. useExponentialShadowMap: boolean;
  9394. /**
  9395. * Gets if the current filter is set to filtered ESM.
  9396. */
  9397. /**
  9398. * Gets if the current filter is set to filtered ESM.
  9399. */
  9400. useBlurExponentialShadowMap: boolean;
  9401. /**
  9402. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9403. * exponential to prevent steep falloff artifacts).
  9404. */
  9405. /**
  9406. * Sets the current filter to "close ESM" (using the inverse of the
  9407. * exponential to prevent steep falloff artifacts).
  9408. */
  9409. useCloseExponentialShadowMap: boolean;
  9410. /**
  9411. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9412. * exponential to prevent steep falloff artifacts).
  9413. */
  9414. /**
  9415. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9416. * exponential to prevent steep falloff artifacts).
  9417. */
  9418. useBlurCloseExponentialShadowMap: boolean;
  9419. /**
  9420. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9421. */
  9422. /**
  9423. * Sets the current filter to "PCF" (percentage closer filtering).
  9424. */
  9425. usePercentageCloserFiltering: boolean;
  9426. private _filteringQuality;
  9427. /**
  9428. * Gets the PCF or PCSS Quality.
  9429. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9430. */
  9431. /**
  9432. * Sets the PCF or PCSS Quality.
  9433. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9434. */
  9435. filteringQuality: number;
  9436. /**
  9437. * Gets if the current filter is set to "PCSS" (contact hardening).
  9438. */
  9439. /**
  9440. * Sets the current filter to "PCSS" (contact hardening).
  9441. */
  9442. useContactHardeningShadow: boolean;
  9443. private _contactHardeningLightSizeUVRatio;
  9444. /**
  9445. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9446. * Using a ratio helps keeping shape stability independently of the map size.
  9447. *
  9448. * It does not account for the light projection as it was having too much
  9449. * instability during the light setup or during light position changes.
  9450. *
  9451. * Only valid if useContactHardeningShadow is true.
  9452. */
  9453. /**
  9454. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9455. * Using a ratio helps keeping shape stability independently of the map size.
  9456. *
  9457. * It does not account for the light projection as it was having too much
  9458. * instability during the light setup or during light position changes.
  9459. *
  9460. * Only valid if useContactHardeningShadow is true.
  9461. */
  9462. contactHardeningLightSizeUVRatio: number;
  9463. private _darkness;
  9464. /** Gets or sets the actual darkness of a shadow */
  9465. darkness: number;
  9466. /**
  9467. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9468. * 0 means strongest and 1 would means no shadow.
  9469. * @returns the darkness.
  9470. */
  9471. getDarkness(): number;
  9472. /**
  9473. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9474. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9475. * @returns the shadow generator allowing fluent coding.
  9476. */
  9477. setDarkness(darkness: number): ShadowGenerator;
  9478. private _transparencyShadow;
  9479. /** Gets or sets the ability to have transparent shadow */
  9480. transparencyShadow: boolean;
  9481. /**
  9482. * Sets the ability to have transparent shadow (boolean).
  9483. * @param transparent True if transparent else False
  9484. * @returns the shadow generator allowing fluent coding
  9485. */
  9486. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9487. private _shadowMap;
  9488. private _shadowMap2;
  9489. /**
  9490. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9491. * @returns The render target texture if present otherwise, null
  9492. */
  9493. getShadowMap(): Nullable<RenderTargetTexture>;
  9494. /**
  9495. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9496. * @returns The render target texture if the shadow map is present otherwise, null
  9497. */
  9498. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9499. /**
  9500. * Gets the class name of that object
  9501. * @returns "ShadowGenerator"
  9502. */
  9503. getClassName(): string;
  9504. /**
  9505. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9506. * @param mesh Mesh to add
  9507. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9508. * @returns the Shadow Generator itself
  9509. */
  9510. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9511. /**
  9512. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9513. * @param mesh Mesh to remove
  9514. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9515. * @returns the Shadow Generator itself
  9516. */
  9517. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9518. /**
  9519. * Controls the extent to which the shadows fade out at the edge of the frustum
  9520. * Used only by directionals and spots
  9521. */
  9522. frustumEdgeFalloff: number;
  9523. private _light;
  9524. /**
  9525. * Returns the associated light object.
  9526. * @returns the light generating the shadow
  9527. */
  9528. getLight(): IShadowLight;
  9529. /**
  9530. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9531. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9532. * It might on the other hand introduce peter panning.
  9533. */
  9534. forceBackFacesOnly: boolean;
  9535. private _scene;
  9536. private _lightDirection;
  9537. private _effect;
  9538. private _viewMatrix;
  9539. private _projectionMatrix;
  9540. private _transformMatrix;
  9541. private _cachedPosition;
  9542. private _cachedDirection;
  9543. private _cachedDefines;
  9544. private _currentRenderID;
  9545. private _boxBlurPostprocess;
  9546. private _kernelBlurXPostprocess;
  9547. private _kernelBlurYPostprocess;
  9548. private _blurPostProcesses;
  9549. private _mapSize;
  9550. private _currentFaceIndex;
  9551. private _currentFaceIndexCache;
  9552. private _textureType;
  9553. private _defaultTextureMatrix;
  9554. private _storedUniqueId;
  9555. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9556. /**
  9557. * Creates a ShadowGenerator object.
  9558. * A ShadowGenerator is the required tool to use the shadows.
  9559. * Each light casting shadows needs to use its own ShadowGenerator.
  9560. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9561. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9562. * @param light The light object generating the shadows.
  9563. * @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.
  9564. */
  9565. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9566. private _initializeGenerator;
  9567. private _initializeShadowMap;
  9568. private _initializeBlurRTTAndPostProcesses;
  9569. private _renderForShadowMap;
  9570. private _renderSubMeshForShadowMap;
  9571. private _applyFilterValues;
  9572. /**
  9573. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9574. * @param onCompiled Callback triggered at the and of the effects compilation
  9575. * @param options Sets of optional options forcing the compilation with different modes
  9576. */
  9577. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9578. useInstances: boolean;
  9579. }>): void;
  9580. /**
  9581. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9582. * @param options Sets of optional options forcing the compilation with different modes
  9583. * @returns A promise that resolves when the compilation completes
  9584. */
  9585. forceCompilationAsync(options?: Partial<{
  9586. useInstances: boolean;
  9587. }>): Promise<void>;
  9588. /**
  9589. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9590. * @param subMesh The submesh we want to render in the shadow map
  9591. * @param useInstances Defines wether will draw in the map using instances
  9592. * @returns true if ready otherwise, false
  9593. */
  9594. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9595. /**
  9596. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9597. * @param defines Defines of the material we want to update
  9598. * @param lightIndex Index of the light in the enabled light list of the material
  9599. */
  9600. prepareDefines(defines: any, lightIndex: number): void;
  9601. /**
  9602. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9603. * defined in the generator but impacting the effect).
  9604. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9605. * @param effect The effect we are binfing the information for
  9606. */
  9607. bindShadowLight(lightIndex: string, effect: Effect): void;
  9608. /**
  9609. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9610. * (eq to shadow prjection matrix * light transform matrix)
  9611. * @returns The transform matrix used to create the shadow map
  9612. */
  9613. getTransformMatrix(): Matrix;
  9614. /**
  9615. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9616. * Cube and 2D textures for instance.
  9617. */
  9618. recreateShadowMap(): void;
  9619. private _disposeBlurPostProcesses;
  9620. private _disposeRTTandPostProcesses;
  9621. /**
  9622. * Disposes the ShadowGenerator.
  9623. * Returns nothing.
  9624. */
  9625. dispose(): void;
  9626. /**
  9627. * Serializes the shadow generator setup to a json object.
  9628. * @returns The serialized JSON object
  9629. */
  9630. serialize(): any;
  9631. /**
  9632. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9633. * @param parsedShadowGenerator The JSON object to parse
  9634. * @param scene The scene to create the shadow map for
  9635. * @returns The parsed shadow generator
  9636. */
  9637. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9638. }
  9639. }
  9640. declare module BABYLON {
  9641. /**
  9642. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9643. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9644. * 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.
  9645. */
  9646. export abstract class Light extends Node {
  9647. /**
  9648. * Falloff Default: light is falling off following the material specification:
  9649. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9650. */
  9651. static readonly FALLOFF_DEFAULT: number;
  9652. /**
  9653. * Falloff Physical: light is falling off following the inverse squared distance law.
  9654. */
  9655. static readonly FALLOFF_PHYSICAL: number;
  9656. /**
  9657. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9658. * to enhance interoperability with other engines.
  9659. */
  9660. static readonly FALLOFF_GLTF: number;
  9661. /**
  9662. * Falloff Standard: light is falling off like in the standard material
  9663. * to enhance interoperability with other materials.
  9664. */
  9665. static readonly FALLOFF_STANDARD: number;
  9666. /**
  9667. * If every light affecting the material is in this lightmapMode,
  9668. * material.lightmapTexture adds or multiplies
  9669. * (depends on material.useLightmapAsShadowmap)
  9670. * after every other light calculations.
  9671. */
  9672. static readonly LIGHTMAP_DEFAULT: number;
  9673. /**
  9674. * material.lightmapTexture as only diffuse lighting from this light
  9675. * adds only specular lighting from this light
  9676. * adds dynamic shadows
  9677. */
  9678. static readonly LIGHTMAP_SPECULAR: number;
  9679. /**
  9680. * material.lightmapTexture as only lighting
  9681. * no light calculation from this light
  9682. * only adds dynamic shadows from this light
  9683. */
  9684. static readonly LIGHTMAP_SHADOWSONLY: number;
  9685. /**
  9686. * Each light type uses the default quantity according to its type:
  9687. * point/spot lights use luminous intensity
  9688. * directional lights use illuminance
  9689. */
  9690. static readonly INTENSITYMODE_AUTOMATIC: number;
  9691. /**
  9692. * lumen (lm)
  9693. */
  9694. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9695. /**
  9696. * candela (lm/sr)
  9697. */
  9698. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9699. /**
  9700. * lux (lm/m^2)
  9701. */
  9702. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9703. /**
  9704. * nit (cd/m^2)
  9705. */
  9706. static readonly INTENSITYMODE_LUMINANCE: number;
  9707. /**
  9708. * Light type const id of the point light.
  9709. */
  9710. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9711. /**
  9712. * Light type const id of the directional light.
  9713. */
  9714. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9715. /**
  9716. * Light type const id of the spot light.
  9717. */
  9718. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9719. /**
  9720. * Light type const id of the hemispheric light.
  9721. */
  9722. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9723. /**
  9724. * Diffuse gives the basic color to an object.
  9725. */
  9726. diffuse: Color3;
  9727. /**
  9728. * Specular produces a highlight color on an object.
  9729. * Note: This is note affecting PBR materials.
  9730. */
  9731. specular: Color3;
  9732. /**
  9733. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9734. * falling off base on range or angle.
  9735. * This can be set to any values in Light.FALLOFF_x.
  9736. *
  9737. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9738. * other types of materials.
  9739. */
  9740. falloffType: number;
  9741. /**
  9742. * Strength of the light.
  9743. * Note: By default it is define in the framework own unit.
  9744. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9745. */
  9746. intensity: number;
  9747. private _range;
  9748. protected _inverseSquaredRange: number;
  9749. /**
  9750. * Defines how far from the source the light is impacting in scene units.
  9751. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9752. */
  9753. /**
  9754. * Defines how far from the source the light is impacting in scene units.
  9755. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9756. */
  9757. range: number;
  9758. /**
  9759. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9760. * of light.
  9761. */
  9762. private _photometricScale;
  9763. private _intensityMode;
  9764. /**
  9765. * Gets the photometric scale used to interpret the intensity.
  9766. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9767. */
  9768. /**
  9769. * Sets the photometric scale used to interpret the intensity.
  9770. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9771. */
  9772. intensityMode: number;
  9773. private _radius;
  9774. /**
  9775. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9776. */
  9777. /**
  9778. * sets the light radius used by PBR Materials to simulate soft area lights.
  9779. */
  9780. radius: number;
  9781. private _renderPriority;
  9782. /**
  9783. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9784. * exceeding the number allowed of the materials.
  9785. */
  9786. renderPriority: number;
  9787. private _shadowEnabled;
  9788. /**
  9789. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9790. * the current shadow generator.
  9791. */
  9792. /**
  9793. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9794. * the current shadow generator.
  9795. */
  9796. shadowEnabled: boolean;
  9797. private _includedOnlyMeshes;
  9798. /**
  9799. * Gets the only meshes impacted by this light.
  9800. */
  9801. /**
  9802. * Sets the only meshes impacted by this light.
  9803. */
  9804. includedOnlyMeshes: AbstractMesh[];
  9805. private _excludedMeshes;
  9806. /**
  9807. * Gets the meshes not impacted by this light.
  9808. */
  9809. /**
  9810. * Sets the meshes not impacted by this light.
  9811. */
  9812. excludedMeshes: AbstractMesh[];
  9813. private _excludeWithLayerMask;
  9814. /**
  9815. * Gets the layer id use to find what meshes are not impacted by the light.
  9816. * Inactive if 0
  9817. */
  9818. /**
  9819. * Sets the layer id use to find what meshes are not impacted by the light.
  9820. * Inactive if 0
  9821. */
  9822. excludeWithLayerMask: number;
  9823. private _includeOnlyWithLayerMask;
  9824. /**
  9825. * Gets the layer id use to find what meshes are impacted by the light.
  9826. * Inactive if 0
  9827. */
  9828. /**
  9829. * Sets the layer id use to find what meshes are impacted by the light.
  9830. * Inactive if 0
  9831. */
  9832. includeOnlyWithLayerMask: number;
  9833. private _lightmapMode;
  9834. /**
  9835. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9836. */
  9837. /**
  9838. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9839. */
  9840. lightmapMode: number;
  9841. /**
  9842. * Shadow generator associted to the light.
  9843. * @hidden Internal use only.
  9844. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9845. /**
  9846. * @hidden Internal use only.
  9847. */ private _excludedMeshesIds: string[];
  9848. /**
  9849. * @hidden Internal use only.
  9850. */ private _includedOnlyMeshesIds: string[];
  9851. /**
  9852. * The current light unifom buffer.
  9853. * @hidden Internal use only.
  9854. */ private _uniformBuffer: UniformBuffer;
  9855. /** @hidden */ private _renderId: number;
  9856. /**
  9857. * Creates a Light object in the scene.
  9858. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9859. * @param name The firendly name of the light
  9860. * @param scene The scene the light belongs too
  9861. */
  9862. constructor(name: string, scene: Scene);
  9863. protected abstract _buildUniformLayout(): void;
  9864. /**
  9865. * Sets the passed Effect "effect" with the Light information.
  9866. * @param effect The effect to update
  9867. * @param lightIndex The index of the light in the effect to update
  9868. * @returns The light
  9869. */
  9870. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9871. /**
  9872. * Sets the passed Effect "effect" with the Light information.
  9873. * @param effect The effect to update
  9874. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9875. * @returns The light
  9876. */
  9877. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9878. /**
  9879. * Returns the string "Light".
  9880. * @returns the class name
  9881. */
  9882. getClassName(): string;
  9883. /** @hidden */ protected readonly _isLight: boolean;
  9884. /**
  9885. * Converts the light information to a readable string for debug purpose.
  9886. * @param fullDetails Supports for multiple levels of logging within scene loading
  9887. * @returns the human readable light info
  9888. */
  9889. toString(fullDetails?: boolean): string;
  9890. /** @hidden */
  9891. protected _syncParentEnabledState(): void;
  9892. /**
  9893. * Set the enabled state of this node.
  9894. * @param value - the new enabled state
  9895. */
  9896. setEnabled(value: boolean): void;
  9897. /**
  9898. * Returns the Light associated shadow generator if any.
  9899. * @return the associated shadow generator.
  9900. */
  9901. getShadowGenerator(): Nullable<IShadowGenerator>;
  9902. /**
  9903. * Returns a Vector3, the absolute light position in the World.
  9904. * @returns the world space position of the light
  9905. */
  9906. getAbsolutePosition(): Vector3;
  9907. /**
  9908. * Specifies if the light will affect the passed mesh.
  9909. * @param mesh The mesh to test against the light
  9910. * @return true the mesh is affected otherwise, false.
  9911. */
  9912. canAffectMesh(mesh: AbstractMesh): boolean;
  9913. /**
  9914. * Sort function to order lights for rendering.
  9915. * @param a First Light object to compare to second.
  9916. * @param b Second Light object to compare first.
  9917. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9918. */
  9919. static CompareLightsPriority(a: Light, b: Light): number;
  9920. /**
  9921. * Releases resources associated with this node.
  9922. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9923. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9924. */
  9925. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9926. /**
  9927. * Returns the light type ID (integer).
  9928. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9929. */
  9930. getTypeID(): number;
  9931. /**
  9932. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9933. * @returns the scaled intensity in intensity mode unit
  9934. */
  9935. getScaledIntensity(): number;
  9936. /**
  9937. * Returns a new Light object, named "name", from the current one.
  9938. * @param name The name of the cloned light
  9939. * @returns the new created light
  9940. */
  9941. clone(name: string): Nullable<Light>;
  9942. /**
  9943. * Serializes the current light into a Serialization object.
  9944. * @returns the serialized object.
  9945. */
  9946. serialize(): any;
  9947. /**
  9948. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9949. * This new light is named "name" and added to the passed scene.
  9950. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9951. * @param name The friendly name of the light
  9952. * @param scene The scene the new light will belong to
  9953. * @returns the constructor function
  9954. */
  9955. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9956. /**
  9957. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9958. * @param parsedLight The JSON representation of the light
  9959. * @param scene The scene to create the parsed light in
  9960. * @returns the created light after parsing
  9961. */
  9962. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9963. private _hookArrayForExcluded;
  9964. private _hookArrayForIncludedOnly;
  9965. private _resyncMeshes;
  9966. /**
  9967. * Forces the meshes to update their light related information in their rendering used effects
  9968. * @hidden Internal Use Only
  9969. */ private _markMeshesAsLightDirty(): void;
  9970. /**
  9971. * Recomputes the cached photometric scale if needed.
  9972. */
  9973. private _computePhotometricScale;
  9974. /**
  9975. * Returns the Photometric Scale according to the light type and intensity mode.
  9976. */
  9977. private _getPhotometricScale;
  9978. /**
  9979. * Reorder the light in the scene according to their defined priority.
  9980. * @hidden Internal Use Only
  9981. */ private _reorderLightsInScene(): void;
  9982. /**
  9983. * Prepares the list of defines specific to the light type.
  9984. * @param defines the list of defines
  9985. * @param lightIndex defines the index of the light for the effect
  9986. */
  9987. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9988. }
  9989. }
  9990. declare module BABYLON {
  9991. /**
  9992. * Interface used to define Action
  9993. */
  9994. export interface IAction {
  9995. /**
  9996. * Trigger for the action
  9997. */
  9998. trigger: number;
  9999. /** Options of the trigger */
  10000. triggerOptions: any;
  10001. /**
  10002. * Gets the trigger parameters
  10003. * @returns the trigger parameters
  10004. */
  10005. getTriggerParameter(): any;
  10006. /**
  10007. * Internal only - executes current action event
  10008. * @hidden
  10009. */ private _executeCurrent(evt?: ActionEvent): void;
  10010. /**
  10011. * Serialize placeholder for child classes
  10012. * @param parent of child
  10013. * @returns the serialized object
  10014. */
  10015. serialize(parent: any): any;
  10016. /**
  10017. * Internal only
  10018. * @hidden
  10019. */ private _prepare(): void;
  10020. /**
  10021. * Internal only - manager for action
  10022. * @hidden
  10023. */ private _actionManager: AbstractActionManager;
  10024. /**
  10025. * Adds action to chain of actions, may be a DoNothingAction
  10026. * @param action defines the next action to execute
  10027. * @returns The action passed in
  10028. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10029. */
  10030. then(action: IAction): IAction;
  10031. }
  10032. /**
  10033. * The action to be carried out following a trigger
  10034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10035. */
  10036. export class Action implements IAction {
  10037. /** the trigger, with or without parameters, for the action */
  10038. triggerOptions: any;
  10039. /**
  10040. * Trigger for the action
  10041. */
  10042. trigger: number;
  10043. /**
  10044. * Internal only - manager for action
  10045. * @hidden
  10046. */ private _actionManager: ActionManager;
  10047. private _nextActiveAction;
  10048. private _child;
  10049. private _condition?;
  10050. private _triggerParameter;
  10051. /**
  10052. * An event triggered prior to action being executed.
  10053. */
  10054. onBeforeExecuteObservable: Observable<Action>;
  10055. /**
  10056. * Creates a new Action
  10057. * @param triggerOptions the trigger, with or without parameters, for the action
  10058. * @param condition an optional determinant of action
  10059. */
  10060. constructor(
  10061. /** the trigger, with or without parameters, for the action */
  10062. triggerOptions: any, condition?: Condition);
  10063. /**
  10064. * Internal only
  10065. * @hidden
  10066. */ private _prepare(): void;
  10067. /**
  10068. * Gets the trigger parameters
  10069. * @returns the trigger parameters
  10070. */
  10071. getTriggerParameter(): any;
  10072. /**
  10073. * Internal only - executes current action event
  10074. * @hidden
  10075. */ private _executeCurrent(evt?: ActionEvent): void;
  10076. /**
  10077. * Execute placeholder for child classes
  10078. * @param evt optional action event
  10079. */
  10080. execute(evt?: ActionEvent): void;
  10081. /**
  10082. * Skips to next active action
  10083. */
  10084. skipToNextActiveAction(): void;
  10085. /**
  10086. * Adds action to chain of actions, may be a DoNothingAction
  10087. * @param action defines the next action to execute
  10088. * @returns The action passed in
  10089. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10090. */
  10091. then(action: Action): Action;
  10092. /**
  10093. * Internal only
  10094. * @hidden
  10095. */ private _getProperty(propertyPath: string): string;
  10096. /**
  10097. * Internal only
  10098. * @hidden
  10099. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10100. /**
  10101. * Serialize placeholder for child classes
  10102. * @param parent of child
  10103. * @returns the serialized object
  10104. */
  10105. serialize(parent: any): any;
  10106. /**
  10107. * Internal only called by serialize
  10108. * @hidden
  10109. */
  10110. protected _serialize(serializedAction: any, parent?: any): any;
  10111. /**
  10112. * Internal only
  10113. * @hidden
  10114. */ private static _SerializeValueAsString: (value: any) => string;
  10115. /**
  10116. * Internal only
  10117. * @hidden
  10118. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10119. name: string;
  10120. targetType: string;
  10121. value: string;
  10122. };
  10123. }
  10124. }
  10125. declare module BABYLON {
  10126. /**
  10127. * A Condition applied to an Action
  10128. */
  10129. export class Condition {
  10130. /**
  10131. * Internal only - manager for action
  10132. * @hidden
  10133. */ private _actionManager: ActionManager;
  10134. /**
  10135. * Internal only
  10136. * @hidden
  10137. */ private _evaluationId: number;
  10138. /**
  10139. * Internal only
  10140. * @hidden
  10141. */ private _currentResult: boolean;
  10142. /**
  10143. * Creates a new Condition
  10144. * @param actionManager the manager of the action the condition is applied to
  10145. */
  10146. constructor(actionManager: ActionManager);
  10147. /**
  10148. * Check if the current condition is valid
  10149. * @returns a boolean
  10150. */
  10151. isValid(): boolean;
  10152. /**
  10153. * Internal only
  10154. * @hidden
  10155. */ private _getProperty(propertyPath: string): string;
  10156. /**
  10157. * Internal only
  10158. * @hidden
  10159. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10160. /**
  10161. * Serialize placeholder for child classes
  10162. * @returns the serialized object
  10163. */
  10164. serialize(): any;
  10165. /**
  10166. * Internal only
  10167. * @hidden
  10168. */
  10169. protected _serialize(serializedCondition: any): any;
  10170. }
  10171. /**
  10172. * Defines specific conditional operators as extensions of Condition
  10173. */
  10174. export class ValueCondition extends Condition {
  10175. /** path to specify the property of the target the conditional operator uses */
  10176. propertyPath: string;
  10177. /** the value compared by the conditional operator against the current value of the property */
  10178. value: any;
  10179. /** the conditional operator, default ValueCondition.IsEqual */
  10180. operator: number;
  10181. /**
  10182. * Internal only
  10183. * @hidden
  10184. */
  10185. private static _IsEqual;
  10186. /**
  10187. * Internal only
  10188. * @hidden
  10189. */
  10190. private static _IsDifferent;
  10191. /**
  10192. * Internal only
  10193. * @hidden
  10194. */
  10195. private static _IsGreater;
  10196. /**
  10197. * Internal only
  10198. * @hidden
  10199. */
  10200. private static _IsLesser;
  10201. /**
  10202. * returns the number for IsEqual
  10203. */
  10204. static readonly IsEqual: number;
  10205. /**
  10206. * Returns the number for IsDifferent
  10207. */
  10208. static readonly IsDifferent: number;
  10209. /**
  10210. * Returns the number for IsGreater
  10211. */
  10212. static readonly IsGreater: number;
  10213. /**
  10214. * Returns the number for IsLesser
  10215. */
  10216. static readonly IsLesser: number;
  10217. /**
  10218. * Internal only The action manager for the condition
  10219. * @hidden
  10220. */ private _actionManager: ActionManager;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. private _target;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. private _effectiveTarget;
  10231. /**
  10232. * Internal only
  10233. * @hidden
  10234. */
  10235. private _property;
  10236. /**
  10237. * Creates a new ValueCondition
  10238. * @param actionManager manager for the action the condition applies to
  10239. * @param target for the action
  10240. * @param propertyPath path to specify the property of the target the conditional operator uses
  10241. * @param value the value compared by the conditional operator against the current value of the property
  10242. * @param operator the conditional operator, default ValueCondition.IsEqual
  10243. */
  10244. constructor(actionManager: ActionManager, target: any,
  10245. /** path to specify the property of the target the conditional operator uses */
  10246. propertyPath: string,
  10247. /** the value compared by the conditional operator against the current value of the property */
  10248. value: any,
  10249. /** the conditional operator, default ValueCondition.IsEqual */
  10250. operator?: number);
  10251. /**
  10252. * Compares the given value with the property value for the specified conditional operator
  10253. * @returns the result of the comparison
  10254. */
  10255. isValid(): boolean;
  10256. /**
  10257. * Serialize the ValueCondition into a JSON compatible object
  10258. * @returns serialization object
  10259. */
  10260. serialize(): any;
  10261. /**
  10262. * Gets the name of the conditional operator for the ValueCondition
  10263. * @param operator the conditional operator
  10264. * @returns the name
  10265. */
  10266. static GetOperatorName(operator: number): string;
  10267. }
  10268. /**
  10269. * Defines a predicate condition as an extension of Condition
  10270. */
  10271. export class PredicateCondition extends Condition {
  10272. /** defines the predicate function used to validate the condition */
  10273. predicate: () => boolean;
  10274. /**
  10275. * Internal only - manager for action
  10276. * @hidden
  10277. */ private _actionManager: ActionManager;
  10278. /**
  10279. * Creates a new PredicateCondition
  10280. * @param actionManager manager for the action the condition applies to
  10281. * @param predicate defines the predicate function used to validate the condition
  10282. */
  10283. constructor(actionManager: ActionManager,
  10284. /** defines the predicate function used to validate the condition */
  10285. predicate: () => boolean);
  10286. /**
  10287. * @returns the validity of the predicate condition
  10288. */
  10289. isValid(): boolean;
  10290. }
  10291. /**
  10292. * Defines a state condition as an extension of Condition
  10293. */
  10294. export class StateCondition extends Condition {
  10295. /** Value to compare with target state */
  10296. value: string;
  10297. /**
  10298. * Internal only - manager for action
  10299. * @hidden
  10300. */ private _actionManager: ActionManager;
  10301. /**
  10302. * Internal only
  10303. * @hidden
  10304. */
  10305. private _target;
  10306. /**
  10307. * Creates a new StateCondition
  10308. * @param actionManager manager for the action the condition applies to
  10309. * @param target of the condition
  10310. * @param value to compare with target state
  10311. */
  10312. constructor(actionManager: ActionManager, target: any,
  10313. /** Value to compare with target state */
  10314. value: string);
  10315. /**
  10316. * Gets a boolean indicating if the current condition is met
  10317. * @returns the validity of the state
  10318. */
  10319. isValid(): boolean;
  10320. /**
  10321. * Serialize the StateCondition into a JSON compatible object
  10322. * @returns serialization object
  10323. */
  10324. serialize(): any;
  10325. }
  10326. }
  10327. declare module BABYLON {
  10328. /**
  10329. * This defines an action responsible to toggle a boolean once triggered.
  10330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10331. */
  10332. export class SwitchBooleanAction extends Action {
  10333. /**
  10334. * The path to the boolean property in the target object
  10335. */
  10336. propertyPath: string;
  10337. private _target;
  10338. private _effectiveTarget;
  10339. private _property;
  10340. /**
  10341. * Instantiate the action
  10342. * @param triggerOptions defines the trigger options
  10343. * @param target defines the object containing the boolean
  10344. * @param propertyPath defines the path to the boolean property in the target object
  10345. * @param condition defines the trigger related conditions
  10346. */
  10347. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10348. /** @hidden */ private _prepare(): void;
  10349. /**
  10350. * Execute the action toggle the boolean value.
  10351. */
  10352. execute(): void;
  10353. /**
  10354. * Serializes the actions and its related information.
  10355. * @param parent defines the object to serialize in
  10356. * @returns the serialized object
  10357. */
  10358. serialize(parent: any): any;
  10359. }
  10360. /**
  10361. * This defines an action responsible to set a the state field of the target
  10362. * to a desired value once triggered.
  10363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10364. */
  10365. export class SetStateAction extends Action {
  10366. /**
  10367. * The value to store in the state field.
  10368. */
  10369. value: string;
  10370. private _target;
  10371. /**
  10372. * Instantiate the action
  10373. * @param triggerOptions defines the trigger options
  10374. * @param target defines the object containing the state property
  10375. * @param value defines the value to store in the state field
  10376. * @param condition defines the trigger related conditions
  10377. */
  10378. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10379. /**
  10380. * Execute the action and store the value on the target state property.
  10381. */
  10382. execute(): void;
  10383. /**
  10384. * Serializes the actions and its related information.
  10385. * @param parent defines the object to serialize in
  10386. * @returns the serialized object
  10387. */
  10388. serialize(parent: any): any;
  10389. }
  10390. /**
  10391. * This defines an action responsible to set a property of the target
  10392. * to a desired value once triggered.
  10393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10394. */
  10395. export class SetValueAction extends Action {
  10396. /**
  10397. * The path of the property to set in the target.
  10398. */
  10399. propertyPath: string;
  10400. /**
  10401. * The value to set in the property
  10402. */
  10403. value: any;
  10404. private _target;
  10405. private _effectiveTarget;
  10406. private _property;
  10407. /**
  10408. * Instantiate the action
  10409. * @param triggerOptions defines the trigger options
  10410. * @param target defines the object containing the property
  10411. * @param propertyPath defines the path of the property to set in the target
  10412. * @param value defines the value to set in the property
  10413. * @param condition defines the trigger related conditions
  10414. */
  10415. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10416. /** @hidden */ private _prepare(): void;
  10417. /**
  10418. * Execute the action and set the targetted property to the desired value.
  10419. */
  10420. execute(): void;
  10421. /**
  10422. * Serializes the actions and its related information.
  10423. * @param parent defines the object to serialize in
  10424. * @returns the serialized object
  10425. */
  10426. serialize(parent: any): any;
  10427. }
  10428. /**
  10429. * This defines an action responsible to increment the target value
  10430. * to a desired value once triggered.
  10431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10432. */
  10433. export class IncrementValueAction extends Action {
  10434. /**
  10435. * The path of the property to increment in the target.
  10436. */
  10437. propertyPath: string;
  10438. /**
  10439. * The value we should increment the property by.
  10440. */
  10441. value: any;
  10442. private _target;
  10443. private _effectiveTarget;
  10444. private _property;
  10445. /**
  10446. * Instantiate the action
  10447. * @param triggerOptions defines the trigger options
  10448. * @param target defines the object containing the property
  10449. * @param propertyPath defines the path of the property to increment in the target
  10450. * @param value defines the value value we should increment the property by
  10451. * @param condition defines the trigger related conditions
  10452. */
  10453. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10454. /** @hidden */ private _prepare(): void;
  10455. /**
  10456. * Execute the action and increment the target of the value amount.
  10457. */
  10458. execute(): void;
  10459. /**
  10460. * Serializes the actions and its related information.
  10461. * @param parent defines the object to serialize in
  10462. * @returns the serialized object
  10463. */
  10464. serialize(parent: any): any;
  10465. }
  10466. /**
  10467. * This defines an action responsible to start an animation once triggered.
  10468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10469. */
  10470. export class PlayAnimationAction extends Action {
  10471. /**
  10472. * Where the animation should start (animation frame)
  10473. */
  10474. from: number;
  10475. /**
  10476. * Where the animation should stop (animation frame)
  10477. */
  10478. to: number;
  10479. /**
  10480. * Define if the animation should loop or stop after the first play.
  10481. */
  10482. loop?: boolean;
  10483. private _target;
  10484. /**
  10485. * Instantiate the action
  10486. * @param triggerOptions defines the trigger options
  10487. * @param target defines the target animation or animation name
  10488. * @param from defines from where the animation should start (animation frame)
  10489. * @param end defines where the animation should stop (animation frame)
  10490. * @param loop defines if the animation should loop or stop after the first play
  10491. * @param condition defines the trigger related conditions
  10492. */
  10493. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10494. /** @hidden */ private _prepare(): void;
  10495. /**
  10496. * Execute the action and play the animation.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to stop an animation once triggered.
  10508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10509. */
  10510. export class StopAnimationAction extends Action {
  10511. private _target;
  10512. /**
  10513. * Instantiate the action
  10514. * @param triggerOptions defines the trigger options
  10515. * @param target defines the target animation or animation name
  10516. * @param condition defines the trigger related conditions
  10517. */
  10518. constructor(triggerOptions: any, target: any, condition?: Condition);
  10519. /** @hidden */ private _prepare(): void;
  10520. /**
  10521. * Execute the action and stop the animation.
  10522. */
  10523. execute(): void;
  10524. /**
  10525. * Serializes the actions and its related information.
  10526. * @param parent defines the object to serialize in
  10527. * @returns the serialized object
  10528. */
  10529. serialize(parent: any): any;
  10530. }
  10531. /**
  10532. * This defines an action responsible that does nothing once triggered.
  10533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10534. */
  10535. export class DoNothingAction extends Action {
  10536. /**
  10537. * Instantiate the action
  10538. * @param triggerOptions defines the trigger options
  10539. * @param condition defines the trigger related conditions
  10540. */
  10541. constructor(triggerOptions?: any, condition?: Condition);
  10542. /**
  10543. * Execute the action and do nothing.
  10544. */
  10545. execute(): void;
  10546. /**
  10547. * Serializes the actions and its related information.
  10548. * @param parent defines the object to serialize in
  10549. * @returns the serialized object
  10550. */
  10551. serialize(parent: any): any;
  10552. }
  10553. /**
  10554. * This defines an action responsible to trigger several actions once triggered.
  10555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10556. */
  10557. export class CombineAction extends Action {
  10558. /**
  10559. * The list of aggregated animations to run.
  10560. */
  10561. children: Action[];
  10562. /**
  10563. * Instantiate the action
  10564. * @param triggerOptions defines the trigger options
  10565. * @param children defines the list of aggregated animations to run
  10566. * @param condition defines the trigger related conditions
  10567. */
  10568. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10569. /** @hidden */ private _prepare(): void;
  10570. /**
  10571. * Execute the action and executes all the aggregated actions.
  10572. */
  10573. execute(evt: ActionEvent): void;
  10574. /**
  10575. * Serializes the actions and its related information.
  10576. * @param parent defines the object to serialize in
  10577. * @returns the serialized object
  10578. */
  10579. serialize(parent: any): any;
  10580. }
  10581. /**
  10582. * This defines an action responsible to run code (external event) once triggered.
  10583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10584. */
  10585. export class ExecuteCodeAction extends Action {
  10586. /**
  10587. * The callback function to run.
  10588. */
  10589. func: (evt: ActionEvent) => void;
  10590. /**
  10591. * Instantiate the action
  10592. * @param triggerOptions defines the trigger options
  10593. * @param func defines the callback function to run
  10594. * @param condition defines the trigger related conditions
  10595. */
  10596. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10597. /**
  10598. * Execute the action and run the attached code.
  10599. */
  10600. execute(evt: ActionEvent): void;
  10601. }
  10602. /**
  10603. * This defines an action responsible to set the parent property of the target once triggered.
  10604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10605. */
  10606. export class SetParentAction extends Action {
  10607. private _parent;
  10608. private _target;
  10609. /**
  10610. * Instantiate the action
  10611. * @param triggerOptions defines the trigger options
  10612. * @param target defines the target containing the parent property
  10613. * @param parent defines from where the animation should start (animation frame)
  10614. * @param condition defines the trigger related conditions
  10615. */
  10616. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10617. /** @hidden */ private _prepare(): void;
  10618. /**
  10619. * Execute the action and set the parent property.
  10620. */
  10621. execute(): void;
  10622. /**
  10623. * Serializes the actions and its related information.
  10624. * @param parent defines the object to serialize in
  10625. * @returns the serialized object
  10626. */
  10627. serialize(parent: any): any;
  10628. }
  10629. }
  10630. declare module BABYLON {
  10631. /**
  10632. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10633. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10635. */
  10636. export class ActionManager extends AbstractActionManager {
  10637. /**
  10638. * Nothing
  10639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10640. */
  10641. static readonly NothingTrigger: number;
  10642. /**
  10643. * On pick
  10644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10645. */
  10646. static readonly OnPickTrigger: number;
  10647. /**
  10648. * On left pick
  10649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10650. */
  10651. static readonly OnLeftPickTrigger: number;
  10652. /**
  10653. * On right pick
  10654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10655. */
  10656. static readonly OnRightPickTrigger: number;
  10657. /**
  10658. * On center pick
  10659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10660. */
  10661. static readonly OnCenterPickTrigger: number;
  10662. /**
  10663. * On pick down
  10664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10665. */
  10666. static readonly OnPickDownTrigger: number;
  10667. /**
  10668. * On double pick
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10670. */
  10671. static readonly OnDoublePickTrigger: number;
  10672. /**
  10673. * On pick up
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10675. */
  10676. static readonly OnPickUpTrigger: number;
  10677. /**
  10678. * On pick out.
  10679. * This trigger will only be raised if you also declared a OnPickDown
  10680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10681. */
  10682. static readonly OnPickOutTrigger: number;
  10683. /**
  10684. * On long press
  10685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10686. */
  10687. static readonly OnLongPressTrigger: number;
  10688. /**
  10689. * On pointer over
  10690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10691. */
  10692. static readonly OnPointerOverTrigger: number;
  10693. /**
  10694. * On pointer out
  10695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10696. */
  10697. static readonly OnPointerOutTrigger: number;
  10698. /**
  10699. * On every frame
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10701. */
  10702. static readonly OnEveryFrameTrigger: number;
  10703. /**
  10704. * On intersection enter
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10706. */
  10707. static readonly OnIntersectionEnterTrigger: number;
  10708. /**
  10709. * On intersection exit
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10711. */
  10712. static readonly OnIntersectionExitTrigger: number;
  10713. /**
  10714. * On key down
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10716. */
  10717. static readonly OnKeyDownTrigger: number;
  10718. /**
  10719. * On key up
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10721. */
  10722. static readonly OnKeyUpTrigger: number;
  10723. private _scene;
  10724. /**
  10725. * Creates a new action manager
  10726. * @param scene defines the hosting scene
  10727. */
  10728. constructor(scene: Scene);
  10729. /**
  10730. * Releases all associated resources
  10731. */
  10732. dispose(): void;
  10733. /**
  10734. * Gets hosting scene
  10735. * @returns the hosting scene
  10736. */
  10737. getScene(): Scene;
  10738. /**
  10739. * Does this action manager handles actions of any of the given triggers
  10740. * @param triggers defines the triggers to be tested
  10741. * @return a boolean indicating whether one (or more) of the triggers is handled
  10742. */
  10743. hasSpecificTriggers(triggers: number[]): boolean;
  10744. /**
  10745. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10746. * speed.
  10747. * @param triggerA defines the trigger to be tested
  10748. * @param triggerB defines the trigger to be tested
  10749. * @return a boolean indicating whether one (or more) of the triggers is handled
  10750. */
  10751. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10752. /**
  10753. * Does this action manager handles actions of a given trigger
  10754. * @param trigger defines the trigger to be tested
  10755. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10756. * @return whether the trigger is handled
  10757. */
  10758. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10759. /**
  10760. * Does this action manager has pointer triggers
  10761. */
  10762. readonly hasPointerTriggers: boolean;
  10763. /**
  10764. * Does this action manager has pick triggers
  10765. */
  10766. readonly hasPickTriggers: boolean;
  10767. /**
  10768. * Registers an action to this action manager
  10769. * @param action defines the action to be registered
  10770. * @return the action amended (prepared) after registration
  10771. */
  10772. registerAction(action: IAction): Nullable<IAction>;
  10773. /**
  10774. * Unregisters an action to this action manager
  10775. * @param action defines the action to be unregistered
  10776. * @return a boolean indicating whether the action has been unregistered
  10777. */
  10778. unregisterAction(action: IAction): Boolean;
  10779. /**
  10780. * Process a specific trigger
  10781. * @param trigger defines the trigger to process
  10782. * @param evt defines the event details to be processed
  10783. */
  10784. processTrigger(trigger: number, evt?: IActionEvent): void;
  10785. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10786. /** @hidden */ private _getProperty(propertyPath: string): string;
  10787. /**
  10788. * Serialize this manager to a JSON object
  10789. * @param name defines the property name to store this manager
  10790. * @returns a JSON representation of this manager
  10791. */
  10792. serialize(name: string): any;
  10793. /**
  10794. * Creates a new ActionManager from a JSON data
  10795. * @param parsedActions defines the JSON data to read from
  10796. * @param object defines the hosting mesh
  10797. * @param scene defines the hosting scene
  10798. */
  10799. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10800. /**
  10801. * Get a trigger name by index
  10802. * @param trigger defines the trigger index
  10803. * @returns a trigger name
  10804. */
  10805. static GetTriggerName(trigger: number): string;
  10806. }
  10807. }
  10808. declare module BABYLON {
  10809. /**
  10810. * Class representing a ray with position and direction
  10811. */
  10812. export class Ray {
  10813. /** origin point */
  10814. origin: Vector3;
  10815. /** direction */
  10816. direction: Vector3;
  10817. /** length of the ray */
  10818. length: number;
  10819. private static readonly TmpVector3;
  10820. private _tmpRay;
  10821. /**
  10822. * Creates a new ray
  10823. * @param origin origin point
  10824. * @param direction direction
  10825. * @param length length of the ray
  10826. */
  10827. constructor(
  10828. /** origin point */
  10829. origin: Vector3,
  10830. /** direction */
  10831. direction: Vector3,
  10832. /** length of the ray */
  10833. length?: number);
  10834. /**
  10835. * Checks if the ray intersects a box
  10836. * @param minimum bound of the box
  10837. * @param maximum bound of the box
  10838. * @param intersectionTreshold extra extend to be added to the box in all direction
  10839. * @returns if the box was hit
  10840. */
  10841. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10842. /**
  10843. * Checks if the ray intersects a box
  10844. * @param box the bounding box to check
  10845. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10846. * @returns if the box was hit
  10847. */
  10848. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10849. /**
  10850. * If the ray hits a sphere
  10851. * @param sphere the bounding sphere to check
  10852. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10853. * @returns true if it hits the sphere
  10854. */
  10855. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10856. /**
  10857. * If the ray hits a triange
  10858. * @param vertex0 triangle vertex
  10859. * @param vertex1 triangle vertex
  10860. * @param vertex2 triangle vertex
  10861. * @returns intersection information if hit
  10862. */
  10863. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10864. /**
  10865. * Checks if ray intersects a plane
  10866. * @param plane the plane to check
  10867. * @returns the distance away it was hit
  10868. */
  10869. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10870. /**
  10871. * Calculate the intercept of a ray on a given axis
  10872. * @param axis to check 'x' | 'y' | 'z'
  10873. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10874. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10875. */
  10876. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10877. /**
  10878. * Checks if ray intersects a mesh
  10879. * @param mesh the mesh to check
  10880. * @param fastCheck if only the bounding box should checked
  10881. * @returns picking info of the intersecton
  10882. */
  10883. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10884. /**
  10885. * Checks if ray intersects a mesh
  10886. * @param meshes the meshes to check
  10887. * @param fastCheck if only the bounding box should checked
  10888. * @param results array to store result in
  10889. * @returns Array of picking infos
  10890. */
  10891. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10892. private _comparePickingInfo;
  10893. private static smallnum;
  10894. private static rayl;
  10895. /**
  10896. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10897. * @param sega the first point of the segment to test the intersection against
  10898. * @param segb the second point of the segment to test the intersection against
  10899. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10900. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10901. */
  10902. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10903. /**
  10904. * Update the ray from viewport position
  10905. * @param x position
  10906. * @param y y position
  10907. * @param viewportWidth viewport width
  10908. * @param viewportHeight viewport height
  10909. * @param world world matrix
  10910. * @param view view matrix
  10911. * @param projection projection matrix
  10912. * @returns this ray updated
  10913. */
  10914. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10915. /**
  10916. * Creates a ray with origin and direction of 0,0,0
  10917. * @returns the new ray
  10918. */
  10919. static Zero(): Ray;
  10920. /**
  10921. * Creates a new ray from screen space and viewport
  10922. * @param x position
  10923. * @param y y position
  10924. * @param viewportWidth viewport width
  10925. * @param viewportHeight viewport height
  10926. * @param world world matrix
  10927. * @param view view matrix
  10928. * @param projection projection matrix
  10929. * @returns new ray
  10930. */
  10931. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10932. /**
  10933. * 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
  10934. * transformed to the given world matrix.
  10935. * @param origin The origin point
  10936. * @param end The end point
  10937. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10938. * @returns the new ray
  10939. */
  10940. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10941. /**
  10942. * Transforms a ray by a matrix
  10943. * @param ray ray to transform
  10944. * @param matrix matrix to apply
  10945. * @returns the resulting new ray
  10946. */
  10947. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10948. /**
  10949. * Transforms a ray by a matrix
  10950. * @param ray ray to transform
  10951. * @param matrix matrix to apply
  10952. * @param result ray to store result in
  10953. */
  10954. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10955. /**
  10956. * Unproject a ray from screen space to object space
  10957. * @param sourceX defines the screen space x coordinate to use
  10958. * @param sourceY defines the screen space y coordinate to use
  10959. * @param viewportWidth defines the current width of the viewport
  10960. * @param viewportHeight defines the current height of the viewport
  10961. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10962. * @param view defines the view matrix to use
  10963. * @param projection defines the projection matrix to use
  10964. */
  10965. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10966. }
  10967. /**
  10968. * Type used to define predicate used to select faces when a mesh intersection is detected
  10969. */
  10970. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10971. interface Scene {
  10972. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  10973. /** @hidden */ private _cachedRayForTransform: Ray;
  10974. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  10975. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10976. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10977. }
  10978. }
  10979. declare module BABYLON {
  10980. /**
  10981. * Groups all the scene component constants in one place to ease maintenance.
  10982. * @hidden
  10983. */
  10984. export class SceneComponentConstants {
  10985. static readonly NAME_EFFECTLAYER: string;
  10986. static readonly NAME_LAYER: string;
  10987. static readonly NAME_LENSFLARESYSTEM: string;
  10988. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10989. static readonly NAME_PARTICLESYSTEM: string;
  10990. static readonly NAME_GAMEPAD: string;
  10991. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10992. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10993. static readonly NAME_DEPTHRENDERER: string;
  10994. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10995. static readonly NAME_SPRITE: string;
  10996. static readonly NAME_OUTLINERENDERER: string;
  10997. static readonly NAME_PROCEDURALTEXTURE: string;
  10998. static readonly NAME_SHADOWGENERATOR: string;
  10999. static readonly NAME_OCTREE: string;
  11000. static readonly NAME_PHYSICSENGINE: string;
  11001. static readonly NAME_AUDIO: string;
  11002. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11003. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11004. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11005. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11006. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11007. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11008. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11009. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11010. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11011. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11012. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11013. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11014. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11015. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11016. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11017. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11018. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11019. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11020. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11021. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11022. static readonly STEP_AFTERRENDER_AUDIO: number;
  11023. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11024. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11025. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11026. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11027. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11028. static readonly STEP_POINTERMOVE_SPRITE: number;
  11029. static readonly STEP_POINTERDOWN_SPRITE: number;
  11030. static readonly STEP_POINTERUP_SPRITE: number;
  11031. }
  11032. /**
  11033. * This represents a scene component.
  11034. *
  11035. * This is used to decouple the dependency the scene is having on the different workloads like
  11036. * layers, post processes...
  11037. */
  11038. export interface ISceneComponent {
  11039. /**
  11040. * The name of the component. Each component must have a unique name.
  11041. */
  11042. name: string;
  11043. /**
  11044. * The scene the component belongs to.
  11045. */
  11046. scene: Scene;
  11047. /**
  11048. * Register the component to one instance of a scene.
  11049. */
  11050. register(): void;
  11051. /**
  11052. * Rebuilds the elements related to this component in case of
  11053. * context lost for instance.
  11054. */
  11055. rebuild(): void;
  11056. /**
  11057. * Disposes the component and the associated ressources.
  11058. */
  11059. dispose(): void;
  11060. }
  11061. /**
  11062. * This represents a SERIALIZABLE scene component.
  11063. *
  11064. * This extends Scene Component to add Serialization methods on top.
  11065. */
  11066. export interface ISceneSerializableComponent extends ISceneComponent {
  11067. /**
  11068. * Adds all the elements from the container to the scene
  11069. * @param container the container holding the elements
  11070. */
  11071. addFromContainer(container: AbstractScene): void;
  11072. /**
  11073. * Removes all the elements in the container from the scene
  11074. * @param container contains the elements to remove
  11075. * @param dispose if the removed element should be disposed (default: false)
  11076. */
  11077. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11078. /**
  11079. * Serializes the component data to the specified json object
  11080. * @param serializationObject The object to serialize to
  11081. */
  11082. serialize(serializationObject: any): void;
  11083. }
  11084. /**
  11085. * Strong typing of a Mesh related stage step action
  11086. */
  11087. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11088. /**
  11089. * Strong typing of a Evaluate Sub Mesh related stage step action
  11090. */
  11091. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11092. /**
  11093. * Strong typing of a Active Mesh related stage step action
  11094. */
  11095. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11096. /**
  11097. * Strong typing of a Camera related stage step action
  11098. */
  11099. export type CameraStageAction = (camera: Camera) => void;
  11100. /**
  11101. * Strong typing of a Camera Frame buffer related stage step action
  11102. */
  11103. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11104. /**
  11105. * Strong typing of a Render Target related stage step action
  11106. */
  11107. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11108. /**
  11109. * Strong typing of a RenderingGroup related stage step action
  11110. */
  11111. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11112. /**
  11113. * Strong typing of a Mesh Render related stage step action
  11114. */
  11115. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11116. /**
  11117. * Strong typing of a simple stage step action
  11118. */
  11119. export type SimpleStageAction = () => void;
  11120. /**
  11121. * Strong typing of a render target action.
  11122. */
  11123. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11124. /**
  11125. * Strong typing of a pointer move action.
  11126. */
  11127. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11128. /**
  11129. * Strong typing of a pointer up/down action.
  11130. */
  11131. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11132. /**
  11133. * Representation of a stage in the scene (Basically a list of ordered steps)
  11134. * @hidden
  11135. */
  11136. export class Stage<T extends Function> extends Array<{
  11137. index: number;
  11138. component: ISceneComponent;
  11139. action: T;
  11140. }> {
  11141. /**
  11142. * Hide ctor from the rest of the world.
  11143. * @param items The items to add.
  11144. */
  11145. private constructor();
  11146. /**
  11147. * Creates a new Stage.
  11148. * @returns A new instance of a Stage
  11149. */
  11150. static Create<T extends Function>(): Stage<T>;
  11151. /**
  11152. * Registers a step in an ordered way in the targeted stage.
  11153. * @param index Defines the position to register the step in
  11154. * @param component Defines the component attached to the step
  11155. * @param action Defines the action to launch during the step
  11156. */
  11157. registerStep(index: number, component: ISceneComponent, action: T): void;
  11158. /**
  11159. * Clears all the steps from the stage.
  11160. */
  11161. clear(): void;
  11162. }
  11163. }
  11164. declare module BABYLON {
  11165. interface Scene {
  11166. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11167. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11168. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11169. /**
  11170. * All of the sprite managers added to this scene
  11171. * @see http://doc.babylonjs.com/babylon101/sprites
  11172. */
  11173. spriteManagers: Array<ISpriteManager>;
  11174. /**
  11175. * An event triggered when sprites rendering is about to start
  11176. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11177. */
  11178. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11179. /**
  11180. * An event triggered when sprites rendering is done
  11181. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11182. */
  11183. onAfterSpritesRenderingObservable: Observable<Scene>;
  11184. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11185. /** Launch a ray to try to pick a sprite in the scene
  11186. * @param x position on screen
  11187. * @param y position on screen
  11188. * @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
  11189. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11190. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11191. * @returns a PickingInfo
  11192. */
  11193. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11194. /** Use the given ray to pick a sprite in the scene
  11195. * @param ray The ray (in world space) to use to pick meshes
  11196. * @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
  11197. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11198. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11199. * @returns a PickingInfo
  11200. */
  11201. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11202. /** @hidden */ private _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11203. /** Launch a ray to try to pick sprites in the scene
  11204. * @param x position on screen
  11205. * @param y position on screen
  11206. * @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
  11207. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11208. * @returns a PickingInfo array
  11209. */
  11210. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11211. /** Use the given ray to pick sprites in the scene
  11212. * @param ray The ray (in world space) to use to pick meshes
  11213. * @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
  11214. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11215. * @returns a PickingInfo array
  11216. */
  11217. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11218. /**
  11219. * Force the sprite under the pointer
  11220. * @param sprite defines the sprite to use
  11221. */
  11222. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11223. /**
  11224. * Gets the sprite under the pointer
  11225. * @returns a Sprite or null if no sprite is under the pointer
  11226. */
  11227. getPointerOverSprite(): Nullable<Sprite>;
  11228. }
  11229. /**
  11230. * Defines the sprite scene component responsible to manage sprites
  11231. * in a given scene.
  11232. */
  11233. export class SpriteSceneComponent implements ISceneComponent {
  11234. /**
  11235. * The component name helpfull to identify the component in the list of scene components.
  11236. */
  11237. readonly name: string;
  11238. /**
  11239. * The scene the component belongs to.
  11240. */
  11241. scene: Scene;
  11242. /** @hidden */
  11243. private _spritePredicate;
  11244. /**
  11245. * Creates a new instance of the component for the given scene
  11246. * @param scene Defines the scene to register the component in
  11247. */
  11248. constructor(scene: Scene);
  11249. /**
  11250. * Registers the component in a given scene
  11251. */
  11252. register(): void;
  11253. /**
  11254. * Rebuilds the elements related to this component in case of
  11255. * context lost for instance.
  11256. */
  11257. rebuild(): void;
  11258. /**
  11259. * Disposes the component and the associated ressources.
  11260. */
  11261. dispose(): void;
  11262. private _pickSpriteButKeepRay;
  11263. private _pointerMove;
  11264. private _pointerDown;
  11265. private _pointerUp;
  11266. }
  11267. }
  11268. declare module BABYLON {
  11269. /** @hidden */
  11270. export var fogFragmentDeclaration: {
  11271. name: string;
  11272. shader: string;
  11273. };
  11274. }
  11275. declare module BABYLON {
  11276. /** @hidden */
  11277. export var fogFragment: {
  11278. name: string;
  11279. shader: string;
  11280. };
  11281. }
  11282. declare module BABYLON {
  11283. /** @hidden */
  11284. export var spritesPixelShader: {
  11285. name: string;
  11286. shader: string;
  11287. };
  11288. }
  11289. declare module BABYLON {
  11290. /** @hidden */
  11291. export var fogVertexDeclaration: {
  11292. name: string;
  11293. shader: string;
  11294. };
  11295. }
  11296. declare module BABYLON {
  11297. /** @hidden */
  11298. export var spritesVertexShader: {
  11299. name: string;
  11300. shader: string;
  11301. };
  11302. }
  11303. declare module BABYLON {
  11304. /**
  11305. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11306. */
  11307. export interface ISpriteManager extends IDisposable {
  11308. /**
  11309. * Restricts the camera to viewing objects with the same layerMask.
  11310. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11311. */
  11312. layerMask: number;
  11313. /**
  11314. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11315. */
  11316. isPickable: boolean;
  11317. /**
  11318. * Specifies the rendering group id for this mesh (0 by default)
  11319. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11320. */
  11321. renderingGroupId: number;
  11322. /**
  11323. * Defines the list of sprites managed by the manager.
  11324. */
  11325. sprites: Array<Sprite>;
  11326. /**
  11327. * Tests the intersection of a sprite with a specific ray.
  11328. * @param ray The ray we are sending to test the collision
  11329. * @param camera The camera space we are sending rays in
  11330. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11331. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11332. * @returns picking info or null.
  11333. */
  11334. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11335. /**
  11336. * Intersects the sprites with a ray
  11337. * @param ray defines the ray to intersect with
  11338. * @param camera defines the current active camera
  11339. * @param predicate defines a predicate used to select candidate sprites
  11340. * @returns null if no hit or a PickingInfo array
  11341. */
  11342. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11343. /**
  11344. * Renders the list of sprites on screen.
  11345. */
  11346. render(): void;
  11347. }
  11348. /**
  11349. * Class used to manage multiple sprites on the same spritesheet
  11350. * @see http://doc.babylonjs.com/babylon101/sprites
  11351. */
  11352. export class SpriteManager implements ISpriteManager {
  11353. /** defines the manager's name */
  11354. name: string;
  11355. /** Gets the list of sprites */
  11356. sprites: Sprite[];
  11357. /** Gets or sets the rendering group id (0 by default) */
  11358. renderingGroupId: number;
  11359. /** Gets or sets camera layer mask */
  11360. layerMask: number;
  11361. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11362. fogEnabled: boolean;
  11363. /** Gets or sets a boolean indicating if the sprites are pickable */
  11364. isPickable: boolean;
  11365. /** Defines the default width of a cell in the spritesheet */
  11366. cellWidth: number;
  11367. /** Defines the default height of a cell in the spritesheet */
  11368. cellHeight: number;
  11369. /** Associative array from JSON sprite data file */
  11370. private _cellData;
  11371. /** Array of sprite names from JSON sprite data file */
  11372. private _spriteMap;
  11373. /** True when packed cell data from JSON file is ready*/
  11374. private _packedAndReady;
  11375. /**
  11376. * An event triggered when the manager is disposed.
  11377. */
  11378. onDisposeObservable: Observable<SpriteManager>;
  11379. private _onDisposeObserver;
  11380. /**
  11381. * Callback called when the manager is disposed
  11382. */
  11383. onDispose: () => void;
  11384. private _capacity;
  11385. private _fromPacked;
  11386. private _spriteTexture;
  11387. private _epsilon;
  11388. private _scene;
  11389. private _vertexData;
  11390. private _buffer;
  11391. private _vertexBuffers;
  11392. private _indexBuffer;
  11393. private _effectBase;
  11394. private _effectFog;
  11395. /**
  11396. * Gets or sets the spritesheet texture
  11397. */
  11398. texture: Texture;
  11399. /**
  11400. * Creates a new sprite manager
  11401. * @param name defines the manager's name
  11402. * @param imgUrl defines the sprite sheet url
  11403. * @param capacity defines the maximum allowed number of sprites
  11404. * @param cellSize defines the size of a sprite cell
  11405. * @param scene defines the hosting scene
  11406. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11407. * @param samplingMode defines the smapling mode to use with spritesheet
  11408. * @param fromPacked set to false; do not alter
  11409. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11410. */
  11411. constructor(
  11412. /** defines the manager's name */
  11413. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11414. private _makePacked;
  11415. private _appendSpriteVertex;
  11416. /**
  11417. * Intersects the sprites with a ray
  11418. * @param ray defines the ray to intersect with
  11419. * @param camera defines the current active camera
  11420. * @param predicate defines a predicate used to select candidate sprites
  11421. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11422. * @returns null if no hit or a PickingInfo
  11423. */
  11424. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11425. /**
  11426. * Intersects the sprites with a ray
  11427. * @param ray defines the ray to intersect with
  11428. * @param camera defines the current active camera
  11429. * @param predicate defines a predicate used to select candidate sprites
  11430. * @returns null if no hit or a PickingInfo array
  11431. */
  11432. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11433. /**
  11434. * Render all child sprites
  11435. */
  11436. render(): void;
  11437. /**
  11438. * Release associated resources
  11439. */
  11440. dispose(): void;
  11441. }
  11442. }
  11443. declare module BABYLON {
  11444. /**
  11445. * Class used to represent a sprite
  11446. * @see http://doc.babylonjs.com/babylon101/sprites
  11447. */
  11448. export class Sprite {
  11449. /** defines the name */
  11450. name: string;
  11451. /** Gets or sets the current world position */
  11452. position: Vector3;
  11453. /** Gets or sets the main color */
  11454. color: Color4;
  11455. /** Gets or sets the width */
  11456. width: number;
  11457. /** Gets or sets the height */
  11458. height: number;
  11459. /** Gets or sets rotation angle */
  11460. angle: number;
  11461. /** Gets or sets the cell index in the sprite sheet */
  11462. cellIndex: number;
  11463. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11464. cellRef: string;
  11465. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11466. invertU: number;
  11467. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11468. invertV: number;
  11469. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11470. disposeWhenFinishedAnimating: boolean;
  11471. /** Gets the list of attached animations */
  11472. animations: Animation[];
  11473. /** Gets or sets a boolean indicating if the sprite can be picked */
  11474. isPickable: boolean;
  11475. /**
  11476. * Gets or sets the associated action manager
  11477. */
  11478. actionManager: Nullable<ActionManager>;
  11479. private _animationStarted;
  11480. private _loopAnimation;
  11481. private _fromIndex;
  11482. private _toIndex;
  11483. private _delay;
  11484. private _direction;
  11485. private _manager;
  11486. private _time;
  11487. private _onAnimationEnd;
  11488. /**
  11489. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11490. */
  11491. isVisible: boolean;
  11492. /**
  11493. * Gets or sets the sprite size
  11494. */
  11495. size: number;
  11496. /**
  11497. * Creates a new Sprite
  11498. * @param name defines the name
  11499. * @param manager defines the manager
  11500. */
  11501. constructor(
  11502. /** defines the name */
  11503. name: string, manager: ISpriteManager);
  11504. /**
  11505. * Starts an animation
  11506. * @param from defines the initial key
  11507. * @param to defines the end key
  11508. * @param loop defines if the animation must loop
  11509. * @param delay defines the start delay (in ms)
  11510. * @param onAnimationEnd defines a callback to call when animation ends
  11511. */
  11512. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11513. /** Stops current animation (if any) */
  11514. stopAnimation(): void;
  11515. /** @hidden */ private _animate(deltaTime: number): void;
  11516. /** Release associated resources */
  11517. dispose(): void;
  11518. }
  11519. }
  11520. declare module BABYLON {
  11521. /**
  11522. * Information about the result of picking within a scene
  11523. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11524. */
  11525. export class PickingInfo {
  11526. /** @hidden */ private _pickingUnavailable: boolean;
  11527. /**
  11528. * If the pick collided with an object
  11529. */
  11530. hit: boolean;
  11531. /**
  11532. * Distance away where the pick collided
  11533. */
  11534. distance: number;
  11535. /**
  11536. * The location of pick collision
  11537. */
  11538. pickedPoint: Nullable<Vector3>;
  11539. /**
  11540. * The mesh corresponding the the pick collision
  11541. */
  11542. pickedMesh: Nullable<AbstractMesh>;
  11543. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11544. bu: number;
  11545. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11546. bv: number;
  11547. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11548. faceId: number;
  11549. /** Id of the the submesh that was picked */
  11550. subMeshId: number;
  11551. /** If a sprite was picked, this will be the sprite the pick collided with */
  11552. pickedSprite: Nullable<Sprite>;
  11553. /**
  11554. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11555. */
  11556. originMesh: Nullable<AbstractMesh>;
  11557. /**
  11558. * The ray that was used to perform the picking.
  11559. */
  11560. ray: Nullable<Ray>;
  11561. /**
  11562. * Gets the normal correspodning to the face the pick collided with
  11563. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11564. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11565. * @returns The normal correspodning to the face the pick collided with
  11566. */
  11567. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11568. /**
  11569. * Gets the texture coordinates of where the pick occured
  11570. * @returns the vector containing the coordnates of the texture
  11571. */
  11572. getTextureCoordinates(): Nullable<Vector2>;
  11573. }
  11574. }
  11575. declare module BABYLON {
  11576. /**
  11577. * Gather the list of pointer event types as constants.
  11578. */
  11579. export class PointerEventTypes {
  11580. /**
  11581. * 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.
  11582. */
  11583. static readonly POINTERDOWN: number;
  11584. /**
  11585. * The pointerup event is fired when a pointer is no longer active.
  11586. */
  11587. static readonly POINTERUP: number;
  11588. /**
  11589. * The pointermove event is fired when a pointer changes coordinates.
  11590. */
  11591. static readonly POINTERMOVE: number;
  11592. /**
  11593. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11594. */
  11595. static readonly POINTERWHEEL: number;
  11596. /**
  11597. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11598. */
  11599. static readonly POINTERPICK: number;
  11600. /**
  11601. * The pointertap event is fired when a the object has been touched and released without drag.
  11602. */
  11603. static readonly POINTERTAP: number;
  11604. /**
  11605. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11606. */
  11607. static readonly POINTERDOUBLETAP: number;
  11608. }
  11609. /**
  11610. * Base class of pointer info types.
  11611. */
  11612. export class PointerInfoBase {
  11613. /**
  11614. * Defines the type of event (PointerEventTypes)
  11615. */
  11616. type: number;
  11617. /**
  11618. * Defines the related dom event
  11619. */
  11620. event: PointerEvent | MouseWheelEvent;
  11621. /**
  11622. * Instantiates the base class of pointers info.
  11623. * @param type Defines the type of event (PointerEventTypes)
  11624. * @param event Defines the related dom event
  11625. */
  11626. constructor(
  11627. /**
  11628. * Defines the type of event (PointerEventTypes)
  11629. */
  11630. type: number,
  11631. /**
  11632. * Defines the related dom event
  11633. */
  11634. event: PointerEvent | MouseWheelEvent);
  11635. }
  11636. /**
  11637. * This class is used to store pointer related info for the onPrePointerObservable event.
  11638. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11639. */
  11640. export class PointerInfoPre extends PointerInfoBase {
  11641. /**
  11642. * Ray from a pointer if availible (eg. 6dof controller)
  11643. */
  11644. ray: Nullable<Ray>;
  11645. /**
  11646. * Defines the local position of the pointer on the canvas.
  11647. */
  11648. localPosition: Vector2;
  11649. /**
  11650. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11651. */
  11652. skipOnPointerObservable: boolean;
  11653. /**
  11654. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11655. * @param type Defines the type of event (PointerEventTypes)
  11656. * @param event Defines the related dom event
  11657. * @param localX Defines the local x coordinates of the pointer when the event occured
  11658. * @param localY Defines the local y coordinates of the pointer when the event occured
  11659. */
  11660. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11661. }
  11662. /**
  11663. * This type contains all the data related to a pointer event in Babylon.js.
  11664. * 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.
  11665. */
  11666. export class PointerInfo extends PointerInfoBase {
  11667. /**
  11668. * Defines the picking info associated to the info (if any)\
  11669. */
  11670. pickInfo: Nullable<PickingInfo>;
  11671. /**
  11672. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11673. * @param type Defines the type of event (PointerEventTypes)
  11674. * @param event Defines the related dom event
  11675. * @param pickInfo Defines the picking info associated to the info (if any)\
  11676. */
  11677. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11678. /**
  11679. * Defines the picking info associated to the info (if any)\
  11680. */
  11681. pickInfo: Nullable<PickingInfo>);
  11682. }
  11683. /**
  11684. * Data relating to a touch event on the screen.
  11685. */
  11686. export interface PointerTouch {
  11687. /**
  11688. * X coordinate of touch.
  11689. */
  11690. x: number;
  11691. /**
  11692. * Y coordinate of touch.
  11693. */
  11694. y: number;
  11695. /**
  11696. * Id of touch. Unique for each finger.
  11697. */
  11698. pointerId: number;
  11699. /**
  11700. * Event type passed from DOM.
  11701. */
  11702. type: any;
  11703. }
  11704. }
  11705. declare module BABYLON {
  11706. /**
  11707. * Manage the mouse inputs to control the movement of a free camera.
  11708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11709. */
  11710. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11711. /**
  11712. * Define if touch is enabled in the mouse input
  11713. */
  11714. touchEnabled: boolean;
  11715. /**
  11716. * Defines the camera the input is attached to.
  11717. */
  11718. camera: FreeCamera;
  11719. /**
  11720. * Defines the buttons associated with the input to handle camera move.
  11721. */
  11722. buttons: number[];
  11723. /**
  11724. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11725. */
  11726. angularSensibility: number;
  11727. private _pointerInput;
  11728. private _onMouseMove;
  11729. private _observer;
  11730. private previousPosition;
  11731. /**
  11732. * Observable for when a pointer move event occurs containing the move offset
  11733. */
  11734. onPointerMovedObservable: Observable<{
  11735. offsetX: number;
  11736. offsetY: number;
  11737. }>;
  11738. /**
  11739. * @hidden
  11740. * If the camera should be rotated automatically based on pointer movement
  11741. */ private _allowCameraRotation: boolean;
  11742. /**
  11743. * Manage the mouse inputs to control the movement of a free camera.
  11744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11745. * @param touchEnabled Defines if touch is enabled or not
  11746. */
  11747. constructor(
  11748. /**
  11749. * Define if touch is enabled in the mouse input
  11750. */
  11751. touchEnabled?: boolean);
  11752. /**
  11753. * Attach the input controls to a specific dom element to get the input from.
  11754. * @param element Defines the element the controls should be listened from
  11755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11756. */
  11757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11758. /**
  11759. * Called on JS contextmenu event.
  11760. * Override this method to provide functionality.
  11761. */
  11762. protected onContextMenu(evt: PointerEvent): void;
  11763. /**
  11764. * Detach the current controls from the specified dom element.
  11765. * @param element Defines the element to stop listening the inputs from
  11766. */
  11767. detachControl(element: Nullable<HTMLElement>): void;
  11768. /**
  11769. * Gets the class name of the current intput.
  11770. * @returns the class name
  11771. */
  11772. getClassName(): string;
  11773. /**
  11774. * Get the friendly name associated with the input class.
  11775. * @returns the input friendly name
  11776. */
  11777. getSimpleName(): string;
  11778. }
  11779. }
  11780. declare module BABYLON {
  11781. /**
  11782. * Manage the touch inputs to control the movement of a free camera.
  11783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11784. */
  11785. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11786. /**
  11787. * Defines the camera the input is attached to.
  11788. */
  11789. camera: FreeCamera;
  11790. /**
  11791. * Defines the touch sensibility for rotation.
  11792. * The higher the faster.
  11793. */
  11794. touchAngularSensibility: number;
  11795. /**
  11796. * Defines the touch sensibility for move.
  11797. * The higher the faster.
  11798. */
  11799. touchMoveSensibility: number;
  11800. private _offsetX;
  11801. private _offsetY;
  11802. private _pointerPressed;
  11803. private _pointerInput;
  11804. private _observer;
  11805. private _onLostFocus;
  11806. /**
  11807. * Attach the input controls to a specific dom element to get the input from.
  11808. * @param element Defines the element the controls should be listened from
  11809. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11810. */
  11811. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11812. /**
  11813. * Detach the current controls from the specified dom element.
  11814. * @param element Defines the element to stop listening the inputs from
  11815. */
  11816. detachControl(element: Nullable<HTMLElement>): void;
  11817. /**
  11818. * Update the current camera state depending on the inputs that have been used this frame.
  11819. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11820. */
  11821. checkInputs(): void;
  11822. /**
  11823. * Gets the class name of the current intput.
  11824. * @returns the class name
  11825. */
  11826. getClassName(): string;
  11827. /**
  11828. * Get the friendly name associated with the input class.
  11829. * @returns the input friendly name
  11830. */
  11831. getSimpleName(): string;
  11832. }
  11833. }
  11834. declare module BABYLON {
  11835. /**
  11836. * Default Inputs manager for the FreeCamera.
  11837. * It groups all the default supported inputs for ease of use.
  11838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11839. */
  11840. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11841. /**
  11842. * @hidden
  11843. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11844. /**
  11845. * Instantiates a new FreeCameraInputsManager.
  11846. * @param camera Defines the camera the inputs belong to
  11847. */
  11848. constructor(camera: FreeCamera);
  11849. /**
  11850. * Add keyboard input support to the input manager.
  11851. * @returns the current input manager
  11852. */
  11853. addKeyboard(): FreeCameraInputsManager;
  11854. /**
  11855. * Add mouse input support to the input manager.
  11856. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11857. * @returns the current input manager
  11858. */
  11859. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11860. /**
  11861. * Removes the mouse input support from the manager
  11862. * @returns the current input manager
  11863. */
  11864. removeMouse(): FreeCameraInputsManager;
  11865. /**
  11866. * Add touch input support to the input manager.
  11867. * @returns the current input manager
  11868. */
  11869. addTouch(): FreeCameraInputsManager;
  11870. /**
  11871. * Remove all attached input methods from a camera
  11872. */
  11873. clear(): void;
  11874. }
  11875. }
  11876. declare module BABYLON {
  11877. /**
  11878. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11879. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11881. */
  11882. export class FreeCamera extends TargetCamera {
  11883. /**
  11884. * Define the collision ellipsoid of the camera.
  11885. * This is helpful to simulate a camera body like the player body around the camera
  11886. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11887. */
  11888. ellipsoid: Vector3;
  11889. /**
  11890. * Define an offset for the position of the ellipsoid around the camera.
  11891. * This can be helpful to determine the center of the body near the gravity center of the body
  11892. * instead of its head.
  11893. */
  11894. ellipsoidOffset: Vector3;
  11895. /**
  11896. * Enable or disable collisions of the camera with the rest of the scene objects.
  11897. */
  11898. checkCollisions: boolean;
  11899. /**
  11900. * Enable or disable gravity on the camera.
  11901. */
  11902. applyGravity: boolean;
  11903. /**
  11904. * Define the input manager associated to the camera.
  11905. */
  11906. inputs: FreeCameraInputsManager;
  11907. /**
  11908. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11909. * Higher values reduce sensitivity.
  11910. */
  11911. /**
  11912. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11913. * Higher values reduce sensitivity.
  11914. */
  11915. angularSensibility: number;
  11916. /**
  11917. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11918. */
  11919. keysUp: number[];
  11920. /**
  11921. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11922. */
  11923. keysDown: number[];
  11924. /**
  11925. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11926. */
  11927. keysLeft: number[];
  11928. /**
  11929. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11930. */
  11931. keysRight: number[];
  11932. /**
  11933. * Event raised when the camera collide with a mesh in the scene.
  11934. */
  11935. onCollide: (collidedMesh: AbstractMesh) => void;
  11936. private _collider;
  11937. private _needMoveForGravity;
  11938. private _oldPosition;
  11939. private _diffPosition;
  11940. private _newPosition;
  11941. /** @hidden */ private _localDirection: Vector3;
  11942. /** @hidden */ private _transformedDirection: Vector3;
  11943. /**
  11944. * Instantiates a Free Camera.
  11945. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11946. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11947. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11948. * @param name Define the name of the camera in the scene
  11949. * @param position Define the start position of the camera in the scene
  11950. * @param scene Define the scene the camera belongs to
  11951. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11952. */
  11953. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11954. /**
  11955. * Attached controls to the current camera.
  11956. * @param element Defines the element the controls should be listened from
  11957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11958. */
  11959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11960. /**
  11961. * Detach the current controls from the camera.
  11962. * The camera will stop reacting to inputs.
  11963. * @param element Defines the element to stop listening the inputs from
  11964. */
  11965. detachControl(element: HTMLElement): void;
  11966. private _collisionMask;
  11967. /**
  11968. * Define a collision mask to limit the list of object the camera can collide with
  11969. */
  11970. collisionMask: number;
  11971. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  11972. private _onCollisionPositionChange;
  11973. /** @hidden */ private _checkInputs(): void;
  11974. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  11975. /** @hidden */ private _updatePosition(): void;
  11976. /**
  11977. * Destroy the camera and release the current resources hold by it.
  11978. */
  11979. dispose(): void;
  11980. /**
  11981. * Gets the current object class name.
  11982. * @return the class name
  11983. */
  11984. getClassName(): string;
  11985. }
  11986. }
  11987. declare module BABYLON {
  11988. /**
  11989. * Represents a gamepad control stick position
  11990. */
  11991. export class StickValues {
  11992. /**
  11993. * The x component of the control stick
  11994. */
  11995. x: number;
  11996. /**
  11997. * The y component of the control stick
  11998. */
  11999. y: number;
  12000. /**
  12001. * Initializes the gamepad x and y control stick values
  12002. * @param x The x component of the gamepad control stick value
  12003. * @param y The y component of the gamepad control stick value
  12004. */
  12005. constructor(
  12006. /**
  12007. * The x component of the control stick
  12008. */
  12009. x: number,
  12010. /**
  12011. * The y component of the control stick
  12012. */
  12013. y: number);
  12014. }
  12015. /**
  12016. * An interface which manages callbacks for gamepad button changes
  12017. */
  12018. export interface GamepadButtonChanges {
  12019. /**
  12020. * Called when a gamepad has been changed
  12021. */
  12022. changed: boolean;
  12023. /**
  12024. * Called when a gamepad press event has been triggered
  12025. */
  12026. pressChanged: boolean;
  12027. /**
  12028. * Called when a touch event has been triggered
  12029. */
  12030. touchChanged: boolean;
  12031. /**
  12032. * Called when a value has changed
  12033. */
  12034. valueChanged: boolean;
  12035. }
  12036. /**
  12037. * Represents a gamepad
  12038. */
  12039. export class Gamepad {
  12040. /**
  12041. * The id of the gamepad
  12042. */
  12043. id: string;
  12044. /**
  12045. * The index of the gamepad
  12046. */
  12047. index: number;
  12048. /**
  12049. * The browser gamepad
  12050. */
  12051. browserGamepad: any;
  12052. /**
  12053. * Specifies what type of gamepad this represents
  12054. */
  12055. type: number;
  12056. private _leftStick;
  12057. private _rightStick;
  12058. /** @hidden */ private _isConnected: boolean;
  12059. private _leftStickAxisX;
  12060. private _leftStickAxisY;
  12061. private _rightStickAxisX;
  12062. private _rightStickAxisY;
  12063. /**
  12064. * Triggered when the left control stick has been changed
  12065. */
  12066. private _onleftstickchanged;
  12067. /**
  12068. * Triggered when the right control stick has been changed
  12069. */
  12070. private _onrightstickchanged;
  12071. /**
  12072. * Represents a gamepad controller
  12073. */
  12074. static GAMEPAD: number;
  12075. /**
  12076. * Represents a generic controller
  12077. */
  12078. static GENERIC: number;
  12079. /**
  12080. * Represents an XBox controller
  12081. */
  12082. static XBOX: number;
  12083. /**
  12084. * Represents a pose-enabled controller
  12085. */
  12086. static POSE_ENABLED: number;
  12087. /**
  12088. * Represents an Dual Shock controller
  12089. */
  12090. static DUALSHOCK: number;
  12091. /**
  12092. * Specifies whether the left control stick should be Y-inverted
  12093. */
  12094. protected _invertLeftStickY: boolean;
  12095. /**
  12096. * Specifies if the gamepad has been connected
  12097. */
  12098. readonly isConnected: boolean;
  12099. /**
  12100. * Initializes the gamepad
  12101. * @param id The id of the gamepad
  12102. * @param index The index of the gamepad
  12103. * @param browserGamepad The browser gamepad
  12104. * @param leftStickX The x component of the left joystick
  12105. * @param leftStickY The y component of the left joystick
  12106. * @param rightStickX The x component of the right joystick
  12107. * @param rightStickY The y component of the right joystick
  12108. */
  12109. constructor(
  12110. /**
  12111. * The id of the gamepad
  12112. */
  12113. id: string,
  12114. /**
  12115. * The index of the gamepad
  12116. */
  12117. index: number,
  12118. /**
  12119. * The browser gamepad
  12120. */
  12121. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12122. /**
  12123. * Callback triggered when the left joystick has changed
  12124. * @param callback
  12125. */
  12126. onleftstickchanged(callback: (values: StickValues) => void): void;
  12127. /**
  12128. * Callback triggered when the right joystick has changed
  12129. * @param callback
  12130. */
  12131. onrightstickchanged(callback: (values: StickValues) => void): void;
  12132. /**
  12133. * Gets the left joystick
  12134. */
  12135. /**
  12136. * Sets the left joystick values
  12137. */
  12138. leftStick: StickValues;
  12139. /**
  12140. * Gets the right joystick
  12141. */
  12142. /**
  12143. * Sets the right joystick value
  12144. */
  12145. rightStick: StickValues;
  12146. /**
  12147. * Updates the gamepad joystick positions
  12148. */
  12149. update(): void;
  12150. /**
  12151. * Disposes the gamepad
  12152. */
  12153. dispose(): void;
  12154. }
  12155. /**
  12156. * Represents a generic gamepad
  12157. */
  12158. export class GenericPad extends Gamepad {
  12159. private _buttons;
  12160. private _onbuttondown;
  12161. private _onbuttonup;
  12162. /**
  12163. * Observable triggered when a button has been pressed
  12164. */
  12165. onButtonDownObservable: Observable<number>;
  12166. /**
  12167. * Observable triggered when a button has been released
  12168. */
  12169. onButtonUpObservable: Observable<number>;
  12170. /**
  12171. * Callback triggered when a button has been pressed
  12172. * @param callback Called when a button has been pressed
  12173. */
  12174. onbuttondown(callback: (buttonPressed: number) => void): void;
  12175. /**
  12176. * Callback triggered when a button has been released
  12177. * @param callback Called when a button has been released
  12178. */
  12179. onbuttonup(callback: (buttonReleased: number) => void): void;
  12180. /**
  12181. * Initializes the generic gamepad
  12182. * @param id The id of the generic gamepad
  12183. * @param index The index of the generic gamepad
  12184. * @param browserGamepad The browser gamepad
  12185. */
  12186. constructor(id: string, index: number, browserGamepad: any);
  12187. private _setButtonValue;
  12188. /**
  12189. * Updates the generic gamepad
  12190. */
  12191. update(): void;
  12192. /**
  12193. * Disposes the generic gamepad
  12194. */
  12195. dispose(): void;
  12196. }
  12197. }
  12198. declare module BABYLON {
  12199. interface Engine {
  12200. /**
  12201. * Creates a raw texture
  12202. * @param data defines the data to store in the texture
  12203. * @param width defines the width of the texture
  12204. * @param height defines the height of the texture
  12205. * @param format defines the format of the data
  12206. * @param generateMipMaps defines if the engine should generate the mip levels
  12207. * @param invertY defines if data must be stored with Y axis inverted
  12208. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12209. * @param compression defines the compression used (null by default)
  12210. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12211. * @returns the raw texture inside an InternalTexture
  12212. */
  12213. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12214. /**
  12215. * Update a raw texture
  12216. * @param texture defines the texture to update
  12217. * @param data defines the data to store in the texture
  12218. * @param format defines the format of the data
  12219. * @param invertY defines if data must be stored with Y axis inverted
  12220. */
  12221. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12222. /**
  12223. * Update a raw texture
  12224. * @param texture defines the texture to update
  12225. * @param data defines the data to store in the texture
  12226. * @param format defines the format of the data
  12227. * @param invertY defines if data must be stored with Y axis inverted
  12228. * @param compression defines the compression used (null by default)
  12229. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12230. */
  12231. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12232. /**
  12233. * Creates a new raw cube texture
  12234. * @param data defines the array of data to use to create each face
  12235. * @param size defines the size of the textures
  12236. * @param format defines the format of the data
  12237. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12238. * @param generateMipMaps defines if the engine should generate the mip levels
  12239. * @param invertY defines if data must be stored with Y axis inverted
  12240. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12241. * @param compression defines the compression used (null by default)
  12242. * @returns the cube texture as an InternalTexture
  12243. */
  12244. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12245. /**
  12246. * Update a raw cube texture
  12247. * @param texture defines the texture to udpdate
  12248. * @param data defines the data to store
  12249. * @param format defines the data format
  12250. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12251. * @param invertY defines if data must be stored with Y axis inverted
  12252. */
  12253. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12254. /**
  12255. * Update a raw cube texture
  12256. * @param texture defines the texture to udpdate
  12257. * @param data defines the data to store
  12258. * @param format defines the data format
  12259. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12260. * @param invertY defines if data must be stored with Y axis inverted
  12261. * @param compression defines the compression used (null by default)
  12262. */
  12263. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12264. /**
  12265. * Update a raw cube texture
  12266. * @param texture defines the texture to udpdate
  12267. * @param data defines the data to store
  12268. * @param format defines the data format
  12269. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12270. * @param invertY defines if data must be stored with Y axis inverted
  12271. * @param compression defines the compression used (null by default)
  12272. * @param level defines which level of the texture to update
  12273. */
  12274. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12275. /**
  12276. * Creates a new raw cube texture from a specified url
  12277. * @param url defines the url where the data is located
  12278. * @param scene defines the current scene
  12279. * @param size defines the size of the textures
  12280. * @param format defines the format of the data
  12281. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12282. * @param noMipmap defines if the engine should avoid generating the mip levels
  12283. * @param callback defines a callback used to extract texture data from loaded data
  12284. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12285. * @param onLoad defines a callback called when texture is loaded
  12286. * @param onError defines a callback called if there is an error
  12287. * @returns the cube texture as an InternalTexture
  12288. */
  12289. 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;
  12290. /**
  12291. * Creates a new raw cube texture from a specified url
  12292. * @param url defines the url where the data is located
  12293. * @param scene defines the current scene
  12294. * @param size defines the size of the textures
  12295. * @param format defines the format of the data
  12296. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12297. * @param noMipmap defines if the engine should avoid generating the mip levels
  12298. * @param callback defines a callback used to extract texture data from loaded data
  12299. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12300. * @param onLoad defines a callback called when texture is loaded
  12301. * @param onError defines a callback called if there is an error
  12302. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12303. * @param invertY defines if data must be stored with Y axis inverted
  12304. * @returns the cube texture as an InternalTexture
  12305. */
  12306. 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;
  12307. /**
  12308. * Creates a new raw 3D texture
  12309. * @param data defines the data used to create the texture
  12310. * @param width defines the width of the texture
  12311. * @param height defines the height of the texture
  12312. * @param depth defines the depth of the texture
  12313. * @param format defines the format of the texture
  12314. * @param generateMipMaps defines if the engine must generate mip levels
  12315. * @param invertY defines if data must be stored with Y axis inverted
  12316. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12317. * @param compression defines the compressed used (can be null)
  12318. * @param textureType defines the compressed used (can be null)
  12319. * @returns a new raw 3D texture (stored in an InternalTexture)
  12320. */
  12321. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12322. /**
  12323. * Update a raw 3D texture
  12324. * @param texture defines the texture to update
  12325. * @param data defines the data to store
  12326. * @param format defines the data format
  12327. * @param invertY defines if data must be stored with Y axis inverted
  12328. */
  12329. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12330. /**
  12331. * Update a raw 3D texture
  12332. * @param texture defines the texture to update
  12333. * @param data defines the data to store
  12334. * @param format defines the data format
  12335. * @param invertY defines if data must be stored with Y axis inverted
  12336. * @param compression defines the used compression (can be null)
  12337. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12338. */
  12339. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12340. /**
  12341. * Creates a new raw 2D array texture
  12342. * @param data defines the data used to create the texture
  12343. * @param width defines the width of the texture
  12344. * @param height defines the height of the texture
  12345. * @param depth defines the number of layers of the texture
  12346. * @param format defines the format of the texture
  12347. * @param generateMipMaps defines if the engine must generate mip levels
  12348. * @param invertY defines if data must be stored with Y axis inverted
  12349. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12350. * @param compression defines the compressed used (can be null)
  12351. * @param textureType defines the compressed used (can be null)
  12352. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12353. */
  12354. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12355. /**
  12356. * Update a raw 2D array texture
  12357. * @param texture defines the texture to update
  12358. * @param data defines the data to store
  12359. * @param format defines the data format
  12360. * @param invertY defines if data must be stored with Y axis inverted
  12361. */
  12362. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12363. /**
  12364. * Update a raw 2D array texture
  12365. * @param texture defines the texture to update
  12366. * @param data defines the data to store
  12367. * @param format defines the data format
  12368. * @param invertY defines if data must be stored with Y axis inverted
  12369. * @param compression defines the used compression (can be null)
  12370. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12371. */
  12372. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12373. }
  12374. }
  12375. declare module BABYLON {
  12376. /**
  12377. * Raw texture can help creating a texture directly from an array of data.
  12378. * This can be super useful if you either get the data from an uncompressed source or
  12379. * if you wish to create your texture pixel by pixel.
  12380. */
  12381. export class RawTexture extends Texture {
  12382. /**
  12383. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12384. */
  12385. format: number;
  12386. private _engine;
  12387. /**
  12388. * Instantiates a new RawTexture.
  12389. * Raw texture can help creating a texture directly from an array of data.
  12390. * This can be super useful if you either get the data from an uncompressed source or
  12391. * if you wish to create your texture pixel by pixel.
  12392. * @param data define the array of data to use to create the texture
  12393. * @param width define the width of the texture
  12394. * @param height define the height of the texture
  12395. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12396. * @param scene define the scene the texture belongs to
  12397. * @param generateMipMaps define whether mip maps should be generated or not
  12398. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12399. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12400. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12401. */
  12402. constructor(data: ArrayBufferView, width: number, height: number,
  12403. /**
  12404. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12405. */
  12406. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12407. /**
  12408. * Updates the texture underlying data.
  12409. * @param data Define the new data of the texture
  12410. */
  12411. update(data: ArrayBufferView): void;
  12412. /**
  12413. * Creates a luminance texture from some data.
  12414. * @param data Define the texture data
  12415. * @param width Define the width of the texture
  12416. * @param height Define the height of the texture
  12417. * @param scene Define the scene the texture belongs to
  12418. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12419. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12420. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12421. * @returns the luminance texture
  12422. */
  12423. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12424. /**
  12425. * Creates a luminance alpha texture from some data.
  12426. * @param data Define the texture data
  12427. * @param width Define the width of the texture
  12428. * @param height Define the height of the texture
  12429. * @param scene Define the scene the texture belongs to
  12430. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12431. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12432. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12433. * @returns the luminance alpha texture
  12434. */
  12435. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12436. /**
  12437. * Creates an alpha texture from some data.
  12438. * @param data Define the texture data
  12439. * @param width Define the width of the texture
  12440. * @param height Define the height of the texture
  12441. * @param scene Define the scene the texture belongs to
  12442. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12443. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12444. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12445. * @returns the alpha texture
  12446. */
  12447. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12448. /**
  12449. * Creates a RGB texture from some data.
  12450. * @param data Define the texture data
  12451. * @param width Define the width of the texture
  12452. * @param height Define the height of the texture
  12453. * @param scene Define the scene the texture belongs to
  12454. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12455. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12456. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12457. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12458. * @returns the RGB alpha texture
  12459. */
  12460. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12461. /**
  12462. * Creates a RGBA texture from some data.
  12463. * @param data Define the texture data
  12464. * @param width Define the width of the texture
  12465. * @param height Define the height of the texture
  12466. * @param scene Define the scene the texture belongs to
  12467. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12468. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12469. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12470. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12471. * @returns the RGBA texture
  12472. */
  12473. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12474. /**
  12475. * Creates a R texture from some data.
  12476. * @param data Define the texture data
  12477. * @param width Define the width of the texture
  12478. * @param height Define the height of the texture
  12479. * @param scene Define the scene the texture belongs to
  12480. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12481. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12482. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12483. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12484. * @returns the R texture
  12485. */
  12486. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12487. }
  12488. }
  12489. declare module BABYLON {
  12490. /**
  12491. * Interface for the size containing width and height
  12492. */
  12493. export interface ISize {
  12494. /**
  12495. * Width
  12496. */
  12497. width: number;
  12498. /**
  12499. * Heighht
  12500. */
  12501. height: number;
  12502. }
  12503. /**
  12504. * Size containing widht and height
  12505. */
  12506. export class Size implements ISize {
  12507. /**
  12508. * Width
  12509. */
  12510. width: number;
  12511. /**
  12512. * Height
  12513. */
  12514. height: number;
  12515. /**
  12516. * Creates a Size object from the given width and height (floats).
  12517. * @param width width of the new size
  12518. * @param height height of the new size
  12519. */
  12520. constructor(width: number, height: number);
  12521. /**
  12522. * Returns a string with the Size width and height
  12523. * @returns a string with the Size width and height
  12524. */
  12525. toString(): string;
  12526. /**
  12527. * "Size"
  12528. * @returns the string "Size"
  12529. */
  12530. getClassName(): string;
  12531. /**
  12532. * Returns the Size hash code.
  12533. * @returns a hash code for a unique width and height
  12534. */
  12535. getHashCode(): number;
  12536. /**
  12537. * Updates the current size from the given one.
  12538. * @param src the given size
  12539. */
  12540. copyFrom(src: Size): void;
  12541. /**
  12542. * Updates in place the current Size from the given floats.
  12543. * @param width width of the new size
  12544. * @param height height of the new size
  12545. * @returns the updated Size.
  12546. */
  12547. copyFromFloats(width: number, height: number): Size;
  12548. /**
  12549. * Updates in place the current Size from the given floats.
  12550. * @param width width to set
  12551. * @param height height to set
  12552. * @returns the updated Size.
  12553. */
  12554. set(width: number, height: number): Size;
  12555. /**
  12556. * Multiplies the width and height by numbers
  12557. * @param w factor to multiple the width by
  12558. * @param h factor to multiple the height by
  12559. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12560. */
  12561. multiplyByFloats(w: number, h: number): Size;
  12562. /**
  12563. * Clones the size
  12564. * @returns a new Size copied from the given one.
  12565. */
  12566. clone(): Size;
  12567. /**
  12568. * True if the current Size and the given one width and height are strictly equal.
  12569. * @param other the other size to compare against
  12570. * @returns True if the current Size and the given one width and height are strictly equal.
  12571. */
  12572. equals(other: Size): boolean;
  12573. /**
  12574. * The surface of the Size : width * height (float).
  12575. */
  12576. readonly surface: number;
  12577. /**
  12578. * Create a new size of zero
  12579. * @returns a new Size set to (0.0, 0.0)
  12580. */
  12581. static Zero(): Size;
  12582. /**
  12583. * Sums the width and height of two sizes
  12584. * @param otherSize size to add to this size
  12585. * @returns a new Size set as the addition result of the current Size and the given one.
  12586. */
  12587. add(otherSize: Size): Size;
  12588. /**
  12589. * Subtracts the width and height of two
  12590. * @param otherSize size to subtract to this size
  12591. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12592. */
  12593. subtract(otherSize: Size): Size;
  12594. /**
  12595. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12596. * @param start starting size to lerp between
  12597. * @param end end size to lerp between
  12598. * @param amount amount to lerp between the start and end values
  12599. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12600. */
  12601. static Lerp(start: Size, end: Size, amount: number): Size;
  12602. }
  12603. }
  12604. declare module BABYLON {
  12605. /**
  12606. * Defines a runtime animation
  12607. */
  12608. export class RuntimeAnimation {
  12609. private _events;
  12610. /**
  12611. * The current frame of the runtime animation
  12612. */
  12613. private _currentFrame;
  12614. /**
  12615. * The animation used by the runtime animation
  12616. */
  12617. private _animation;
  12618. /**
  12619. * The target of the runtime animation
  12620. */
  12621. private _target;
  12622. /**
  12623. * The initiating animatable
  12624. */
  12625. private _host;
  12626. /**
  12627. * The original value of the runtime animation
  12628. */
  12629. private _originalValue;
  12630. /**
  12631. * The original blend value of the runtime animation
  12632. */
  12633. private _originalBlendValue;
  12634. /**
  12635. * The offsets cache of the runtime animation
  12636. */
  12637. private _offsetsCache;
  12638. /**
  12639. * The high limits cache of the runtime animation
  12640. */
  12641. private _highLimitsCache;
  12642. /**
  12643. * Specifies if the runtime animation has been stopped
  12644. */
  12645. private _stopped;
  12646. /**
  12647. * The blending factor of the runtime animation
  12648. */
  12649. private _blendingFactor;
  12650. /**
  12651. * The BabylonJS scene
  12652. */
  12653. private _scene;
  12654. /**
  12655. * The current value of the runtime animation
  12656. */
  12657. private _currentValue;
  12658. /** @hidden */ private _animationState: _IAnimationState;
  12659. /**
  12660. * The active target of the runtime animation
  12661. */
  12662. private _activeTargets;
  12663. private _currentActiveTarget;
  12664. private _directTarget;
  12665. /**
  12666. * The target path of the runtime animation
  12667. */
  12668. private _targetPath;
  12669. /**
  12670. * The weight of the runtime animation
  12671. */
  12672. private _weight;
  12673. /**
  12674. * The ratio offset of the runtime animation
  12675. */
  12676. private _ratioOffset;
  12677. /**
  12678. * The previous delay of the runtime animation
  12679. */
  12680. private _previousDelay;
  12681. /**
  12682. * The previous ratio of the runtime animation
  12683. */
  12684. private _previousRatio;
  12685. private _enableBlending;
  12686. private _keys;
  12687. private _minFrame;
  12688. private _maxFrame;
  12689. private _minValue;
  12690. private _maxValue;
  12691. private _targetIsArray;
  12692. /**
  12693. * Gets the current frame of the runtime animation
  12694. */
  12695. readonly currentFrame: number;
  12696. /**
  12697. * Gets the weight of the runtime animation
  12698. */
  12699. readonly weight: number;
  12700. /**
  12701. * Gets the current value of the runtime animation
  12702. */
  12703. readonly currentValue: any;
  12704. /**
  12705. * Gets the target path of the runtime animation
  12706. */
  12707. readonly targetPath: string;
  12708. /**
  12709. * Gets the actual target of the runtime animation
  12710. */
  12711. readonly target: any;
  12712. /** @hidden */ private _onLoop: () => void;
  12713. /**
  12714. * Create a new RuntimeAnimation object
  12715. * @param target defines the target of the animation
  12716. * @param animation defines the source animation object
  12717. * @param scene defines the hosting scene
  12718. * @param host defines the initiating Animatable
  12719. */
  12720. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12721. private _preparePath;
  12722. /**
  12723. * Gets the animation from the runtime animation
  12724. */
  12725. readonly animation: Animation;
  12726. /**
  12727. * Resets the runtime animation to the beginning
  12728. * @param restoreOriginal defines whether to restore the target property to the original value
  12729. */
  12730. reset(restoreOriginal?: boolean): void;
  12731. /**
  12732. * Specifies if the runtime animation is stopped
  12733. * @returns Boolean specifying if the runtime animation is stopped
  12734. */
  12735. isStopped(): boolean;
  12736. /**
  12737. * Disposes of the runtime animation
  12738. */
  12739. dispose(): void;
  12740. /**
  12741. * Apply the interpolated value to the target
  12742. * @param currentValue defines the value computed by the animation
  12743. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12744. */
  12745. setValue(currentValue: any, weight: number): void;
  12746. private _getOriginalValues;
  12747. private _setValue;
  12748. /**
  12749. * Gets the loop pmode of the runtime animation
  12750. * @returns Loop Mode
  12751. */
  12752. private _getCorrectLoopMode;
  12753. /**
  12754. * Move the current animation to a given frame
  12755. * @param frame defines the frame to move to
  12756. */
  12757. goToFrame(frame: number): void;
  12758. /**
  12759. * @hidden Internal use only
  12760. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12761. /**
  12762. * Execute the current animation
  12763. * @param delay defines the delay to add to the current frame
  12764. * @param from defines the lower bound of the animation range
  12765. * @param to defines the upper bound of the animation range
  12766. * @param loop defines if the current animation must loop
  12767. * @param speedRatio defines the current speed ratio
  12768. * @param weight defines the weight of the animation (default is -1 so no weight)
  12769. * @param onLoop optional callback called when animation loops
  12770. * @returns a boolean indicating if the animation is running
  12771. */
  12772. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12773. }
  12774. }
  12775. declare module BABYLON {
  12776. /**
  12777. * Class used to store an actual running animation
  12778. */
  12779. export class Animatable {
  12780. /** defines the target object */
  12781. target: any;
  12782. /** defines the starting frame number (default is 0) */
  12783. fromFrame: number;
  12784. /** defines the ending frame number (default is 100) */
  12785. toFrame: number;
  12786. /** defines if the animation must loop (default is false) */
  12787. loopAnimation: boolean;
  12788. /** defines a callback to call when animation ends if it is not looping */
  12789. onAnimationEnd?: (() => void) | null | undefined;
  12790. /** defines a callback to call when animation loops */
  12791. onAnimationLoop?: (() => void) | null | undefined;
  12792. private _localDelayOffset;
  12793. private _pausedDelay;
  12794. private _runtimeAnimations;
  12795. private _paused;
  12796. private _scene;
  12797. private _speedRatio;
  12798. private _weight;
  12799. private _syncRoot;
  12800. /**
  12801. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12802. * This will only apply for non looping animation (default is true)
  12803. */
  12804. disposeOnEnd: boolean;
  12805. /**
  12806. * Gets a boolean indicating if the animation has started
  12807. */
  12808. animationStarted: boolean;
  12809. /**
  12810. * Observer raised when the animation ends
  12811. */
  12812. onAnimationEndObservable: Observable<Animatable>;
  12813. /**
  12814. * Observer raised when the animation loops
  12815. */
  12816. onAnimationLoopObservable: Observable<Animatable>;
  12817. /**
  12818. * Gets the root Animatable used to synchronize and normalize animations
  12819. */
  12820. readonly syncRoot: Nullable<Animatable>;
  12821. /**
  12822. * Gets the current frame of the first RuntimeAnimation
  12823. * Used to synchronize Animatables
  12824. */
  12825. readonly masterFrame: number;
  12826. /**
  12827. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12828. */
  12829. weight: number;
  12830. /**
  12831. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12832. */
  12833. speedRatio: number;
  12834. /**
  12835. * Creates a new Animatable
  12836. * @param scene defines the hosting scene
  12837. * @param target defines the target object
  12838. * @param fromFrame defines the starting frame number (default is 0)
  12839. * @param toFrame defines the ending frame number (default is 100)
  12840. * @param loopAnimation defines if the animation must loop (default is false)
  12841. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12842. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12843. * @param animations defines a group of animation to add to the new Animatable
  12844. * @param onAnimationLoop defines a callback to call when animation loops
  12845. */
  12846. constructor(scene: Scene,
  12847. /** defines the target object */
  12848. target: any,
  12849. /** defines the starting frame number (default is 0) */
  12850. fromFrame?: number,
  12851. /** defines the ending frame number (default is 100) */
  12852. toFrame?: number,
  12853. /** defines if the animation must loop (default is false) */
  12854. loopAnimation?: boolean, speedRatio?: number,
  12855. /** defines a callback to call when animation ends if it is not looping */
  12856. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12857. /** defines a callback to call when animation loops */
  12858. onAnimationLoop?: (() => void) | null | undefined);
  12859. /**
  12860. * Synchronize and normalize current Animatable with a source Animatable
  12861. * This is useful when using animation weights and when animations are not of the same length
  12862. * @param root defines the root Animatable to synchronize with
  12863. * @returns the current Animatable
  12864. */
  12865. syncWith(root: Animatable): Animatable;
  12866. /**
  12867. * Gets the list of runtime animations
  12868. * @returns an array of RuntimeAnimation
  12869. */
  12870. getAnimations(): RuntimeAnimation[];
  12871. /**
  12872. * Adds more animations to the current animatable
  12873. * @param target defines the target of the animations
  12874. * @param animations defines the new animations to add
  12875. */
  12876. appendAnimations(target: any, animations: Animation[]): void;
  12877. /**
  12878. * Gets the source animation for a specific property
  12879. * @param property defines the propertyu to look for
  12880. * @returns null or the source animation for the given property
  12881. */
  12882. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12883. /**
  12884. * Gets the runtime animation for a specific property
  12885. * @param property defines the propertyu to look for
  12886. * @returns null or the runtime animation for the given property
  12887. */
  12888. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12889. /**
  12890. * Resets the animatable to its original state
  12891. */
  12892. reset(): void;
  12893. /**
  12894. * Allows the animatable to blend with current running animations
  12895. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12896. * @param blendingSpeed defines the blending speed to use
  12897. */
  12898. enableBlending(blendingSpeed: number): void;
  12899. /**
  12900. * Disable animation blending
  12901. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12902. */
  12903. disableBlending(): void;
  12904. /**
  12905. * Jump directly to a given frame
  12906. * @param frame defines the frame to jump to
  12907. */
  12908. goToFrame(frame: number): void;
  12909. /**
  12910. * Pause the animation
  12911. */
  12912. pause(): void;
  12913. /**
  12914. * Restart the animation
  12915. */
  12916. restart(): void;
  12917. private _raiseOnAnimationEnd;
  12918. /**
  12919. * Stop and delete the current animation
  12920. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12921. * @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)
  12922. */
  12923. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12924. /**
  12925. * Wait asynchronously for the animation to end
  12926. * @returns a promise which will be fullfilled when the animation ends
  12927. */
  12928. waitAsync(): Promise<Animatable>;
  12929. /** @hidden */ private _animate(delay: number): boolean;
  12930. }
  12931. interface Scene {
  12932. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12933. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  12934. totalWeight: number;
  12935. animations: RuntimeAnimation[];
  12936. originalValue: Matrix;
  12937. }): any;
  12938. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  12939. totalWeight: number;
  12940. animations: RuntimeAnimation[];
  12941. originalValue: Quaternion;
  12942. }, refQuaternion: Quaternion): Quaternion;
  12943. /** @hidden */ private _processLateAnimationBindings(): void;
  12944. /**
  12945. * Will start the animation sequence of a given target
  12946. * @param target defines the target
  12947. * @param from defines from which frame should animation start
  12948. * @param to defines until which frame should animation run.
  12949. * @param weight defines the weight to apply to the animation (1.0 by default)
  12950. * @param loop defines if the animation loops
  12951. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12952. * @param onAnimationEnd defines the function to be executed when the animation ends
  12953. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12954. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12955. * @param onAnimationLoop defines the callback to call when an animation loops
  12956. * @returns the animatable object created for this animation
  12957. */
  12958. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12959. /**
  12960. * Will start the animation sequence of a given target
  12961. * @param target defines the target
  12962. * @param from defines from which frame should animation start
  12963. * @param to defines until which frame should animation run.
  12964. * @param loop defines if the animation loops
  12965. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12966. * @param onAnimationEnd defines the function to be executed when the animation ends
  12967. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12968. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12969. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12970. * @param onAnimationLoop defines the callback to call when an animation loops
  12971. * @returns the animatable object created for this animation
  12972. */
  12973. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12974. /**
  12975. * Will start the animation sequence of a given target and its hierarchy
  12976. * @param target defines the target
  12977. * @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.
  12978. * @param from defines from which frame should animation start
  12979. * @param to defines until which frame should animation run.
  12980. * @param loop defines if the animation loops
  12981. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12982. * @param onAnimationEnd defines the function to be executed when the animation ends
  12983. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12984. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12985. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12986. * @param onAnimationLoop defines the callback to call when an animation loops
  12987. * @returns the list of created animatables
  12988. */
  12989. 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[];
  12990. /**
  12991. * Begin a new animation on a given node
  12992. * @param target defines the target where the animation will take place
  12993. * @param animations defines the list of animations to start
  12994. * @param from defines the initial value
  12995. * @param to defines the final value
  12996. * @param loop defines if you want animation to loop (off by default)
  12997. * @param speedRatio defines the speed ratio to apply to all animations
  12998. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12999. * @param onAnimationLoop defines the callback to call when an animation loops
  13000. * @returns the list of created animatables
  13001. */
  13002. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13003. /**
  13004. * Begin a new animation on a given node and its hierarchy
  13005. * @param target defines the root node where the animation will take place
  13006. * @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.
  13007. * @param animations defines the list of animations to start
  13008. * @param from defines the initial value
  13009. * @param to defines the final value
  13010. * @param loop defines if you want animation to loop (off by default)
  13011. * @param speedRatio defines the speed ratio to apply to all animations
  13012. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13013. * @param onAnimationLoop defines the callback to call when an animation loops
  13014. * @returns the list of animatables created for all nodes
  13015. */
  13016. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13017. /**
  13018. * Gets the animatable associated with a specific target
  13019. * @param target defines the target of the animatable
  13020. * @returns the required animatable if found
  13021. */
  13022. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13023. /**
  13024. * Gets all animatables associated with a given target
  13025. * @param target defines the target to look animatables for
  13026. * @returns an array of Animatables
  13027. */
  13028. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13029. /**
  13030. * Stops and removes all animations that have been applied to the scene
  13031. */
  13032. stopAllAnimations(): void;
  13033. /**
  13034. * Gets the current delta time used by animation engine
  13035. */
  13036. deltaTime: number;
  13037. }
  13038. interface Bone {
  13039. /**
  13040. * Copy an animation range from another bone
  13041. * @param source defines the source bone
  13042. * @param rangeName defines the range name to copy
  13043. * @param frameOffset defines the frame offset
  13044. * @param rescaleAsRequired defines if rescaling must be applied if required
  13045. * @param skelDimensionsRatio defines the scaling ratio
  13046. * @returns true if operation was successful
  13047. */
  13048. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13049. }
  13050. }
  13051. declare module BABYLON {
  13052. /**
  13053. * Class used to override all child animations of a given target
  13054. */
  13055. export class AnimationPropertiesOverride {
  13056. /**
  13057. * Gets or sets a value indicating if animation blending must be used
  13058. */
  13059. enableBlending: boolean;
  13060. /**
  13061. * Gets or sets the blending speed to use when enableBlending is true
  13062. */
  13063. blendingSpeed: number;
  13064. /**
  13065. * Gets or sets the default loop mode to use
  13066. */
  13067. loopMode: number;
  13068. }
  13069. }
  13070. declare module BABYLON {
  13071. /**
  13072. * Class used to handle skinning animations
  13073. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13074. */
  13075. export class Skeleton implements IAnimatable {
  13076. /** defines the skeleton name */
  13077. name: string;
  13078. /** defines the skeleton Id */
  13079. id: string;
  13080. /**
  13081. * Defines the list of child bones
  13082. */
  13083. bones: Bone[];
  13084. /**
  13085. * Defines an estimate of the dimension of the skeleton at rest
  13086. */
  13087. dimensionsAtRest: Vector3;
  13088. /**
  13089. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13090. */
  13091. needInitialSkinMatrix: boolean;
  13092. /**
  13093. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13094. */
  13095. overrideMesh: Nullable<AbstractMesh>;
  13096. /**
  13097. * Gets the list of animations attached to this skeleton
  13098. */
  13099. animations: Array<Animation>;
  13100. private _scene;
  13101. private _isDirty;
  13102. private _transformMatrices;
  13103. private _transformMatrixTexture;
  13104. private _meshesWithPoseMatrix;
  13105. private _animatables;
  13106. private _identity;
  13107. private _synchronizedWithMesh;
  13108. private _ranges;
  13109. private _lastAbsoluteTransformsUpdateId;
  13110. private _canUseTextureForBones;
  13111. private _uniqueId;
  13112. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  13113. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  13114. /**
  13115. * Specifies if the skeleton should be serialized
  13116. */
  13117. doNotSerialize: boolean;
  13118. private _useTextureToStoreBoneMatrices;
  13119. /**
  13120. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13121. * Please note that this option is not available if the hardware does not support it
  13122. */
  13123. useTextureToStoreBoneMatrices: boolean;
  13124. private _animationPropertiesOverride;
  13125. /**
  13126. * Gets or sets the animation properties override
  13127. */
  13128. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13129. /**
  13130. * List of inspectable custom properties (used by the Inspector)
  13131. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13132. */
  13133. inspectableCustomProperties: IInspectable[];
  13134. /**
  13135. * An observable triggered before computing the skeleton's matrices
  13136. */
  13137. onBeforeComputeObservable: Observable<Skeleton>;
  13138. /**
  13139. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13140. */
  13141. readonly isUsingTextureForMatrices: boolean;
  13142. /**
  13143. * Gets the unique ID of this skeleton
  13144. */
  13145. readonly uniqueId: number;
  13146. /**
  13147. * Creates a new skeleton
  13148. * @param name defines the skeleton name
  13149. * @param id defines the skeleton Id
  13150. * @param scene defines the hosting scene
  13151. */
  13152. constructor(
  13153. /** defines the skeleton name */
  13154. name: string,
  13155. /** defines the skeleton Id */
  13156. id: string, scene: Scene);
  13157. /**
  13158. * Gets the current object class name.
  13159. * @return the class name
  13160. */
  13161. getClassName(): string;
  13162. /**
  13163. * Returns an array containing the root bones
  13164. * @returns an array containing the root bones
  13165. */
  13166. getChildren(): Array<Bone>;
  13167. /**
  13168. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13169. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13170. * @returns a Float32Array containing matrices data
  13171. */
  13172. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13173. /**
  13174. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13175. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13176. * @returns a raw texture containing the data
  13177. */
  13178. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13179. /**
  13180. * Gets the current hosting scene
  13181. * @returns a scene object
  13182. */
  13183. getScene(): Scene;
  13184. /**
  13185. * Gets a string representing the current skeleton data
  13186. * @param fullDetails defines a boolean indicating if we want a verbose version
  13187. * @returns a string representing the current skeleton data
  13188. */
  13189. toString(fullDetails?: boolean): string;
  13190. /**
  13191. * Get bone's index searching by name
  13192. * @param name defines bone's name to search for
  13193. * @return the indice of the bone. Returns -1 if not found
  13194. */
  13195. getBoneIndexByName(name: string): number;
  13196. /**
  13197. * Creater a new animation range
  13198. * @param name defines the name of the range
  13199. * @param from defines the start key
  13200. * @param to defines the end key
  13201. */
  13202. createAnimationRange(name: string, from: number, to: number): void;
  13203. /**
  13204. * Delete a specific animation range
  13205. * @param name defines the name of the range
  13206. * @param deleteFrames defines if frames must be removed as well
  13207. */
  13208. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13209. /**
  13210. * Gets a specific animation range
  13211. * @param name defines the name of the range to look for
  13212. * @returns the requested animation range or null if not found
  13213. */
  13214. getAnimationRange(name: string): Nullable<AnimationRange>;
  13215. /**
  13216. * Gets the list of all animation ranges defined on this skeleton
  13217. * @returns an array
  13218. */
  13219. getAnimationRanges(): Nullable<AnimationRange>[];
  13220. /**
  13221. * Copy animation range from a source skeleton.
  13222. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13223. * @param source defines the source skeleton
  13224. * @param name defines the name of the range to copy
  13225. * @param rescaleAsRequired defines if rescaling must be applied if required
  13226. * @returns true if operation was successful
  13227. */
  13228. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13229. /**
  13230. * Forces the skeleton to go to rest pose
  13231. */
  13232. returnToRest(): void;
  13233. private _getHighestAnimationFrame;
  13234. /**
  13235. * Begin a specific animation range
  13236. * @param name defines the name of the range to start
  13237. * @param loop defines if looping must be turned on (false by default)
  13238. * @param speedRatio defines the speed ratio to apply (1 by default)
  13239. * @param onAnimationEnd defines a callback which will be called when animation will end
  13240. * @returns a new animatable
  13241. */
  13242. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13243. /** @hidden */ private _markAsDirty(): void;
  13244. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13245. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13246. private _computeTransformMatrices;
  13247. /**
  13248. * Build all resources required to render a skeleton
  13249. */
  13250. prepare(): void;
  13251. /**
  13252. * Gets the list of animatables currently running for this skeleton
  13253. * @returns an array of animatables
  13254. */
  13255. getAnimatables(): IAnimatable[];
  13256. /**
  13257. * Clone the current skeleton
  13258. * @param name defines the name of the new skeleton
  13259. * @param id defines the id of the new skeleton
  13260. * @returns the new skeleton
  13261. */
  13262. clone(name: string, id?: string): Skeleton;
  13263. /**
  13264. * Enable animation blending for this skeleton
  13265. * @param blendingSpeed defines the blending speed to apply
  13266. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13267. */
  13268. enableBlending(blendingSpeed?: number): void;
  13269. /**
  13270. * Releases all resources associated with the current skeleton
  13271. */
  13272. dispose(): void;
  13273. /**
  13274. * Serialize the skeleton in a JSON object
  13275. * @returns a JSON object
  13276. */
  13277. serialize(): any;
  13278. /**
  13279. * Creates a new skeleton from serialized data
  13280. * @param parsedSkeleton defines the serialized data
  13281. * @param scene defines the hosting scene
  13282. * @returns a new skeleton
  13283. */
  13284. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13285. /**
  13286. * Compute all node absolute transforms
  13287. * @param forceUpdate defines if computation must be done even if cache is up to date
  13288. */
  13289. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13290. /**
  13291. * Gets the root pose matrix
  13292. * @returns a matrix
  13293. */
  13294. getPoseMatrix(): Nullable<Matrix>;
  13295. /**
  13296. * Sorts bones per internal index
  13297. */
  13298. sortBones(): void;
  13299. private _sortBones;
  13300. }
  13301. }
  13302. declare module BABYLON {
  13303. /**
  13304. * Class used to store bone information
  13305. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13306. */
  13307. export class Bone extends Node {
  13308. /**
  13309. * defines the bone name
  13310. */
  13311. name: string;
  13312. private static _tmpVecs;
  13313. private static _tmpQuat;
  13314. private static _tmpMats;
  13315. /**
  13316. * Gets the list of child bones
  13317. */
  13318. children: Bone[];
  13319. /** Gets the animations associated with this bone */
  13320. animations: Animation[];
  13321. /**
  13322. * Gets or sets bone length
  13323. */
  13324. length: number;
  13325. /**
  13326. * @hidden Internal only
  13327. * Set this value to map this bone to a different index in the transform matrices
  13328. * Set this value to -1 to exclude the bone from the transform matrices
  13329. */ private _index: Nullable<number>;
  13330. private _skeleton;
  13331. private _localMatrix;
  13332. private _restPose;
  13333. private _baseMatrix;
  13334. private _absoluteTransform;
  13335. private _invertedAbsoluteTransform;
  13336. private _parent;
  13337. private _scalingDeterminant;
  13338. private _worldTransform;
  13339. private _localScaling;
  13340. private _localRotation;
  13341. private _localPosition;
  13342. private _needToDecompose;
  13343. private _needToCompose;
  13344. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13345. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13346. /** @hidden */
  13347. /** @hidden */ private _matrix: Matrix;
  13348. /**
  13349. * Create a new bone
  13350. * @param name defines the bone name
  13351. * @param skeleton defines the parent skeleton
  13352. * @param parentBone defines the parent (can be null if the bone is the root)
  13353. * @param localMatrix defines the local matrix
  13354. * @param restPose defines the rest pose matrix
  13355. * @param baseMatrix defines the base matrix
  13356. * @param index defines index of the bone in the hiearchy
  13357. */
  13358. constructor(
  13359. /**
  13360. * defines the bone name
  13361. */
  13362. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13363. /**
  13364. * Gets the current object class name.
  13365. * @return the class name
  13366. */
  13367. getClassName(): string;
  13368. /**
  13369. * Gets the parent skeleton
  13370. * @returns a skeleton
  13371. */
  13372. getSkeleton(): Skeleton;
  13373. /**
  13374. * Gets parent bone
  13375. * @returns a bone or null if the bone is the root of the bone hierarchy
  13376. */
  13377. getParent(): Nullable<Bone>;
  13378. /**
  13379. * Returns an array containing the root bones
  13380. * @returns an array containing the root bones
  13381. */
  13382. getChildren(): Array<Bone>;
  13383. /**
  13384. * Gets the node index in matrix array generated for rendering
  13385. * @returns the node index
  13386. */
  13387. getIndex(): number;
  13388. /**
  13389. * Sets the parent bone
  13390. * @param parent defines the parent (can be null if the bone is the root)
  13391. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13392. */
  13393. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13394. /**
  13395. * Gets the local matrix
  13396. * @returns a matrix
  13397. */
  13398. getLocalMatrix(): Matrix;
  13399. /**
  13400. * Gets the base matrix (initial matrix which remains unchanged)
  13401. * @returns a matrix
  13402. */
  13403. getBaseMatrix(): Matrix;
  13404. /**
  13405. * Gets the rest pose matrix
  13406. * @returns a matrix
  13407. */
  13408. getRestPose(): Matrix;
  13409. /**
  13410. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13411. */
  13412. getWorldMatrix(): Matrix;
  13413. /**
  13414. * Sets the local matrix to rest pose matrix
  13415. */
  13416. returnToRest(): void;
  13417. /**
  13418. * Gets the inverse of the absolute transform matrix.
  13419. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13420. * @returns a matrix
  13421. */
  13422. getInvertedAbsoluteTransform(): Matrix;
  13423. /**
  13424. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13425. * @returns a matrix
  13426. */
  13427. getAbsoluteTransform(): Matrix;
  13428. /**
  13429. * Links with the given transform node.
  13430. * The local matrix of this bone is copied from the transform node every frame.
  13431. * @param transformNode defines the transform node to link to
  13432. */
  13433. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13434. /**
  13435. * Gets the node used to drive the bone's transformation
  13436. * @returns a transform node or null
  13437. */
  13438. getTransformNode(): Nullable<TransformNode>;
  13439. /** Gets or sets current position (in local space) */
  13440. position: Vector3;
  13441. /** Gets or sets current rotation (in local space) */
  13442. rotation: Vector3;
  13443. /** Gets or sets current rotation quaternion (in local space) */
  13444. rotationQuaternion: Quaternion;
  13445. /** Gets or sets current scaling (in local space) */
  13446. scaling: Vector3;
  13447. /**
  13448. * Gets the animation properties override
  13449. */
  13450. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13451. private _decompose;
  13452. private _compose;
  13453. /**
  13454. * Update the base and local matrices
  13455. * @param matrix defines the new base or local matrix
  13456. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13457. * @param updateLocalMatrix defines if the local matrix should be updated
  13458. */
  13459. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13460. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13461. /**
  13462. * Flag the bone as dirty (Forcing it to update everything)
  13463. */
  13464. markAsDirty(): void;
  13465. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13466. private _markAsDirtyAndDecompose;
  13467. /**
  13468. * Translate the bone in local or world space
  13469. * @param vec The amount to translate the bone
  13470. * @param space The space that the translation is in
  13471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13472. */
  13473. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13474. /**
  13475. * Set the postion of the bone in local or world space
  13476. * @param position The position to set the bone
  13477. * @param space The space that the position is in
  13478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13479. */
  13480. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13481. /**
  13482. * Set the absolute position of the bone (world space)
  13483. * @param position The position to set the bone
  13484. * @param mesh The mesh that this bone is attached to
  13485. */
  13486. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13487. /**
  13488. * Scale the bone on the x, y and z axes (in local space)
  13489. * @param x The amount to scale the bone on the x axis
  13490. * @param y The amount to scale the bone on the y axis
  13491. * @param z The amount to scale the bone on the z axis
  13492. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13493. */
  13494. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13495. /**
  13496. * Set the bone scaling in local space
  13497. * @param scale defines the scaling vector
  13498. */
  13499. setScale(scale: Vector3): void;
  13500. /**
  13501. * Gets the current scaling in local space
  13502. * @returns the current scaling vector
  13503. */
  13504. getScale(): Vector3;
  13505. /**
  13506. * Gets the current scaling in local space and stores it in a target vector
  13507. * @param result defines the target vector
  13508. */
  13509. getScaleToRef(result: Vector3): void;
  13510. /**
  13511. * Set the yaw, pitch, and roll of the bone in local or world space
  13512. * @param yaw The rotation of the bone on the y axis
  13513. * @param pitch The rotation of the bone on the x axis
  13514. * @param roll The rotation of the bone on the z axis
  13515. * @param space The space that the axes of rotation are in
  13516. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13517. */
  13518. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13519. /**
  13520. * Add a rotation to the bone on an axis in local or world space
  13521. * @param axis The axis to rotate the bone on
  13522. * @param amount The amount to rotate the bone
  13523. * @param space The space that the axis is in
  13524. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13525. */
  13526. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13527. /**
  13528. * Set the rotation of the bone to a particular axis angle in local or world space
  13529. * @param axis The axis to rotate the bone on
  13530. * @param angle The angle that the bone should be rotated to
  13531. * @param space The space that the axis is in
  13532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13533. */
  13534. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13535. /**
  13536. * Set the euler rotation of the bone in local of world space
  13537. * @param rotation The euler rotation that the bone should be set to
  13538. * @param space The space that the rotation is in
  13539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13540. */
  13541. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13542. /**
  13543. * Set the quaternion rotation of the bone in local of world space
  13544. * @param quat The quaternion rotation that the bone should be set to
  13545. * @param space The space that the rotation is in
  13546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13547. */
  13548. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13549. /**
  13550. * Set the rotation matrix of the bone in local of world space
  13551. * @param rotMat The rotation matrix that the bone should be set to
  13552. * @param space The space that the rotation is in
  13553. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13554. */
  13555. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13556. private _rotateWithMatrix;
  13557. private _getNegativeRotationToRef;
  13558. /**
  13559. * Get the position of the bone in local or world space
  13560. * @param space The space that the returned position is in
  13561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13562. * @returns The position of the bone
  13563. */
  13564. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13565. /**
  13566. * Copy the position of the bone to a vector3 in local or world space
  13567. * @param space The space that the returned position is in
  13568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13569. * @param result The vector3 to copy the position to
  13570. */
  13571. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13572. /**
  13573. * Get the absolute position of the bone (world space)
  13574. * @param mesh The mesh that this bone is attached to
  13575. * @returns The absolute position of the bone
  13576. */
  13577. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13578. /**
  13579. * Copy the absolute position of the bone (world space) to the result param
  13580. * @param mesh The mesh that this bone is attached to
  13581. * @param result The vector3 to copy the absolute position to
  13582. */
  13583. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13584. /**
  13585. * Compute the absolute transforms of this bone and its children
  13586. */
  13587. computeAbsoluteTransforms(): void;
  13588. /**
  13589. * Get the world direction from an axis that is in the local space of the bone
  13590. * @param localAxis The local direction that is used to compute the world direction
  13591. * @param mesh The mesh that this bone is attached to
  13592. * @returns The world direction
  13593. */
  13594. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13595. /**
  13596. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13597. * @param localAxis The local direction that is used to compute the world direction
  13598. * @param mesh The mesh that this bone is attached to
  13599. * @param result The vector3 that the world direction will be copied to
  13600. */
  13601. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13602. /**
  13603. * Get the euler rotation of the bone in local or world space
  13604. * @param space The space that the rotation should be in
  13605. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13606. * @returns The euler rotation
  13607. */
  13608. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13609. /**
  13610. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13611. * @param space The space that the rotation should be in
  13612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13613. * @param result The vector3 that the rotation should be copied to
  13614. */
  13615. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13616. /**
  13617. * Get the quaternion rotation of the bone in either local or world space
  13618. * @param space The space that the rotation should be in
  13619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13620. * @returns The quaternion rotation
  13621. */
  13622. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13623. /**
  13624. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13625. * @param space The space that the rotation should be in
  13626. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13627. * @param result The quaternion that the rotation should be copied to
  13628. */
  13629. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13630. /**
  13631. * Get the rotation matrix of the bone in local or world space
  13632. * @param space The space that the rotation should be in
  13633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13634. * @returns The rotation matrix
  13635. */
  13636. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13637. /**
  13638. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13639. * @param space The space that the rotation should be in
  13640. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13641. * @param result The quaternion that the rotation should be copied to
  13642. */
  13643. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13644. /**
  13645. * Get the world position of a point that is in the local space of the bone
  13646. * @param position The local position
  13647. * @param mesh The mesh that this bone is attached to
  13648. * @returns The world position
  13649. */
  13650. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13651. /**
  13652. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13653. * @param position The local position
  13654. * @param mesh The mesh that this bone is attached to
  13655. * @param result The vector3 that the world position should be copied to
  13656. */
  13657. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13658. /**
  13659. * Get the local position of a point that is in world space
  13660. * @param position The world position
  13661. * @param mesh The mesh that this bone is attached to
  13662. * @returns The local position
  13663. */
  13664. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13665. /**
  13666. * Get the local position of a point that is in world space and copy it to the result param
  13667. * @param position The world position
  13668. * @param mesh The mesh that this bone is attached to
  13669. * @param result The vector3 that the local position should be copied to
  13670. */
  13671. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13672. }
  13673. }
  13674. declare module BABYLON {
  13675. /**
  13676. * 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.
  13677. * @see https://doc.babylonjs.com/how_to/transformnode
  13678. */
  13679. export class TransformNode extends Node {
  13680. /**
  13681. * Object will not rotate to face the camera
  13682. */
  13683. static BILLBOARDMODE_NONE: number;
  13684. /**
  13685. * Object will rotate to face the camera but only on the x axis
  13686. */
  13687. static BILLBOARDMODE_X: number;
  13688. /**
  13689. * Object will rotate to face the camera but only on the y axis
  13690. */
  13691. static BILLBOARDMODE_Y: number;
  13692. /**
  13693. * Object will rotate to face the camera but only on the z axis
  13694. */
  13695. static BILLBOARDMODE_Z: number;
  13696. /**
  13697. * Object will rotate to face the camera
  13698. */
  13699. static BILLBOARDMODE_ALL: number;
  13700. /**
  13701. * Object will rotate to face the camera's position instead of orientation
  13702. */
  13703. static BILLBOARDMODE_USE_POSITION: number;
  13704. private _forward;
  13705. private _forwardInverted;
  13706. private _up;
  13707. private _right;
  13708. private _rightInverted;
  13709. private _position;
  13710. private _rotation;
  13711. private _rotationQuaternion;
  13712. protected _scaling: Vector3;
  13713. protected _isDirty: boolean;
  13714. private _transformToBoneReferal;
  13715. private _isAbsoluteSynced;
  13716. private _billboardMode;
  13717. /**
  13718. * Gets or sets the billboard mode. Default is 0.
  13719. *
  13720. * | Value | Type | Description |
  13721. * | --- | --- | --- |
  13722. * | 0 | BILLBOARDMODE_NONE | |
  13723. * | 1 | BILLBOARDMODE_X | |
  13724. * | 2 | BILLBOARDMODE_Y | |
  13725. * | 4 | BILLBOARDMODE_Z | |
  13726. * | 7 | BILLBOARDMODE_ALL | |
  13727. *
  13728. */
  13729. billboardMode: number;
  13730. private _preserveParentRotationForBillboard;
  13731. /**
  13732. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13733. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13734. */
  13735. preserveParentRotationForBillboard: boolean;
  13736. /**
  13737. * 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
  13738. */
  13739. scalingDeterminant: number;
  13740. private _infiniteDistance;
  13741. /**
  13742. * Gets or sets the distance of the object to max, often used by skybox
  13743. */
  13744. infiniteDistance: boolean;
  13745. /**
  13746. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13747. * By default the system will update normals to compensate
  13748. */
  13749. ignoreNonUniformScaling: boolean;
  13750. /**
  13751. * 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
  13752. */
  13753. reIntegrateRotationIntoRotationQuaternion: boolean;
  13754. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13755. /** @hidden */ private _localMatrix: Matrix;
  13756. private _usePivotMatrix;
  13757. private _absolutePosition;
  13758. private _absoluteScaling;
  13759. private _absoluteRotationQuaternion;
  13760. private _pivotMatrix;
  13761. private _pivotMatrixInverse;
  13762. protected _postMultiplyPivotMatrix: boolean;
  13763. protected _isWorldMatrixFrozen: boolean;
  13764. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13765. /**
  13766. * An event triggered after the world matrix is updated
  13767. */
  13768. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13769. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13770. /**
  13771. * Gets a string identifying the name of the class
  13772. * @returns "TransformNode" string
  13773. */
  13774. getClassName(): string;
  13775. /**
  13776. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13777. */
  13778. position: Vector3;
  13779. /**
  13780. * 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)).
  13781. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13782. */
  13783. rotation: Vector3;
  13784. /**
  13785. * 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)).
  13786. */
  13787. scaling: Vector3;
  13788. /**
  13789. * 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).
  13790. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13791. */
  13792. rotationQuaternion: Nullable<Quaternion>;
  13793. /**
  13794. * The forward direction of that transform in world space.
  13795. */
  13796. readonly forward: Vector3;
  13797. /**
  13798. * The up direction of that transform in world space.
  13799. */
  13800. readonly up: Vector3;
  13801. /**
  13802. * The right direction of that transform in world space.
  13803. */
  13804. readonly right: Vector3;
  13805. /**
  13806. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13807. * @param matrix the matrix to copy the pose from
  13808. * @returns this TransformNode.
  13809. */
  13810. updatePoseMatrix(matrix: Matrix): TransformNode;
  13811. /**
  13812. * Returns the mesh Pose matrix.
  13813. * @returns the pose matrix
  13814. */
  13815. getPoseMatrix(): Matrix;
  13816. /** @hidden */ private _isSynchronized(): boolean;
  13817. /** @hidden */ private _initCache(): void;
  13818. /**
  13819. * Flag the transform node as dirty (Forcing it to update everything)
  13820. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13821. * @returns this transform node
  13822. */
  13823. markAsDirty(property: string): TransformNode;
  13824. /**
  13825. * Returns the current mesh absolute position.
  13826. * Returns a Vector3.
  13827. */
  13828. readonly absolutePosition: Vector3;
  13829. /**
  13830. * Returns the current mesh absolute scaling.
  13831. * Returns a Vector3.
  13832. */
  13833. readonly absoluteScaling: Vector3;
  13834. /**
  13835. * Returns the current mesh absolute rotation.
  13836. * Returns a Quaternion.
  13837. */
  13838. readonly absoluteRotationQuaternion: Quaternion;
  13839. /**
  13840. * Sets a new matrix to apply before all other transformation
  13841. * @param matrix defines the transform matrix
  13842. * @returns the current TransformNode
  13843. */
  13844. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13845. /**
  13846. * Sets a new pivot matrix to the current node
  13847. * @param matrix defines the new pivot matrix to use
  13848. * @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
  13849. * @returns the current TransformNode
  13850. */
  13851. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13852. /**
  13853. * Returns the mesh pivot matrix.
  13854. * Default : Identity.
  13855. * @returns the matrix
  13856. */
  13857. getPivotMatrix(): Matrix;
  13858. /**
  13859. * Instantiate (when possible) or clone that node with its hierarchy
  13860. * @param newParent defines the new parent to use for the instance (or clone)
  13861. * @param options defines options to configure how copy is done
  13862. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13863. * @returns an instance (or a clone) of the current node with its hiearchy
  13864. */
  13865. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13866. doNotInstantiate: boolean;
  13867. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13868. /**
  13869. * Prevents the World matrix to be computed any longer
  13870. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13871. * @returns the TransformNode.
  13872. */
  13873. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13874. /**
  13875. * Allows back the World matrix computation.
  13876. * @returns the TransformNode.
  13877. */
  13878. unfreezeWorldMatrix(): this;
  13879. /**
  13880. * True if the World matrix has been frozen.
  13881. */
  13882. readonly isWorldMatrixFrozen: boolean;
  13883. /**
  13884. * Retuns the mesh absolute position in the World.
  13885. * @returns a Vector3.
  13886. */
  13887. getAbsolutePosition(): Vector3;
  13888. /**
  13889. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13890. * @param absolutePosition the absolute position to set
  13891. * @returns the TransformNode.
  13892. */
  13893. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13894. /**
  13895. * Sets the mesh position in its local space.
  13896. * @param vector3 the position to set in localspace
  13897. * @returns the TransformNode.
  13898. */
  13899. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13900. /**
  13901. * Returns the mesh position in the local space from the current World matrix values.
  13902. * @returns a new Vector3.
  13903. */
  13904. getPositionExpressedInLocalSpace(): Vector3;
  13905. /**
  13906. * Translates the mesh along the passed Vector3 in its local space.
  13907. * @param vector3 the distance to translate in localspace
  13908. * @returns the TransformNode.
  13909. */
  13910. locallyTranslate(vector3: Vector3): TransformNode;
  13911. private static _lookAtVectorCache;
  13912. /**
  13913. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13914. * @param targetPoint the position (must be in same space as current mesh) to look at
  13915. * @param yawCor optional yaw (y-axis) correction in radians
  13916. * @param pitchCor optional pitch (x-axis) correction in radians
  13917. * @param rollCor optional roll (z-axis) correction in radians
  13918. * @param space the choosen space of the target
  13919. * @returns the TransformNode.
  13920. */
  13921. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13922. /**
  13923. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13924. * This Vector3 is expressed in the World space.
  13925. * @param localAxis axis to rotate
  13926. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13927. */
  13928. getDirection(localAxis: Vector3): Vector3;
  13929. /**
  13930. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13931. * localAxis is expressed in the mesh local space.
  13932. * result is computed in the Wordl space from the mesh World matrix.
  13933. * @param localAxis axis to rotate
  13934. * @param result the resulting transformnode
  13935. * @returns this TransformNode.
  13936. */
  13937. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13938. /**
  13939. * Sets this transform node rotation to the given local axis.
  13940. * @param localAxis the axis in local space
  13941. * @param yawCor optional yaw (y-axis) correction in radians
  13942. * @param pitchCor optional pitch (x-axis) correction in radians
  13943. * @param rollCor optional roll (z-axis) correction in radians
  13944. * @returns this TransformNode
  13945. */
  13946. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13947. /**
  13948. * Sets a new pivot point to the current node
  13949. * @param point defines the new pivot point to use
  13950. * @param space defines if the point is in world or local space (local by default)
  13951. * @returns the current TransformNode
  13952. */
  13953. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13954. /**
  13955. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13956. * @returns the pivot point
  13957. */
  13958. getPivotPoint(): Vector3;
  13959. /**
  13960. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13961. * @param result the vector3 to store the result
  13962. * @returns this TransformNode.
  13963. */
  13964. getPivotPointToRef(result: Vector3): TransformNode;
  13965. /**
  13966. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13967. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13968. */
  13969. getAbsolutePivotPoint(): Vector3;
  13970. /**
  13971. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13972. * @param result vector3 to store the result
  13973. * @returns this TransformNode.
  13974. */
  13975. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13976. /**
  13977. * Defines the passed node as the parent of the current node.
  13978. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13979. * @see https://doc.babylonjs.com/how_to/parenting
  13980. * @param node the node ot set as the parent
  13981. * @returns this TransformNode.
  13982. */
  13983. setParent(node: Nullable<Node>): TransformNode;
  13984. private _nonUniformScaling;
  13985. /**
  13986. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13987. */
  13988. readonly nonUniformScaling: boolean;
  13989. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  13990. /**
  13991. * Attach the current TransformNode to another TransformNode associated with a bone
  13992. * @param bone Bone affecting the TransformNode
  13993. * @param affectedTransformNode TransformNode associated with the bone
  13994. * @returns this object
  13995. */
  13996. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13997. /**
  13998. * Detach the transform node if its associated with a bone
  13999. * @returns this object
  14000. */
  14001. detachFromBone(): TransformNode;
  14002. private static _rotationAxisCache;
  14003. /**
  14004. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14005. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14006. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14007. * The passed axis is also normalized.
  14008. * @param axis the axis to rotate around
  14009. * @param amount the amount to rotate in radians
  14010. * @param space Space to rotate in (Default: local)
  14011. * @returns the TransformNode.
  14012. */
  14013. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14014. /**
  14015. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14016. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14017. * The passed axis is also normalized. .
  14018. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14019. * @param point the point to rotate around
  14020. * @param axis the axis to rotate around
  14021. * @param amount the amount to rotate in radians
  14022. * @returns the TransformNode
  14023. */
  14024. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14025. /**
  14026. * Translates the mesh along the axis vector for the passed distance in the given space.
  14027. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14028. * @param axis the axis to translate in
  14029. * @param distance the distance to translate
  14030. * @param space Space to rotate in (Default: local)
  14031. * @returns the TransformNode.
  14032. */
  14033. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14034. /**
  14035. * Adds a rotation step to the mesh current rotation.
  14036. * x, y, z are Euler angles expressed in radians.
  14037. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14038. * This means this rotation is made in the mesh local space only.
  14039. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14040. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14041. * ```javascript
  14042. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14043. * ```
  14044. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14045. * 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.
  14046. * @param x Rotation to add
  14047. * @param y Rotation to add
  14048. * @param z Rotation to add
  14049. * @returns the TransformNode.
  14050. */
  14051. addRotation(x: number, y: number, z: number): TransformNode;
  14052. /**
  14053. * @hidden
  14054. */
  14055. protected _getEffectiveParent(): Nullable<Node>;
  14056. /**
  14057. * Computes the world matrix of the node
  14058. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14059. * @returns the world matrix
  14060. */
  14061. computeWorldMatrix(force?: boolean): Matrix;
  14062. protected _afterComputeWorldMatrix(): void;
  14063. /**
  14064. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14065. * @param func callback function to add
  14066. *
  14067. * @returns the TransformNode.
  14068. */
  14069. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14070. /**
  14071. * Removes a registered callback function.
  14072. * @param func callback function to remove
  14073. * @returns the TransformNode.
  14074. */
  14075. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14076. /**
  14077. * Gets the position of the current mesh in camera space
  14078. * @param camera defines the camera to use
  14079. * @returns a position
  14080. */
  14081. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14082. /**
  14083. * Returns the distance from the mesh to the active camera
  14084. * @param camera defines the camera to use
  14085. * @returns the distance
  14086. */
  14087. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14088. /**
  14089. * Clone the current transform node
  14090. * @param name Name of the new clone
  14091. * @param newParent New parent for the clone
  14092. * @param doNotCloneChildren Do not clone children hierarchy
  14093. * @returns the new transform node
  14094. */
  14095. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14096. /**
  14097. * Serializes the objects information.
  14098. * @param currentSerializationObject defines the object to serialize in
  14099. * @returns the serialized object
  14100. */
  14101. serialize(currentSerializationObject?: any): any;
  14102. /**
  14103. * Returns a new TransformNode object parsed from the source provided.
  14104. * @param parsedTransformNode is the source.
  14105. * @param scene the scne the object belongs to
  14106. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14107. * @returns a new TransformNode object parsed from the source provided.
  14108. */
  14109. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14110. /**
  14111. * Get all child-transformNodes of this node
  14112. * @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
  14113. * @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
  14114. * @returns an array of TransformNode
  14115. */
  14116. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14117. /**
  14118. * Releases resources associated with this transform node.
  14119. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14120. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14121. */
  14122. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14123. /**
  14124. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14125. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14126. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14127. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14128. * @returns the current mesh
  14129. */
  14130. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14131. private _syncAbsoluteScalingAndRotation;
  14132. }
  14133. }
  14134. declare module BABYLON {
  14135. /**
  14136. * Defines the types of pose enabled controllers that are supported
  14137. */
  14138. export enum PoseEnabledControllerType {
  14139. /**
  14140. * HTC Vive
  14141. */
  14142. VIVE = 0,
  14143. /**
  14144. * Oculus Rift
  14145. */
  14146. OCULUS = 1,
  14147. /**
  14148. * Windows mixed reality
  14149. */
  14150. WINDOWS = 2,
  14151. /**
  14152. * Samsung gear VR
  14153. */
  14154. GEAR_VR = 3,
  14155. /**
  14156. * Google Daydream
  14157. */
  14158. DAYDREAM = 4,
  14159. /**
  14160. * Generic
  14161. */
  14162. GENERIC = 5
  14163. }
  14164. /**
  14165. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14166. */
  14167. export interface MutableGamepadButton {
  14168. /**
  14169. * Value of the button/trigger
  14170. */
  14171. value: number;
  14172. /**
  14173. * If the button/trigger is currently touched
  14174. */
  14175. touched: boolean;
  14176. /**
  14177. * If the button/trigger is currently pressed
  14178. */
  14179. pressed: boolean;
  14180. }
  14181. /**
  14182. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14183. * @hidden
  14184. */
  14185. export interface ExtendedGamepadButton extends GamepadButton {
  14186. /**
  14187. * If the button/trigger is currently pressed
  14188. */
  14189. readonly pressed: boolean;
  14190. /**
  14191. * If the button/trigger is currently touched
  14192. */
  14193. readonly touched: boolean;
  14194. /**
  14195. * Value of the button/trigger
  14196. */
  14197. readonly value: number;
  14198. }
  14199. /** @hidden */
  14200. export interface _GamePadFactory {
  14201. /**
  14202. * Returns wether or not the current gamepad can be created for this type of controller.
  14203. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14204. * @returns true if it can be created, otherwise false
  14205. */
  14206. canCreate(gamepadInfo: any): boolean;
  14207. /**
  14208. * Creates a new instance of the Gamepad.
  14209. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14210. * @returns the new gamepad instance
  14211. */
  14212. create(gamepadInfo: any): Gamepad;
  14213. }
  14214. /**
  14215. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14216. */
  14217. export class PoseEnabledControllerHelper {
  14218. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14219. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14220. /**
  14221. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14222. * @param vrGamepad the gamepad to initialized
  14223. * @returns a vr controller of the type the gamepad identified as
  14224. */
  14225. static InitiateController(vrGamepad: any): Gamepad;
  14226. }
  14227. /**
  14228. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14229. */
  14230. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14231. /**
  14232. * If the controller is used in a webXR session
  14233. */
  14234. isXR: boolean;
  14235. private _deviceRoomPosition;
  14236. private _deviceRoomRotationQuaternion;
  14237. /**
  14238. * The device position in babylon space
  14239. */
  14240. devicePosition: Vector3;
  14241. /**
  14242. * The device rotation in babylon space
  14243. */
  14244. deviceRotationQuaternion: Quaternion;
  14245. /**
  14246. * The scale factor of the device in babylon space
  14247. */
  14248. deviceScaleFactor: number;
  14249. /**
  14250. * (Likely devicePosition should be used instead) The device position in its room space
  14251. */
  14252. position: Vector3;
  14253. /**
  14254. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14255. */
  14256. rotationQuaternion: Quaternion;
  14257. /**
  14258. * The type of controller (Eg. Windows mixed reality)
  14259. */
  14260. controllerType: PoseEnabledControllerType;
  14261. protected _calculatedPosition: Vector3;
  14262. private _calculatedRotation;
  14263. /**
  14264. * The raw pose from the device
  14265. */
  14266. rawPose: DevicePose;
  14267. private _trackPosition;
  14268. private _maxRotationDistFromHeadset;
  14269. private _draggedRoomRotation;
  14270. /**
  14271. * @hidden
  14272. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14273. /**
  14274. * Internal, the mesh attached to the controller
  14275. * @hidden
  14276. */ private _mesh: Nullable<AbstractMesh>;
  14277. private _poseControlledCamera;
  14278. private _leftHandSystemQuaternion;
  14279. /**
  14280. * Internal, matrix used to convert room space to babylon space
  14281. * @hidden
  14282. */ private _deviceToWorld: Matrix;
  14283. /**
  14284. * Node to be used when casting a ray from the controller
  14285. * @hidden
  14286. */ private _pointingPoseNode: Nullable<TransformNode>;
  14287. /**
  14288. * Name of the child mesh that can be used to cast a ray from the controller
  14289. */
  14290. static readonly POINTING_POSE: string;
  14291. /**
  14292. * Creates a new PoseEnabledController from a gamepad
  14293. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14294. */
  14295. constructor(browserGamepad: any);
  14296. private _workingMatrix;
  14297. /**
  14298. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14299. */
  14300. update(): void;
  14301. /**
  14302. * Updates only the pose device and mesh without doing any button event checking
  14303. */
  14304. protected _updatePoseAndMesh(): void;
  14305. /**
  14306. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14307. * @param poseData raw pose fromthe device
  14308. */
  14309. updateFromDevice(poseData: DevicePose): void;
  14310. /**
  14311. * @hidden
  14312. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14313. /**
  14314. * Attaches a mesh to the controller
  14315. * @param mesh the mesh to be attached
  14316. */
  14317. attachToMesh(mesh: AbstractMesh): void;
  14318. /**
  14319. * Attaches the controllers mesh to a camera
  14320. * @param camera the camera the mesh should be attached to
  14321. */
  14322. attachToPoseControlledCamera(camera: TargetCamera): void;
  14323. /**
  14324. * Disposes of the controller
  14325. */
  14326. dispose(): void;
  14327. /**
  14328. * The mesh that is attached to the controller
  14329. */
  14330. readonly mesh: Nullable<AbstractMesh>;
  14331. /**
  14332. * Gets the ray of the controller in the direction the controller is pointing
  14333. * @param length the length the resulting ray should be
  14334. * @returns a ray in the direction the controller is pointing
  14335. */
  14336. getForwardRay(length?: number): Ray;
  14337. }
  14338. }
  14339. declare module BABYLON {
  14340. /**
  14341. * Defines the WebVRController object that represents controllers tracked in 3D space
  14342. */
  14343. export abstract class WebVRController extends PoseEnabledController {
  14344. /**
  14345. * Internal, the default controller model for the controller
  14346. */
  14347. protected _defaultModel: Nullable<AbstractMesh>;
  14348. /**
  14349. * Fired when the trigger state has changed
  14350. */
  14351. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14352. /**
  14353. * Fired when the main button state has changed
  14354. */
  14355. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14356. /**
  14357. * Fired when the secondary button state has changed
  14358. */
  14359. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14360. /**
  14361. * Fired when the pad state has changed
  14362. */
  14363. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14364. /**
  14365. * Fired when controllers stick values have changed
  14366. */
  14367. onPadValuesChangedObservable: Observable<StickValues>;
  14368. /**
  14369. * Array of button availible on the controller
  14370. */
  14371. protected _buttons: Array<MutableGamepadButton>;
  14372. private _onButtonStateChange;
  14373. /**
  14374. * Fired when a controller button's state has changed
  14375. * @param callback the callback containing the button that was modified
  14376. */
  14377. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14378. /**
  14379. * X and Y axis corresponding to the controllers joystick
  14380. */
  14381. pad: StickValues;
  14382. /**
  14383. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14384. */
  14385. hand: string;
  14386. /**
  14387. * The default controller model for the controller
  14388. */
  14389. readonly defaultModel: Nullable<AbstractMesh>;
  14390. /**
  14391. * Creates a new WebVRController from a gamepad
  14392. * @param vrGamepad the gamepad that the WebVRController should be created from
  14393. */
  14394. constructor(vrGamepad: any);
  14395. /**
  14396. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14397. */
  14398. update(): void;
  14399. /**
  14400. * Function to be called when a button is modified
  14401. */
  14402. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14403. /**
  14404. * Loads a mesh and attaches it to the controller
  14405. * @param scene the scene the mesh should be added to
  14406. * @param meshLoaded callback for when the mesh has been loaded
  14407. */
  14408. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14409. private _setButtonValue;
  14410. private _changes;
  14411. private _checkChanges;
  14412. /**
  14413. * Disposes of th webVRCOntroller
  14414. */
  14415. dispose(): void;
  14416. }
  14417. }
  14418. declare module BABYLON {
  14419. /**
  14420. * The HemisphericLight simulates the ambient environment light,
  14421. * so the passed direction is the light reflection direction, not the incoming direction.
  14422. */
  14423. export class HemisphericLight extends Light {
  14424. /**
  14425. * The groundColor is the light in the opposite direction to the one specified during creation.
  14426. * 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.
  14427. */
  14428. groundColor: Color3;
  14429. /**
  14430. * The light reflection direction, not the incoming direction.
  14431. */
  14432. direction: Vector3;
  14433. /**
  14434. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14435. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14436. * The HemisphericLight can't cast shadows.
  14437. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14438. * @param name The friendly name of the light
  14439. * @param direction The direction of the light reflection
  14440. * @param scene The scene the light belongs to
  14441. */
  14442. constructor(name: string, direction: Vector3, scene: Scene);
  14443. protected _buildUniformLayout(): void;
  14444. /**
  14445. * Returns the string "HemisphericLight".
  14446. * @return The class name
  14447. */
  14448. getClassName(): string;
  14449. /**
  14450. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14451. * Returns the updated direction.
  14452. * @param target The target the direction should point to
  14453. * @return The computed direction
  14454. */
  14455. setDirectionToTarget(target: Vector3): Vector3;
  14456. /**
  14457. * Returns the shadow generator associated to the light.
  14458. * @returns Always null for hemispheric lights because it does not support shadows.
  14459. */
  14460. getShadowGenerator(): Nullable<IShadowGenerator>;
  14461. /**
  14462. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14463. * @param effect The effect to update
  14464. * @param lightIndex The index of the light in the effect to update
  14465. * @returns The hemispheric light
  14466. */
  14467. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14468. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14469. /**
  14470. * Computes the world matrix of the node
  14471. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14472. * @param useWasUpdatedFlag defines a reserved property
  14473. * @returns the world matrix
  14474. */
  14475. computeWorldMatrix(): Matrix;
  14476. /**
  14477. * Returns the integer 3.
  14478. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14479. */
  14480. getTypeID(): number;
  14481. /**
  14482. * Prepares the list of defines specific to the light type.
  14483. * @param defines the list of defines
  14484. * @param lightIndex defines the index of the light for the effect
  14485. */
  14486. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14487. }
  14488. }
  14489. declare module BABYLON {
  14490. /** @hidden */
  14491. export var vrMultiviewToSingleviewPixelShader: {
  14492. name: string;
  14493. shader: string;
  14494. };
  14495. }
  14496. declare module BABYLON {
  14497. /**
  14498. * Renders to multiple views with a single draw call
  14499. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14500. */
  14501. export class MultiviewRenderTarget extends RenderTargetTexture {
  14502. /**
  14503. * Creates a multiview render target
  14504. * @param scene scene used with the render target
  14505. * @param size the size of the render target (used for each view)
  14506. */
  14507. constructor(scene: Scene, size?: number | {
  14508. width: number;
  14509. height: number;
  14510. } | {
  14511. ratio: number;
  14512. });
  14513. /**
  14514. * @hidden
  14515. * @param faceIndex the face index, if its a cube texture
  14516. */ private _bindFrameBuffer(faceIndex?: number): void;
  14517. /**
  14518. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14519. * @returns the view count
  14520. */
  14521. getViewCount(): number;
  14522. }
  14523. }
  14524. declare module BABYLON {
  14525. /**
  14526. * Represents a camera frustum
  14527. */
  14528. export class Frustum {
  14529. /**
  14530. * Gets the planes representing the frustum
  14531. * @param transform matrix to be applied to the returned planes
  14532. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14533. */
  14534. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14535. /**
  14536. * Gets the near frustum plane transformed by the transform matrix
  14537. * @param transform transformation matrix to be applied to the resulting frustum plane
  14538. * @param frustumPlane the resuling frustum plane
  14539. */
  14540. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14541. /**
  14542. * Gets the far frustum plane transformed by the transform matrix
  14543. * @param transform transformation matrix to be applied to the resulting frustum plane
  14544. * @param frustumPlane the resuling frustum plane
  14545. */
  14546. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14547. /**
  14548. * Gets the left frustum plane transformed by the transform matrix
  14549. * @param transform transformation matrix to be applied to the resulting frustum plane
  14550. * @param frustumPlane the resuling frustum plane
  14551. */
  14552. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14553. /**
  14554. * Gets the right frustum plane transformed by the transform matrix
  14555. * @param transform transformation matrix to be applied to the resulting frustum plane
  14556. * @param frustumPlane the resuling frustum plane
  14557. */
  14558. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14559. /**
  14560. * Gets the top frustum plane transformed by the transform matrix
  14561. * @param transform transformation matrix to be applied to the resulting frustum plane
  14562. * @param frustumPlane the resuling frustum plane
  14563. */
  14564. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14565. /**
  14566. * Gets the bottom frustum plane transformed by the transform matrix
  14567. * @param transform transformation matrix to be applied to the resulting frustum plane
  14568. * @param frustumPlane the resuling frustum plane
  14569. */
  14570. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14571. /**
  14572. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14573. * @param transform transformation matrix to be applied to the resulting frustum planes
  14574. * @param frustumPlanes the resuling frustum planes
  14575. */
  14576. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14577. }
  14578. }
  14579. declare module BABYLON {
  14580. interface Engine {
  14581. /**
  14582. * Creates a new multiview render target
  14583. * @param width defines the width of the texture
  14584. * @param height defines the height of the texture
  14585. * @returns the created multiview texture
  14586. */
  14587. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14588. /**
  14589. * Binds a multiview framebuffer to be drawn to
  14590. * @param multiviewTexture texture to bind
  14591. */
  14592. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14593. }
  14594. interface Camera {
  14595. /**
  14596. * @hidden
  14597. * 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)
  14598. */ private _useMultiviewToSingleView: boolean;
  14599. /**
  14600. * @hidden
  14601. * 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)
  14602. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14603. /**
  14604. * @hidden
  14605. * ensures the multiview texture of the camera exists and has the specified width/height
  14606. * @param width height to set on the multiview texture
  14607. * @param height width to set on the multiview texture
  14608. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14609. }
  14610. interface Scene {
  14611. /** @hidden */ private _transformMatrixR: Matrix;
  14612. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14613. /** @hidden */ private _createMultiviewUbo(): void;
  14614. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14615. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14616. }
  14617. }
  14618. declare module BABYLON {
  14619. /**
  14620. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14621. * This will not be used for webXR as it supports displaying texture arrays directly
  14622. */
  14623. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14624. /**
  14625. * Initializes a VRMultiviewToSingleview
  14626. * @param name name of the post process
  14627. * @param camera camera to be applied to
  14628. * @param scaleFactor scaling factor to the size of the output texture
  14629. */
  14630. constructor(name: string, camera: Camera, scaleFactor: number);
  14631. }
  14632. }
  14633. declare module BABYLON {
  14634. /**
  14635. * Interface used to define additional presentation attributes
  14636. */
  14637. export interface IVRPresentationAttributes {
  14638. /**
  14639. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  14640. */
  14641. highRefreshRate: boolean;
  14642. /**
  14643. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  14644. */
  14645. foveationLevel: number;
  14646. }
  14647. interface Engine {
  14648. /** @hidden */ private _vrDisplay: any;
  14649. /** @hidden */ private _vrSupported: boolean;
  14650. /** @hidden */ private _oldSize: Size;
  14651. /** @hidden */ private _oldHardwareScaleFactor: number;
  14652. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14653. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14654. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14655. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14656. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14657. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14658. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14659. /**
  14660. * Observable signaled when VR display mode changes
  14661. */
  14662. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14663. /**
  14664. * Observable signaled when VR request present is complete
  14665. */
  14666. onVRRequestPresentComplete: Observable<boolean>;
  14667. /**
  14668. * Observable signaled when VR request present starts
  14669. */
  14670. onVRRequestPresentStart: Observable<Engine>;
  14671. /**
  14672. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14673. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14674. */
  14675. isInVRExclusivePointerMode: boolean;
  14676. /**
  14677. * Gets a boolean indicating if a webVR device was detected
  14678. * @returns true if a webVR device was detected
  14679. */
  14680. isVRDevicePresent(): boolean;
  14681. /**
  14682. * Gets the current webVR device
  14683. * @returns the current webVR device (or null)
  14684. */
  14685. getVRDevice(): any;
  14686. /**
  14687. * Initializes a webVR display and starts listening to display change events
  14688. * The onVRDisplayChangedObservable will be notified upon these changes
  14689. * @returns A promise containing a VRDisplay and if vr is supported
  14690. */
  14691. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14692. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14693. /**
  14694. * Gets or sets the presentation attributes used to configure VR rendering
  14695. */
  14696. vrPresentationAttributes?: IVRPresentationAttributes;
  14697. /**
  14698. * Call this function to switch to webVR mode
  14699. * Will do nothing if webVR is not supported or if there is no webVR device
  14700. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14701. */
  14702. enableVR(): void;
  14703. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14704. }
  14705. }
  14706. declare module BABYLON {
  14707. /**
  14708. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14709. * IMPORTANT!! The data is right-hand data.
  14710. * @export
  14711. * @interface DevicePose
  14712. */
  14713. export interface DevicePose {
  14714. /**
  14715. * The position of the device, values in array are [x,y,z].
  14716. */
  14717. readonly position: Nullable<Float32Array>;
  14718. /**
  14719. * The linearVelocity of the device, values in array are [x,y,z].
  14720. */
  14721. readonly linearVelocity: Nullable<Float32Array>;
  14722. /**
  14723. * The linearAcceleration of the device, values in array are [x,y,z].
  14724. */
  14725. readonly linearAcceleration: Nullable<Float32Array>;
  14726. /**
  14727. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14728. */
  14729. readonly orientation: Nullable<Float32Array>;
  14730. /**
  14731. * The angularVelocity of the device, values in array are [x,y,z].
  14732. */
  14733. readonly angularVelocity: Nullable<Float32Array>;
  14734. /**
  14735. * The angularAcceleration of the device, values in array are [x,y,z].
  14736. */
  14737. readonly angularAcceleration: Nullable<Float32Array>;
  14738. }
  14739. /**
  14740. * Interface representing a pose controlled object in Babylon.
  14741. * A pose controlled object has both regular pose values as well as pose values
  14742. * from an external device such as a VR head mounted display
  14743. */
  14744. export interface PoseControlled {
  14745. /**
  14746. * The position of the object in babylon space.
  14747. */
  14748. position: Vector3;
  14749. /**
  14750. * The rotation quaternion of the object in babylon space.
  14751. */
  14752. rotationQuaternion: Quaternion;
  14753. /**
  14754. * The position of the device in babylon space.
  14755. */
  14756. devicePosition?: Vector3;
  14757. /**
  14758. * The rotation quaternion of the device in babylon space.
  14759. */
  14760. deviceRotationQuaternion: Quaternion;
  14761. /**
  14762. * The raw pose coming from the device.
  14763. */
  14764. rawPose: Nullable<DevicePose>;
  14765. /**
  14766. * The scale of the device to be used when translating from device space to babylon space.
  14767. */
  14768. deviceScaleFactor: number;
  14769. /**
  14770. * Updates the poseControlled values based on the input device pose.
  14771. * @param poseData the pose data to update the object with
  14772. */
  14773. updateFromDevice(poseData: DevicePose): void;
  14774. }
  14775. /**
  14776. * Set of options to customize the webVRCamera
  14777. */
  14778. export interface WebVROptions {
  14779. /**
  14780. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14781. */
  14782. trackPosition?: boolean;
  14783. /**
  14784. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14785. */
  14786. positionScale?: number;
  14787. /**
  14788. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14789. */
  14790. displayName?: string;
  14791. /**
  14792. * Should the native controller meshes be initialized. (default: true)
  14793. */
  14794. controllerMeshes?: boolean;
  14795. /**
  14796. * Creating a default HemiLight only on controllers. (default: true)
  14797. */
  14798. defaultLightingOnControllers?: boolean;
  14799. /**
  14800. * If you don't want to use the default VR button of the helper. (default: false)
  14801. */
  14802. useCustomVRButton?: boolean;
  14803. /**
  14804. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14805. */
  14806. customVRButton?: HTMLButtonElement;
  14807. /**
  14808. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14809. */
  14810. rayLength?: number;
  14811. /**
  14812. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14813. */
  14814. defaultHeight?: number;
  14815. /**
  14816. * If multiview should be used if availible (default: false)
  14817. */
  14818. useMultiview?: boolean;
  14819. }
  14820. /**
  14821. * This represents a WebVR camera.
  14822. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14823. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14824. */
  14825. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14826. private webVROptions;
  14827. /**
  14828. * @hidden
  14829. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14830. */ private _vrDevice: any;
  14831. /**
  14832. * The rawPose of the vrDevice.
  14833. */
  14834. rawPose: Nullable<DevicePose>;
  14835. private _onVREnabled;
  14836. private _specsVersion;
  14837. private _attached;
  14838. private _frameData;
  14839. protected _descendants: Array<Node>;
  14840. private _deviceRoomPosition;
  14841. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14842. private _standingMatrix;
  14843. /**
  14844. * Represents device position in babylon space.
  14845. */
  14846. devicePosition: Vector3;
  14847. /**
  14848. * Represents device rotation in babylon space.
  14849. */
  14850. deviceRotationQuaternion: Quaternion;
  14851. /**
  14852. * The scale of the device to be used when translating from device space to babylon space.
  14853. */
  14854. deviceScaleFactor: number;
  14855. private _deviceToWorld;
  14856. private _worldToDevice;
  14857. /**
  14858. * References to the webVR controllers for the vrDevice.
  14859. */
  14860. controllers: Array<WebVRController>;
  14861. /**
  14862. * Emits an event when a controller is attached.
  14863. */
  14864. onControllersAttachedObservable: Observable<WebVRController[]>;
  14865. /**
  14866. * Emits an event when a controller's mesh has been loaded;
  14867. */
  14868. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14869. /**
  14870. * Emits an event when the HMD's pose has been updated.
  14871. */
  14872. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14873. private _poseSet;
  14874. /**
  14875. * If the rig cameras be used as parent instead of this camera.
  14876. */
  14877. rigParenting: boolean;
  14878. private _lightOnControllers;
  14879. private _defaultHeight?;
  14880. /**
  14881. * Instantiates a WebVRFreeCamera.
  14882. * @param name The name of the WebVRFreeCamera
  14883. * @param position The starting anchor position for the camera
  14884. * @param scene The scene the camera belongs to
  14885. * @param webVROptions a set of customizable options for the webVRCamera
  14886. */
  14887. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14888. /**
  14889. * Gets the device distance from the ground in meters.
  14890. * @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.
  14891. */
  14892. deviceDistanceToRoomGround(): number;
  14893. /**
  14894. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14895. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14896. */
  14897. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14898. /**
  14899. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14900. * @returns A promise with a boolean set to if the standing matrix is supported.
  14901. */
  14902. useStandingMatrixAsync(): Promise<boolean>;
  14903. /**
  14904. * Disposes the camera
  14905. */
  14906. dispose(): void;
  14907. /**
  14908. * Gets a vrController by name.
  14909. * @param name The name of the controller to retreive
  14910. * @returns the controller matching the name specified or null if not found
  14911. */
  14912. getControllerByName(name: string): Nullable<WebVRController>;
  14913. private _leftController;
  14914. /**
  14915. * The controller corresponding to the users left hand.
  14916. */
  14917. readonly leftController: Nullable<WebVRController>;
  14918. private _rightController;
  14919. /**
  14920. * The controller corresponding to the users right hand.
  14921. */
  14922. readonly rightController: Nullable<WebVRController>;
  14923. /**
  14924. * Casts a ray forward from the vrCamera's gaze.
  14925. * @param length Length of the ray (default: 100)
  14926. * @returns the ray corresponding to the gaze
  14927. */
  14928. getForwardRay(length?: number): Ray;
  14929. /**
  14930. * @hidden
  14931. * Updates the camera based on device's frame data
  14932. */ private _checkInputs(): void;
  14933. /**
  14934. * Updates the poseControlled values based on the input device pose.
  14935. * @param poseData Pose coming from the device
  14936. */
  14937. updateFromDevice(poseData: DevicePose): void;
  14938. private _htmlElementAttached;
  14939. private _detachIfAttached;
  14940. /**
  14941. * WebVR's attach control will start broadcasting frames to the device.
  14942. * Note that in certain browsers (chrome for example) this function must be called
  14943. * within a user-interaction callback. Example:
  14944. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14945. *
  14946. * @param element html element to attach the vrDevice to
  14947. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14948. */
  14949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14950. /**
  14951. * Detaches the camera from the html element and disables VR
  14952. *
  14953. * @param element html element to detach from
  14954. */
  14955. detachControl(element: HTMLElement): void;
  14956. /**
  14957. * @returns the name of this class
  14958. */
  14959. getClassName(): string;
  14960. /**
  14961. * Calls resetPose on the vrDisplay
  14962. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14963. */
  14964. resetToCurrentRotation(): void;
  14965. /**
  14966. * @hidden
  14967. * Updates the rig cameras (left and right eye)
  14968. */ private _updateRigCameras(): void;
  14969. private _workingVector;
  14970. private _oneVector;
  14971. private _workingMatrix;
  14972. private updateCacheCalled;
  14973. private _correctPositionIfNotTrackPosition;
  14974. /**
  14975. * @hidden
  14976. * Updates the cached values of the camera
  14977. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14978. */ private _updateCache(ignoreParentClass?: boolean): void;
  14979. /**
  14980. * @hidden
  14981. * Get current device position in babylon world
  14982. */ private _computeDevicePosition(): void;
  14983. /**
  14984. * Updates the current device position and rotation in the babylon world
  14985. */
  14986. update(): void;
  14987. /**
  14988. * @hidden
  14989. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14990. * @returns an identity matrix
  14991. */ private _getViewMatrix(): Matrix;
  14992. private _tmpMatrix;
  14993. /**
  14994. * This function is called by the two RIG cameras.
  14995. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14996. * @hidden
  14997. */ private _getWebVRViewMatrix(): Matrix;
  14998. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  14999. private _onGamepadConnectedObserver;
  15000. private _onGamepadDisconnectedObserver;
  15001. private _updateCacheWhenTrackingDisabledObserver;
  15002. /**
  15003. * Initializes the controllers and their meshes
  15004. */
  15005. initControllers(): void;
  15006. }
  15007. }
  15008. declare module BABYLON {
  15009. /**
  15010. * Size options for a post process
  15011. */
  15012. export type PostProcessOptions = {
  15013. width: number;
  15014. height: number;
  15015. };
  15016. /**
  15017. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15018. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15019. */
  15020. export class PostProcess {
  15021. /** Name of the PostProcess. */
  15022. name: string;
  15023. /**
  15024. * Gets or sets the unique id of the post process
  15025. */
  15026. uniqueId: number;
  15027. /**
  15028. * Width of the texture to apply the post process on
  15029. */
  15030. width: number;
  15031. /**
  15032. * Height of the texture to apply the post process on
  15033. */
  15034. height: number;
  15035. /**
  15036. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15037. * @hidden
  15038. */ private _outputTexture: Nullable<InternalTexture>;
  15039. /**
  15040. * Sampling mode used by the shader
  15041. * See https://doc.babylonjs.com/classes/3.1/texture
  15042. */
  15043. renderTargetSamplingMode: number;
  15044. /**
  15045. * Clear color to use when screen clearing
  15046. */
  15047. clearColor: Color4;
  15048. /**
  15049. * If the buffer needs to be cleared before applying the post process. (default: true)
  15050. * Should be set to false if shader will overwrite all previous pixels.
  15051. */
  15052. autoClear: boolean;
  15053. /**
  15054. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15055. */
  15056. alphaMode: number;
  15057. /**
  15058. * Sets the setAlphaBlendConstants of the babylon engine
  15059. */
  15060. alphaConstants: Color4;
  15061. /**
  15062. * Animations to be used for the post processing
  15063. */
  15064. animations: Animation[];
  15065. /**
  15066. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15067. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15068. */
  15069. enablePixelPerfectMode: boolean;
  15070. /**
  15071. * Force the postprocess to be applied without taking in account viewport
  15072. */
  15073. forceFullscreenViewport: boolean;
  15074. /**
  15075. * List of inspectable custom properties (used by the Inspector)
  15076. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15077. */
  15078. inspectableCustomProperties: IInspectable[];
  15079. /**
  15080. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15081. *
  15082. * | Value | Type | Description |
  15083. * | ----- | ----------------------------------- | ----------- |
  15084. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15085. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15086. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15087. *
  15088. */
  15089. scaleMode: number;
  15090. /**
  15091. * Force textures to be a power of two (default: false)
  15092. */
  15093. alwaysForcePOT: boolean;
  15094. private _samples;
  15095. /**
  15096. * Number of sample textures (default: 1)
  15097. */
  15098. samples: number;
  15099. /**
  15100. * Modify the scale of the post process to be the same as the viewport (default: false)
  15101. */
  15102. adaptScaleToCurrentViewport: boolean;
  15103. private _camera;
  15104. private _scene;
  15105. private _engine;
  15106. private _options;
  15107. private _reusable;
  15108. private _textureType;
  15109. /**
  15110. * Smart array of input and output textures for the post process.
  15111. * @hidden
  15112. */ private _textures: SmartArray<InternalTexture>;
  15113. /**
  15114. * The index in _textures that corresponds to the output texture.
  15115. * @hidden
  15116. */ private _currentRenderTextureInd: number;
  15117. private _effect;
  15118. private _samplers;
  15119. private _fragmentUrl;
  15120. private _vertexUrl;
  15121. private _parameters;
  15122. private _scaleRatio;
  15123. protected _indexParameters: any;
  15124. private _shareOutputWithPostProcess;
  15125. private _texelSize;
  15126. private _forcedOutputTexture;
  15127. /**
  15128. * Returns the fragment url or shader name used in the post process.
  15129. * @returns the fragment url or name in the shader store.
  15130. */
  15131. getEffectName(): string;
  15132. /**
  15133. * An event triggered when the postprocess is activated.
  15134. */
  15135. onActivateObservable: Observable<Camera>;
  15136. private _onActivateObserver;
  15137. /**
  15138. * A function that is added to the onActivateObservable
  15139. */
  15140. onActivate: Nullable<(camera: Camera) => void>;
  15141. /**
  15142. * An event triggered when the postprocess changes its size.
  15143. */
  15144. onSizeChangedObservable: Observable<PostProcess>;
  15145. private _onSizeChangedObserver;
  15146. /**
  15147. * A function that is added to the onSizeChangedObservable
  15148. */
  15149. onSizeChanged: (postProcess: PostProcess) => void;
  15150. /**
  15151. * An event triggered when the postprocess applies its effect.
  15152. */
  15153. onApplyObservable: Observable<Effect>;
  15154. private _onApplyObserver;
  15155. /**
  15156. * A function that is added to the onApplyObservable
  15157. */
  15158. onApply: (effect: Effect) => void;
  15159. /**
  15160. * An event triggered before rendering the postprocess
  15161. */
  15162. onBeforeRenderObservable: Observable<Effect>;
  15163. private _onBeforeRenderObserver;
  15164. /**
  15165. * A function that is added to the onBeforeRenderObservable
  15166. */
  15167. onBeforeRender: (effect: Effect) => void;
  15168. /**
  15169. * An event triggered after rendering the postprocess
  15170. */
  15171. onAfterRenderObservable: Observable<Effect>;
  15172. private _onAfterRenderObserver;
  15173. /**
  15174. * A function that is added to the onAfterRenderObservable
  15175. */
  15176. onAfterRender: (efect: Effect) => void;
  15177. /**
  15178. * 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
  15179. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15180. */
  15181. inputTexture: InternalTexture;
  15182. /**
  15183. * Gets the camera which post process is applied to.
  15184. * @returns The camera the post process is applied to.
  15185. */
  15186. getCamera(): Camera;
  15187. /**
  15188. * Gets the texel size of the postprocess.
  15189. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15190. */
  15191. readonly texelSize: Vector2;
  15192. /**
  15193. * Creates a new instance PostProcess
  15194. * @param name The name of the PostProcess.
  15195. * @param fragmentUrl The url of the fragment shader to be used.
  15196. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15197. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15198. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15199. * @param camera The camera to apply the render pass to.
  15200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15201. * @param engine The engine which the post process will be applied. (default: current engine)
  15202. * @param reusable If the post process can be reused on the same frame. (default: false)
  15203. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15204. * @param textureType Type of textures used when performing the post process. (default: 0)
  15205. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15206. * @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
  15207. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15208. */
  15209. constructor(
  15210. /** Name of the PostProcess. */
  15211. 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);
  15212. /**
  15213. * Gets a string idenfifying the name of the class
  15214. * @returns "PostProcess" string
  15215. */
  15216. getClassName(): string;
  15217. /**
  15218. * Gets the engine which this post process belongs to.
  15219. * @returns The engine the post process was enabled with.
  15220. */
  15221. getEngine(): Engine;
  15222. /**
  15223. * The effect that is created when initializing the post process.
  15224. * @returns The created effect corresponding the the postprocess.
  15225. */
  15226. getEffect(): Effect;
  15227. /**
  15228. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15229. * @param postProcess The post process to share the output with.
  15230. * @returns This post process.
  15231. */
  15232. shareOutputWith(postProcess: PostProcess): PostProcess;
  15233. /**
  15234. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15235. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15236. */
  15237. useOwnOutput(): void;
  15238. /**
  15239. * Updates the effect with the current post process compile time values and recompiles the shader.
  15240. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15241. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15242. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15243. * @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
  15244. * @param onCompiled Called when the shader has been compiled.
  15245. * @param onError Called if there is an error when compiling a shader.
  15246. */
  15247. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15248. /**
  15249. * The post process is reusable if it can be used multiple times within one frame.
  15250. * @returns If the post process is reusable
  15251. */
  15252. isReusable(): boolean;
  15253. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15254. markTextureDirty(): void;
  15255. /**
  15256. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15257. * 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.
  15258. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15259. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15260. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15261. * @returns The target texture that was bound to be written to.
  15262. */
  15263. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15264. /**
  15265. * If the post process is supported.
  15266. */
  15267. readonly isSupported: boolean;
  15268. /**
  15269. * The aspect ratio of the output texture.
  15270. */
  15271. readonly aspectRatio: number;
  15272. /**
  15273. * Get a value indicating if the post-process is ready to be used
  15274. * @returns true if the post-process is ready (shader is compiled)
  15275. */
  15276. isReady(): boolean;
  15277. /**
  15278. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15279. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15280. */
  15281. apply(): Nullable<Effect>;
  15282. private _disposeTextures;
  15283. /**
  15284. * Disposes the post process.
  15285. * @param camera The camera to dispose the post process on.
  15286. */
  15287. dispose(camera?: Camera): void;
  15288. }
  15289. }
  15290. declare module BABYLON {
  15291. /** @hidden */
  15292. export var kernelBlurVaryingDeclaration: {
  15293. name: string;
  15294. shader: string;
  15295. };
  15296. }
  15297. declare module BABYLON {
  15298. /** @hidden */
  15299. export var kernelBlurFragment: {
  15300. name: string;
  15301. shader: string;
  15302. };
  15303. }
  15304. declare module BABYLON {
  15305. /** @hidden */
  15306. export var kernelBlurFragment2: {
  15307. name: string;
  15308. shader: string;
  15309. };
  15310. }
  15311. declare module BABYLON {
  15312. /** @hidden */
  15313. export var kernelBlurPixelShader: {
  15314. name: string;
  15315. shader: string;
  15316. };
  15317. }
  15318. declare module BABYLON {
  15319. /** @hidden */
  15320. export var kernelBlurVertex: {
  15321. name: string;
  15322. shader: string;
  15323. };
  15324. }
  15325. declare module BABYLON {
  15326. /** @hidden */
  15327. export var kernelBlurVertexShader: {
  15328. name: string;
  15329. shader: string;
  15330. };
  15331. }
  15332. declare module BABYLON {
  15333. /**
  15334. * The Blur Post Process which blurs an image based on a kernel and direction.
  15335. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15336. */
  15337. export class BlurPostProcess extends PostProcess {
  15338. /** The direction in which to blur the image. */
  15339. direction: Vector2;
  15340. private blockCompilation;
  15341. protected _kernel: number;
  15342. protected _idealKernel: number;
  15343. protected _packedFloat: boolean;
  15344. private _staticDefines;
  15345. /**
  15346. * Sets the length in pixels of the blur sample region
  15347. */
  15348. /**
  15349. * Gets the length in pixels of the blur sample region
  15350. */
  15351. kernel: number;
  15352. /**
  15353. * Sets wether or not the blur needs to unpack/repack floats
  15354. */
  15355. /**
  15356. * Gets wether or not the blur is unpacking/repacking floats
  15357. */
  15358. packedFloat: boolean;
  15359. /**
  15360. * Creates a new instance BlurPostProcess
  15361. * @param name The name of the effect.
  15362. * @param direction The direction in which to blur the image.
  15363. * @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.
  15364. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15365. * @param camera The camera to apply the render pass to.
  15366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15367. * @param engine The engine which the post process will be applied. (default: current engine)
  15368. * @param reusable If the post process can be reused on the same frame. (default: false)
  15369. * @param textureType Type of textures used when performing the post process. (default: 0)
  15370. * @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)
  15371. */
  15372. constructor(name: string,
  15373. /** The direction in which to blur the image. */
  15374. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15375. /**
  15376. * Updates the effect with the current post process compile time values and recompiles the shader.
  15377. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15378. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15379. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15380. * @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
  15381. * @param onCompiled Called when the shader has been compiled.
  15382. * @param onError Called if there is an error when compiling a shader.
  15383. */
  15384. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15385. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15386. /**
  15387. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15388. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15389. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15390. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15391. * The gaps between physical kernels are compensated for in the weighting of the samples
  15392. * @param idealKernel Ideal blur kernel.
  15393. * @return Nearest best kernel.
  15394. */
  15395. protected _nearestBestKernel(idealKernel: number): number;
  15396. /**
  15397. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15398. * @param x The point on the Gaussian distribution to sample.
  15399. * @return the value of the Gaussian function at x.
  15400. */
  15401. protected _gaussianWeight(x: number): number;
  15402. /**
  15403. * Generates a string that can be used as a floating point number in GLSL.
  15404. * @param x Value to print.
  15405. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15406. * @return GLSL float string.
  15407. */
  15408. protected _glslFloat(x: number, decimalFigures?: number): string;
  15409. }
  15410. }
  15411. declare module BABYLON {
  15412. /**
  15413. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15414. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15415. * You can then easily use it as a reflectionTexture on a flat surface.
  15416. * In case the surface is not a plane, please consider relying on reflection probes.
  15417. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15418. */
  15419. export class MirrorTexture extends RenderTargetTexture {
  15420. private scene;
  15421. /**
  15422. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15423. * 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.
  15424. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15425. */
  15426. mirrorPlane: Plane;
  15427. /**
  15428. * Define the blur ratio used to blur the reflection if needed.
  15429. */
  15430. blurRatio: number;
  15431. /**
  15432. * Define the adaptive blur kernel used to blur the reflection if needed.
  15433. * This will autocompute the closest best match for the `blurKernel`
  15434. */
  15435. adaptiveBlurKernel: number;
  15436. /**
  15437. * Define the blur kernel used to blur the reflection if needed.
  15438. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15439. */
  15440. blurKernel: number;
  15441. /**
  15442. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15443. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15444. */
  15445. blurKernelX: number;
  15446. /**
  15447. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15448. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15449. */
  15450. blurKernelY: number;
  15451. private _autoComputeBlurKernel;
  15452. protected _onRatioRescale(): void;
  15453. private _updateGammaSpace;
  15454. private _imageProcessingConfigChangeObserver;
  15455. private _transformMatrix;
  15456. private _mirrorMatrix;
  15457. private _savedViewMatrix;
  15458. private _blurX;
  15459. private _blurY;
  15460. private _adaptiveBlurKernel;
  15461. private _blurKernelX;
  15462. private _blurKernelY;
  15463. private _blurRatio;
  15464. /**
  15465. * Instantiates a Mirror Texture.
  15466. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15467. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15468. * You can then easily use it as a reflectionTexture on a flat surface.
  15469. * In case the surface is not a plane, please consider relying on reflection probes.
  15470. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15471. * @param name
  15472. * @param size
  15473. * @param scene
  15474. * @param generateMipMaps
  15475. * @param type
  15476. * @param samplingMode
  15477. * @param generateDepthBuffer
  15478. */
  15479. constructor(name: string, size: number | {
  15480. width: number;
  15481. height: number;
  15482. } | {
  15483. ratio: number;
  15484. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15485. private _preparePostProcesses;
  15486. /**
  15487. * Clone the mirror texture.
  15488. * @returns the cloned texture
  15489. */
  15490. clone(): MirrorTexture;
  15491. /**
  15492. * Serialize the texture to a JSON representation you could use in Parse later on
  15493. * @returns the serialized JSON representation
  15494. */
  15495. serialize(): any;
  15496. /**
  15497. * Dispose the texture and release its associated resources.
  15498. */
  15499. dispose(): void;
  15500. }
  15501. }
  15502. declare module BABYLON {
  15503. /**
  15504. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15505. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15506. */
  15507. export class Texture extends BaseTexture {
  15508. /**
  15509. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15510. */
  15511. static SerializeBuffers: boolean;
  15512. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15513. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15514. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15515. /** nearest is mag = nearest and min = nearest and mip = linear */
  15516. static readonly NEAREST_SAMPLINGMODE: number;
  15517. /** nearest is mag = nearest and min = nearest and mip = linear */
  15518. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15519. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15520. static readonly BILINEAR_SAMPLINGMODE: number;
  15521. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15522. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15523. /** Trilinear is mag = linear and min = linear and mip = linear */
  15524. static readonly TRILINEAR_SAMPLINGMODE: number;
  15525. /** Trilinear is mag = linear and min = linear and mip = linear */
  15526. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15527. /** mag = nearest and min = nearest and mip = nearest */
  15528. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15529. /** mag = nearest and min = linear and mip = nearest */
  15530. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15531. /** mag = nearest and min = linear and mip = linear */
  15532. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15533. /** mag = nearest and min = linear and mip = none */
  15534. static readonly NEAREST_LINEAR: number;
  15535. /** mag = nearest and min = nearest and mip = none */
  15536. static readonly NEAREST_NEAREST: number;
  15537. /** mag = linear and min = nearest and mip = nearest */
  15538. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15539. /** mag = linear and min = nearest and mip = linear */
  15540. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15541. /** mag = linear and min = linear and mip = none */
  15542. static readonly LINEAR_LINEAR: number;
  15543. /** mag = linear and min = nearest and mip = none */
  15544. static readonly LINEAR_NEAREST: number;
  15545. /** Explicit coordinates mode */
  15546. static readonly EXPLICIT_MODE: number;
  15547. /** Spherical coordinates mode */
  15548. static readonly SPHERICAL_MODE: number;
  15549. /** Planar coordinates mode */
  15550. static readonly PLANAR_MODE: number;
  15551. /** Cubic coordinates mode */
  15552. static readonly CUBIC_MODE: number;
  15553. /** Projection coordinates mode */
  15554. static readonly PROJECTION_MODE: number;
  15555. /** Inverse Cubic coordinates mode */
  15556. static readonly SKYBOX_MODE: number;
  15557. /** Inverse Cubic coordinates mode */
  15558. static readonly INVCUBIC_MODE: number;
  15559. /** Equirectangular coordinates mode */
  15560. static readonly EQUIRECTANGULAR_MODE: number;
  15561. /** Equirectangular Fixed coordinates mode */
  15562. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15563. /** Equirectangular Fixed Mirrored coordinates mode */
  15564. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15565. /** Texture is not repeating outside of 0..1 UVs */
  15566. static readonly CLAMP_ADDRESSMODE: number;
  15567. /** Texture is repeating outside of 0..1 UVs */
  15568. static readonly WRAP_ADDRESSMODE: number;
  15569. /** Texture is repeating and mirrored */
  15570. static readonly MIRROR_ADDRESSMODE: number;
  15571. /**
  15572. * 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
  15573. */
  15574. static UseSerializedUrlIfAny: boolean;
  15575. /**
  15576. * Define the url of the texture.
  15577. */
  15578. url: Nullable<string>;
  15579. /**
  15580. * Define an offset on the texture to offset the u coordinates of the UVs
  15581. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15582. */
  15583. uOffset: number;
  15584. /**
  15585. * Define an offset on the texture to offset the v coordinates of the UVs
  15586. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15587. */
  15588. vOffset: number;
  15589. /**
  15590. * Define an offset on the texture to scale the u coordinates of the UVs
  15591. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15592. */
  15593. uScale: number;
  15594. /**
  15595. * Define an offset on the texture to scale the v coordinates of the UVs
  15596. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15597. */
  15598. vScale: number;
  15599. /**
  15600. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15601. * @see http://doc.babylonjs.com/how_to/more_materials
  15602. */
  15603. uAng: number;
  15604. /**
  15605. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15606. * @see http://doc.babylonjs.com/how_to/more_materials
  15607. */
  15608. vAng: number;
  15609. /**
  15610. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15611. * @see http://doc.babylonjs.com/how_to/more_materials
  15612. */
  15613. wAng: number;
  15614. /**
  15615. * Defines the center of rotation (U)
  15616. */
  15617. uRotationCenter: number;
  15618. /**
  15619. * Defines the center of rotation (V)
  15620. */
  15621. vRotationCenter: number;
  15622. /**
  15623. * Defines the center of rotation (W)
  15624. */
  15625. wRotationCenter: number;
  15626. /**
  15627. * Are mip maps generated for this texture or not.
  15628. */
  15629. readonly noMipmap: boolean;
  15630. /**
  15631. * List of inspectable custom properties (used by the Inspector)
  15632. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15633. */
  15634. inspectableCustomProperties: Nullable<IInspectable[]>;
  15635. private _noMipmap;
  15636. /** @hidden */ private _invertY: boolean;
  15637. private _rowGenerationMatrix;
  15638. private _cachedTextureMatrix;
  15639. private _projectionModeMatrix;
  15640. private _t0;
  15641. private _t1;
  15642. private _t2;
  15643. private _cachedUOffset;
  15644. private _cachedVOffset;
  15645. private _cachedUScale;
  15646. private _cachedVScale;
  15647. private _cachedUAng;
  15648. private _cachedVAng;
  15649. private _cachedWAng;
  15650. private _cachedProjectionMatrixId;
  15651. private _cachedCoordinatesMode;
  15652. /** @hidden */
  15653. protected _initialSamplingMode: number;
  15654. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15655. private _deleteBuffer;
  15656. protected _format: Nullable<number>;
  15657. private _delayedOnLoad;
  15658. private _delayedOnError;
  15659. private _mimeType?;
  15660. /**
  15661. * Observable triggered once the texture has been loaded.
  15662. */
  15663. onLoadObservable: Observable<Texture>;
  15664. protected _isBlocking: boolean;
  15665. /**
  15666. * Is the texture preventing material to render while loading.
  15667. * If false, a default texture will be used instead of the loading one during the preparation step.
  15668. */
  15669. isBlocking: boolean;
  15670. /**
  15671. * Get the current sampling mode associated with the texture.
  15672. */
  15673. readonly samplingMode: number;
  15674. /**
  15675. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15676. */
  15677. readonly invertY: boolean;
  15678. /**
  15679. * Instantiates a new texture.
  15680. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15681. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15682. * @param url defines the url of the picture to load as a texture
  15683. * @param scene defines the scene or engine the texture will belong to
  15684. * @param noMipmap defines if the texture will require mip maps or not
  15685. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15686. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15687. * @param onLoad defines a callback triggered when the texture has been loaded
  15688. * @param onError defines a callback triggered when an error occurred during the loading session
  15689. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15690. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15691. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15692. * @param mimeType defines an optional mime type information
  15693. */
  15694. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  15695. /**
  15696. * Update the url (and optional buffer) of this texture if url was null during construction.
  15697. * @param url the url of the texture
  15698. * @param buffer the buffer of the texture (defaults to null)
  15699. * @param onLoad callback called when the texture is loaded (defaults to null)
  15700. */
  15701. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15702. /**
  15703. * Finish the loading sequence of a texture flagged as delayed load.
  15704. * @hidden
  15705. */
  15706. delayLoad(): void;
  15707. private _prepareRowForTextureGeneration;
  15708. /**
  15709. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15710. * @returns the transform matrix of the texture.
  15711. */
  15712. getTextureMatrix(): Matrix;
  15713. /**
  15714. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15715. * @returns The reflection texture transform
  15716. */
  15717. getReflectionTextureMatrix(): Matrix;
  15718. /**
  15719. * Clones the texture.
  15720. * @returns the cloned texture
  15721. */
  15722. clone(): Texture;
  15723. /**
  15724. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15725. * @returns The JSON representation of the texture
  15726. */
  15727. serialize(): any;
  15728. /**
  15729. * Get the current class name of the texture useful for serialization or dynamic coding.
  15730. * @returns "Texture"
  15731. */
  15732. getClassName(): string;
  15733. /**
  15734. * Dispose the texture and release its associated resources.
  15735. */
  15736. dispose(): void;
  15737. /**
  15738. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15739. * @param parsedTexture Define the JSON representation of the texture
  15740. * @param scene Define the scene the parsed texture should be instantiated in
  15741. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15742. * @returns The parsed texture if successful
  15743. */
  15744. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15745. /**
  15746. * Creates a texture from its base 64 representation.
  15747. * @param data Define the base64 payload without the data: prefix
  15748. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15749. * @param scene Define the scene the texture should belong to
  15750. * @param noMipmap Forces the texture to not create mip map information if true
  15751. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15752. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15753. * @param onLoad define a callback triggered when the texture has been loaded
  15754. * @param onError define a callback triggered when an error occurred during the loading session
  15755. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15756. * @returns the created texture
  15757. */
  15758. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15759. /**
  15760. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15761. * @param data Define the base64 payload without the data: prefix
  15762. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15763. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15764. * @param scene Define the scene the texture should belong to
  15765. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15766. * @param noMipmap Forces the texture to not create mip map information if true
  15767. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15768. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15769. * @param onLoad define a callback triggered when the texture has been loaded
  15770. * @param onError define a callback triggered when an error occurred during the loading session
  15771. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15772. * @returns the created texture
  15773. */
  15774. 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;
  15775. }
  15776. }
  15777. declare module BABYLON {
  15778. /**
  15779. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15780. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15781. */
  15782. export class PostProcessManager {
  15783. private _scene;
  15784. private _indexBuffer;
  15785. private _vertexBuffers;
  15786. /**
  15787. * Creates a new instance PostProcess
  15788. * @param scene The scene that the post process is associated with.
  15789. */
  15790. constructor(scene: Scene);
  15791. private _prepareBuffers;
  15792. private _buildIndexBuffer;
  15793. /**
  15794. * Rebuilds the vertex buffers of the manager.
  15795. * @hidden
  15796. */ private _rebuild(): void;
  15797. /**
  15798. * Prepares a frame to be run through a post process.
  15799. * @param sourceTexture The input texture to the post procesess. (default: null)
  15800. * @param postProcesses An array of post processes to be run. (default: null)
  15801. * @returns True if the post processes were able to be run.
  15802. * @hidden
  15803. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15804. /**
  15805. * Manually render a set of post processes to a texture.
  15806. * @param postProcesses An array of post processes to be run.
  15807. * @param targetTexture The target texture to render to.
  15808. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15809. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15810. * @param lodLevel defines which lod of the texture to render to
  15811. */
  15812. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15813. /**
  15814. * Finalize the result of the output of the postprocesses.
  15815. * @param doNotPresent If true the result will not be displayed to the screen.
  15816. * @param targetTexture The target texture to render to.
  15817. * @param faceIndex The index of the face to bind the target texture to.
  15818. * @param postProcesses The array of post processes to render.
  15819. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15820. * @hidden
  15821. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15822. /**
  15823. * Disposes of the post process manager.
  15824. */
  15825. dispose(): void;
  15826. }
  15827. }
  15828. declare module BABYLON {
  15829. /** Interface used by value gradients (color, factor, ...) */
  15830. export interface IValueGradient {
  15831. /**
  15832. * Gets or sets the gradient value (between 0 and 1)
  15833. */
  15834. gradient: number;
  15835. }
  15836. /** Class used to store color4 gradient */
  15837. export class ColorGradient implements IValueGradient {
  15838. /**
  15839. * Gets or sets the gradient value (between 0 and 1)
  15840. */
  15841. gradient: number;
  15842. /**
  15843. * Gets or sets first associated color
  15844. */
  15845. color1: Color4;
  15846. /**
  15847. * Gets or sets second associated color
  15848. */
  15849. color2?: Color4;
  15850. /**
  15851. * Will get a color picked randomly between color1 and color2.
  15852. * If color2 is undefined then color1 will be used
  15853. * @param result defines the target Color4 to store the result in
  15854. */
  15855. getColorToRef(result: Color4): void;
  15856. }
  15857. /** Class used to store color 3 gradient */
  15858. export class Color3Gradient implements IValueGradient {
  15859. /**
  15860. * Gets or sets the gradient value (between 0 and 1)
  15861. */
  15862. gradient: number;
  15863. /**
  15864. * Gets or sets the associated color
  15865. */
  15866. color: Color3;
  15867. }
  15868. /** Class used to store factor gradient */
  15869. export class FactorGradient implements IValueGradient {
  15870. /**
  15871. * Gets or sets the gradient value (between 0 and 1)
  15872. */
  15873. gradient: number;
  15874. /**
  15875. * Gets or sets first associated factor
  15876. */
  15877. factor1: number;
  15878. /**
  15879. * Gets or sets second associated factor
  15880. */
  15881. factor2?: number;
  15882. /**
  15883. * Will get a number picked randomly between factor1 and factor2.
  15884. * If factor2 is undefined then factor1 will be used
  15885. * @returns the picked number
  15886. */
  15887. getFactor(): number;
  15888. }
  15889. /**
  15890. * Helper used to simplify some generic gradient tasks
  15891. */
  15892. export class GradientHelper {
  15893. /**
  15894. * Gets the current gradient from an array of IValueGradient
  15895. * @param ratio defines the current ratio to get
  15896. * @param gradients defines the array of IValueGradient
  15897. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15898. */
  15899. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15900. }
  15901. }
  15902. declare module BABYLON {
  15903. interface ThinEngine {
  15904. /**
  15905. * Creates a dynamic texture
  15906. * @param width defines the width of the texture
  15907. * @param height defines the height of the texture
  15908. * @param generateMipMaps defines if the engine should generate the mip levels
  15909. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  15910. * @returns the dynamic texture inside an InternalTexture
  15911. */
  15912. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  15913. /**
  15914. * Update the content of a dynamic texture
  15915. * @param texture defines the texture to update
  15916. * @param canvas defines the canvas containing the source
  15917. * @param invertY defines if data must be stored with Y axis inverted
  15918. * @param premulAlpha defines if alpha is stored as premultiplied
  15919. * @param format defines the format of the data
  15920. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  15921. */
  15922. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  15923. }
  15924. }
  15925. declare module BABYLON {
  15926. /**
  15927. * Helper class used to generate a canvas to manipulate images
  15928. */
  15929. export class CanvasGenerator {
  15930. /**
  15931. * Create a new canvas (or offscreen canvas depending on the context)
  15932. * @param width defines the expected width
  15933. * @param height defines the expected height
  15934. * @return a new canvas or offscreen canvas
  15935. */
  15936. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  15937. }
  15938. }
  15939. declare module BABYLON {
  15940. /**
  15941. * A class extending Texture allowing drawing on a texture
  15942. * @see http://doc.babylonjs.com/how_to/dynamictexture
  15943. */
  15944. export class DynamicTexture extends Texture {
  15945. private _generateMipMaps;
  15946. private _canvas;
  15947. private _context;
  15948. private _engine;
  15949. /**
  15950. * Creates a DynamicTexture
  15951. * @param name defines the name of the texture
  15952. * @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
  15953. * @param scene defines the scene where you want the texture
  15954. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  15955. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  15956. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  15957. */
  15958. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  15959. /**
  15960. * Get the current class name of the texture useful for serialization or dynamic coding.
  15961. * @returns "DynamicTexture"
  15962. */
  15963. getClassName(): string;
  15964. /**
  15965. * Gets the current state of canRescale
  15966. */
  15967. readonly canRescale: boolean;
  15968. private _recreate;
  15969. /**
  15970. * Scales the texture
  15971. * @param ratio the scale factor to apply to both width and height
  15972. */
  15973. scale(ratio: number): void;
  15974. /**
  15975. * Resizes the texture
  15976. * @param width the new width
  15977. * @param height the new height
  15978. */
  15979. scaleTo(width: number, height: number): void;
  15980. /**
  15981. * Gets the context of the canvas used by the texture
  15982. * @returns the canvas context of the dynamic texture
  15983. */
  15984. getContext(): CanvasRenderingContext2D;
  15985. /**
  15986. * Clears the texture
  15987. */
  15988. clear(): void;
  15989. /**
  15990. * Updates the texture
  15991. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15992. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  15993. */
  15994. update(invertY?: boolean, premulAlpha?: boolean): void;
  15995. /**
  15996. * Draws text onto the texture
  15997. * @param text defines the text to be drawn
  15998. * @param x defines the placement of the text from the left
  15999. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16000. * @param font defines the font to be used with font-style, font-size, font-name
  16001. * @param color defines the color used for the text
  16002. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16003. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16004. * @param update defines whether texture is immediately update (default is true)
  16005. */
  16006. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16007. /**
  16008. * Clones the texture
  16009. * @returns the clone of the texture.
  16010. */
  16011. clone(): DynamicTexture;
  16012. /**
  16013. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16014. * @returns a serialized dynamic texture object
  16015. */
  16016. serialize(): any;
  16017. /** @hidden */ private _rebuild(): void;
  16018. }
  16019. }
  16020. declare module BABYLON {
  16021. interface AbstractScene {
  16022. /**
  16023. * The list of procedural textures added to the scene
  16024. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16025. */
  16026. proceduralTextures: Array<ProceduralTexture>;
  16027. }
  16028. /**
  16029. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16030. * in a given scene.
  16031. */
  16032. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16033. /**
  16034. * The component name helpfull to identify the component in the list of scene components.
  16035. */
  16036. readonly name: string;
  16037. /**
  16038. * The scene the component belongs to.
  16039. */
  16040. scene: Scene;
  16041. /**
  16042. * Creates a new instance of the component for the given scene
  16043. * @param scene Defines the scene to register the component in
  16044. */
  16045. constructor(scene: Scene);
  16046. /**
  16047. * Registers the component in a given scene
  16048. */
  16049. register(): void;
  16050. /**
  16051. * Rebuilds the elements related to this component in case of
  16052. * context lost for instance.
  16053. */
  16054. rebuild(): void;
  16055. /**
  16056. * Disposes the component and the associated ressources.
  16057. */
  16058. dispose(): void;
  16059. private _beforeClear;
  16060. }
  16061. }
  16062. declare module BABYLON {
  16063. interface ThinEngine {
  16064. /**
  16065. * Creates a new render target cube texture
  16066. * @param size defines the size of the texture
  16067. * @param options defines the options used to create the texture
  16068. * @returns a new render target cube texture stored in an InternalTexture
  16069. */
  16070. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16071. }
  16072. }
  16073. declare module BABYLON {
  16074. /** @hidden */
  16075. export var proceduralVertexShader: {
  16076. name: string;
  16077. shader: string;
  16078. };
  16079. }
  16080. declare module BABYLON {
  16081. /**
  16082. * 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.
  16083. * This is the base class of any Procedural texture and contains most of the shareable code.
  16084. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16085. */
  16086. export class ProceduralTexture extends Texture {
  16087. isCube: boolean;
  16088. /**
  16089. * Define if the texture is enabled or not (disabled texture will not render)
  16090. */
  16091. isEnabled: boolean;
  16092. /**
  16093. * Define if the texture must be cleared before rendering (default is true)
  16094. */
  16095. autoClear: boolean;
  16096. /**
  16097. * Callback called when the texture is generated
  16098. */
  16099. onGenerated: () => void;
  16100. /**
  16101. * Event raised when the texture is generated
  16102. */
  16103. onGeneratedObservable: Observable<ProceduralTexture>;
  16104. /** @hidden */ private _generateMipMaps: boolean;
  16105. /** @hidden **/ private _effect: Effect;
  16106. /** @hidden */ private _textures: {
  16107. [key: string]: Texture;
  16108. };
  16109. private _size;
  16110. private _currentRefreshId;
  16111. private _refreshRate;
  16112. private _vertexBuffers;
  16113. private _indexBuffer;
  16114. private _uniforms;
  16115. private _samplers;
  16116. private _fragment;
  16117. private _floats;
  16118. private _ints;
  16119. private _floatsArrays;
  16120. private _colors3;
  16121. private _colors4;
  16122. private _vectors2;
  16123. private _vectors3;
  16124. private _matrices;
  16125. private _fallbackTexture;
  16126. private _fallbackTextureUsed;
  16127. private _engine;
  16128. private _cachedDefines;
  16129. private _contentUpdateId;
  16130. private _contentData;
  16131. /**
  16132. * Instantiates a new procedural texture.
  16133. * 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.
  16134. * This is the base class of any Procedural texture and contains most of the shareable code.
  16135. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16136. * @param name Define the name of the texture
  16137. * @param size Define the size of the texture to create
  16138. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16139. * @param scene Define the scene the texture belongs to
  16140. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16141. * @param generateMipMaps Define if the texture should creates mip maps or not
  16142. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16143. */
  16144. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16145. /**
  16146. * The effect that is created when initializing the post process.
  16147. * @returns The created effect corresponding the the postprocess.
  16148. */
  16149. getEffect(): Effect;
  16150. /**
  16151. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16152. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16153. */
  16154. getContent(): Nullable<ArrayBufferView>;
  16155. private _createIndexBuffer;
  16156. /** @hidden */ private _rebuild(): void;
  16157. /**
  16158. * Resets the texture in order to recreate its associated resources.
  16159. * This can be called in case of context loss
  16160. */
  16161. reset(): void;
  16162. protected _getDefines(): string;
  16163. /**
  16164. * Is the texture ready to be used ? (rendered at least once)
  16165. * @returns true if ready, otherwise, false.
  16166. */
  16167. isReady(): boolean;
  16168. /**
  16169. * Resets the refresh counter of the texture and start bak from scratch.
  16170. * Could be useful to regenerate the texture if it is setup to render only once.
  16171. */
  16172. resetRefreshCounter(): void;
  16173. /**
  16174. * Set the fragment shader to use in order to render the texture.
  16175. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16176. */
  16177. setFragment(fragment: any): void;
  16178. /**
  16179. * Define the refresh rate of the texture or the rendering frequency.
  16180. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16181. */
  16182. refreshRate: number;
  16183. /** @hidden */ private _shouldRender(): boolean;
  16184. /**
  16185. * Get the size the texture is rendering at.
  16186. * @returns the size (texture is always squared)
  16187. */
  16188. getRenderSize(): number;
  16189. /**
  16190. * Resize the texture to new value.
  16191. * @param size Define the new size the texture should have
  16192. * @param generateMipMaps Define whether the new texture should create mip maps
  16193. */
  16194. resize(size: number, generateMipMaps: boolean): void;
  16195. private _checkUniform;
  16196. /**
  16197. * Set a texture in the shader program used to render.
  16198. * @param name Define the name of the uniform samplers as defined in the shader
  16199. * @param texture Define the texture to bind to this sampler
  16200. * @return the texture itself allowing "fluent" like uniform updates
  16201. */
  16202. setTexture(name: string, texture: Texture): ProceduralTexture;
  16203. /**
  16204. * Set a float in the shader.
  16205. * @param name Define the name of the uniform as defined in the shader
  16206. * @param value Define the value to give to the uniform
  16207. * @return the texture itself allowing "fluent" like uniform updates
  16208. */
  16209. setFloat(name: string, value: number): ProceduralTexture;
  16210. /**
  16211. * Set a int in the shader.
  16212. * @param name Define the name of the uniform as defined in the shader
  16213. * @param value Define the value to give to the uniform
  16214. * @return the texture itself allowing "fluent" like uniform updates
  16215. */
  16216. setInt(name: string, value: number): ProceduralTexture;
  16217. /**
  16218. * Set an array of floats in the shader.
  16219. * @param name Define the name of the uniform as defined in the shader
  16220. * @param value Define the value to give to the uniform
  16221. * @return the texture itself allowing "fluent" like uniform updates
  16222. */
  16223. setFloats(name: string, value: number[]): ProceduralTexture;
  16224. /**
  16225. * Set a vec3 in the shader from a Color3.
  16226. * @param name Define the name of the uniform as defined in the shader
  16227. * @param value Define the value to give to the uniform
  16228. * @return the texture itself allowing "fluent" like uniform updates
  16229. */
  16230. setColor3(name: string, value: Color3): ProceduralTexture;
  16231. /**
  16232. * Set a vec4 in the shader from a Color4.
  16233. * @param name Define the name of the uniform as defined in the shader
  16234. * @param value Define the value to give to the uniform
  16235. * @return the texture itself allowing "fluent" like uniform updates
  16236. */
  16237. setColor4(name: string, value: Color4): ProceduralTexture;
  16238. /**
  16239. * Set a vec2 in the shader from a Vector2.
  16240. * @param name Define the name of the uniform as defined in the shader
  16241. * @param value Define the value to give to the uniform
  16242. * @return the texture itself allowing "fluent" like uniform updates
  16243. */
  16244. setVector2(name: string, value: Vector2): ProceduralTexture;
  16245. /**
  16246. * Set a vec3 in the shader from a Vector3.
  16247. * @param name Define the name of the uniform as defined in the shader
  16248. * @param value Define the value to give to the uniform
  16249. * @return the texture itself allowing "fluent" like uniform updates
  16250. */
  16251. setVector3(name: string, value: Vector3): ProceduralTexture;
  16252. /**
  16253. * Set a mat4 in the shader from a MAtrix.
  16254. * @param name Define the name of the uniform as defined in the shader
  16255. * @param value Define the value to give to the uniform
  16256. * @return the texture itself allowing "fluent" like uniform updates
  16257. */
  16258. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16259. /**
  16260. * Render the texture to its associated render target.
  16261. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16262. */
  16263. render(useCameraPostProcess?: boolean): void;
  16264. /**
  16265. * Clone the texture.
  16266. * @returns the cloned texture
  16267. */
  16268. clone(): ProceduralTexture;
  16269. /**
  16270. * Dispose the texture and release its asoociated resources.
  16271. */
  16272. dispose(): void;
  16273. }
  16274. }
  16275. declare module BABYLON {
  16276. /**
  16277. * This represents the base class for particle system in Babylon.
  16278. * 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.
  16279. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16280. * @example https://doc.babylonjs.com/babylon101/particles
  16281. */
  16282. export class BaseParticleSystem {
  16283. /**
  16284. * Source color is added to the destination color without alpha affecting the result
  16285. */
  16286. static BLENDMODE_ONEONE: number;
  16287. /**
  16288. * Blend current color and particle color using particle’s alpha
  16289. */
  16290. static BLENDMODE_STANDARD: number;
  16291. /**
  16292. * Add current color and particle color multiplied by particle’s alpha
  16293. */
  16294. static BLENDMODE_ADD: number;
  16295. /**
  16296. * Multiply current color with particle color
  16297. */
  16298. static BLENDMODE_MULTIPLY: number;
  16299. /**
  16300. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16301. */
  16302. static BLENDMODE_MULTIPLYADD: number;
  16303. /**
  16304. * List of animations used by the particle system.
  16305. */
  16306. animations: Animation[];
  16307. /**
  16308. * The id of the Particle system.
  16309. */
  16310. id: string;
  16311. /**
  16312. * The friendly name of the Particle system.
  16313. */
  16314. name: string;
  16315. /**
  16316. * The rendering group used by the Particle system to chose when to render.
  16317. */
  16318. renderingGroupId: number;
  16319. /**
  16320. * The emitter represents the Mesh or position we are attaching the particle system to.
  16321. */
  16322. emitter: Nullable<AbstractMesh | Vector3>;
  16323. /**
  16324. * The maximum number of particles to emit per frame
  16325. */
  16326. emitRate: number;
  16327. /**
  16328. * If you want to launch only a few particles at once, that can be done, as well.
  16329. */
  16330. manualEmitCount: number;
  16331. /**
  16332. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16333. */
  16334. updateSpeed: number;
  16335. /**
  16336. * The amount of time the particle system is running (depends of the overall update speed).
  16337. */
  16338. targetStopDuration: number;
  16339. /**
  16340. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16341. */
  16342. disposeOnStop: boolean;
  16343. /**
  16344. * Minimum power of emitting particles.
  16345. */
  16346. minEmitPower: number;
  16347. /**
  16348. * Maximum power of emitting particles.
  16349. */
  16350. maxEmitPower: number;
  16351. /**
  16352. * Minimum life time of emitting particles.
  16353. */
  16354. minLifeTime: number;
  16355. /**
  16356. * Maximum life time of emitting particles.
  16357. */
  16358. maxLifeTime: number;
  16359. /**
  16360. * Minimum Size of emitting particles.
  16361. */
  16362. minSize: number;
  16363. /**
  16364. * Maximum Size of emitting particles.
  16365. */
  16366. maxSize: number;
  16367. /**
  16368. * Minimum scale of emitting particles on X axis.
  16369. */
  16370. minScaleX: number;
  16371. /**
  16372. * Maximum scale of emitting particles on X axis.
  16373. */
  16374. maxScaleX: number;
  16375. /**
  16376. * Minimum scale of emitting particles on Y axis.
  16377. */
  16378. minScaleY: number;
  16379. /**
  16380. * Maximum scale of emitting particles on Y axis.
  16381. */
  16382. maxScaleY: number;
  16383. /**
  16384. * Gets or sets the minimal initial rotation in radians.
  16385. */
  16386. minInitialRotation: number;
  16387. /**
  16388. * Gets or sets the maximal initial rotation in radians.
  16389. */
  16390. maxInitialRotation: number;
  16391. /**
  16392. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16393. */
  16394. minAngularSpeed: number;
  16395. /**
  16396. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16397. */
  16398. maxAngularSpeed: number;
  16399. /**
  16400. * The texture used to render each particle. (this can be a spritesheet)
  16401. */
  16402. particleTexture: Nullable<Texture>;
  16403. /**
  16404. * The layer mask we are rendering the particles through.
  16405. */
  16406. layerMask: number;
  16407. /**
  16408. * This can help using your own shader to render the particle system.
  16409. * The according effect will be created
  16410. */
  16411. customShader: any;
  16412. /**
  16413. * By default particle system starts as soon as they are created. This prevents the
  16414. * automatic start to happen and let you decide when to start emitting particles.
  16415. */
  16416. preventAutoStart: boolean;
  16417. private _noiseTexture;
  16418. /**
  16419. * Gets or sets a texture used to add random noise to particle positions
  16420. */
  16421. noiseTexture: Nullable<ProceduralTexture>;
  16422. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16423. noiseStrength: Vector3;
  16424. /**
  16425. * Callback triggered when the particle animation is ending.
  16426. */
  16427. onAnimationEnd: Nullable<() => void>;
  16428. /**
  16429. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16430. */
  16431. blendMode: number;
  16432. /**
  16433. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16434. * to override the particles.
  16435. */
  16436. forceDepthWrite: boolean;
  16437. /** 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 */
  16438. preWarmCycles: number;
  16439. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16440. preWarmStepOffset: number;
  16441. /**
  16442. * 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)
  16443. */
  16444. spriteCellChangeSpeed: number;
  16445. /**
  16446. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16447. */
  16448. startSpriteCellID: number;
  16449. /**
  16450. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16451. */
  16452. endSpriteCellID: number;
  16453. /**
  16454. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16455. */
  16456. spriteCellWidth: number;
  16457. /**
  16458. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16459. */
  16460. spriteCellHeight: number;
  16461. /**
  16462. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16463. */
  16464. spriteRandomStartCell: boolean;
  16465. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16466. translationPivot: Vector2;
  16467. /** @hidden */
  16468. protected _isAnimationSheetEnabled: boolean;
  16469. /**
  16470. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16471. */
  16472. beginAnimationOnStart: boolean;
  16473. /**
  16474. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16475. */
  16476. beginAnimationFrom: number;
  16477. /**
  16478. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16479. */
  16480. beginAnimationTo: number;
  16481. /**
  16482. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16483. */
  16484. beginAnimationLoop: boolean;
  16485. /**
  16486. * Gets or sets a world offset applied to all particles
  16487. */
  16488. worldOffset: Vector3;
  16489. /**
  16490. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16491. */
  16492. isAnimationSheetEnabled: boolean;
  16493. /**
  16494. * Get hosting scene
  16495. * @returns the scene
  16496. */
  16497. getScene(): Scene;
  16498. /**
  16499. * You can use gravity if you want to give an orientation to your particles.
  16500. */
  16501. gravity: Vector3;
  16502. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16503. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16504. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16505. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16506. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16507. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16508. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16509. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16510. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16511. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16512. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16513. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16514. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16515. /**
  16516. * Defines the delay in milliseconds before starting the system (0 by default)
  16517. */
  16518. startDelay: number;
  16519. /**
  16520. * Gets the current list of drag gradients.
  16521. * You must use addDragGradient and removeDragGradient to udpate this list
  16522. * @returns the list of drag gradients
  16523. */
  16524. getDragGradients(): Nullable<Array<FactorGradient>>;
  16525. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16526. limitVelocityDamping: number;
  16527. /**
  16528. * Gets the current list of limit velocity gradients.
  16529. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16530. * @returns the list of limit velocity gradients
  16531. */
  16532. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16533. /**
  16534. * Gets the current list of color gradients.
  16535. * You must use addColorGradient and removeColorGradient to udpate this list
  16536. * @returns the list of color gradients
  16537. */
  16538. getColorGradients(): Nullable<Array<ColorGradient>>;
  16539. /**
  16540. * Gets the current list of size gradients.
  16541. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16542. * @returns the list of size gradients
  16543. */
  16544. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16545. /**
  16546. * Gets the current list of color remap gradients.
  16547. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16548. * @returns the list of color remap gradients
  16549. */
  16550. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16551. /**
  16552. * Gets the current list of alpha remap gradients.
  16553. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16554. * @returns the list of alpha remap gradients
  16555. */
  16556. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16557. /**
  16558. * Gets the current list of life time gradients.
  16559. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16560. * @returns the list of life time gradients
  16561. */
  16562. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16563. /**
  16564. * Gets the current list of angular speed gradients.
  16565. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16566. * @returns the list of angular speed gradients
  16567. */
  16568. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16569. /**
  16570. * Gets the current list of velocity gradients.
  16571. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16572. * @returns the list of velocity gradients
  16573. */
  16574. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16575. /**
  16576. * Gets the current list of start size gradients.
  16577. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16578. * @returns the list of start size gradients
  16579. */
  16580. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16581. /**
  16582. * Gets the current list of emit rate gradients.
  16583. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16584. * @returns the list of emit rate gradients
  16585. */
  16586. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16587. /**
  16588. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16589. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16590. */
  16591. direction1: Vector3;
  16592. /**
  16593. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16594. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16595. */
  16596. direction2: Vector3;
  16597. /**
  16598. * 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.
  16599. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16600. */
  16601. minEmitBox: Vector3;
  16602. /**
  16603. * 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.
  16604. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16605. */
  16606. maxEmitBox: Vector3;
  16607. /**
  16608. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16609. */
  16610. color1: Color4;
  16611. /**
  16612. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16613. */
  16614. color2: Color4;
  16615. /**
  16616. * Color the particle will have at the end of its lifetime
  16617. */
  16618. colorDead: Color4;
  16619. /**
  16620. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16621. */
  16622. textureMask: Color4;
  16623. /**
  16624. * The particle emitter type defines the emitter used by the particle system.
  16625. * It can be for example box, sphere, or cone...
  16626. */
  16627. particleEmitterType: IParticleEmitterType;
  16628. /** @hidden */ private _isSubEmitter: boolean;
  16629. /**
  16630. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16631. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16632. */
  16633. billboardMode: number;
  16634. protected _isBillboardBased: boolean;
  16635. /**
  16636. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16637. */
  16638. isBillboardBased: boolean;
  16639. /**
  16640. * The scene the particle system belongs to.
  16641. */
  16642. protected _scene: Scene;
  16643. /**
  16644. * Local cache of defines for image processing.
  16645. */
  16646. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16647. /**
  16648. * Default configuration related to image processing available in the standard Material.
  16649. */
  16650. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16651. /**
  16652. * Gets the image processing configuration used either in this material.
  16653. */
  16654. /**
  16655. * Sets the Default image processing configuration used either in the this material.
  16656. *
  16657. * If sets to null, the scene one is in use.
  16658. */
  16659. imageProcessingConfiguration: ImageProcessingConfiguration;
  16660. /**
  16661. * Attaches a new image processing configuration to the Standard Material.
  16662. * @param configuration
  16663. */
  16664. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16665. /** @hidden */
  16666. protected _reset(): void;
  16667. /** @hidden */
  16668. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16669. /**
  16670. * Instantiates a particle system.
  16671. * 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.
  16672. * @param name The name of the particle system
  16673. */
  16674. constructor(name: string);
  16675. /**
  16676. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16677. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16678. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16679. * @returns the emitter
  16680. */
  16681. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16682. /**
  16683. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16684. * @param radius The radius of the hemisphere to emit from
  16685. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16686. * @returns the emitter
  16687. */
  16688. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16689. /**
  16690. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16691. * @param radius The radius of the sphere to emit from
  16692. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16693. * @returns the emitter
  16694. */
  16695. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16696. /**
  16697. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16698. * @param radius The radius of the sphere to emit from
  16699. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16700. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16701. * @returns the emitter
  16702. */
  16703. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16704. /**
  16705. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16706. * @param radius The radius of the emission cylinder
  16707. * @param height The height of the emission cylinder
  16708. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16709. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16710. * @returns the emitter
  16711. */
  16712. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16713. /**
  16714. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16715. * @param radius The radius of the cylinder to emit from
  16716. * @param height The height of the emission cylinder
  16717. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16718. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16719. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16720. * @returns the emitter
  16721. */
  16722. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16723. /**
  16724. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16725. * @param radius The radius of the cone to emit from
  16726. * @param angle The base angle of the cone
  16727. * @returns the emitter
  16728. */
  16729. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16730. /**
  16731. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16732. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16733. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16734. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16735. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16736. * @returns the emitter
  16737. */
  16738. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16739. }
  16740. }
  16741. declare module BABYLON {
  16742. /**
  16743. * Type of sub emitter
  16744. */
  16745. export enum SubEmitterType {
  16746. /**
  16747. * Attached to the particle over it's lifetime
  16748. */
  16749. ATTACHED = 0,
  16750. /**
  16751. * Created when the particle dies
  16752. */
  16753. END = 1
  16754. }
  16755. /**
  16756. * Sub emitter class used to emit particles from an existing particle
  16757. */
  16758. export class SubEmitter {
  16759. /**
  16760. * the particle system to be used by the sub emitter
  16761. */
  16762. particleSystem: ParticleSystem;
  16763. /**
  16764. * Type of the submitter (Default: END)
  16765. */
  16766. type: SubEmitterType;
  16767. /**
  16768. * 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)
  16769. * Note: This only is supported when using an emitter of type Mesh
  16770. */
  16771. inheritDirection: boolean;
  16772. /**
  16773. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16774. */
  16775. inheritedVelocityAmount: number;
  16776. /**
  16777. * Creates a sub emitter
  16778. * @param particleSystem the particle system to be used by the sub emitter
  16779. */
  16780. constructor(
  16781. /**
  16782. * the particle system to be used by the sub emitter
  16783. */
  16784. particleSystem: ParticleSystem);
  16785. /**
  16786. * Clones the sub emitter
  16787. * @returns the cloned sub emitter
  16788. */
  16789. clone(): SubEmitter;
  16790. /**
  16791. * Serialize current object to a JSON object
  16792. * @returns the serialized object
  16793. */
  16794. serialize(): any;
  16795. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16796. /**
  16797. * Creates a new SubEmitter from a serialized JSON version
  16798. * @param serializationObject defines the JSON object to read from
  16799. * @param scene defines the hosting scene
  16800. * @param rootUrl defines the rootUrl for data loading
  16801. * @returns a new SubEmitter
  16802. */
  16803. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16804. /** Release associated resources */
  16805. dispose(): void;
  16806. }
  16807. }
  16808. declare module BABYLON {
  16809. /** @hidden */
  16810. export var clipPlaneFragmentDeclaration: {
  16811. name: string;
  16812. shader: string;
  16813. };
  16814. }
  16815. declare module BABYLON {
  16816. /** @hidden */
  16817. export var imageProcessingDeclaration: {
  16818. name: string;
  16819. shader: string;
  16820. };
  16821. }
  16822. declare module BABYLON {
  16823. /** @hidden */
  16824. export var imageProcessingFunctions: {
  16825. name: string;
  16826. shader: string;
  16827. };
  16828. }
  16829. declare module BABYLON {
  16830. /** @hidden */
  16831. export var clipPlaneFragment: {
  16832. name: string;
  16833. shader: string;
  16834. };
  16835. }
  16836. declare module BABYLON {
  16837. /** @hidden */
  16838. export var particlesPixelShader: {
  16839. name: string;
  16840. shader: string;
  16841. };
  16842. }
  16843. declare module BABYLON {
  16844. /** @hidden */
  16845. export var clipPlaneVertexDeclaration: {
  16846. name: string;
  16847. shader: string;
  16848. };
  16849. }
  16850. declare module BABYLON {
  16851. /** @hidden */
  16852. export var clipPlaneVertex: {
  16853. name: string;
  16854. shader: string;
  16855. };
  16856. }
  16857. declare module BABYLON {
  16858. /** @hidden */
  16859. export var particlesVertexShader: {
  16860. name: string;
  16861. shader: string;
  16862. };
  16863. }
  16864. declare module BABYLON {
  16865. /**
  16866. * This represents a particle system in Babylon.
  16867. * 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.
  16868. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16869. * @example https://doc.babylonjs.com/babylon101/particles
  16870. */
  16871. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16872. /**
  16873. * Billboard mode will only apply to Y axis
  16874. */
  16875. static readonly BILLBOARDMODE_Y: number;
  16876. /**
  16877. * Billboard mode will apply to all axes
  16878. */
  16879. static readonly BILLBOARDMODE_ALL: number;
  16880. /**
  16881. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16882. */
  16883. static readonly BILLBOARDMODE_STRETCHED: number;
  16884. /**
  16885. * This function can be defined to provide custom update for active particles.
  16886. * This function will be called instead of regular update (age, position, color, etc.).
  16887. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16888. */
  16889. updateFunction: (particles: Particle[]) => void;
  16890. private _emitterWorldMatrix;
  16891. /**
  16892. * This function can be defined to specify initial direction for every new particle.
  16893. * It by default use the emitterType defined function
  16894. */
  16895. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16896. /**
  16897. * This function can be defined to specify initial position for every new particle.
  16898. * It by default use the emitterType defined function
  16899. */
  16900. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16901. /**
  16902. * @hidden
  16903. */ private _inheritedVelocityOffset: Vector3;
  16904. /**
  16905. * An event triggered when the system is disposed
  16906. */
  16907. onDisposeObservable: Observable<ParticleSystem>;
  16908. private _onDisposeObserver;
  16909. /**
  16910. * Sets a callback that will be triggered when the system is disposed
  16911. */
  16912. onDispose: () => void;
  16913. private _particles;
  16914. private _epsilon;
  16915. private _capacity;
  16916. private _stockParticles;
  16917. private _newPartsExcess;
  16918. private _vertexData;
  16919. private _vertexBuffer;
  16920. private _vertexBuffers;
  16921. private _spriteBuffer;
  16922. private _indexBuffer;
  16923. private _effect;
  16924. private _customEffect;
  16925. private _cachedDefines;
  16926. private _scaledColorStep;
  16927. private _colorDiff;
  16928. private _scaledDirection;
  16929. private _scaledGravity;
  16930. private _currentRenderId;
  16931. private _alive;
  16932. private _useInstancing;
  16933. private _started;
  16934. private _stopped;
  16935. private _actualFrame;
  16936. private _scaledUpdateSpeed;
  16937. private _vertexBufferSize;
  16938. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16939. /** @hidden */ private _currentEmitRate1: number;
  16940. /** @hidden */ private _currentEmitRate2: number;
  16941. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16942. /** @hidden */ private _currentStartSize1: number;
  16943. /** @hidden */ private _currentStartSize2: number;
  16944. private readonly _rawTextureWidth;
  16945. private _rampGradientsTexture;
  16946. private _useRampGradients;
  16947. /** Gets or sets a boolean indicating that ramp gradients must be used
  16948. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16949. */
  16950. useRampGradients: boolean;
  16951. /**
  16952. * 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.
  16953. * 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: [])
  16954. */
  16955. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16956. private _subEmitters;
  16957. /**
  16958. * @hidden
  16959. * If the particle systems emitter should be disposed when the particle system is disposed
  16960. */ private _disposeEmitterOnDispose: boolean;
  16961. /**
  16962. * The current active Sub-systems, this property is used by the root particle system only.
  16963. */
  16964. activeSubSystems: Array<ParticleSystem>;
  16965. private _rootParticleSystem;
  16966. /**
  16967. * Gets the current list of active particles
  16968. */
  16969. readonly particles: Particle[];
  16970. /**
  16971. * Returns the string "ParticleSystem"
  16972. * @returns a string containing the class name
  16973. */
  16974. getClassName(): string;
  16975. /**
  16976. * Instantiates a particle system.
  16977. * 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.
  16978. * @param name The name of the particle system
  16979. * @param capacity The max number of particles alive at the same time
  16980. * @param scene The scene the particle system belongs to
  16981. * @param customEffect a custom effect used to change the way particles are rendered by default
  16982. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16983. * @param epsilon Offset used to render the particles
  16984. */
  16985. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16986. private _addFactorGradient;
  16987. private _removeFactorGradient;
  16988. /**
  16989. * Adds a new life time gradient
  16990. * @param gradient defines the gradient to use (between 0 and 1)
  16991. * @param factor defines the life time factor to affect to the specified gradient
  16992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16993. * @returns the current particle system
  16994. */
  16995. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16996. /**
  16997. * Remove a specific life time gradient
  16998. * @param gradient defines the gradient to remove
  16999. * @returns the current particle system
  17000. */
  17001. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17002. /**
  17003. * Adds a new size gradient
  17004. * @param gradient defines the gradient to use (between 0 and 1)
  17005. * @param factor defines the size factor to affect to the specified gradient
  17006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17007. * @returns the current particle system
  17008. */
  17009. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17010. /**
  17011. * Remove a specific size gradient
  17012. * @param gradient defines the gradient to remove
  17013. * @returns the current particle system
  17014. */
  17015. removeSizeGradient(gradient: number): IParticleSystem;
  17016. /**
  17017. * Adds a new color remap gradient
  17018. * @param gradient defines the gradient to use (between 0 and 1)
  17019. * @param min defines the color remap minimal range
  17020. * @param max defines the color remap maximal range
  17021. * @returns the current particle system
  17022. */
  17023. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17024. /**
  17025. * Remove a specific color remap gradient
  17026. * @param gradient defines the gradient to remove
  17027. * @returns the current particle system
  17028. */
  17029. removeColorRemapGradient(gradient: number): IParticleSystem;
  17030. /**
  17031. * Adds a new alpha remap gradient
  17032. * @param gradient defines the gradient to use (between 0 and 1)
  17033. * @param min defines the alpha remap minimal range
  17034. * @param max defines the alpha remap maximal range
  17035. * @returns the current particle system
  17036. */
  17037. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17038. /**
  17039. * Remove a specific alpha remap gradient
  17040. * @param gradient defines the gradient to remove
  17041. * @returns the current particle system
  17042. */
  17043. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17044. /**
  17045. * Adds a new angular speed gradient
  17046. * @param gradient defines the gradient to use (between 0 and 1)
  17047. * @param factor defines the angular speed to affect to the specified gradient
  17048. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17049. * @returns the current particle system
  17050. */
  17051. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17052. /**
  17053. * Remove a specific angular speed gradient
  17054. * @param gradient defines the gradient to remove
  17055. * @returns the current particle system
  17056. */
  17057. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17058. /**
  17059. * Adds a new velocity gradient
  17060. * @param gradient defines the gradient to use (between 0 and 1)
  17061. * @param factor defines the velocity to affect to the specified gradient
  17062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17063. * @returns the current particle system
  17064. */
  17065. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17066. /**
  17067. * Remove a specific velocity gradient
  17068. * @param gradient defines the gradient to remove
  17069. * @returns the current particle system
  17070. */
  17071. removeVelocityGradient(gradient: number): IParticleSystem;
  17072. /**
  17073. * Adds a new limit velocity gradient
  17074. * @param gradient defines the gradient to use (between 0 and 1)
  17075. * @param factor defines the limit velocity value to affect to the specified gradient
  17076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17077. * @returns the current particle system
  17078. */
  17079. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17080. /**
  17081. * Remove a specific limit velocity gradient
  17082. * @param gradient defines the gradient to remove
  17083. * @returns the current particle system
  17084. */
  17085. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17086. /**
  17087. * Adds a new drag gradient
  17088. * @param gradient defines the gradient to use (between 0 and 1)
  17089. * @param factor defines the drag value to affect to the specified gradient
  17090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17091. * @returns the current particle system
  17092. */
  17093. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17094. /**
  17095. * Remove a specific drag gradient
  17096. * @param gradient defines the gradient to remove
  17097. * @returns the current particle system
  17098. */
  17099. removeDragGradient(gradient: number): IParticleSystem;
  17100. /**
  17101. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17102. * @param gradient defines the gradient to use (between 0 and 1)
  17103. * @param factor defines the emit rate value to affect to the specified gradient
  17104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17105. * @returns the current particle system
  17106. */
  17107. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17108. /**
  17109. * Remove a specific emit rate gradient
  17110. * @param gradient defines the gradient to remove
  17111. * @returns the current particle system
  17112. */
  17113. removeEmitRateGradient(gradient: number): IParticleSystem;
  17114. /**
  17115. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17116. * @param gradient defines the gradient to use (between 0 and 1)
  17117. * @param factor defines the start size value to affect to the specified gradient
  17118. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17119. * @returns the current particle system
  17120. */
  17121. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17122. /**
  17123. * Remove a specific start size gradient
  17124. * @param gradient defines the gradient to remove
  17125. * @returns the current particle system
  17126. */
  17127. removeStartSizeGradient(gradient: number): IParticleSystem;
  17128. private _createRampGradientTexture;
  17129. /**
  17130. * Gets the current list of ramp gradients.
  17131. * You must use addRampGradient and removeRampGradient to udpate this list
  17132. * @returns the list of ramp gradients
  17133. */
  17134. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17135. /**
  17136. * Adds a new ramp gradient used to remap particle colors
  17137. * @param gradient defines the gradient to use (between 0 and 1)
  17138. * @param color defines the color to affect to the specified gradient
  17139. * @returns the current particle system
  17140. */
  17141. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17142. /**
  17143. * Remove a specific ramp gradient
  17144. * @param gradient defines the gradient to remove
  17145. * @returns the current particle system
  17146. */
  17147. removeRampGradient(gradient: number): ParticleSystem;
  17148. /**
  17149. * Adds a new color gradient
  17150. * @param gradient defines the gradient to use (between 0 and 1)
  17151. * @param color1 defines the color to affect to the specified gradient
  17152. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17153. * @returns this particle system
  17154. */
  17155. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17156. /**
  17157. * Remove a specific color gradient
  17158. * @param gradient defines the gradient to remove
  17159. * @returns this particle system
  17160. */
  17161. removeColorGradient(gradient: number): IParticleSystem;
  17162. private _fetchR;
  17163. protected _reset(): void;
  17164. private _resetEffect;
  17165. private _createVertexBuffers;
  17166. private _createIndexBuffer;
  17167. /**
  17168. * Gets the maximum number of particles active at the same time.
  17169. * @returns The max number of active particles.
  17170. */
  17171. getCapacity(): number;
  17172. /**
  17173. * Gets whether there are still active particles in the system.
  17174. * @returns True if it is alive, otherwise false.
  17175. */
  17176. isAlive(): boolean;
  17177. /**
  17178. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17179. * @returns True if it has been started, otherwise false.
  17180. */
  17181. isStarted(): boolean;
  17182. private _prepareSubEmitterInternalArray;
  17183. /**
  17184. * Starts the particle system and begins to emit
  17185. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17186. */
  17187. start(delay?: number): void;
  17188. /**
  17189. * Stops the particle system.
  17190. * @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.
  17191. */
  17192. stop(stopSubEmitters?: boolean): void;
  17193. /**
  17194. * Remove all active particles
  17195. */
  17196. reset(): void;
  17197. /**
  17198. * @hidden (for internal use only)
  17199. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17200. /**
  17201. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17202. * Its lifetime will start back at 0.
  17203. */
  17204. recycleParticle: (particle: Particle) => void;
  17205. private _stopSubEmitters;
  17206. private _createParticle;
  17207. private _removeFromRoot;
  17208. private _emitFromParticle;
  17209. private _update;
  17210. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17211. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17212. /** @hidden */
  17213. private _getEffect;
  17214. /**
  17215. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17216. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17217. */
  17218. animate(preWarmOnly?: boolean): void;
  17219. private _appendParticleVertices;
  17220. /**
  17221. * Rebuilds the particle system.
  17222. */
  17223. rebuild(): void;
  17224. /**
  17225. * Is this system ready to be used/rendered
  17226. * @return true if the system is ready
  17227. */
  17228. isReady(): boolean;
  17229. private _render;
  17230. /**
  17231. * Renders the particle system in its current state.
  17232. * @returns the current number of particles
  17233. */
  17234. render(): number;
  17235. /**
  17236. * Disposes the particle system and free the associated resources
  17237. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17238. */
  17239. dispose(disposeTexture?: boolean): void;
  17240. /**
  17241. * Clones the particle system.
  17242. * @param name The name of the cloned object
  17243. * @param newEmitter The new emitter to use
  17244. * @returns the cloned particle system
  17245. */
  17246. clone(name: string, newEmitter: any): ParticleSystem;
  17247. /**
  17248. * Serializes the particle system to a JSON object.
  17249. * @returns the JSON object
  17250. */
  17251. serialize(): any;
  17252. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17253. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17254. /**
  17255. * Parses a JSON object to create a particle system.
  17256. * @param parsedParticleSystem The JSON object to parse
  17257. * @param scene The scene to create the particle system in
  17258. * @param rootUrl The root url to use to load external dependencies like texture
  17259. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17260. * @returns the Parsed particle system
  17261. */
  17262. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17263. }
  17264. }
  17265. declare module BABYLON {
  17266. /**
  17267. * A particle represents one of the element emitted by a particle system.
  17268. * This is mainly define by its coordinates, direction, velocity and age.
  17269. */
  17270. export class Particle {
  17271. /**
  17272. * The particle system the particle belongs to.
  17273. */
  17274. particleSystem: ParticleSystem;
  17275. private static _Count;
  17276. /**
  17277. * Unique ID of the particle
  17278. */
  17279. id: number;
  17280. /**
  17281. * The world position of the particle in the scene.
  17282. */
  17283. position: Vector3;
  17284. /**
  17285. * The world direction of the particle in the scene.
  17286. */
  17287. direction: Vector3;
  17288. /**
  17289. * The color of the particle.
  17290. */
  17291. color: Color4;
  17292. /**
  17293. * The color change of the particle per step.
  17294. */
  17295. colorStep: Color4;
  17296. /**
  17297. * Defines how long will the life of the particle be.
  17298. */
  17299. lifeTime: number;
  17300. /**
  17301. * The current age of the particle.
  17302. */
  17303. age: number;
  17304. /**
  17305. * The current size of the particle.
  17306. */
  17307. size: number;
  17308. /**
  17309. * The current scale of the particle.
  17310. */
  17311. scale: Vector2;
  17312. /**
  17313. * The current angle of the particle.
  17314. */
  17315. angle: number;
  17316. /**
  17317. * Defines how fast is the angle changing.
  17318. */
  17319. angularSpeed: number;
  17320. /**
  17321. * Defines the cell index used by the particle to be rendered from a sprite.
  17322. */
  17323. cellIndex: number;
  17324. /**
  17325. * The information required to support color remapping
  17326. */
  17327. remapData: Vector4;
  17328. /** @hidden */ private _randomCellOffset?: number;
  17329. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17330. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17331. /** @hidden */ private _initialStartSpriteCellID: number;
  17332. /** @hidden */ private _initialEndSpriteCellID: number;
  17333. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17334. /** @hidden */ private _currentColor1: Color4;
  17335. /** @hidden */ private _currentColor2: Color4;
  17336. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17337. /** @hidden */ private _currentSize1: number;
  17338. /** @hidden */ private _currentSize2: number;
  17339. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17340. /** @hidden */ private _currentAngularSpeed1: number;
  17341. /** @hidden */ private _currentAngularSpeed2: number;
  17342. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17343. /** @hidden */ private _currentVelocity1: number;
  17344. /** @hidden */ private _currentVelocity2: number;
  17345. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17346. /** @hidden */ private _currentLimitVelocity1: number;
  17347. /** @hidden */ private _currentLimitVelocity2: number;
  17348. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17349. /** @hidden */ private _currentDrag1: number;
  17350. /** @hidden */ private _currentDrag2: number;
  17351. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17352. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17353. /**
  17354. * Creates a new instance Particle
  17355. * @param particleSystem the particle system the particle belongs to
  17356. */
  17357. constructor(
  17358. /**
  17359. * The particle system the particle belongs to.
  17360. */
  17361. particleSystem: ParticleSystem);
  17362. private updateCellInfoFromSystem;
  17363. /**
  17364. * Defines how the sprite cell index is updated for the particle
  17365. */
  17366. updateCellIndex(): void;
  17367. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17368. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17369. /** @hidden */ private _reset(): void;
  17370. /**
  17371. * Copy the properties of particle to another one.
  17372. * @param other the particle to copy the information to.
  17373. */
  17374. copyTo(other: Particle): void;
  17375. }
  17376. }
  17377. declare module BABYLON {
  17378. /**
  17379. * Particle emitter represents a volume emitting particles.
  17380. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17381. */
  17382. export interface IParticleEmitterType {
  17383. /**
  17384. * Called by the particle System when the direction is computed for the created particle.
  17385. * @param worldMatrix is the world matrix of the particle system
  17386. * @param directionToUpdate is the direction vector to update with the result
  17387. * @param particle is the particle we are computed the direction for
  17388. */
  17389. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17390. /**
  17391. * Called by the particle System when the position is computed for the created particle.
  17392. * @param worldMatrix is the world matrix of the particle system
  17393. * @param positionToUpdate is the position vector to update with the result
  17394. * @param particle is the particle we are computed the position for
  17395. */
  17396. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17397. /**
  17398. * Clones the current emitter and returns a copy of it
  17399. * @returns the new emitter
  17400. */
  17401. clone(): IParticleEmitterType;
  17402. /**
  17403. * Called by the GPUParticleSystem to setup the update shader
  17404. * @param effect defines the update shader
  17405. */
  17406. applyToShader(effect: Effect): void;
  17407. /**
  17408. * Returns a string to use to update the GPU particles update shader
  17409. * @returns the effect defines string
  17410. */
  17411. getEffectDefines(): string;
  17412. /**
  17413. * Returns a string representing the class name
  17414. * @returns a string containing the class name
  17415. */
  17416. getClassName(): string;
  17417. /**
  17418. * Serializes the particle system to a JSON object.
  17419. * @returns the JSON object
  17420. */
  17421. serialize(): any;
  17422. /**
  17423. * Parse properties from a JSON object
  17424. * @param serializationObject defines the JSON object
  17425. */
  17426. parse(serializationObject: any): void;
  17427. }
  17428. }
  17429. declare module BABYLON {
  17430. /**
  17431. * Particle emitter emitting particles from the inside of a box.
  17432. * It emits the particles randomly between 2 given directions.
  17433. */
  17434. export class BoxParticleEmitter implements IParticleEmitterType {
  17435. /**
  17436. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17437. */
  17438. direction1: Vector3;
  17439. /**
  17440. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17441. */
  17442. direction2: Vector3;
  17443. /**
  17444. * 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.
  17445. */
  17446. minEmitBox: Vector3;
  17447. /**
  17448. * 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.
  17449. */
  17450. maxEmitBox: Vector3;
  17451. /**
  17452. * Creates a new instance BoxParticleEmitter
  17453. */
  17454. constructor();
  17455. /**
  17456. * Called by the particle System when the direction is computed for the created particle.
  17457. * @param worldMatrix is the world matrix of the particle system
  17458. * @param directionToUpdate is the direction vector to update with the result
  17459. * @param particle is the particle we are computed the direction for
  17460. */
  17461. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17462. /**
  17463. * Called by the particle System when the position is computed for the created particle.
  17464. * @param worldMatrix is the world matrix of the particle system
  17465. * @param positionToUpdate is the position vector to update with the result
  17466. * @param particle is the particle we are computed the position for
  17467. */
  17468. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17469. /**
  17470. * Clones the current emitter and returns a copy of it
  17471. * @returns the new emitter
  17472. */
  17473. clone(): BoxParticleEmitter;
  17474. /**
  17475. * Called by the GPUParticleSystem to setup the update shader
  17476. * @param effect defines the update shader
  17477. */
  17478. applyToShader(effect: Effect): void;
  17479. /**
  17480. * Returns a string to use to update the GPU particles update shader
  17481. * @returns a string containng the defines string
  17482. */
  17483. getEffectDefines(): string;
  17484. /**
  17485. * Returns the string "BoxParticleEmitter"
  17486. * @returns a string containing the class name
  17487. */
  17488. getClassName(): string;
  17489. /**
  17490. * Serializes the particle system to a JSON object.
  17491. * @returns the JSON object
  17492. */
  17493. serialize(): any;
  17494. /**
  17495. * Parse properties from a JSON object
  17496. * @param serializationObject defines the JSON object
  17497. */
  17498. parse(serializationObject: any): void;
  17499. }
  17500. }
  17501. declare module BABYLON {
  17502. /**
  17503. * Particle emitter emitting particles from the inside of a cone.
  17504. * It emits the particles alongside the cone volume from the base to the particle.
  17505. * The emission direction might be randomized.
  17506. */
  17507. export class ConeParticleEmitter implements IParticleEmitterType {
  17508. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17509. directionRandomizer: number;
  17510. private _radius;
  17511. private _angle;
  17512. private _height;
  17513. /**
  17514. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17515. */
  17516. radiusRange: number;
  17517. /**
  17518. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17519. */
  17520. heightRange: number;
  17521. /**
  17522. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17523. */
  17524. emitFromSpawnPointOnly: boolean;
  17525. /**
  17526. * Gets or sets the radius of the emission cone
  17527. */
  17528. radius: number;
  17529. /**
  17530. * Gets or sets the angle of the emission cone
  17531. */
  17532. angle: number;
  17533. private _buildHeight;
  17534. /**
  17535. * Creates a new instance ConeParticleEmitter
  17536. * @param radius the radius of the emission cone (1 by default)
  17537. * @param angle the cone base angle (PI by default)
  17538. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17539. */
  17540. constructor(radius?: number, angle?: number,
  17541. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17542. directionRandomizer?: number);
  17543. /**
  17544. * Called by the particle System when the direction is computed for the created particle.
  17545. * @param worldMatrix is the world matrix of the particle system
  17546. * @param directionToUpdate is the direction vector to update with the result
  17547. * @param particle is the particle we are computed the direction for
  17548. */
  17549. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17550. /**
  17551. * Called by the particle System when the position is computed for the created particle.
  17552. * @param worldMatrix is the world matrix of the particle system
  17553. * @param positionToUpdate is the position vector to update with the result
  17554. * @param particle is the particle we are computed the position for
  17555. */
  17556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17557. /**
  17558. * Clones the current emitter and returns a copy of it
  17559. * @returns the new emitter
  17560. */
  17561. clone(): ConeParticleEmitter;
  17562. /**
  17563. * Called by the GPUParticleSystem to setup the update shader
  17564. * @param effect defines the update shader
  17565. */
  17566. applyToShader(effect: Effect): void;
  17567. /**
  17568. * Returns a string to use to update the GPU particles update shader
  17569. * @returns a string containng the defines string
  17570. */
  17571. getEffectDefines(): string;
  17572. /**
  17573. * Returns the string "ConeParticleEmitter"
  17574. * @returns a string containing the class name
  17575. */
  17576. getClassName(): string;
  17577. /**
  17578. * Serializes the particle system to a JSON object.
  17579. * @returns the JSON object
  17580. */
  17581. serialize(): any;
  17582. /**
  17583. * Parse properties from a JSON object
  17584. * @param serializationObject defines the JSON object
  17585. */
  17586. parse(serializationObject: any): void;
  17587. }
  17588. }
  17589. declare module BABYLON {
  17590. /**
  17591. * Particle emitter emitting particles from the inside of a cylinder.
  17592. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17593. */
  17594. export class CylinderParticleEmitter implements IParticleEmitterType {
  17595. /**
  17596. * The radius of the emission cylinder.
  17597. */
  17598. radius: number;
  17599. /**
  17600. * The height of the emission cylinder.
  17601. */
  17602. height: number;
  17603. /**
  17604. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17605. */
  17606. radiusRange: number;
  17607. /**
  17608. * How much to randomize the particle direction [0-1].
  17609. */
  17610. directionRandomizer: number;
  17611. /**
  17612. * Creates a new instance CylinderParticleEmitter
  17613. * @param radius the radius of the emission cylinder (1 by default)
  17614. * @param height the height of the emission cylinder (1 by default)
  17615. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17616. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17617. */
  17618. constructor(
  17619. /**
  17620. * The radius of the emission cylinder.
  17621. */
  17622. radius?: number,
  17623. /**
  17624. * The height of the emission cylinder.
  17625. */
  17626. height?: number,
  17627. /**
  17628. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17629. */
  17630. radiusRange?: number,
  17631. /**
  17632. * How much to randomize the particle direction [0-1].
  17633. */
  17634. directionRandomizer?: number);
  17635. /**
  17636. * Called by the particle System when the direction is computed for the created particle.
  17637. * @param worldMatrix is the world matrix of the particle system
  17638. * @param directionToUpdate is the direction vector to update with the result
  17639. * @param particle is the particle we are computed the direction for
  17640. */
  17641. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17642. /**
  17643. * Called by the particle System when the position is computed for the created particle.
  17644. * @param worldMatrix is the world matrix of the particle system
  17645. * @param positionToUpdate is the position vector to update with the result
  17646. * @param particle is the particle we are computed the position for
  17647. */
  17648. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17649. /**
  17650. * Clones the current emitter and returns a copy of it
  17651. * @returns the new emitter
  17652. */
  17653. clone(): CylinderParticleEmitter;
  17654. /**
  17655. * Called by the GPUParticleSystem to setup the update shader
  17656. * @param effect defines the update shader
  17657. */
  17658. applyToShader(effect: Effect): void;
  17659. /**
  17660. * Returns a string to use to update the GPU particles update shader
  17661. * @returns a string containng the defines string
  17662. */
  17663. getEffectDefines(): string;
  17664. /**
  17665. * Returns the string "CylinderParticleEmitter"
  17666. * @returns a string containing the class name
  17667. */
  17668. getClassName(): string;
  17669. /**
  17670. * Serializes the particle system to a JSON object.
  17671. * @returns the JSON object
  17672. */
  17673. serialize(): any;
  17674. /**
  17675. * Parse properties from a JSON object
  17676. * @param serializationObject defines the JSON object
  17677. */
  17678. parse(serializationObject: any): void;
  17679. }
  17680. /**
  17681. * Particle emitter emitting particles from the inside of a cylinder.
  17682. * It emits the particles randomly between two vectors.
  17683. */
  17684. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17685. /**
  17686. * The min limit of the emission direction.
  17687. */
  17688. direction1: Vector3;
  17689. /**
  17690. * The max limit of the emission direction.
  17691. */
  17692. direction2: Vector3;
  17693. /**
  17694. * Creates a new instance CylinderDirectedParticleEmitter
  17695. * @param radius the radius of the emission cylinder (1 by default)
  17696. * @param height the height of the emission cylinder (1 by default)
  17697. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17698. * @param direction1 the min limit of the emission direction (up vector by default)
  17699. * @param direction2 the max limit of the emission direction (up vector by default)
  17700. */
  17701. constructor(radius?: number, height?: number, radiusRange?: number,
  17702. /**
  17703. * The min limit of the emission direction.
  17704. */
  17705. direction1?: Vector3,
  17706. /**
  17707. * The max limit of the emission direction.
  17708. */
  17709. direction2?: Vector3);
  17710. /**
  17711. * Called by the particle System when the direction is computed for the created particle.
  17712. * @param worldMatrix is the world matrix of the particle system
  17713. * @param directionToUpdate is the direction vector to update with the result
  17714. * @param particle is the particle we are computed the direction for
  17715. */
  17716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17717. /**
  17718. * Clones the current emitter and returns a copy of it
  17719. * @returns the new emitter
  17720. */
  17721. clone(): CylinderDirectedParticleEmitter;
  17722. /**
  17723. * Called by the GPUParticleSystem to setup the update shader
  17724. * @param effect defines the update shader
  17725. */
  17726. applyToShader(effect: Effect): void;
  17727. /**
  17728. * Returns a string to use to update the GPU particles update shader
  17729. * @returns a string containng the defines string
  17730. */
  17731. getEffectDefines(): string;
  17732. /**
  17733. * Returns the string "CylinderDirectedParticleEmitter"
  17734. * @returns a string containing the class name
  17735. */
  17736. getClassName(): string;
  17737. /**
  17738. * Serializes the particle system to a JSON object.
  17739. * @returns the JSON object
  17740. */
  17741. serialize(): any;
  17742. /**
  17743. * Parse properties from a JSON object
  17744. * @param serializationObject defines the JSON object
  17745. */
  17746. parse(serializationObject: any): void;
  17747. }
  17748. }
  17749. declare module BABYLON {
  17750. /**
  17751. * Particle emitter emitting particles from the inside of a hemisphere.
  17752. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17753. */
  17754. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17755. /**
  17756. * The radius of the emission hemisphere.
  17757. */
  17758. radius: number;
  17759. /**
  17760. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17761. */
  17762. radiusRange: number;
  17763. /**
  17764. * How much to randomize the particle direction [0-1].
  17765. */
  17766. directionRandomizer: number;
  17767. /**
  17768. * Creates a new instance HemisphericParticleEmitter
  17769. * @param radius the radius of the emission hemisphere (1 by default)
  17770. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17771. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17772. */
  17773. constructor(
  17774. /**
  17775. * The radius of the emission hemisphere.
  17776. */
  17777. radius?: number,
  17778. /**
  17779. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17780. */
  17781. radiusRange?: number,
  17782. /**
  17783. * How much to randomize the particle direction [0-1].
  17784. */
  17785. directionRandomizer?: number);
  17786. /**
  17787. * Called by the particle System when the direction is computed for the created particle.
  17788. * @param worldMatrix is the world matrix of the particle system
  17789. * @param directionToUpdate is the direction vector to update with the result
  17790. * @param particle is the particle we are computed the direction for
  17791. */
  17792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17793. /**
  17794. * Called by the particle System when the position is computed for the created particle.
  17795. * @param worldMatrix is the world matrix of the particle system
  17796. * @param positionToUpdate is the position vector to update with the result
  17797. * @param particle is the particle we are computed the position for
  17798. */
  17799. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17800. /**
  17801. * Clones the current emitter and returns a copy of it
  17802. * @returns the new emitter
  17803. */
  17804. clone(): HemisphericParticleEmitter;
  17805. /**
  17806. * Called by the GPUParticleSystem to setup the update shader
  17807. * @param effect defines the update shader
  17808. */
  17809. applyToShader(effect: Effect): void;
  17810. /**
  17811. * Returns a string to use to update the GPU particles update shader
  17812. * @returns a string containng the defines string
  17813. */
  17814. getEffectDefines(): string;
  17815. /**
  17816. * Returns the string "HemisphericParticleEmitter"
  17817. * @returns a string containing the class name
  17818. */
  17819. getClassName(): string;
  17820. /**
  17821. * Serializes the particle system to a JSON object.
  17822. * @returns the JSON object
  17823. */
  17824. serialize(): any;
  17825. /**
  17826. * Parse properties from a JSON object
  17827. * @param serializationObject defines the JSON object
  17828. */
  17829. parse(serializationObject: any): void;
  17830. }
  17831. }
  17832. declare module BABYLON {
  17833. /**
  17834. * Particle emitter emitting particles from a point.
  17835. * It emits the particles randomly between 2 given directions.
  17836. */
  17837. export class PointParticleEmitter implements IParticleEmitterType {
  17838. /**
  17839. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17840. */
  17841. direction1: Vector3;
  17842. /**
  17843. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17844. */
  17845. direction2: Vector3;
  17846. /**
  17847. * Creates a new instance PointParticleEmitter
  17848. */
  17849. constructor();
  17850. /**
  17851. * Called by the particle System when the direction is computed for the created particle.
  17852. * @param worldMatrix is the world matrix of the particle system
  17853. * @param directionToUpdate is the direction vector to update with the result
  17854. * @param particle is the particle we are computed the direction for
  17855. */
  17856. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17857. /**
  17858. * Called by the particle System when the position is computed for the created particle.
  17859. * @param worldMatrix is the world matrix of the particle system
  17860. * @param positionToUpdate is the position vector to update with the result
  17861. * @param particle is the particle we are computed the position for
  17862. */
  17863. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17864. /**
  17865. * Clones the current emitter and returns a copy of it
  17866. * @returns the new emitter
  17867. */
  17868. clone(): PointParticleEmitter;
  17869. /**
  17870. * Called by the GPUParticleSystem to setup the update shader
  17871. * @param effect defines the update shader
  17872. */
  17873. applyToShader(effect: Effect): void;
  17874. /**
  17875. * Returns a string to use to update the GPU particles update shader
  17876. * @returns a string containng the defines string
  17877. */
  17878. getEffectDefines(): string;
  17879. /**
  17880. * Returns the string "PointParticleEmitter"
  17881. * @returns a string containing the class name
  17882. */
  17883. getClassName(): string;
  17884. /**
  17885. * Serializes the particle system to a JSON object.
  17886. * @returns the JSON object
  17887. */
  17888. serialize(): any;
  17889. /**
  17890. * Parse properties from a JSON object
  17891. * @param serializationObject defines the JSON object
  17892. */
  17893. parse(serializationObject: any): void;
  17894. }
  17895. }
  17896. declare module BABYLON {
  17897. /**
  17898. * Particle emitter emitting particles from the inside of a sphere.
  17899. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17900. */
  17901. export class SphereParticleEmitter implements IParticleEmitterType {
  17902. /**
  17903. * The radius of the emission sphere.
  17904. */
  17905. radius: number;
  17906. /**
  17907. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17908. */
  17909. radiusRange: number;
  17910. /**
  17911. * How much to randomize the particle direction [0-1].
  17912. */
  17913. directionRandomizer: number;
  17914. /**
  17915. * Creates a new instance SphereParticleEmitter
  17916. * @param radius the radius of the emission sphere (1 by default)
  17917. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17918. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17919. */
  17920. constructor(
  17921. /**
  17922. * The radius of the emission sphere.
  17923. */
  17924. radius?: number,
  17925. /**
  17926. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17927. */
  17928. radiusRange?: number,
  17929. /**
  17930. * How much to randomize the particle direction [0-1].
  17931. */
  17932. directionRandomizer?: number);
  17933. /**
  17934. * Called by the particle System when the direction is computed for the created particle.
  17935. * @param worldMatrix is the world matrix of the particle system
  17936. * @param directionToUpdate is the direction vector to update with the result
  17937. * @param particle is the particle we are computed the direction for
  17938. */
  17939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17940. /**
  17941. * Called by the particle System when the position is computed for the created particle.
  17942. * @param worldMatrix is the world matrix of the particle system
  17943. * @param positionToUpdate is the position vector to update with the result
  17944. * @param particle is the particle we are computed the position for
  17945. */
  17946. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17947. /**
  17948. * Clones the current emitter and returns a copy of it
  17949. * @returns the new emitter
  17950. */
  17951. clone(): SphereParticleEmitter;
  17952. /**
  17953. * Called by the GPUParticleSystem to setup the update shader
  17954. * @param effect defines the update shader
  17955. */
  17956. applyToShader(effect: Effect): void;
  17957. /**
  17958. * Returns a string to use to update the GPU particles update shader
  17959. * @returns a string containng the defines string
  17960. */
  17961. getEffectDefines(): string;
  17962. /**
  17963. * Returns the string "SphereParticleEmitter"
  17964. * @returns a string containing the class name
  17965. */
  17966. getClassName(): string;
  17967. /**
  17968. * Serializes the particle system to a JSON object.
  17969. * @returns the JSON object
  17970. */
  17971. serialize(): any;
  17972. /**
  17973. * Parse properties from a JSON object
  17974. * @param serializationObject defines the JSON object
  17975. */
  17976. parse(serializationObject: any): void;
  17977. }
  17978. /**
  17979. * Particle emitter emitting particles from the inside of a sphere.
  17980. * It emits the particles randomly between two vectors.
  17981. */
  17982. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17983. /**
  17984. * The min limit of the emission direction.
  17985. */
  17986. direction1: Vector3;
  17987. /**
  17988. * The max limit of the emission direction.
  17989. */
  17990. direction2: Vector3;
  17991. /**
  17992. * Creates a new instance SphereDirectedParticleEmitter
  17993. * @param radius the radius of the emission sphere (1 by default)
  17994. * @param direction1 the min limit of the emission direction (up vector by default)
  17995. * @param direction2 the max limit of the emission direction (up vector by default)
  17996. */
  17997. constructor(radius?: number,
  17998. /**
  17999. * The min limit of the emission direction.
  18000. */
  18001. direction1?: Vector3,
  18002. /**
  18003. * The max limit of the emission direction.
  18004. */
  18005. direction2?: Vector3);
  18006. /**
  18007. * Called by the particle System when the direction is computed for the created particle.
  18008. * @param worldMatrix is the world matrix of the particle system
  18009. * @param directionToUpdate is the direction vector to update with the result
  18010. * @param particle is the particle we are computed the direction for
  18011. */
  18012. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18013. /**
  18014. * Clones the current emitter and returns a copy of it
  18015. * @returns the new emitter
  18016. */
  18017. clone(): SphereDirectedParticleEmitter;
  18018. /**
  18019. * Called by the GPUParticleSystem to setup the update shader
  18020. * @param effect defines the update shader
  18021. */
  18022. applyToShader(effect: Effect): void;
  18023. /**
  18024. * Returns a string to use to update the GPU particles update shader
  18025. * @returns a string containng the defines string
  18026. */
  18027. getEffectDefines(): string;
  18028. /**
  18029. * Returns the string "SphereDirectedParticleEmitter"
  18030. * @returns a string containing the class name
  18031. */
  18032. getClassName(): string;
  18033. /**
  18034. * Serializes the particle system to a JSON object.
  18035. * @returns the JSON object
  18036. */
  18037. serialize(): any;
  18038. /**
  18039. * Parse properties from a JSON object
  18040. * @param serializationObject defines the JSON object
  18041. */
  18042. parse(serializationObject: any): void;
  18043. }
  18044. }
  18045. declare module BABYLON {
  18046. /**
  18047. * Interface representing a particle system in Babylon.js.
  18048. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18049. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18050. */
  18051. export interface IParticleSystem {
  18052. /**
  18053. * List of animations used by the particle system.
  18054. */
  18055. animations: Animation[];
  18056. /**
  18057. * The id of the Particle system.
  18058. */
  18059. id: string;
  18060. /**
  18061. * The name of the Particle system.
  18062. */
  18063. name: string;
  18064. /**
  18065. * The emitter represents the Mesh or position we are attaching the particle system to.
  18066. */
  18067. emitter: Nullable<AbstractMesh | Vector3>;
  18068. /**
  18069. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18070. */
  18071. isBillboardBased: boolean;
  18072. /**
  18073. * The rendering group used by the Particle system to chose when to render.
  18074. */
  18075. renderingGroupId: number;
  18076. /**
  18077. * The layer mask we are rendering the particles through.
  18078. */
  18079. layerMask: number;
  18080. /**
  18081. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18082. */
  18083. updateSpeed: number;
  18084. /**
  18085. * The amount of time the particle system is running (depends of the overall update speed).
  18086. */
  18087. targetStopDuration: number;
  18088. /**
  18089. * The texture used to render each particle. (this can be a spritesheet)
  18090. */
  18091. particleTexture: Nullable<Texture>;
  18092. /**
  18093. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18094. */
  18095. blendMode: number;
  18096. /**
  18097. * Minimum life time of emitting particles.
  18098. */
  18099. minLifeTime: number;
  18100. /**
  18101. * Maximum life time of emitting particles.
  18102. */
  18103. maxLifeTime: number;
  18104. /**
  18105. * Minimum Size of emitting particles.
  18106. */
  18107. minSize: number;
  18108. /**
  18109. * Maximum Size of emitting particles.
  18110. */
  18111. maxSize: number;
  18112. /**
  18113. * Minimum scale of emitting particles on X axis.
  18114. */
  18115. minScaleX: number;
  18116. /**
  18117. * Maximum scale of emitting particles on X axis.
  18118. */
  18119. maxScaleX: number;
  18120. /**
  18121. * Minimum scale of emitting particles on Y axis.
  18122. */
  18123. minScaleY: number;
  18124. /**
  18125. * Maximum scale of emitting particles on Y axis.
  18126. */
  18127. maxScaleY: number;
  18128. /**
  18129. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18130. */
  18131. color1: Color4;
  18132. /**
  18133. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18134. */
  18135. color2: Color4;
  18136. /**
  18137. * Color the particle will have at the end of its lifetime.
  18138. */
  18139. colorDead: Color4;
  18140. /**
  18141. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18142. */
  18143. emitRate: number;
  18144. /**
  18145. * You can use gravity if you want to give an orientation to your particles.
  18146. */
  18147. gravity: Vector3;
  18148. /**
  18149. * Minimum power of emitting particles.
  18150. */
  18151. minEmitPower: number;
  18152. /**
  18153. * Maximum power of emitting particles.
  18154. */
  18155. maxEmitPower: number;
  18156. /**
  18157. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18158. */
  18159. minAngularSpeed: number;
  18160. /**
  18161. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18162. */
  18163. maxAngularSpeed: number;
  18164. /**
  18165. * Gets or sets the minimal initial rotation in radians.
  18166. */
  18167. minInitialRotation: number;
  18168. /**
  18169. * Gets or sets the maximal initial rotation in radians.
  18170. */
  18171. maxInitialRotation: number;
  18172. /**
  18173. * The particle emitter type defines the emitter used by the particle system.
  18174. * It can be for example box, sphere, or cone...
  18175. */
  18176. particleEmitterType: Nullable<IParticleEmitterType>;
  18177. /**
  18178. * Defines the delay in milliseconds before starting the system (0 by default)
  18179. */
  18180. startDelay: number;
  18181. /**
  18182. * 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
  18183. */
  18184. preWarmCycles: number;
  18185. /**
  18186. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18187. */
  18188. preWarmStepOffset: number;
  18189. /**
  18190. * 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)
  18191. */
  18192. spriteCellChangeSpeed: number;
  18193. /**
  18194. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18195. */
  18196. startSpriteCellID: number;
  18197. /**
  18198. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18199. */
  18200. endSpriteCellID: number;
  18201. /**
  18202. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18203. */
  18204. spriteCellWidth: number;
  18205. /**
  18206. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18207. */
  18208. spriteCellHeight: number;
  18209. /**
  18210. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18211. */
  18212. spriteRandomStartCell: boolean;
  18213. /**
  18214. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18215. */
  18216. isAnimationSheetEnabled: boolean;
  18217. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18218. translationPivot: Vector2;
  18219. /**
  18220. * Gets or sets a texture used to add random noise to particle positions
  18221. */
  18222. noiseTexture: Nullable<BaseTexture>;
  18223. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18224. noiseStrength: Vector3;
  18225. /**
  18226. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18227. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18228. */
  18229. billboardMode: number;
  18230. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18231. limitVelocityDamping: number;
  18232. /**
  18233. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18234. */
  18235. beginAnimationOnStart: boolean;
  18236. /**
  18237. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18238. */
  18239. beginAnimationFrom: number;
  18240. /**
  18241. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18242. */
  18243. beginAnimationTo: number;
  18244. /**
  18245. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18246. */
  18247. beginAnimationLoop: boolean;
  18248. /**
  18249. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18250. */
  18251. disposeOnStop: boolean;
  18252. /**
  18253. * Gets the maximum number of particles active at the same time.
  18254. * @returns The max number of active particles.
  18255. */
  18256. getCapacity(): number;
  18257. /**
  18258. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18259. * @returns True if it has been started, otherwise false.
  18260. */
  18261. isStarted(): boolean;
  18262. /**
  18263. * Animates the particle system for this frame.
  18264. */
  18265. animate(): void;
  18266. /**
  18267. * Renders the particle system in its current state.
  18268. * @returns the current number of particles
  18269. */
  18270. render(): number;
  18271. /**
  18272. * Dispose the particle system and frees its associated resources.
  18273. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18274. */
  18275. dispose(disposeTexture?: boolean): void;
  18276. /**
  18277. * Clones the particle system.
  18278. * @param name The name of the cloned object
  18279. * @param newEmitter The new emitter to use
  18280. * @returns the cloned particle system
  18281. */
  18282. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18283. /**
  18284. * Serializes the particle system to a JSON object.
  18285. * @returns the JSON object
  18286. */
  18287. serialize(): any;
  18288. /**
  18289. * Rebuild the particle system
  18290. */
  18291. rebuild(): void;
  18292. /**
  18293. * Starts the particle system and begins to emit
  18294. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18295. */
  18296. start(delay?: number): void;
  18297. /**
  18298. * Stops the particle system.
  18299. */
  18300. stop(): void;
  18301. /**
  18302. * Remove all active particles
  18303. */
  18304. reset(): void;
  18305. /**
  18306. * Is this system ready to be used/rendered
  18307. * @return true if the system is ready
  18308. */
  18309. isReady(): boolean;
  18310. /**
  18311. * Adds a new color gradient
  18312. * @param gradient defines the gradient to use (between 0 and 1)
  18313. * @param color1 defines the color to affect to the specified gradient
  18314. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18315. * @returns the current particle system
  18316. */
  18317. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18318. /**
  18319. * Remove a specific color gradient
  18320. * @param gradient defines the gradient to remove
  18321. * @returns the current particle system
  18322. */
  18323. removeColorGradient(gradient: number): IParticleSystem;
  18324. /**
  18325. * Adds a new size gradient
  18326. * @param gradient defines the gradient to use (between 0 and 1)
  18327. * @param factor defines the size factor to affect to the specified gradient
  18328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18329. * @returns the current particle system
  18330. */
  18331. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18332. /**
  18333. * Remove a specific size gradient
  18334. * @param gradient defines the gradient to remove
  18335. * @returns the current particle system
  18336. */
  18337. removeSizeGradient(gradient: number): IParticleSystem;
  18338. /**
  18339. * Gets the current list of color gradients.
  18340. * You must use addColorGradient and removeColorGradient to udpate this list
  18341. * @returns the list of color gradients
  18342. */
  18343. getColorGradients(): Nullable<Array<ColorGradient>>;
  18344. /**
  18345. * Gets the current list of size gradients.
  18346. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18347. * @returns the list of size gradients
  18348. */
  18349. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18350. /**
  18351. * Gets the current list of angular speed gradients.
  18352. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18353. * @returns the list of angular speed gradients
  18354. */
  18355. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18356. /**
  18357. * Adds a new angular speed gradient
  18358. * @param gradient defines the gradient to use (between 0 and 1)
  18359. * @param factor defines the angular speed to affect to the specified gradient
  18360. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18361. * @returns the current particle system
  18362. */
  18363. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18364. /**
  18365. * Remove a specific angular speed gradient
  18366. * @param gradient defines the gradient to remove
  18367. * @returns the current particle system
  18368. */
  18369. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18370. /**
  18371. * Gets the current list of velocity gradients.
  18372. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18373. * @returns the list of velocity gradients
  18374. */
  18375. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18376. /**
  18377. * Adds a new velocity gradient
  18378. * @param gradient defines the gradient to use (between 0 and 1)
  18379. * @param factor defines the velocity to affect to the specified gradient
  18380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18381. * @returns the current particle system
  18382. */
  18383. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18384. /**
  18385. * Remove a specific velocity gradient
  18386. * @param gradient defines the gradient to remove
  18387. * @returns the current particle system
  18388. */
  18389. removeVelocityGradient(gradient: number): IParticleSystem;
  18390. /**
  18391. * Gets the current list of limit velocity gradients.
  18392. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18393. * @returns the list of limit velocity gradients
  18394. */
  18395. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18396. /**
  18397. * Adds a new limit velocity gradient
  18398. * @param gradient defines the gradient to use (between 0 and 1)
  18399. * @param factor defines the limit velocity to affect to the specified gradient
  18400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18401. * @returns the current particle system
  18402. */
  18403. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18404. /**
  18405. * Remove a specific limit velocity gradient
  18406. * @param gradient defines the gradient to remove
  18407. * @returns the current particle system
  18408. */
  18409. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18410. /**
  18411. * Adds a new drag gradient
  18412. * @param gradient defines the gradient to use (between 0 and 1)
  18413. * @param factor defines the drag to affect to the specified gradient
  18414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18415. * @returns the current particle system
  18416. */
  18417. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18418. /**
  18419. * Remove a specific drag gradient
  18420. * @param gradient defines the gradient to remove
  18421. * @returns the current particle system
  18422. */
  18423. removeDragGradient(gradient: number): IParticleSystem;
  18424. /**
  18425. * Gets the current list of drag gradients.
  18426. * You must use addDragGradient and removeDragGradient to udpate this list
  18427. * @returns the list of drag gradients
  18428. */
  18429. getDragGradients(): Nullable<Array<FactorGradient>>;
  18430. /**
  18431. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18432. * @param gradient defines the gradient to use (between 0 and 1)
  18433. * @param factor defines the emit rate to affect to the specified gradient
  18434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18435. * @returns the current particle system
  18436. */
  18437. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18438. /**
  18439. * Remove a specific emit rate gradient
  18440. * @param gradient defines the gradient to remove
  18441. * @returns the current particle system
  18442. */
  18443. removeEmitRateGradient(gradient: number): IParticleSystem;
  18444. /**
  18445. * Gets the current list of emit rate gradients.
  18446. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18447. * @returns the list of emit rate gradients
  18448. */
  18449. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18450. /**
  18451. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18452. * @param gradient defines the gradient to use (between 0 and 1)
  18453. * @param factor defines the start size to affect to the specified gradient
  18454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18455. * @returns the current particle system
  18456. */
  18457. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18458. /**
  18459. * Remove a specific start size gradient
  18460. * @param gradient defines the gradient to remove
  18461. * @returns the current particle system
  18462. */
  18463. removeStartSizeGradient(gradient: number): IParticleSystem;
  18464. /**
  18465. * Gets the current list of start size gradients.
  18466. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18467. * @returns the list of start size gradients
  18468. */
  18469. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18470. /**
  18471. * Adds a new life time gradient
  18472. * @param gradient defines the gradient to use (between 0 and 1)
  18473. * @param factor defines the life time factor to affect to the specified gradient
  18474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18475. * @returns the current particle system
  18476. */
  18477. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18478. /**
  18479. * Remove a specific life time gradient
  18480. * @param gradient defines the gradient to remove
  18481. * @returns the current particle system
  18482. */
  18483. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18484. /**
  18485. * Gets the current list of life time gradients.
  18486. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18487. * @returns the list of life time gradients
  18488. */
  18489. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18490. /**
  18491. * Gets the current list of color gradients.
  18492. * You must use addColorGradient and removeColorGradient to udpate this list
  18493. * @returns the list of color gradients
  18494. */
  18495. getColorGradients(): Nullable<Array<ColorGradient>>;
  18496. /**
  18497. * Adds a new ramp gradient used to remap particle colors
  18498. * @param gradient defines the gradient to use (between 0 and 1)
  18499. * @param color defines the color to affect to the specified gradient
  18500. * @returns the current particle system
  18501. */
  18502. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18503. /**
  18504. * Gets the current list of ramp gradients.
  18505. * You must use addRampGradient and removeRampGradient to udpate this list
  18506. * @returns the list of ramp gradients
  18507. */
  18508. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18509. /** Gets or sets a boolean indicating that ramp gradients must be used
  18510. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18511. */
  18512. useRampGradients: boolean;
  18513. /**
  18514. * Adds a new color remap gradient
  18515. * @param gradient defines the gradient to use (between 0 and 1)
  18516. * @param min defines the color remap minimal range
  18517. * @param max defines the color remap maximal range
  18518. * @returns the current particle system
  18519. */
  18520. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18521. /**
  18522. * Gets the current list of color remap gradients.
  18523. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18524. * @returns the list of color remap gradients
  18525. */
  18526. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18527. /**
  18528. * Adds a new alpha remap gradient
  18529. * @param gradient defines the gradient to use (between 0 and 1)
  18530. * @param min defines the alpha remap minimal range
  18531. * @param max defines the alpha remap maximal range
  18532. * @returns the current particle system
  18533. */
  18534. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18535. /**
  18536. * Gets the current list of alpha remap gradients.
  18537. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18538. * @returns the list of alpha remap gradients
  18539. */
  18540. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18541. /**
  18542. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18545. * @returns the emitter
  18546. */
  18547. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18548. /**
  18549. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18550. * @param radius The radius of the hemisphere to emit from
  18551. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18552. * @returns the emitter
  18553. */
  18554. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18555. /**
  18556. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18557. * @param radius The radius of the sphere to emit from
  18558. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18559. * @returns the emitter
  18560. */
  18561. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18562. /**
  18563. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18564. * @param radius The radius of the sphere to emit from
  18565. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18566. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18567. * @returns the emitter
  18568. */
  18569. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18570. /**
  18571. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18572. * @param radius The radius of the emission cylinder
  18573. * @param height The height of the emission cylinder
  18574. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18575. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18576. * @returns the emitter
  18577. */
  18578. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18579. /**
  18580. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18581. * @param radius The radius of the cylinder to emit from
  18582. * @param height The height of the emission cylinder
  18583. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18584. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18585. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18586. * @returns the emitter
  18587. */
  18588. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18589. /**
  18590. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18591. * @param radius The radius of the cone to emit from
  18592. * @param angle The base angle of the cone
  18593. * @returns the emitter
  18594. */
  18595. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18596. /**
  18597. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18600. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18601. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18602. * @returns the emitter
  18603. */
  18604. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18605. /**
  18606. * Get hosting scene
  18607. * @returns the scene
  18608. */
  18609. getScene(): Scene;
  18610. }
  18611. }
  18612. declare module BABYLON {
  18613. /**
  18614. * Creates an instance based on a source mesh.
  18615. */
  18616. export class InstancedMesh extends AbstractMesh {
  18617. private _sourceMesh;
  18618. private _currentLOD;
  18619. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18620. constructor(name: string, source: Mesh);
  18621. /**
  18622. * Returns the string "InstancedMesh".
  18623. */
  18624. getClassName(): string;
  18625. /** Gets the list of lights affecting that mesh */
  18626. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light, dispose: boolean): void;
  18627. /**
  18628. * If the source mesh receives shadows
  18629. */
  18630. readonly receiveShadows: boolean;
  18631. /**
  18632. * The material of the source mesh
  18633. */
  18634. readonly material: Nullable<Material>;
  18635. /**
  18636. * Visibility of the source mesh
  18637. */
  18638. readonly visibility: number;
  18639. /**
  18640. * Skeleton of the source mesh
  18641. */
  18642. readonly skeleton: Nullable<Skeleton>;
  18643. /**
  18644. * Rendering ground id of the source mesh
  18645. */
  18646. renderingGroupId: number;
  18647. /**
  18648. * Returns the total number of vertices (integer).
  18649. */
  18650. getTotalVertices(): number;
  18651. /**
  18652. * Returns a positive integer : the total number of indices in this mesh geometry.
  18653. * @returns the numner of indices or zero if the mesh has no geometry.
  18654. */
  18655. getTotalIndices(): number;
  18656. /**
  18657. * The source mesh of the instance
  18658. */
  18659. readonly sourceMesh: Mesh;
  18660. /**
  18661. * Is this node ready to be used/rendered
  18662. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18663. * @return {boolean} is it ready
  18664. */
  18665. isReady(completeCheck?: boolean): boolean;
  18666. /**
  18667. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18668. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18669. * @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.
  18670. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18671. */
  18672. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18673. /**
  18674. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18675. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18676. * The `data` are either a numeric array either a Float32Array.
  18677. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18678. * 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).
  18679. * Note that a new underlying VertexBuffer object is created each call.
  18680. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18681. *
  18682. * Possible `kind` values :
  18683. * - VertexBuffer.PositionKind
  18684. * - VertexBuffer.UVKind
  18685. * - VertexBuffer.UV2Kind
  18686. * - VertexBuffer.UV3Kind
  18687. * - VertexBuffer.UV4Kind
  18688. * - VertexBuffer.UV5Kind
  18689. * - VertexBuffer.UV6Kind
  18690. * - VertexBuffer.ColorKind
  18691. * - VertexBuffer.MatricesIndicesKind
  18692. * - VertexBuffer.MatricesIndicesExtraKind
  18693. * - VertexBuffer.MatricesWeightsKind
  18694. * - VertexBuffer.MatricesWeightsExtraKind
  18695. *
  18696. * Returns the Mesh.
  18697. */
  18698. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18699. /**
  18700. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18701. * If the mesh has no geometry, it is simply returned as it is.
  18702. * The `data` are either a numeric array either a Float32Array.
  18703. * No new underlying VertexBuffer object is created.
  18704. * 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.
  18705. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18706. *
  18707. * Possible `kind` values :
  18708. * - VertexBuffer.PositionKind
  18709. * - VertexBuffer.UVKind
  18710. * - VertexBuffer.UV2Kind
  18711. * - VertexBuffer.UV3Kind
  18712. * - VertexBuffer.UV4Kind
  18713. * - VertexBuffer.UV5Kind
  18714. * - VertexBuffer.UV6Kind
  18715. * - VertexBuffer.ColorKind
  18716. * - VertexBuffer.MatricesIndicesKind
  18717. * - VertexBuffer.MatricesIndicesExtraKind
  18718. * - VertexBuffer.MatricesWeightsKind
  18719. * - VertexBuffer.MatricesWeightsExtraKind
  18720. *
  18721. * Returns the Mesh.
  18722. */
  18723. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18724. /**
  18725. * Sets the mesh indices.
  18726. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18727. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18728. * This method creates a new index buffer each call.
  18729. * Returns the Mesh.
  18730. */
  18731. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18732. /**
  18733. * Boolean : True if the mesh owns the requested kind of data.
  18734. */
  18735. isVerticesDataPresent(kind: string): boolean;
  18736. /**
  18737. * Returns an array of indices (IndicesArray).
  18738. */
  18739. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18740. /**
  18741. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18742. * This means the mesh underlying bounding box and sphere are recomputed.
  18743. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18744. * @returns the current mesh
  18745. */
  18746. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18747. /** @hidden */ private _preActivate(): InstancedMesh;
  18748. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18749. /** @hidden */ private _postActivate(): void;
  18750. getWorldMatrix(): Matrix;
  18751. readonly isAnInstance: boolean;
  18752. /**
  18753. * Returns the current associated LOD AbstractMesh.
  18754. */
  18755. getLOD(camera: Camera): AbstractMesh;
  18756. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18757. /** @hidden */ private _generatePointsArray(): boolean;
  18758. /**
  18759. * Creates a new InstancedMesh from the current mesh.
  18760. * - name (string) : the cloned mesh name
  18761. * - newParent (optional Node) : the optional Node to parent the clone to.
  18762. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18763. *
  18764. * Returns the clone.
  18765. */
  18766. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18767. /**
  18768. * Disposes the InstancedMesh.
  18769. * Returns nothing.
  18770. */
  18771. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18772. }
  18773. interface Mesh {
  18774. /**
  18775. * Register a custom buffer that will be instanced
  18776. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  18777. * @param kind defines the buffer kind
  18778. * @param stride defines the stride in floats
  18779. */
  18780. registerInstancedBuffer(kind: string, stride: number): void;
  18781. /** @hidden */ private _userInstancedBuffersStorage: {
  18782. data: {
  18783. [key: string]: Float32Array;
  18784. };
  18785. sizes: {
  18786. [key: string]: number;
  18787. };
  18788. vertexBuffers: {
  18789. [key: string]: Nullable<VertexBuffer>;
  18790. };
  18791. strides: {
  18792. [key: string]: number;
  18793. };
  18794. };
  18795. }
  18796. interface AbstractMesh {
  18797. /**
  18798. * Object used to store instanced buffers defined by user
  18799. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  18800. */
  18801. instancedBuffers: {
  18802. [key: string]: any;
  18803. };
  18804. }
  18805. }
  18806. declare module BABYLON {
  18807. /**
  18808. * Defines the options associated with the creation of a shader material.
  18809. */
  18810. export interface IShaderMaterialOptions {
  18811. /**
  18812. * Does the material work in alpha blend mode
  18813. */
  18814. needAlphaBlending: boolean;
  18815. /**
  18816. * Does the material work in alpha test mode
  18817. */
  18818. needAlphaTesting: boolean;
  18819. /**
  18820. * The list of attribute names used in the shader
  18821. */
  18822. attributes: string[];
  18823. /**
  18824. * The list of unifrom names used in the shader
  18825. */
  18826. uniforms: string[];
  18827. /**
  18828. * The list of UBO names used in the shader
  18829. */
  18830. uniformBuffers: string[];
  18831. /**
  18832. * The list of sampler names used in the shader
  18833. */
  18834. samplers: string[];
  18835. /**
  18836. * The list of defines used in the shader
  18837. */
  18838. defines: string[];
  18839. }
  18840. /**
  18841. * 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.
  18842. *
  18843. * This returned material effects how the mesh will look based on the code in the shaders.
  18844. *
  18845. * @see http://doc.babylonjs.com/how_to/shader_material
  18846. */
  18847. export class ShaderMaterial extends Material {
  18848. private _shaderPath;
  18849. private _options;
  18850. private _textures;
  18851. private _textureArrays;
  18852. private _floats;
  18853. private _ints;
  18854. private _floatsArrays;
  18855. private _colors3;
  18856. private _colors3Arrays;
  18857. private _colors4;
  18858. private _colors4Arrays;
  18859. private _vectors2;
  18860. private _vectors3;
  18861. private _vectors4;
  18862. private _matrices;
  18863. private _matrixArrays;
  18864. private _matrices3x3;
  18865. private _matrices2x2;
  18866. private _vectors2Arrays;
  18867. private _vectors3Arrays;
  18868. private _vectors4Arrays;
  18869. private _cachedWorldViewMatrix;
  18870. private _cachedWorldViewProjectionMatrix;
  18871. private _renderId;
  18872. /**
  18873. * Instantiate a new shader material.
  18874. * 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.
  18875. * This returned material effects how the mesh will look based on the code in the shaders.
  18876. * @see http://doc.babylonjs.com/how_to/shader_material
  18877. * @param name Define the name of the material in the scene
  18878. * @param scene Define the scene the material belongs to
  18879. * @param shaderPath Defines the route to the shader code in one of three ways:
  18880. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18881. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18882. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18883. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18884. * @param options Define the options used to create the shader
  18885. */
  18886. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18887. /**
  18888. * Gets the shader path used to define the shader code
  18889. * It can be modified to trigger a new compilation
  18890. */
  18891. /**
  18892. * Sets the shader path used to define the shader code
  18893. * It can be modified to trigger a new compilation
  18894. */
  18895. shaderPath: any;
  18896. /**
  18897. * Gets the options used to compile the shader.
  18898. * They can be modified to trigger a new compilation
  18899. */
  18900. readonly options: IShaderMaterialOptions;
  18901. /**
  18902. * Gets the current class name of the material e.g. "ShaderMaterial"
  18903. * Mainly use in serialization.
  18904. * @returns the class name
  18905. */
  18906. getClassName(): string;
  18907. /**
  18908. * Specifies if the material will require alpha blending
  18909. * @returns a boolean specifying if alpha blending is needed
  18910. */
  18911. needAlphaBlending(): boolean;
  18912. /**
  18913. * Specifies if this material should be rendered in alpha test mode
  18914. * @returns a boolean specifying if an alpha test is needed.
  18915. */
  18916. needAlphaTesting(): boolean;
  18917. private _checkUniform;
  18918. /**
  18919. * Set a texture in the shader.
  18920. * @param name Define the name of the uniform samplers as defined in the shader
  18921. * @param texture Define the texture to bind to this sampler
  18922. * @return the material itself allowing "fluent" like uniform updates
  18923. */
  18924. setTexture(name: string, texture: Texture): ShaderMaterial;
  18925. /**
  18926. * Set a texture array in the shader.
  18927. * @param name Define the name of the uniform sampler array as defined in the shader
  18928. * @param textures Define the list of textures to bind to this sampler
  18929. * @return the material itself allowing "fluent" like uniform updates
  18930. */
  18931. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18932. /**
  18933. * Set a float in the shader.
  18934. * @param name Define the name of the uniform as defined in the shader
  18935. * @param value Define the value to give to the uniform
  18936. * @return the material itself allowing "fluent" like uniform updates
  18937. */
  18938. setFloat(name: string, value: number): ShaderMaterial;
  18939. /**
  18940. * Set a int in the shader.
  18941. * @param name Define the name of the uniform as defined in the shader
  18942. * @param value Define the value to give to the uniform
  18943. * @return the material itself allowing "fluent" like uniform updates
  18944. */
  18945. setInt(name: string, value: number): ShaderMaterial;
  18946. /**
  18947. * Set an array of floats in the shader.
  18948. * @param name Define the name of the uniform as defined in the shader
  18949. * @param value Define the value to give to the uniform
  18950. * @return the material itself allowing "fluent" like uniform updates
  18951. */
  18952. setFloats(name: string, value: number[]): ShaderMaterial;
  18953. /**
  18954. * Set a vec3 in the shader from a Color3.
  18955. * @param name Define the name of the uniform as defined in the shader
  18956. * @param value Define the value to give to the uniform
  18957. * @return the material itself allowing "fluent" like uniform updates
  18958. */
  18959. setColor3(name: string, value: Color3): ShaderMaterial;
  18960. /**
  18961. * Set a vec3 array in the shader from a Color3 array.
  18962. * @param name Define the name of the uniform as defined in the shader
  18963. * @param value Define the value to give to the uniform
  18964. * @return the material itself allowing "fluent" like uniform updates
  18965. */
  18966. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18967. /**
  18968. * Set a vec4 in the shader from a Color4.
  18969. * @param name Define the name of the uniform as defined in the shader
  18970. * @param value Define the value to give to the uniform
  18971. * @return the material itself allowing "fluent" like uniform updates
  18972. */
  18973. setColor4(name: string, value: Color4): ShaderMaterial;
  18974. /**
  18975. * Set a vec4 array in the shader from a Color4 array.
  18976. * @param name Define the name of the uniform as defined in the shader
  18977. * @param value Define the value to give to the uniform
  18978. * @return the material itself allowing "fluent" like uniform updates
  18979. */
  18980. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18981. /**
  18982. * Set a vec2 in the shader from a Vector2.
  18983. * @param name Define the name of the uniform as defined in the shader
  18984. * @param value Define the value to give to the uniform
  18985. * @return the material itself allowing "fluent" like uniform updates
  18986. */
  18987. setVector2(name: string, value: Vector2): ShaderMaterial;
  18988. /**
  18989. * Set a vec3 in the shader from a Vector3.
  18990. * @param name Define the name of the uniform as defined in the shader
  18991. * @param value Define the value to give to the uniform
  18992. * @return the material itself allowing "fluent" like uniform updates
  18993. */
  18994. setVector3(name: string, value: Vector3): ShaderMaterial;
  18995. /**
  18996. * Set a vec4 in the shader from a Vector4.
  18997. * @param name Define the name of the uniform as defined in the shader
  18998. * @param value Define the value to give to the uniform
  18999. * @return the material itself allowing "fluent" like uniform updates
  19000. */
  19001. setVector4(name: string, value: Vector4): ShaderMaterial;
  19002. /**
  19003. * Set a mat4 in the shader from a Matrix.
  19004. * @param name Define the name of the uniform as defined in the shader
  19005. * @param value Define the value to give to the uniform
  19006. * @return the material itself allowing "fluent" like uniform updates
  19007. */
  19008. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19009. /**
  19010. * Set a float32Array in the shader from a matrix array.
  19011. * @param name Define the name of the uniform as defined in the shader
  19012. * @param value Define the value to give to the uniform
  19013. * @return the material itself allowing "fluent" like uniform updates
  19014. */
  19015. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19016. /**
  19017. * Set a mat3 in the shader from a Float32Array.
  19018. * @param name Define the name of the uniform as defined in the shader
  19019. * @param value Define the value to give to the uniform
  19020. * @return the material itself allowing "fluent" like uniform updates
  19021. */
  19022. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19023. /**
  19024. * Set a mat2 in the shader from a Float32Array.
  19025. * @param name Define the name of the uniform as defined in the shader
  19026. * @param value Define the value to give to the uniform
  19027. * @return the material itself allowing "fluent" like uniform updates
  19028. */
  19029. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19030. /**
  19031. * Set a vec2 array in the shader from a number array.
  19032. * @param name Define the name of the uniform as defined in the shader
  19033. * @param value Define the value to give to the uniform
  19034. * @return the material itself allowing "fluent" like uniform updates
  19035. */
  19036. setArray2(name: string, value: number[]): ShaderMaterial;
  19037. /**
  19038. * Set a vec3 array in the shader from a number array.
  19039. * @param name Define the name of the uniform as defined in the shader
  19040. * @param value Define the value to give to the uniform
  19041. * @return the material itself allowing "fluent" like uniform updates
  19042. */
  19043. setArray3(name: string, value: number[]): ShaderMaterial;
  19044. /**
  19045. * Set a vec4 array in the shader from a number array.
  19046. * @param name Define the name of the uniform as defined in the shader
  19047. * @param value Define the value to give to the uniform
  19048. * @return the material itself allowing "fluent" like uniform updates
  19049. */
  19050. setArray4(name: string, value: number[]): ShaderMaterial;
  19051. private _checkCache;
  19052. /**
  19053. * Specifies that the submesh is ready to be used
  19054. * @param mesh defines the mesh to check
  19055. * @param subMesh defines which submesh to check
  19056. * @param useInstances specifies that instances should be used
  19057. * @returns a boolean indicating that the submesh is ready or not
  19058. */
  19059. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19060. /**
  19061. * Checks if the material is ready to render the requested mesh
  19062. * @param mesh Define the mesh to render
  19063. * @param useInstances Define whether or not the material is used with instances
  19064. * @returns true if ready, otherwise false
  19065. */
  19066. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19067. /**
  19068. * Binds the world matrix to the material
  19069. * @param world defines the world transformation matrix
  19070. */
  19071. bindOnlyWorldMatrix(world: Matrix): void;
  19072. /**
  19073. * Binds the material to the mesh
  19074. * @param world defines the world transformation matrix
  19075. * @param mesh defines the mesh to bind the material to
  19076. */
  19077. bind(world: Matrix, mesh?: Mesh): void;
  19078. /**
  19079. * Gets the active textures from the material
  19080. * @returns an array of textures
  19081. */
  19082. getActiveTextures(): BaseTexture[];
  19083. /**
  19084. * Specifies if the material uses a texture
  19085. * @param texture defines the texture to check against the material
  19086. * @returns a boolean specifying if the material uses the texture
  19087. */
  19088. hasTexture(texture: BaseTexture): boolean;
  19089. /**
  19090. * Makes a duplicate of the material, and gives it a new name
  19091. * @param name defines the new name for the duplicated material
  19092. * @returns the cloned material
  19093. */
  19094. clone(name: string): ShaderMaterial;
  19095. /**
  19096. * Disposes the material
  19097. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19098. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19099. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19100. */
  19101. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19102. /**
  19103. * Serializes this material in a JSON representation
  19104. * @returns the serialized material object
  19105. */
  19106. serialize(): any;
  19107. /**
  19108. * Creates a shader material from parsed shader material data
  19109. * @param source defines the JSON represnetation of the material
  19110. * @param scene defines the hosting scene
  19111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19112. * @returns a new material
  19113. */
  19114. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19115. }
  19116. }
  19117. declare module BABYLON {
  19118. /** @hidden */
  19119. export var colorPixelShader: {
  19120. name: string;
  19121. shader: string;
  19122. };
  19123. }
  19124. declare module BABYLON {
  19125. /** @hidden */
  19126. export var colorVertexShader: {
  19127. name: string;
  19128. shader: string;
  19129. };
  19130. }
  19131. declare module BABYLON {
  19132. /**
  19133. * Line mesh
  19134. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19135. */
  19136. export class LinesMesh extends Mesh {
  19137. /**
  19138. * If vertex color should be applied to the mesh
  19139. */
  19140. readonly useVertexColor?: boolean | undefined;
  19141. /**
  19142. * If vertex alpha should be applied to the mesh
  19143. */
  19144. readonly useVertexAlpha?: boolean | undefined;
  19145. /**
  19146. * Color of the line (Default: White)
  19147. */
  19148. color: Color3;
  19149. /**
  19150. * Alpha of the line (Default: 1)
  19151. */
  19152. alpha: number;
  19153. /**
  19154. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19155. * This margin is expressed in world space coordinates, so its value may vary.
  19156. * Default value is 0.1
  19157. */
  19158. intersectionThreshold: number;
  19159. private _colorShader;
  19160. private color4;
  19161. /**
  19162. * Creates a new LinesMesh
  19163. * @param name defines the name
  19164. * @param scene defines the hosting scene
  19165. * @param parent defines the parent mesh if any
  19166. * @param source defines the optional source LinesMesh used to clone data from
  19167. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19168. * When false, achieved by calling a clone(), also passing False.
  19169. * This will make creation of children, recursive.
  19170. * @param useVertexColor defines if this LinesMesh supports vertex color
  19171. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19172. */
  19173. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19174. /**
  19175. * If vertex color should be applied to the mesh
  19176. */
  19177. useVertexColor?: boolean | undefined,
  19178. /**
  19179. * If vertex alpha should be applied to the mesh
  19180. */
  19181. useVertexAlpha?: boolean | undefined);
  19182. private _addClipPlaneDefine;
  19183. private _removeClipPlaneDefine;
  19184. isReady(): boolean;
  19185. /**
  19186. * Returns the string "LineMesh"
  19187. */
  19188. getClassName(): string;
  19189. /**
  19190. * @hidden
  19191. */
  19192. /**
  19193. * @hidden
  19194. */
  19195. material: Material;
  19196. /**
  19197. * @hidden
  19198. */
  19199. readonly checkCollisions: boolean;
  19200. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19201. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19202. /**
  19203. * Disposes of the line mesh
  19204. * @param doNotRecurse If children should be disposed
  19205. */
  19206. dispose(doNotRecurse?: boolean): void;
  19207. /**
  19208. * Returns a new LineMesh object cloned from the current one.
  19209. */
  19210. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19211. /**
  19212. * Creates a new InstancedLinesMesh object from the mesh model.
  19213. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19214. * @param name defines the name of the new instance
  19215. * @returns a new InstancedLinesMesh
  19216. */
  19217. createInstance(name: string): InstancedLinesMesh;
  19218. }
  19219. /**
  19220. * Creates an instance based on a source LinesMesh
  19221. */
  19222. export class InstancedLinesMesh extends InstancedMesh {
  19223. /**
  19224. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19225. * This margin is expressed in world space coordinates, so its value may vary.
  19226. * Initilized with the intersectionThreshold value of the source LinesMesh
  19227. */
  19228. intersectionThreshold: number;
  19229. constructor(name: string, source: LinesMesh);
  19230. /**
  19231. * Returns the string "InstancedLinesMesh".
  19232. */
  19233. getClassName(): string;
  19234. }
  19235. }
  19236. declare module BABYLON {
  19237. /** @hidden */
  19238. export var linePixelShader: {
  19239. name: string;
  19240. shader: string;
  19241. };
  19242. }
  19243. declare module BABYLON {
  19244. /** @hidden */
  19245. export var lineVertexShader: {
  19246. name: string;
  19247. shader: string;
  19248. };
  19249. }
  19250. declare module BABYLON {
  19251. interface AbstractMesh {
  19252. /**
  19253. * Gets the edgesRenderer associated with the mesh
  19254. */
  19255. edgesRenderer: Nullable<EdgesRenderer>;
  19256. }
  19257. interface LinesMesh {
  19258. /**
  19259. * Enables the edge rendering mode on the mesh.
  19260. * This mode makes the mesh edges visible
  19261. * @param epsilon defines the maximal distance between two angles to detect a face
  19262. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19263. * @returns the currentAbstractMesh
  19264. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19265. */
  19266. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19267. }
  19268. interface InstancedLinesMesh {
  19269. /**
  19270. * Enables the edge rendering mode on the mesh.
  19271. * This mode makes the mesh edges visible
  19272. * @param epsilon defines the maximal distance between two angles to detect a face
  19273. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19274. * @returns the current InstancedLinesMesh
  19275. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19276. */
  19277. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19278. }
  19279. /**
  19280. * Defines the minimum contract an Edges renderer should follow.
  19281. */
  19282. export interface IEdgesRenderer extends IDisposable {
  19283. /**
  19284. * Gets or sets a boolean indicating if the edgesRenderer is active
  19285. */
  19286. isEnabled: boolean;
  19287. /**
  19288. * Renders the edges of the attached mesh,
  19289. */
  19290. render(): void;
  19291. /**
  19292. * Checks wether or not the edges renderer is ready to render.
  19293. * @return true if ready, otherwise false.
  19294. */
  19295. isReady(): boolean;
  19296. }
  19297. /**
  19298. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19299. */
  19300. export class EdgesRenderer implements IEdgesRenderer {
  19301. /**
  19302. * Define the size of the edges with an orthographic camera
  19303. */
  19304. edgesWidthScalerForOrthographic: number;
  19305. /**
  19306. * Define the size of the edges with a perspective camera
  19307. */
  19308. edgesWidthScalerForPerspective: number;
  19309. protected _source: AbstractMesh;
  19310. protected _linesPositions: number[];
  19311. protected _linesNormals: number[];
  19312. protected _linesIndices: number[];
  19313. protected _epsilon: number;
  19314. protected _indicesCount: number;
  19315. protected _lineShader: ShaderMaterial;
  19316. protected _ib: DataBuffer;
  19317. protected _buffers: {
  19318. [key: string]: Nullable<VertexBuffer>;
  19319. };
  19320. protected _checkVerticesInsteadOfIndices: boolean;
  19321. private _meshRebuildObserver;
  19322. private _meshDisposeObserver;
  19323. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19324. isEnabled: boolean;
  19325. /**
  19326. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19327. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19328. * @param source Mesh used to create edges
  19329. * @param epsilon sum of angles in adjacency to check for edge
  19330. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19331. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19332. */
  19333. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19334. protected _prepareRessources(): void;
  19335. /** @hidden */ private _rebuild(): void;
  19336. /**
  19337. * Releases the required resources for the edges renderer
  19338. */
  19339. dispose(): void;
  19340. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19341. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19342. /**
  19343. * Checks if the pair of p0 and p1 is en edge
  19344. * @param faceIndex
  19345. * @param edge
  19346. * @param faceNormals
  19347. * @param p0
  19348. * @param p1
  19349. * @private
  19350. */
  19351. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19352. /**
  19353. * push line into the position, normal and index buffer
  19354. * @protected
  19355. */
  19356. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19357. /**
  19358. * Generates lines edges from adjacencjes
  19359. * @private
  19360. */ private _generateEdgesLines(): void;
  19361. /**
  19362. * Checks wether or not the edges renderer is ready to render.
  19363. * @return true if ready, otherwise false.
  19364. */
  19365. isReady(): boolean;
  19366. /**
  19367. * Renders the edges of the attached mesh,
  19368. */
  19369. render(): void;
  19370. }
  19371. /**
  19372. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19373. */
  19374. export class LineEdgesRenderer extends EdgesRenderer {
  19375. /**
  19376. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19377. * @param source LineMesh used to generate edges
  19378. * @param epsilon not important (specified angle for edge detection)
  19379. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19380. */
  19381. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19382. /**
  19383. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19384. */ private _generateEdgesLines(): void;
  19385. }
  19386. }
  19387. declare module BABYLON {
  19388. /**
  19389. * This represents the object necessary to create a rendering group.
  19390. * This is exclusively used and created by the rendering manager.
  19391. * To modify the behavior, you use the available helpers in your scene or meshes.
  19392. * @hidden
  19393. */
  19394. export class RenderingGroup {
  19395. index: number;
  19396. private static _zeroVector;
  19397. private _scene;
  19398. private _opaqueSubMeshes;
  19399. private _transparentSubMeshes;
  19400. private _alphaTestSubMeshes;
  19401. private _depthOnlySubMeshes;
  19402. private _particleSystems;
  19403. private _spriteManagers;
  19404. private _opaqueSortCompareFn;
  19405. private _alphaTestSortCompareFn;
  19406. private _transparentSortCompareFn;
  19407. private _renderOpaque;
  19408. private _renderAlphaTest;
  19409. private _renderTransparent;
  19410. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19411. onBeforeTransparentRendering: () => void;
  19412. /**
  19413. * Set the opaque sort comparison function.
  19414. * If null the sub meshes will be render in the order they were created
  19415. */
  19416. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19417. /**
  19418. * Set the alpha test sort comparison function.
  19419. * If null the sub meshes will be render in the order they were created
  19420. */
  19421. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19422. /**
  19423. * Set the transparent sort comparison function.
  19424. * If null the sub meshes will be render in the order they were created
  19425. */
  19426. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19427. /**
  19428. * Creates a new rendering group.
  19429. * @param index The rendering group index
  19430. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19431. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19432. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19433. */
  19434. 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>);
  19435. /**
  19436. * Render all the sub meshes contained in the group.
  19437. * @param customRenderFunction Used to override the default render behaviour of the group.
  19438. * @returns true if rendered some submeshes.
  19439. */
  19440. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19441. /**
  19442. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19443. * @param subMeshes The submeshes to render
  19444. */
  19445. private renderOpaqueSorted;
  19446. /**
  19447. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19448. * @param subMeshes The submeshes to render
  19449. */
  19450. private renderAlphaTestSorted;
  19451. /**
  19452. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19453. * @param subMeshes The submeshes to render
  19454. */
  19455. private renderTransparentSorted;
  19456. /**
  19457. * Renders the submeshes in a specified order.
  19458. * @param subMeshes The submeshes to sort before render
  19459. * @param sortCompareFn The comparison function use to sort
  19460. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19461. * @param transparent Specifies to activate blending if true
  19462. */
  19463. private static renderSorted;
  19464. /**
  19465. * Renders the submeshes in the order they were dispatched (no sort applied).
  19466. * @param subMeshes The submeshes to render
  19467. */
  19468. private static renderUnsorted;
  19469. /**
  19470. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19471. * are rendered back to front if in the same alpha index.
  19472. *
  19473. * @param a The first submesh
  19474. * @param b The second submesh
  19475. * @returns The result of the comparison
  19476. */
  19477. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19478. /**
  19479. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19480. * are rendered back to front.
  19481. *
  19482. * @param a The first submesh
  19483. * @param b The second submesh
  19484. * @returns The result of the comparison
  19485. */
  19486. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19487. /**
  19488. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19489. * are rendered front to back (prevent overdraw).
  19490. *
  19491. * @param a The first submesh
  19492. * @param b The second submesh
  19493. * @returns The result of the comparison
  19494. */
  19495. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19496. /**
  19497. * Resets the different lists of submeshes to prepare a new frame.
  19498. */
  19499. prepare(): void;
  19500. dispose(): void;
  19501. /**
  19502. * Inserts the submesh in its correct queue depending on its material.
  19503. * @param subMesh The submesh to dispatch
  19504. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19505. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19506. */
  19507. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19508. dispatchSprites(spriteManager: ISpriteManager): void;
  19509. dispatchParticles(particleSystem: IParticleSystem): void;
  19510. private _renderParticles;
  19511. private _renderSprites;
  19512. }
  19513. }
  19514. declare module BABYLON {
  19515. /**
  19516. * Interface describing the different options available in the rendering manager
  19517. * regarding Auto Clear between groups.
  19518. */
  19519. export interface IRenderingManagerAutoClearSetup {
  19520. /**
  19521. * Defines whether or not autoclear is enable.
  19522. */
  19523. autoClear: boolean;
  19524. /**
  19525. * Defines whether or not to autoclear the depth buffer.
  19526. */
  19527. depth: boolean;
  19528. /**
  19529. * Defines whether or not to autoclear the stencil buffer.
  19530. */
  19531. stencil: boolean;
  19532. }
  19533. /**
  19534. * This class is used by the onRenderingGroupObservable
  19535. */
  19536. export class RenderingGroupInfo {
  19537. /**
  19538. * The Scene that being rendered
  19539. */
  19540. scene: Scene;
  19541. /**
  19542. * The camera currently used for the rendering pass
  19543. */
  19544. camera: Nullable<Camera>;
  19545. /**
  19546. * The ID of the renderingGroup being processed
  19547. */
  19548. renderingGroupId: number;
  19549. }
  19550. /**
  19551. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19552. * It is enable to manage the different groups as well as the different necessary sort functions.
  19553. * This should not be used directly aside of the few static configurations
  19554. */
  19555. export class RenderingManager {
  19556. /**
  19557. * The max id used for rendering groups (not included)
  19558. */
  19559. static MAX_RENDERINGGROUPS: number;
  19560. /**
  19561. * The min id used for rendering groups (included)
  19562. */
  19563. static MIN_RENDERINGGROUPS: number;
  19564. /**
  19565. * Used to globally prevent autoclearing scenes.
  19566. */
  19567. static AUTOCLEAR: boolean;
  19568. /**
  19569. * @hidden
  19570. */ private _useSceneAutoClearSetup: boolean;
  19571. private _scene;
  19572. private _renderingGroups;
  19573. private _depthStencilBufferAlreadyCleaned;
  19574. private _autoClearDepthStencil;
  19575. private _customOpaqueSortCompareFn;
  19576. private _customAlphaTestSortCompareFn;
  19577. private _customTransparentSortCompareFn;
  19578. private _renderingGroupInfo;
  19579. /**
  19580. * Instantiates a new rendering group for a particular scene
  19581. * @param scene Defines the scene the groups belongs to
  19582. */
  19583. constructor(scene: Scene);
  19584. private _clearDepthStencilBuffer;
  19585. /**
  19586. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19587. * @hidden
  19588. */
  19589. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19590. /**
  19591. * Resets the different information of the group to prepare a new frame
  19592. * @hidden
  19593. */
  19594. reset(): void;
  19595. /**
  19596. * Dispose and release the group and its associated resources.
  19597. * @hidden
  19598. */
  19599. dispose(): void;
  19600. /**
  19601. * Clear the info related to rendering groups preventing retention points during dispose.
  19602. */
  19603. freeRenderingGroups(): void;
  19604. private _prepareRenderingGroup;
  19605. /**
  19606. * Add a sprite manager to the rendering manager in order to render it this frame.
  19607. * @param spriteManager Define the sprite manager to render
  19608. */
  19609. dispatchSprites(spriteManager: ISpriteManager): void;
  19610. /**
  19611. * Add a particle system to the rendering manager in order to render it this frame.
  19612. * @param particleSystem Define the particle system to render
  19613. */
  19614. dispatchParticles(particleSystem: IParticleSystem): void;
  19615. /**
  19616. * Add a submesh to the manager in order to render it this frame
  19617. * @param subMesh The submesh to dispatch
  19618. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19619. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19620. */
  19621. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19622. /**
  19623. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19624. * This allowed control for front to back rendering or reversly depending of the special needs.
  19625. *
  19626. * @param renderingGroupId The rendering group id corresponding to its index
  19627. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19628. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19629. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19630. */
  19631. 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;
  19632. /**
  19633. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19634. *
  19635. * @param renderingGroupId The rendering group id corresponding to its index
  19636. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19637. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19638. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19639. */
  19640. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19641. /**
  19642. * Gets the current auto clear configuration for one rendering group of the rendering
  19643. * manager.
  19644. * @param index the rendering group index to get the information for
  19645. * @returns The auto clear setup for the requested rendering group
  19646. */
  19647. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19648. }
  19649. }
  19650. declare module BABYLON {
  19651. /**
  19652. * This Helps creating a texture that will be created from a camera in your scene.
  19653. * It is basically a dynamic texture that could be used to create special effects for instance.
  19654. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19655. */
  19656. export class RenderTargetTexture extends Texture {
  19657. isCube: boolean;
  19658. /**
  19659. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19660. */
  19661. static readonly REFRESHRATE_RENDER_ONCE: number;
  19662. /**
  19663. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19664. */
  19665. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19666. /**
  19667. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19668. * the central point of your effect and can save a lot of performances.
  19669. */
  19670. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19671. /**
  19672. * Use this predicate to dynamically define the list of mesh you want to render.
  19673. * If set, the renderList property will be overwritten.
  19674. */
  19675. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19676. private _renderList;
  19677. /**
  19678. * Use this list to define the list of mesh you want to render.
  19679. */
  19680. renderList: Nullable<Array<AbstractMesh>>;
  19681. private _hookArray;
  19682. /**
  19683. * Define if particles should be rendered in your texture.
  19684. */
  19685. renderParticles: boolean;
  19686. /**
  19687. * Define if sprites should be rendered in your texture.
  19688. */
  19689. renderSprites: boolean;
  19690. /**
  19691. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19692. */
  19693. coordinatesMode: number;
  19694. /**
  19695. * Define the camera used to render the texture.
  19696. */
  19697. activeCamera: Nullable<Camera>;
  19698. /**
  19699. * Override the render function of the texture with your own one.
  19700. */
  19701. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19702. /**
  19703. * Define if camera post processes should be use while rendering the texture.
  19704. */
  19705. useCameraPostProcesses: boolean;
  19706. /**
  19707. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19708. */
  19709. ignoreCameraViewport: boolean;
  19710. private _postProcessManager;
  19711. private _postProcesses;
  19712. private _resizeObserver;
  19713. /**
  19714. * An event triggered when the texture is unbind.
  19715. */
  19716. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19717. /**
  19718. * An event triggered when the texture is unbind.
  19719. */
  19720. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19721. private _onAfterUnbindObserver;
  19722. /**
  19723. * Set a after unbind callback in the texture.
  19724. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19725. */
  19726. onAfterUnbind: () => void;
  19727. /**
  19728. * An event triggered before rendering the texture
  19729. */
  19730. onBeforeRenderObservable: Observable<number>;
  19731. private _onBeforeRenderObserver;
  19732. /**
  19733. * Set a before render callback in the texture.
  19734. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19735. */
  19736. onBeforeRender: (faceIndex: number) => void;
  19737. /**
  19738. * An event triggered after rendering the texture
  19739. */
  19740. onAfterRenderObservable: Observable<number>;
  19741. private _onAfterRenderObserver;
  19742. /**
  19743. * Set a after render callback in the texture.
  19744. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19745. */
  19746. onAfterRender: (faceIndex: number) => void;
  19747. /**
  19748. * An event triggered after the texture clear
  19749. */
  19750. onClearObservable: Observable<Engine>;
  19751. private _onClearObserver;
  19752. /**
  19753. * Set a clear callback in the texture.
  19754. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19755. */
  19756. onClear: (Engine: Engine) => void;
  19757. /**
  19758. * An event triggered when the texture is resized.
  19759. */
  19760. onResizeObservable: Observable<RenderTargetTexture>;
  19761. /**
  19762. * Define the clear color of the Render Target if it should be different from the scene.
  19763. */
  19764. clearColor: Color4;
  19765. protected _size: number | {
  19766. width: number;
  19767. height: number;
  19768. };
  19769. protected _initialSizeParameter: number | {
  19770. width: number;
  19771. height: number;
  19772. } | {
  19773. ratio: number;
  19774. };
  19775. protected _sizeRatio: Nullable<number>;
  19776. /** @hidden */ private _generateMipMaps: boolean;
  19777. protected _renderingManager: RenderingManager;
  19778. /** @hidden */ private _waitingRenderList: string[];
  19779. protected _doNotChangeAspectRatio: boolean;
  19780. protected _currentRefreshId: number;
  19781. protected _refreshRate: number;
  19782. protected _textureMatrix: Matrix;
  19783. protected _samples: number;
  19784. protected _renderTargetOptions: RenderTargetCreationOptions;
  19785. /**
  19786. * Gets render target creation options that were used.
  19787. */
  19788. readonly renderTargetOptions: RenderTargetCreationOptions;
  19789. protected _engine: Engine;
  19790. protected _onRatioRescale(): void;
  19791. /**
  19792. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19793. * It must define where the camera used to render the texture is set
  19794. */
  19795. boundingBoxPosition: Vector3;
  19796. private _boundingBoxSize;
  19797. /**
  19798. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19799. * When defined, the cubemap will switch to local mode
  19800. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19801. * @example https://www.babylonjs-playground.com/#RNASML
  19802. */
  19803. boundingBoxSize: Vector3;
  19804. /**
  19805. * In case the RTT has been created with a depth texture, get the associated
  19806. * depth texture.
  19807. * Otherwise, return null.
  19808. */
  19809. depthStencilTexture: Nullable<InternalTexture>;
  19810. /**
  19811. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19812. * or used a shadow, depth texture...
  19813. * @param name The friendly name of the texture
  19814. * @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)
  19815. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19816. * @param generateMipMaps True if mip maps need to be generated after render.
  19817. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19818. * @param type The type of the buffer in the RTT (int, half float, float...)
  19819. * @param isCube True if a cube texture needs to be created
  19820. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19821. * @param generateDepthBuffer True to generate a depth buffer
  19822. * @param generateStencilBuffer True to generate a stencil buffer
  19823. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19824. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19825. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19826. */
  19827. constructor(name: string, size: number | {
  19828. width: number;
  19829. height: number;
  19830. } | {
  19831. ratio: number;
  19832. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19833. /**
  19834. * Creates a depth stencil texture.
  19835. * This is only available in WebGL 2 or with the depth texture extension available.
  19836. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19837. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19838. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19839. */
  19840. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19841. private _processSizeParameter;
  19842. /**
  19843. * Define the number of samples to use in case of MSAA.
  19844. * It defaults to one meaning no MSAA has been enabled.
  19845. */
  19846. samples: number;
  19847. /**
  19848. * Resets the refresh counter of the texture and start bak from scratch.
  19849. * Could be useful to regenerate the texture if it is setup to render only once.
  19850. */
  19851. resetRefreshCounter(): void;
  19852. /**
  19853. * Define the refresh rate of the texture or the rendering frequency.
  19854. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19855. */
  19856. refreshRate: number;
  19857. /**
  19858. * Adds a post process to the render target rendering passes.
  19859. * @param postProcess define the post process to add
  19860. */
  19861. addPostProcess(postProcess: PostProcess): void;
  19862. /**
  19863. * Clear all the post processes attached to the render target
  19864. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19865. */
  19866. clearPostProcesses(dispose?: boolean): void;
  19867. /**
  19868. * Remove one of the post process from the list of attached post processes to the texture
  19869. * @param postProcess define the post process to remove from the list
  19870. */
  19871. removePostProcess(postProcess: PostProcess): void;
  19872. /** @hidden */ private _shouldRender(): boolean;
  19873. /**
  19874. * Gets the actual render size of the texture.
  19875. * @returns the width of the render size
  19876. */
  19877. getRenderSize(): number;
  19878. /**
  19879. * Gets the actual render width of the texture.
  19880. * @returns the width of the render size
  19881. */
  19882. getRenderWidth(): number;
  19883. /**
  19884. * Gets the actual render height of the texture.
  19885. * @returns the height of the render size
  19886. */
  19887. getRenderHeight(): number;
  19888. /**
  19889. * Get if the texture can be rescaled or not.
  19890. */
  19891. readonly canRescale: boolean;
  19892. /**
  19893. * Resize the texture using a ratio.
  19894. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19895. */
  19896. scale(ratio: number): void;
  19897. /**
  19898. * Get the texture reflection matrix used to rotate/transform the reflection.
  19899. * @returns the reflection matrix
  19900. */
  19901. getReflectionTextureMatrix(): Matrix;
  19902. /**
  19903. * Resize the texture to a new desired size.
  19904. * Be carrefull as it will recreate all the data in the new texture.
  19905. * @param size Define the new size. It can be:
  19906. * - a number for squared texture,
  19907. * - an object containing { width: number, height: number }
  19908. * - or an object containing a ratio { ratio: number }
  19909. */
  19910. resize(size: number | {
  19911. width: number;
  19912. height: number;
  19913. } | {
  19914. ratio: number;
  19915. }): void;
  19916. /**
  19917. * Renders all the objects from the render list into the texture.
  19918. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19919. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19920. */
  19921. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19922. private _bestReflectionRenderTargetDimension;
  19923. /**
  19924. * @hidden
  19925. * @param faceIndex face index to bind to if this is a cubetexture
  19926. */ private _bindFrameBuffer(faceIndex?: number): void;
  19927. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19928. private renderToTarget;
  19929. /**
  19930. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19931. * This allowed control for front to back rendering or reversly depending of the special needs.
  19932. *
  19933. * @param renderingGroupId The rendering group id corresponding to its index
  19934. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19935. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19936. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19937. */
  19938. 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;
  19939. /**
  19940. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19941. *
  19942. * @param renderingGroupId The rendering group id corresponding to its index
  19943. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19944. */
  19945. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19946. /**
  19947. * Clones the texture.
  19948. * @returns the cloned texture
  19949. */
  19950. clone(): RenderTargetTexture;
  19951. /**
  19952. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19953. * @returns The JSON representation of the texture
  19954. */
  19955. serialize(): any;
  19956. /**
  19957. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19958. */
  19959. disposeFramebufferObjects(): void;
  19960. /**
  19961. * Dispose the texture and release its associated resources.
  19962. */
  19963. dispose(): void;
  19964. /** @hidden */ private _rebuild(): void;
  19965. /**
  19966. * Clear the info related to rendering groups preventing retention point in material dispose.
  19967. */
  19968. freeRenderingGroups(): void;
  19969. /**
  19970. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19971. * @returns the view count
  19972. */
  19973. getViewCount(): number;
  19974. }
  19975. }
  19976. declare module BABYLON {
  19977. /**
  19978. * Options for compiling materials.
  19979. */
  19980. export interface IMaterialCompilationOptions {
  19981. /**
  19982. * Defines whether clip planes are enabled.
  19983. */
  19984. clipPlane: boolean;
  19985. /**
  19986. * Defines whether instances are enabled.
  19987. */
  19988. useInstances: boolean;
  19989. }
  19990. /**
  19991. * Base class for the main features of a material in Babylon.js
  19992. */
  19993. export class Material implements IAnimatable {
  19994. /**
  19995. * Returns the triangle fill mode
  19996. */
  19997. static readonly TriangleFillMode: number;
  19998. /**
  19999. * Returns the wireframe mode
  20000. */
  20001. static readonly WireFrameFillMode: number;
  20002. /**
  20003. * Returns the point fill mode
  20004. */
  20005. static readonly PointFillMode: number;
  20006. /**
  20007. * Returns the point list draw mode
  20008. */
  20009. static readonly PointListDrawMode: number;
  20010. /**
  20011. * Returns the line list draw mode
  20012. */
  20013. static readonly LineListDrawMode: number;
  20014. /**
  20015. * Returns the line loop draw mode
  20016. */
  20017. static readonly LineLoopDrawMode: number;
  20018. /**
  20019. * Returns the line strip draw mode
  20020. */
  20021. static readonly LineStripDrawMode: number;
  20022. /**
  20023. * Returns the triangle strip draw mode
  20024. */
  20025. static readonly TriangleStripDrawMode: number;
  20026. /**
  20027. * Returns the triangle fan draw mode
  20028. */
  20029. static readonly TriangleFanDrawMode: number;
  20030. /**
  20031. * Stores the clock-wise side orientation
  20032. */
  20033. static readonly ClockWiseSideOrientation: number;
  20034. /**
  20035. * Stores the counter clock-wise side orientation
  20036. */
  20037. static readonly CounterClockWiseSideOrientation: number;
  20038. /**
  20039. * The dirty texture flag value
  20040. */
  20041. static readonly TextureDirtyFlag: number;
  20042. /**
  20043. * The dirty light flag value
  20044. */
  20045. static readonly LightDirtyFlag: number;
  20046. /**
  20047. * The dirty fresnel flag value
  20048. */
  20049. static readonly FresnelDirtyFlag: number;
  20050. /**
  20051. * The dirty attribute flag value
  20052. */
  20053. static readonly AttributesDirtyFlag: number;
  20054. /**
  20055. * The dirty misc flag value
  20056. */
  20057. static readonly MiscDirtyFlag: number;
  20058. /**
  20059. * The all dirty flag value
  20060. */
  20061. static readonly AllDirtyFlag: number;
  20062. /**
  20063. * The ID of the material
  20064. */
  20065. id: string;
  20066. /**
  20067. * Gets or sets the unique id of the material
  20068. */
  20069. uniqueId: number;
  20070. /**
  20071. * The name of the material
  20072. */
  20073. name: string;
  20074. /**
  20075. * Gets or sets user defined metadata
  20076. */
  20077. metadata: any;
  20078. /**
  20079. * For internal use only. Please do not use.
  20080. */
  20081. reservedDataStore: any;
  20082. /**
  20083. * Specifies if the ready state should be checked on each call
  20084. */
  20085. checkReadyOnEveryCall: boolean;
  20086. /**
  20087. * Specifies if the ready state should be checked once
  20088. */
  20089. checkReadyOnlyOnce: boolean;
  20090. /**
  20091. * The state of the material
  20092. */
  20093. state: string;
  20094. /**
  20095. * The alpha value of the material
  20096. */
  20097. protected _alpha: number;
  20098. /**
  20099. * List of inspectable custom properties (used by the Inspector)
  20100. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20101. */
  20102. inspectableCustomProperties: IInspectable[];
  20103. /**
  20104. * Sets the alpha value of the material
  20105. */
  20106. /**
  20107. * Gets the alpha value of the material
  20108. */
  20109. alpha: number;
  20110. /**
  20111. * Specifies if back face culling is enabled
  20112. */
  20113. protected _backFaceCulling: boolean;
  20114. /**
  20115. * Sets the back-face culling state
  20116. */
  20117. /**
  20118. * Gets the back-face culling state
  20119. */
  20120. backFaceCulling: boolean;
  20121. /**
  20122. * Stores the value for side orientation
  20123. */
  20124. sideOrientation: number;
  20125. /**
  20126. * Callback triggered when the material is compiled
  20127. */
  20128. onCompiled: Nullable<(effect: Effect) => void>;
  20129. /**
  20130. * Callback triggered when an error occurs
  20131. */
  20132. onError: Nullable<(effect: Effect, errors: string) => void>;
  20133. /**
  20134. * Callback triggered to get the render target textures
  20135. */
  20136. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20137. /**
  20138. * Gets a boolean indicating that current material needs to register RTT
  20139. */
  20140. readonly hasRenderTargetTextures: boolean;
  20141. /**
  20142. * Specifies if the material should be serialized
  20143. */
  20144. doNotSerialize: boolean;
  20145. /**
  20146. * @hidden
  20147. */ private _storeEffectOnSubMeshes: boolean;
  20148. /**
  20149. * Stores the animations for the material
  20150. */
  20151. animations: Nullable<Array<Animation>>;
  20152. /**
  20153. * An event triggered when the material is disposed
  20154. */
  20155. onDisposeObservable: Observable<Material>;
  20156. /**
  20157. * An observer which watches for dispose events
  20158. */
  20159. private _onDisposeObserver;
  20160. private _onUnBindObservable;
  20161. /**
  20162. * Called during a dispose event
  20163. */
  20164. onDispose: () => void;
  20165. private _onBindObservable;
  20166. /**
  20167. * An event triggered when the material is bound
  20168. */
  20169. readonly onBindObservable: Observable<AbstractMesh>;
  20170. /**
  20171. * An observer which watches for bind events
  20172. */
  20173. private _onBindObserver;
  20174. /**
  20175. * Called during a bind event
  20176. */
  20177. onBind: (Mesh: AbstractMesh) => void;
  20178. /**
  20179. * An event triggered when the material is unbound
  20180. */
  20181. readonly onUnBindObservable: Observable<Material>;
  20182. /**
  20183. * Stores the value of the alpha mode
  20184. */
  20185. private _alphaMode;
  20186. /**
  20187. * Sets the value of the alpha mode.
  20188. *
  20189. * | Value | Type | Description |
  20190. * | --- | --- | --- |
  20191. * | 0 | ALPHA_DISABLE | |
  20192. * | 1 | ALPHA_ADD | |
  20193. * | 2 | ALPHA_COMBINE | |
  20194. * | 3 | ALPHA_SUBTRACT | |
  20195. * | 4 | ALPHA_MULTIPLY | |
  20196. * | 5 | ALPHA_MAXIMIZED | |
  20197. * | 6 | ALPHA_ONEONE | |
  20198. * | 7 | ALPHA_PREMULTIPLIED | |
  20199. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20200. * | 9 | ALPHA_INTERPOLATE | |
  20201. * | 10 | ALPHA_SCREENMODE | |
  20202. *
  20203. */
  20204. /**
  20205. * Gets the value of the alpha mode
  20206. */
  20207. alphaMode: number;
  20208. /**
  20209. * Stores the state of the need depth pre-pass value
  20210. */
  20211. private _needDepthPrePass;
  20212. /**
  20213. * Sets the need depth pre-pass value
  20214. */
  20215. /**
  20216. * Gets the depth pre-pass value
  20217. */
  20218. needDepthPrePass: boolean;
  20219. /**
  20220. * Specifies if depth writing should be disabled
  20221. */
  20222. disableDepthWrite: boolean;
  20223. /**
  20224. * Specifies if depth writing should be forced
  20225. */
  20226. forceDepthWrite: boolean;
  20227. /**
  20228. * Specifies if there should be a separate pass for culling
  20229. */
  20230. separateCullingPass: boolean;
  20231. /**
  20232. * Stores the state specifing if fog should be enabled
  20233. */
  20234. private _fogEnabled;
  20235. /**
  20236. * Sets the state for enabling fog
  20237. */
  20238. /**
  20239. * Gets the value of the fog enabled state
  20240. */
  20241. fogEnabled: boolean;
  20242. /**
  20243. * Stores the size of points
  20244. */
  20245. pointSize: number;
  20246. /**
  20247. * Stores the z offset value
  20248. */
  20249. zOffset: number;
  20250. /**
  20251. * Gets a value specifying if wireframe mode is enabled
  20252. */
  20253. /**
  20254. * Sets the state of wireframe mode
  20255. */
  20256. wireframe: boolean;
  20257. /**
  20258. * Gets the value specifying if point clouds are enabled
  20259. */
  20260. /**
  20261. * Sets the state of point cloud mode
  20262. */
  20263. pointsCloud: boolean;
  20264. /**
  20265. * Gets the material fill mode
  20266. */
  20267. /**
  20268. * Sets the material fill mode
  20269. */
  20270. fillMode: number;
  20271. /**
  20272. * @hidden
  20273. * Stores the effects for the material
  20274. */ private _effect: Nullable<Effect>;
  20275. /**
  20276. * @hidden
  20277. * Specifies if the material was previously ready
  20278. */ private _wasPreviouslyReady: boolean;
  20279. /**
  20280. * Specifies if uniform buffers should be used
  20281. */
  20282. private _useUBO;
  20283. /**
  20284. * Stores a reference to the scene
  20285. */
  20286. private _scene;
  20287. /**
  20288. * Stores the fill mode state
  20289. */
  20290. private _fillMode;
  20291. /**
  20292. * Specifies if the depth write state should be cached
  20293. */
  20294. private _cachedDepthWriteState;
  20295. /**
  20296. * Stores the uniform buffer
  20297. */
  20298. protected _uniformBuffer: UniformBuffer;
  20299. /** @hidden */ private _indexInSceneMaterialArray: number;
  20300. /** @hidden */
  20301. meshMap: Nullable<{
  20302. [id: string]: AbstractMesh | undefined;
  20303. }>;
  20304. /**
  20305. * Creates a material instance
  20306. * @param name defines the name of the material
  20307. * @param scene defines the scene to reference
  20308. * @param doNotAdd specifies if the material should be added to the scene
  20309. */
  20310. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20311. /**
  20312. * Returns a string representation of the current material
  20313. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20314. * @returns a string with material information
  20315. */
  20316. toString(fullDetails?: boolean): string;
  20317. /**
  20318. * Gets the class name of the material
  20319. * @returns a string with the class name of the material
  20320. */
  20321. getClassName(): string;
  20322. /**
  20323. * Specifies if updates for the material been locked
  20324. */
  20325. readonly isFrozen: boolean;
  20326. /**
  20327. * Locks updates for the material
  20328. */
  20329. freeze(): void;
  20330. /**
  20331. * Unlocks updates for the material
  20332. */
  20333. unfreeze(): void;
  20334. /**
  20335. * Specifies if the material is ready to be used
  20336. * @param mesh defines the mesh to check
  20337. * @param useInstances specifies if instances should be used
  20338. * @returns a boolean indicating if the material is ready to be used
  20339. */
  20340. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20341. /**
  20342. * Specifies that the submesh is ready to be used
  20343. * @param mesh defines the mesh to check
  20344. * @param subMesh defines which submesh to check
  20345. * @param useInstances specifies that instances should be used
  20346. * @returns a boolean indicating that the submesh is ready or not
  20347. */
  20348. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20349. /**
  20350. * Returns the material effect
  20351. * @returns the effect associated with the material
  20352. */
  20353. getEffect(): Nullable<Effect>;
  20354. /**
  20355. * Returns the current scene
  20356. * @returns a Scene
  20357. */
  20358. getScene(): Scene;
  20359. /**
  20360. * Specifies if the material will require alpha blending
  20361. * @returns a boolean specifying if alpha blending is needed
  20362. */
  20363. needAlphaBlending(): boolean;
  20364. /**
  20365. * Specifies if the mesh will require alpha blending
  20366. * @param mesh defines the mesh to check
  20367. * @returns a boolean specifying if alpha blending is needed for the mesh
  20368. */
  20369. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20370. /**
  20371. * Specifies if this material should be rendered in alpha test mode
  20372. * @returns a boolean specifying if an alpha test is needed.
  20373. */
  20374. needAlphaTesting(): boolean;
  20375. /**
  20376. * Gets the texture used for the alpha test
  20377. * @returns the texture to use for alpha testing
  20378. */
  20379. getAlphaTestTexture(): Nullable<BaseTexture>;
  20380. /**
  20381. * Marks the material to indicate that it needs to be re-calculated
  20382. */
  20383. markDirty(): void;
  20384. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20385. /**
  20386. * Binds the material to the mesh
  20387. * @param world defines the world transformation matrix
  20388. * @param mesh defines the mesh to bind the material to
  20389. */
  20390. bind(world: Matrix, mesh?: Mesh): void;
  20391. /**
  20392. * Binds the submesh to the material
  20393. * @param world defines the world transformation matrix
  20394. * @param mesh defines the mesh containing the submesh
  20395. * @param subMesh defines the submesh to bind the material to
  20396. */
  20397. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20398. /**
  20399. * Binds the world matrix to the material
  20400. * @param world defines the world transformation matrix
  20401. */
  20402. bindOnlyWorldMatrix(world: Matrix): void;
  20403. /**
  20404. * Binds the scene's uniform buffer to the effect.
  20405. * @param effect defines the effect to bind to the scene uniform buffer
  20406. * @param sceneUbo defines the uniform buffer storing scene data
  20407. */
  20408. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20409. /**
  20410. * Binds the view matrix to the effect
  20411. * @param effect defines the effect to bind the view matrix to
  20412. */
  20413. bindView(effect: Effect): void;
  20414. /**
  20415. * Binds the view projection matrix to the effect
  20416. * @param effect defines the effect to bind the view projection matrix to
  20417. */
  20418. bindViewProjection(effect: Effect): void;
  20419. /**
  20420. * Specifies if material alpha testing should be turned on for the mesh
  20421. * @param mesh defines the mesh to check
  20422. */
  20423. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20424. /**
  20425. * Processes to execute after binding the material to a mesh
  20426. * @param mesh defines the rendered mesh
  20427. */
  20428. protected _afterBind(mesh?: Mesh): void;
  20429. /**
  20430. * Unbinds the material from the mesh
  20431. */
  20432. unbind(): void;
  20433. /**
  20434. * Gets the active textures from the material
  20435. * @returns an array of textures
  20436. */
  20437. getActiveTextures(): BaseTexture[];
  20438. /**
  20439. * Specifies if the material uses a texture
  20440. * @param texture defines the texture to check against the material
  20441. * @returns a boolean specifying if the material uses the texture
  20442. */
  20443. hasTexture(texture: BaseTexture): boolean;
  20444. /**
  20445. * Makes a duplicate of the material, and gives it a new name
  20446. * @param name defines the new name for the duplicated material
  20447. * @returns the cloned material
  20448. */
  20449. clone(name: string): Nullable<Material>;
  20450. /**
  20451. * Gets the meshes bound to the material
  20452. * @returns an array of meshes bound to the material
  20453. */
  20454. getBindedMeshes(): AbstractMesh[];
  20455. /**
  20456. * Force shader compilation
  20457. * @param mesh defines the mesh associated with this material
  20458. * @param onCompiled defines a function to execute once the material is compiled
  20459. * @param options defines the options to configure the compilation
  20460. * @param onError defines a function to execute if the material fails compiling
  20461. */
  20462. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20463. /**
  20464. * Force shader compilation
  20465. * @param mesh defines the mesh that will use this material
  20466. * @param options defines additional options for compiling the shaders
  20467. * @returns a promise that resolves when the compilation completes
  20468. */
  20469. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20470. private static readonly _AllDirtyCallBack;
  20471. private static readonly _ImageProcessingDirtyCallBack;
  20472. private static readonly _TextureDirtyCallBack;
  20473. private static readonly _FresnelDirtyCallBack;
  20474. private static readonly _MiscDirtyCallBack;
  20475. private static readonly _LightsDirtyCallBack;
  20476. private static readonly _AttributeDirtyCallBack;
  20477. private static _FresnelAndMiscDirtyCallBack;
  20478. private static _TextureAndMiscDirtyCallBack;
  20479. private static readonly _DirtyCallbackArray;
  20480. private static readonly _RunDirtyCallBacks;
  20481. /**
  20482. * Marks a define in the material to indicate that it needs to be re-computed
  20483. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20484. */
  20485. markAsDirty(flag: number): void;
  20486. /**
  20487. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20488. * @param func defines a function which checks material defines against the submeshes
  20489. */
  20490. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20491. /**
  20492. * Indicates that we need to re-calculated for all submeshes
  20493. */
  20494. protected _markAllSubMeshesAsAllDirty(): void;
  20495. /**
  20496. * Indicates that image processing needs to be re-calculated for all submeshes
  20497. */
  20498. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20499. /**
  20500. * Indicates that textures need to be re-calculated for all submeshes
  20501. */
  20502. protected _markAllSubMeshesAsTexturesDirty(): void;
  20503. /**
  20504. * Indicates that fresnel needs to be re-calculated for all submeshes
  20505. */
  20506. protected _markAllSubMeshesAsFresnelDirty(): void;
  20507. /**
  20508. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20509. */
  20510. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20511. /**
  20512. * Indicates that lights need to be re-calculated for all submeshes
  20513. */
  20514. protected _markAllSubMeshesAsLightsDirty(): void;
  20515. /**
  20516. * Indicates that attributes need to be re-calculated for all submeshes
  20517. */
  20518. protected _markAllSubMeshesAsAttributesDirty(): void;
  20519. /**
  20520. * Indicates that misc needs to be re-calculated for all submeshes
  20521. */
  20522. protected _markAllSubMeshesAsMiscDirty(): void;
  20523. /**
  20524. * Indicates that textures and misc need to be re-calculated for all submeshes
  20525. */
  20526. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20527. /**
  20528. * Disposes the material
  20529. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20530. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20531. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20532. */
  20533. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20534. /** @hidden */
  20535. private releaseVertexArrayObject;
  20536. /**
  20537. * Serializes this material
  20538. * @returns the serialized material object
  20539. */
  20540. serialize(): any;
  20541. /**
  20542. * Creates a material from parsed material data
  20543. * @param parsedMaterial defines parsed material data
  20544. * @param scene defines the hosting scene
  20545. * @param rootUrl defines the root URL to use to load textures
  20546. * @returns a new material
  20547. */
  20548. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20549. }
  20550. }
  20551. declare module BABYLON {
  20552. /**
  20553. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20554. * separate meshes. This can be use to improve performances.
  20555. * @see http://doc.babylonjs.com/how_to/multi_materials
  20556. */
  20557. export class MultiMaterial extends Material {
  20558. private _subMaterials;
  20559. /**
  20560. * Gets or Sets the list of Materials used within the multi material.
  20561. * They need to be ordered according to the submeshes order in the associated mesh
  20562. */
  20563. subMaterials: Nullable<Material>[];
  20564. /**
  20565. * Function used to align with Node.getChildren()
  20566. * @returns the list of Materials used within the multi material
  20567. */
  20568. getChildren(): Nullable<Material>[];
  20569. /**
  20570. * Instantiates a new Multi Material
  20571. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20572. * separate meshes. This can be use to improve performances.
  20573. * @see http://doc.babylonjs.com/how_to/multi_materials
  20574. * @param name Define the name in the scene
  20575. * @param scene Define the scene the material belongs to
  20576. */
  20577. constructor(name: string, scene: Scene);
  20578. private _hookArray;
  20579. /**
  20580. * Get one of the submaterial by its index in the submaterials array
  20581. * @param index The index to look the sub material at
  20582. * @returns The Material if the index has been defined
  20583. */
  20584. getSubMaterial(index: number): Nullable<Material>;
  20585. /**
  20586. * Get the list of active textures for the whole sub materials list.
  20587. * @returns All the textures that will be used during the rendering
  20588. */
  20589. getActiveTextures(): BaseTexture[];
  20590. /**
  20591. * Gets the current class name of the material e.g. "MultiMaterial"
  20592. * Mainly use in serialization.
  20593. * @returns the class name
  20594. */
  20595. getClassName(): string;
  20596. /**
  20597. * Checks if the material is ready to render the requested sub mesh
  20598. * @param mesh Define the mesh the submesh belongs to
  20599. * @param subMesh Define the sub mesh to look readyness for
  20600. * @param useInstances Define whether or not the material is used with instances
  20601. * @returns true if ready, otherwise false
  20602. */
  20603. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20604. /**
  20605. * Clones the current material and its related sub materials
  20606. * @param name Define the name of the newly cloned material
  20607. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20608. * @returns the cloned material
  20609. */
  20610. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20611. /**
  20612. * Serializes the materials into a JSON representation.
  20613. * @returns the JSON representation
  20614. */
  20615. serialize(): any;
  20616. /**
  20617. * Dispose the material and release its associated resources
  20618. * @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)
  20619. * @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)
  20620. * @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)
  20621. */
  20622. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20623. /**
  20624. * Creates a MultiMaterial from parsed MultiMaterial data.
  20625. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20626. * @param scene defines the hosting scene
  20627. * @returns a new MultiMaterial
  20628. */
  20629. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20630. }
  20631. }
  20632. declare module BABYLON {
  20633. /**
  20634. * Base class for submeshes
  20635. */
  20636. export class BaseSubMesh {
  20637. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20638. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20639. /**
  20640. * Gets associated effect
  20641. */
  20642. readonly effect: Nullable<Effect>;
  20643. /**
  20644. * Sets associated effect (effect used to render this submesh)
  20645. * @param effect defines the effect to associate with
  20646. * @param defines defines the set of defines used to compile this effect
  20647. */
  20648. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20649. }
  20650. /**
  20651. * Defines a subdivision inside a mesh
  20652. */
  20653. export class SubMesh extends BaseSubMesh implements ICullable {
  20654. /** the material index to use */
  20655. materialIndex: number;
  20656. /** vertex index start */
  20657. verticesStart: number;
  20658. /** vertices count */
  20659. verticesCount: number;
  20660. /** index start */
  20661. indexStart: number;
  20662. /** indices count */
  20663. indexCount: number;
  20664. /** @hidden */ private _linesIndexCount: number;
  20665. private _mesh;
  20666. private _renderingMesh;
  20667. private _boundingInfo;
  20668. private _linesIndexBuffer;
  20669. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20670. /** @hidden */ private _trianglePlanes: Plane[];
  20671. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20672. /** @hidden */ private _renderId: number;
  20673. /** @hidden */ private _alphaIndex: number;
  20674. /** @hidden */ private _distanceToCamera: number;
  20675. /** @hidden */ private _id: number;
  20676. private _currentMaterial;
  20677. /**
  20678. * Add a new submesh to a mesh
  20679. * @param materialIndex defines the material index to use
  20680. * @param verticesStart defines vertex index start
  20681. * @param verticesCount defines vertices count
  20682. * @param indexStart defines index start
  20683. * @param indexCount defines indices count
  20684. * @param mesh defines the parent mesh
  20685. * @param renderingMesh defines an optional rendering mesh
  20686. * @param createBoundingBox defines if bounding box should be created for this submesh
  20687. * @returns the new submesh
  20688. */
  20689. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20690. /**
  20691. * Creates a new submesh
  20692. * @param materialIndex defines the material index to use
  20693. * @param verticesStart defines vertex index start
  20694. * @param verticesCount defines vertices count
  20695. * @param indexStart defines index start
  20696. * @param indexCount defines indices count
  20697. * @param mesh defines the parent mesh
  20698. * @param renderingMesh defines an optional rendering mesh
  20699. * @param createBoundingBox defines if bounding box should be created for this submesh
  20700. */
  20701. constructor(
  20702. /** the material index to use */
  20703. materialIndex: number,
  20704. /** vertex index start */
  20705. verticesStart: number,
  20706. /** vertices count */
  20707. verticesCount: number,
  20708. /** index start */
  20709. indexStart: number,
  20710. /** indices count */
  20711. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20712. /**
  20713. * Returns true if this submesh covers the entire parent mesh
  20714. * @ignorenaming
  20715. */
  20716. readonly IsGlobal: boolean;
  20717. /**
  20718. * Returns the submesh BoudingInfo object
  20719. * @returns current bounding info (or mesh's one if the submesh is global)
  20720. */
  20721. getBoundingInfo(): BoundingInfo;
  20722. /**
  20723. * Sets the submesh BoundingInfo
  20724. * @param boundingInfo defines the new bounding info to use
  20725. * @returns the SubMesh
  20726. */
  20727. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20728. /**
  20729. * Returns the mesh of the current submesh
  20730. * @return the parent mesh
  20731. */
  20732. getMesh(): AbstractMesh;
  20733. /**
  20734. * Returns the rendering mesh of the submesh
  20735. * @returns the rendering mesh (could be different from parent mesh)
  20736. */
  20737. getRenderingMesh(): Mesh;
  20738. /**
  20739. * Returns the submesh material
  20740. * @returns null or the current material
  20741. */
  20742. getMaterial(): Nullable<Material>;
  20743. /**
  20744. * Sets a new updated BoundingInfo object to the submesh
  20745. * @param data defines an optional position array to use to determine the bounding info
  20746. * @returns the SubMesh
  20747. */
  20748. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20749. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20750. /**
  20751. * Updates the submesh BoundingInfo
  20752. * @param world defines the world matrix to use to update the bounding info
  20753. * @returns the submesh
  20754. */
  20755. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20756. /**
  20757. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20758. * @param frustumPlanes defines the frustum planes
  20759. * @returns true if the submesh is intersecting with the frustum
  20760. */
  20761. isInFrustum(frustumPlanes: Plane[]): boolean;
  20762. /**
  20763. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20764. * @param frustumPlanes defines the frustum planes
  20765. * @returns true if the submesh is inside the frustum
  20766. */
  20767. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20768. /**
  20769. * Renders the submesh
  20770. * @param enableAlphaMode defines if alpha needs to be used
  20771. * @returns the submesh
  20772. */
  20773. render(enableAlphaMode: boolean): SubMesh;
  20774. /**
  20775. * @hidden
  20776. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20777. /**
  20778. * Checks if the submesh intersects with a ray
  20779. * @param ray defines the ray to test
  20780. * @returns true is the passed ray intersects the submesh bounding box
  20781. */
  20782. canIntersects(ray: Ray): boolean;
  20783. /**
  20784. * Intersects current submesh with a ray
  20785. * @param ray defines the ray to test
  20786. * @param positions defines mesh's positions array
  20787. * @param indices defines mesh's indices array
  20788. * @param fastCheck defines if only bounding info should be used
  20789. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20790. * @returns intersection info or null if no intersection
  20791. */
  20792. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20793. /** @hidden */
  20794. private _intersectLines;
  20795. /** @hidden */
  20796. private _intersectUnIndexedLines;
  20797. /** @hidden */
  20798. private _intersectTriangles;
  20799. /** @hidden */
  20800. private _intersectUnIndexedTriangles;
  20801. /** @hidden */ private _rebuild(): void;
  20802. /**
  20803. * Creates a new submesh from the passed mesh
  20804. * @param newMesh defines the new hosting mesh
  20805. * @param newRenderingMesh defines an optional rendering mesh
  20806. * @returns the new submesh
  20807. */
  20808. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20809. /**
  20810. * Release associated resources
  20811. */
  20812. dispose(): void;
  20813. /**
  20814. * Gets the class name
  20815. * @returns the string "SubMesh".
  20816. */
  20817. getClassName(): string;
  20818. /**
  20819. * Creates a new submesh from indices data
  20820. * @param materialIndex the index of the main mesh material
  20821. * @param startIndex the index where to start the copy in the mesh indices array
  20822. * @param indexCount the number of indices to copy then from the startIndex
  20823. * @param mesh the main mesh to create the submesh from
  20824. * @param renderingMesh the optional rendering mesh
  20825. * @returns a new submesh
  20826. */
  20827. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20828. }
  20829. }
  20830. declare module BABYLON {
  20831. /**
  20832. * Class used to represent data loading progression
  20833. */
  20834. export class SceneLoaderFlags {
  20835. private static _ForceFullSceneLoadingForIncremental;
  20836. private static _ShowLoadingScreen;
  20837. private static _CleanBoneMatrixWeights;
  20838. private static _loggingLevel;
  20839. /**
  20840. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20841. */
  20842. static ForceFullSceneLoadingForIncremental: boolean;
  20843. /**
  20844. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20845. */
  20846. static ShowLoadingScreen: boolean;
  20847. /**
  20848. * Defines the current logging level (while loading the scene)
  20849. * @ignorenaming
  20850. */
  20851. static loggingLevel: number;
  20852. /**
  20853. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20854. */
  20855. static CleanBoneMatrixWeights: boolean;
  20856. }
  20857. }
  20858. declare module BABYLON {
  20859. /**
  20860. * Class used to store geometry data (vertex buffers + index buffer)
  20861. */
  20862. export class Geometry implements IGetSetVerticesData {
  20863. /**
  20864. * Gets or sets the ID of the geometry
  20865. */
  20866. id: string;
  20867. /**
  20868. * Gets or sets the unique ID of the geometry
  20869. */
  20870. uniqueId: number;
  20871. /**
  20872. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20873. */
  20874. delayLoadState: number;
  20875. /**
  20876. * Gets the file containing the data to load when running in delay load state
  20877. */
  20878. delayLoadingFile: Nullable<string>;
  20879. /**
  20880. * Callback called when the geometry is updated
  20881. */
  20882. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20883. private _scene;
  20884. private _engine;
  20885. private _meshes;
  20886. private _totalVertices;
  20887. /** @hidden */ private _indices: IndicesArray;
  20888. /** @hidden */ private _vertexBuffers: {
  20889. [key: string]: VertexBuffer;
  20890. };
  20891. private _isDisposed;
  20892. private _extend;
  20893. private _boundingBias;
  20894. /** @hidden */ private _delayInfo: Array<string>;
  20895. private _indexBuffer;
  20896. private _indexBufferIsUpdatable;
  20897. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20898. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20899. /** @hidden */ private _softwareSkinningFrameId: number;
  20900. private _vertexArrayObjects;
  20901. private _updatable;
  20902. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20903. /**
  20904. * 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
  20905. */
  20906. /**
  20907. * 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
  20908. */
  20909. boundingBias: Vector2;
  20910. /**
  20911. * Static function used to attach a new empty geometry to a mesh
  20912. * @param mesh defines the mesh to attach the geometry to
  20913. * @returns the new Geometry
  20914. */
  20915. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20916. /**
  20917. * Creates a new geometry
  20918. * @param id defines the unique ID
  20919. * @param scene defines the hosting scene
  20920. * @param vertexData defines the VertexData used to get geometry data
  20921. * @param updatable defines if geometry must be updatable (false by default)
  20922. * @param mesh defines the mesh that will be associated with the geometry
  20923. */
  20924. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20925. /**
  20926. * Gets the current extend of the geometry
  20927. */
  20928. readonly extend: {
  20929. minimum: Vector3;
  20930. maximum: Vector3;
  20931. };
  20932. /**
  20933. * Gets the hosting scene
  20934. * @returns the hosting Scene
  20935. */
  20936. getScene(): Scene;
  20937. /**
  20938. * Gets the hosting engine
  20939. * @returns the hosting Engine
  20940. */
  20941. getEngine(): Engine;
  20942. /**
  20943. * Defines if the geometry is ready to use
  20944. * @returns true if the geometry is ready to be used
  20945. */
  20946. isReady(): boolean;
  20947. /**
  20948. * Gets a value indicating that the geometry should not be serialized
  20949. */
  20950. readonly doNotSerialize: boolean;
  20951. /** @hidden */ private _rebuild(): void;
  20952. /**
  20953. * Affects all geometry data in one call
  20954. * @param vertexData defines the geometry data
  20955. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20956. */
  20957. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20958. /**
  20959. * Set specific vertex data
  20960. * @param kind defines the data kind (Position, normal, etc...)
  20961. * @param data defines the vertex data to use
  20962. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20963. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20964. */
  20965. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20966. /**
  20967. * Removes a specific vertex data
  20968. * @param kind defines the data kind (Position, normal, etc...)
  20969. */
  20970. removeVerticesData(kind: string): void;
  20971. /**
  20972. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20973. * @param buffer defines the vertex buffer to use
  20974. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20975. */
  20976. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20977. /**
  20978. * Update a specific vertex buffer
  20979. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20980. * It will do nothing if the buffer is not updatable
  20981. * @param kind defines the data kind (Position, normal, etc...)
  20982. * @param data defines the data to use
  20983. * @param offset defines the offset in the target buffer where to store the data
  20984. * @param useBytes set to true if the offset is in bytes
  20985. */
  20986. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20987. /**
  20988. * Update a specific vertex buffer
  20989. * This function will create a new buffer if the current one is not updatable
  20990. * @param kind defines the data kind (Position, normal, etc...)
  20991. * @param data defines the data to use
  20992. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20993. */
  20994. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20995. private _updateBoundingInfo;
  20996. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20997. /**
  20998. * Gets total number of vertices
  20999. * @returns the total number of vertices
  21000. */
  21001. getTotalVertices(): number;
  21002. /**
  21003. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21004. * @param kind defines the data kind (Position, normal, etc...)
  21005. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21006. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21007. * @returns a float array containing vertex data
  21008. */
  21009. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21010. /**
  21011. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21012. * @param kind defines the data kind (Position, normal, etc...)
  21013. * @returns true if the vertex buffer with the specified kind is updatable
  21014. */
  21015. isVertexBufferUpdatable(kind: string): boolean;
  21016. /**
  21017. * Gets a specific vertex buffer
  21018. * @param kind defines the data kind (Position, normal, etc...)
  21019. * @returns a VertexBuffer
  21020. */
  21021. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21022. /**
  21023. * Returns all vertex buffers
  21024. * @return an object holding all vertex buffers indexed by kind
  21025. */
  21026. getVertexBuffers(): Nullable<{
  21027. [key: string]: VertexBuffer;
  21028. }>;
  21029. /**
  21030. * Gets a boolean indicating if specific vertex buffer is present
  21031. * @param kind defines the data kind (Position, normal, etc...)
  21032. * @returns true if data is present
  21033. */
  21034. isVerticesDataPresent(kind: string): boolean;
  21035. /**
  21036. * Gets a list of all attached data kinds (Position, normal, etc...)
  21037. * @returns a list of string containing all kinds
  21038. */
  21039. getVerticesDataKinds(): string[];
  21040. /**
  21041. * Update index buffer
  21042. * @param indices defines the indices to store in the index buffer
  21043. * @param offset defines the offset in the target buffer where to store the data
  21044. * @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)
  21045. */
  21046. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21047. /**
  21048. * Creates a new index buffer
  21049. * @param indices defines the indices to store in the index buffer
  21050. * @param totalVertices defines the total number of vertices (could be null)
  21051. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21052. */
  21053. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21054. /**
  21055. * Return the total number of indices
  21056. * @returns the total number of indices
  21057. */
  21058. getTotalIndices(): number;
  21059. /**
  21060. * Gets the index buffer array
  21061. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21062. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21063. * @returns the index buffer array
  21064. */
  21065. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21066. /**
  21067. * Gets the index buffer
  21068. * @return the index buffer
  21069. */
  21070. getIndexBuffer(): Nullable<DataBuffer>;
  21071. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21072. /**
  21073. * Release the associated resources for a specific mesh
  21074. * @param mesh defines the source mesh
  21075. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21076. */
  21077. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21078. /**
  21079. * Apply current geometry to a given mesh
  21080. * @param mesh defines the mesh to apply geometry to
  21081. */
  21082. applyToMesh(mesh: Mesh): void;
  21083. private _updateExtend;
  21084. private _applyToMesh;
  21085. private notifyUpdate;
  21086. /**
  21087. * Load the geometry if it was flagged as delay loaded
  21088. * @param scene defines the hosting scene
  21089. * @param onLoaded defines a callback called when the geometry is loaded
  21090. */
  21091. load(scene: Scene, onLoaded?: () => void): void;
  21092. private _queueLoad;
  21093. /**
  21094. * Invert the geometry to move from a right handed system to a left handed one.
  21095. */
  21096. toLeftHanded(): void;
  21097. /** @hidden */ private _resetPointsArrayCache(): void;
  21098. /** @hidden */ private _generatePointsArray(): boolean;
  21099. /**
  21100. * Gets a value indicating if the geometry is disposed
  21101. * @returns true if the geometry was disposed
  21102. */
  21103. isDisposed(): boolean;
  21104. private _disposeVertexArrayObjects;
  21105. /**
  21106. * Free all associated resources
  21107. */
  21108. dispose(): void;
  21109. /**
  21110. * Clone the current geometry into a new geometry
  21111. * @param id defines the unique ID of the new geometry
  21112. * @returns a new geometry object
  21113. */
  21114. copy(id: string): Geometry;
  21115. /**
  21116. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21117. * @return a JSON representation of the current geometry data (without the vertices data)
  21118. */
  21119. serialize(): any;
  21120. private toNumberArray;
  21121. /**
  21122. * Serialize all vertices data into a JSON oject
  21123. * @returns a JSON representation of the current geometry data
  21124. */
  21125. serializeVerticeData(): any;
  21126. /**
  21127. * Extracts a clone of a mesh geometry
  21128. * @param mesh defines the source mesh
  21129. * @param id defines the unique ID of the new geometry object
  21130. * @returns the new geometry object
  21131. */
  21132. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21133. /**
  21134. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21135. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21136. * Be aware Math.random() could cause collisions, but:
  21137. * "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"
  21138. * @returns a string containing a new GUID
  21139. */
  21140. static RandomId(): string;
  21141. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21142. private static _CleanMatricesWeights;
  21143. /**
  21144. * Create a new geometry from persisted data (Using .babylon file format)
  21145. * @param parsedVertexData defines the persisted data
  21146. * @param scene defines the hosting scene
  21147. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21148. * @returns the new geometry object
  21149. */
  21150. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21151. }
  21152. }
  21153. declare module BABYLON {
  21154. /**
  21155. * Define an interface for all classes that will get and set the data on vertices
  21156. */
  21157. export interface IGetSetVerticesData {
  21158. /**
  21159. * Gets a boolean indicating if specific vertex data is present
  21160. * @param kind defines the vertex data kind to use
  21161. * @returns true is data kind is present
  21162. */
  21163. isVerticesDataPresent(kind: string): boolean;
  21164. /**
  21165. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21166. * @param kind defines the data kind (Position, normal, etc...)
  21167. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21168. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21169. * @returns a float array containing vertex data
  21170. */
  21171. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21172. /**
  21173. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21174. * @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.
  21175. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21176. * @returns the indices array or an empty array if the mesh has no geometry
  21177. */
  21178. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21179. /**
  21180. * Set specific vertex data
  21181. * @param kind defines the data kind (Position, normal, etc...)
  21182. * @param data defines the vertex data to use
  21183. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21184. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21185. */
  21186. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21187. /**
  21188. * Update a specific associated vertex buffer
  21189. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21190. * - VertexBuffer.PositionKind
  21191. * - VertexBuffer.UVKind
  21192. * - VertexBuffer.UV2Kind
  21193. * - VertexBuffer.UV3Kind
  21194. * - VertexBuffer.UV4Kind
  21195. * - VertexBuffer.UV5Kind
  21196. * - VertexBuffer.UV6Kind
  21197. * - VertexBuffer.ColorKind
  21198. * - VertexBuffer.MatricesIndicesKind
  21199. * - VertexBuffer.MatricesIndicesExtraKind
  21200. * - VertexBuffer.MatricesWeightsKind
  21201. * - VertexBuffer.MatricesWeightsExtraKind
  21202. * @param data defines the data source
  21203. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21204. * @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)
  21205. */
  21206. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21207. /**
  21208. * Creates a new index buffer
  21209. * @param indices defines the indices to store in the index buffer
  21210. * @param totalVertices defines the total number of vertices (could be null)
  21211. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21212. */
  21213. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21214. }
  21215. /**
  21216. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21217. */
  21218. export class VertexData {
  21219. /**
  21220. * Mesh side orientation : usually the external or front surface
  21221. */
  21222. static readonly FRONTSIDE: number;
  21223. /**
  21224. * Mesh side orientation : usually the internal or back surface
  21225. */
  21226. static readonly BACKSIDE: number;
  21227. /**
  21228. * Mesh side orientation : both internal and external or front and back surfaces
  21229. */
  21230. static readonly DOUBLESIDE: number;
  21231. /**
  21232. * Mesh side orientation : by default, `FRONTSIDE`
  21233. */
  21234. static readonly DEFAULTSIDE: number;
  21235. /**
  21236. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21237. */
  21238. positions: Nullable<FloatArray>;
  21239. /**
  21240. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21241. */
  21242. normals: Nullable<FloatArray>;
  21243. /**
  21244. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21245. */
  21246. tangents: Nullable<FloatArray>;
  21247. /**
  21248. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21249. */
  21250. uvs: Nullable<FloatArray>;
  21251. /**
  21252. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21253. */
  21254. uvs2: Nullable<FloatArray>;
  21255. /**
  21256. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21257. */
  21258. uvs3: Nullable<FloatArray>;
  21259. /**
  21260. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21261. */
  21262. uvs4: Nullable<FloatArray>;
  21263. /**
  21264. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21265. */
  21266. uvs5: Nullable<FloatArray>;
  21267. /**
  21268. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21269. */
  21270. uvs6: Nullable<FloatArray>;
  21271. /**
  21272. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21273. */
  21274. colors: Nullable<FloatArray>;
  21275. /**
  21276. * 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).
  21277. */
  21278. matricesIndices: Nullable<FloatArray>;
  21279. /**
  21280. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21281. */
  21282. matricesWeights: Nullable<FloatArray>;
  21283. /**
  21284. * An array extending the number of possible indices
  21285. */
  21286. matricesIndicesExtra: Nullable<FloatArray>;
  21287. /**
  21288. * An array extending the number of possible weights when the number of indices is extended
  21289. */
  21290. matricesWeightsExtra: Nullable<FloatArray>;
  21291. /**
  21292. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21293. */
  21294. indices: Nullable<IndicesArray>;
  21295. /**
  21296. * Uses the passed data array to set the set the values for the specified kind of data
  21297. * @param data a linear array of floating numbers
  21298. * @param kind the type of data that is being set, eg positions, colors etc
  21299. */
  21300. set(data: FloatArray, kind: string): void;
  21301. /**
  21302. * Associates the vertexData to the passed Mesh.
  21303. * Sets it as updatable or not (default `false`)
  21304. * @param mesh the mesh the vertexData is applied to
  21305. * @param updatable when used and having the value true allows new data to update the vertexData
  21306. * @returns the VertexData
  21307. */
  21308. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21309. /**
  21310. * Associates the vertexData to the passed Geometry.
  21311. * Sets it as updatable or not (default `false`)
  21312. * @param geometry the geometry the vertexData is applied to
  21313. * @param updatable when used and having the value true allows new data to update the vertexData
  21314. * @returns VertexData
  21315. */
  21316. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21317. /**
  21318. * Updates the associated mesh
  21319. * @param mesh the mesh to be updated
  21320. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21321. * @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
  21322. * @returns VertexData
  21323. */
  21324. updateMesh(mesh: Mesh): VertexData;
  21325. /**
  21326. * Updates the associated geometry
  21327. * @param geometry the geometry to be updated
  21328. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21329. * @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
  21330. * @returns VertexData.
  21331. */
  21332. updateGeometry(geometry: Geometry): VertexData;
  21333. private _applyTo;
  21334. private _update;
  21335. /**
  21336. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21337. * @param matrix the transforming matrix
  21338. * @returns the VertexData
  21339. */
  21340. transform(matrix: Matrix): VertexData;
  21341. /**
  21342. * Merges the passed VertexData into the current one
  21343. * @param other the VertexData to be merged into the current one
  21344. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21345. * @returns the modified VertexData
  21346. */
  21347. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21348. private _mergeElement;
  21349. private _validate;
  21350. /**
  21351. * Serializes the VertexData
  21352. * @returns a serialized object
  21353. */
  21354. serialize(): any;
  21355. /**
  21356. * Extracts the vertexData from a mesh
  21357. * @param mesh the mesh from which to extract the VertexData
  21358. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21359. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21360. * @returns the object VertexData associated to the passed mesh
  21361. */
  21362. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21363. /**
  21364. * Extracts the vertexData from the geometry
  21365. * @param geometry the geometry from which to extract the VertexData
  21366. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21367. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21368. * @returns the object VertexData associated to the passed mesh
  21369. */
  21370. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21371. private static _ExtractFrom;
  21372. /**
  21373. * Creates the VertexData for a Ribbon
  21374. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21375. * * pathArray array of paths, each of which an array of successive Vector3
  21376. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21377. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21378. * * 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
  21379. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21380. * * 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)
  21381. * * 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)
  21382. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21383. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21384. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21385. * @returns the VertexData of the ribbon
  21386. */
  21387. static CreateRibbon(options: {
  21388. pathArray: Vector3[][];
  21389. closeArray?: boolean;
  21390. closePath?: boolean;
  21391. offset?: number;
  21392. sideOrientation?: number;
  21393. frontUVs?: Vector4;
  21394. backUVs?: Vector4;
  21395. invertUV?: boolean;
  21396. uvs?: Vector2[];
  21397. colors?: Color4[];
  21398. }): VertexData;
  21399. /**
  21400. * Creates the VertexData for a box
  21401. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21402. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21403. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21404. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21405. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21406. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21407. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21409. * * 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)
  21410. * * 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)
  21411. * @returns the VertexData of the box
  21412. */
  21413. static CreateBox(options: {
  21414. size?: number;
  21415. width?: number;
  21416. height?: number;
  21417. depth?: number;
  21418. faceUV?: Vector4[];
  21419. faceColors?: Color4[];
  21420. sideOrientation?: number;
  21421. frontUVs?: Vector4;
  21422. backUVs?: Vector4;
  21423. }): VertexData;
  21424. /**
  21425. * Creates the VertexData for a tiled box
  21426. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21427. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21428. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21429. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21430. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21431. * @returns the VertexData of the box
  21432. */
  21433. static CreateTiledBox(options: {
  21434. pattern?: number;
  21435. width?: number;
  21436. height?: number;
  21437. depth?: number;
  21438. tileSize?: number;
  21439. tileWidth?: number;
  21440. tileHeight?: number;
  21441. alignHorizontal?: number;
  21442. alignVertical?: number;
  21443. faceUV?: Vector4[];
  21444. faceColors?: Color4[];
  21445. sideOrientation?: number;
  21446. }): VertexData;
  21447. /**
  21448. * Creates the VertexData for a tiled plane
  21449. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21450. * * pattern a limited pattern arrangement depending on the number
  21451. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21452. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21453. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21455. * * 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)
  21456. * * 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)
  21457. * @returns the VertexData of the tiled plane
  21458. */
  21459. static CreateTiledPlane(options: {
  21460. pattern?: number;
  21461. tileSize?: number;
  21462. tileWidth?: number;
  21463. tileHeight?: number;
  21464. size?: number;
  21465. width?: number;
  21466. height?: number;
  21467. alignHorizontal?: number;
  21468. alignVertical?: number;
  21469. sideOrientation?: number;
  21470. frontUVs?: Vector4;
  21471. backUVs?: Vector4;
  21472. }): VertexData;
  21473. /**
  21474. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21475. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21476. * * segments sets the number of horizontal strips optional, default 32
  21477. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21478. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21479. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21480. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21481. * * 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
  21482. * * 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
  21483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21484. * * 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)
  21485. * * 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)
  21486. * @returns the VertexData of the ellipsoid
  21487. */
  21488. static CreateSphere(options: {
  21489. segments?: number;
  21490. diameter?: number;
  21491. diameterX?: number;
  21492. diameterY?: number;
  21493. diameterZ?: number;
  21494. arc?: number;
  21495. slice?: number;
  21496. sideOrientation?: number;
  21497. frontUVs?: Vector4;
  21498. backUVs?: Vector4;
  21499. }): VertexData;
  21500. /**
  21501. * Creates the VertexData for a cylinder, cone or prism
  21502. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21503. * * height sets the height (y direction) of the cylinder, optional, default 2
  21504. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21505. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21506. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21507. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21508. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21509. * * 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
  21510. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21511. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21512. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21513. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21515. * * 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)
  21516. * * 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)
  21517. * @returns the VertexData of the cylinder, cone or prism
  21518. */
  21519. static CreateCylinder(options: {
  21520. height?: number;
  21521. diameterTop?: number;
  21522. diameterBottom?: number;
  21523. diameter?: number;
  21524. tessellation?: number;
  21525. subdivisions?: number;
  21526. arc?: number;
  21527. faceColors?: Color4[];
  21528. faceUV?: Vector4[];
  21529. hasRings?: boolean;
  21530. enclose?: boolean;
  21531. sideOrientation?: number;
  21532. frontUVs?: Vector4;
  21533. backUVs?: Vector4;
  21534. }): VertexData;
  21535. /**
  21536. * Creates the VertexData for a torus
  21537. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21538. * * diameter the diameter of the torus, optional default 1
  21539. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21540. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21541. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21542. * * 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)
  21543. * * 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)
  21544. * @returns the VertexData of the torus
  21545. */
  21546. static CreateTorus(options: {
  21547. diameter?: number;
  21548. thickness?: number;
  21549. tessellation?: number;
  21550. sideOrientation?: number;
  21551. frontUVs?: Vector4;
  21552. backUVs?: Vector4;
  21553. }): VertexData;
  21554. /**
  21555. * Creates the VertexData of the LineSystem
  21556. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21557. * - lines an array of lines, each line being an array of successive Vector3
  21558. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21559. * @returns the VertexData of the LineSystem
  21560. */
  21561. static CreateLineSystem(options: {
  21562. lines: Vector3[][];
  21563. colors?: Nullable<Color4[][]>;
  21564. }): VertexData;
  21565. /**
  21566. * Create the VertexData for a DashedLines
  21567. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21568. * - points an array successive Vector3
  21569. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21570. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21571. * - dashNb the intended total number of dashes, optional, default 200
  21572. * @returns the VertexData for the DashedLines
  21573. */
  21574. static CreateDashedLines(options: {
  21575. points: Vector3[];
  21576. dashSize?: number;
  21577. gapSize?: number;
  21578. dashNb?: number;
  21579. }): VertexData;
  21580. /**
  21581. * Creates the VertexData for a Ground
  21582. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21583. * - width the width (x direction) of the ground, optional, default 1
  21584. * - height the height (z direction) of the ground, optional, default 1
  21585. * - subdivisions the number of subdivisions per side, optional, default 1
  21586. * @returns the VertexData of the Ground
  21587. */
  21588. static CreateGround(options: {
  21589. width?: number;
  21590. height?: number;
  21591. subdivisions?: number;
  21592. subdivisionsX?: number;
  21593. subdivisionsY?: number;
  21594. }): VertexData;
  21595. /**
  21596. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21597. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21598. * * xmin the ground minimum X coordinate, optional, default -1
  21599. * * zmin the ground minimum Z coordinate, optional, default -1
  21600. * * xmax the ground maximum X coordinate, optional, default 1
  21601. * * zmax the ground maximum Z coordinate, optional, default 1
  21602. * * 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}
  21603. * * 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}
  21604. * @returns the VertexData of the TiledGround
  21605. */
  21606. static CreateTiledGround(options: {
  21607. xmin: number;
  21608. zmin: number;
  21609. xmax: number;
  21610. zmax: number;
  21611. subdivisions?: {
  21612. w: number;
  21613. h: number;
  21614. };
  21615. precision?: {
  21616. w: number;
  21617. h: number;
  21618. };
  21619. }): VertexData;
  21620. /**
  21621. * Creates the VertexData of the Ground designed from a heightmap
  21622. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21623. * * width the width (x direction) of the ground
  21624. * * height the height (z direction) of the ground
  21625. * * subdivisions the number of subdivisions per side
  21626. * * minHeight the minimum altitude on the ground, optional, default 0
  21627. * * maxHeight the maximum altitude on the ground, optional default 1
  21628. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21629. * * buffer the array holding the image color data
  21630. * * bufferWidth the width of image
  21631. * * bufferHeight the height of image
  21632. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21633. * @returns the VertexData of the Ground designed from a heightmap
  21634. */
  21635. static CreateGroundFromHeightMap(options: {
  21636. width: number;
  21637. height: number;
  21638. subdivisions: number;
  21639. minHeight: number;
  21640. maxHeight: number;
  21641. colorFilter: Color3;
  21642. buffer: Uint8Array;
  21643. bufferWidth: number;
  21644. bufferHeight: number;
  21645. alphaFilter: number;
  21646. }): VertexData;
  21647. /**
  21648. * Creates the VertexData for a Plane
  21649. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21650. * * size sets the width and height of the plane to the value of size, optional default 1
  21651. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21652. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21653. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21654. * * 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)
  21655. * * 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)
  21656. * @returns the VertexData of the box
  21657. */
  21658. static CreatePlane(options: {
  21659. size?: number;
  21660. width?: number;
  21661. height?: number;
  21662. sideOrientation?: number;
  21663. frontUVs?: Vector4;
  21664. backUVs?: Vector4;
  21665. }): VertexData;
  21666. /**
  21667. * Creates the VertexData of the Disc or regular Polygon
  21668. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21669. * * radius the radius of the disc, optional default 0.5
  21670. * * tessellation the number of polygon sides, optional, default 64
  21671. * * 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
  21672. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21673. * * 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)
  21674. * * 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)
  21675. * @returns the VertexData of the box
  21676. */
  21677. static CreateDisc(options: {
  21678. radius?: number;
  21679. tessellation?: number;
  21680. arc?: number;
  21681. sideOrientation?: number;
  21682. frontUVs?: Vector4;
  21683. backUVs?: Vector4;
  21684. }): VertexData;
  21685. /**
  21686. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21687. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21688. * @param polygon a mesh built from polygonTriangulation.build()
  21689. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21690. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21691. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21692. * @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)
  21693. * @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)
  21694. * @returns the VertexData of the Polygon
  21695. */
  21696. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21697. /**
  21698. * Creates the VertexData of the IcoSphere
  21699. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21700. * * radius the radius of the IcoSphere, optional default 1
  21701. * * radiusX allows stretching in the x direction, optional, default radius
  21702. * * radiusY allows stretching in the y direction, optional, default radius
  21703. * * radiusZ allows stretching in the z direction, optional, default radius
  21704. * * flat when true creates a flat shaded mesh, optional, default true
  21705. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21706. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21707. * * 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)
  21708. * * 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)
  21709. * @returns the VertexData of the IcoSphere
  21710. */
  21711. static CreateIcoSphere(options: {
  21712. radius?: number;
  21713. radiusX?: number;
  21714. radiusY?: number;
  21715. radiusZ?: number;
  21716. flat?: boolean;
  21717. subdivisions?: number;
  21718. sideOrientation?: number;
  21719. frontUVs?: Vector4;
  21720. backUVs?: Vector4;
  21721. }): VertexData;
  21722. /**
  21723. * Creates the VertexData for a Polyhedron
  21724. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21725. * * type provided types are:
  21726. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21727. * * 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)
  21728. * * size the size of the IcoSphere, optional default 1
  21729. * * sizeX allows stretching in the x direction, optional, default size
  21730. * * sizeY allows stretching in the y direction, optional, default size
  21731. * * sizeZ allows stretching in the z direction, optional, default size
  21732. * * 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
  21733. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21734. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21735. * * flat when true creates a flat shaded mesh, optional, default true
  21736. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21737. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21738. * * 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)
  21739. * * 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)
  21740. * @returns the VertexData of the Polyhedron
  21741. */
  21742. static CreatePolyhedron(options: {
  21743. type?: number;
  21744. size?: number;
  21745. sizeX?: number;
  21746. sizeY?: number;
  21747. sizeZ?: number;
  21748. custom?: any;
  21749. faceUV?: Vector4[];
  21750. faceColors?: Color4[];
  21751. flat?: boolean;
  21752. sideOrientation?: number;
  21753. frontUVs?: Vector4;
  21754. backUVs?: Vector4;
  21755. }): VertexData;
  21756. /**
  21757. * Creates the VertexData for a TorusKnot
  21758. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21759. * * radius the radius of the torus knot, optional, default 2
  21760. * * tube the thickness of the tube, optional, default 0.5
  21761. * * radialSegments the number of sides on each tube segments, optional, default 32
  21762. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21763. * * p the number of windings around the z axis, optional, default 2
  21764. * * q the number of windings around the x axis, optional, default 3
  21765. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21766. * * 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)
  21767. * * 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)
  21768. * @returns the VertexData of the Torus Knot
  21769. */
  21770. static CreateTorusKnot(options: {
  21771. radius?: number;
  21772. tube?: number;
  21773. radialSegments?: number;
  21774. tubularSegments?: number;
  21775. p?: number;
  21776. q?: number;
  21777. sideOrientation?: number;
  21778. frontUVs?: Vector4;
  21779. backUVs?: Vector4;
  21780. }): VertexData;
  21781. /**
  21782. * Compute normals for given positions and indices
  21783. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21784. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21785. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21786. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21787. * * facetNormals : optional array of facet normals (vector3)
  21788. * * facetPositions : optional array of facet positions (vector3)
  21789. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21790. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21791. * * bInfo : optional bounding info, required for facetPartitioning computation
  21792. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21793. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21794. * * useRightHandedSystem: optional boolean to for right handed system computation
  21795. * * depthSort : optional boolean to enable the facet depth sort computation
  21796. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21797. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21798. */
  21799. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21800. facetNormals?: any;
  21801. facetPositions?: any;
  21802. facetPartitioning?: any;
  21803. ratio?: number;
  21804. bInfo?: any;
  21805. bbSize?: Vector3;
  21806. subDiv?: any;
  21807. useRightHandedSystem?: boolean;
  21808. depthSort?: boolean;
  21809. distanceTo?: Vector3;
  21810. depthSortedFacets?: any;
  21811. }): void;
  21812. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21813. /**
  21814. * Applies VertexData created from the imported parameters to the geometry
  21815. * @param parsedVertexData the parsed data from an imported file
  21816. * @param geometry the geometry to apply the VertexData to
  21817. */
  21818. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21819. }
  21820. }
  21821. declare module BABYLON {
  21822. /**
  21823. * Defines a target to use with MorphTargetManager
  21824. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21825. */
  21826. export class MorphTarget implements IAnimatable {
  21827. /** defines the name of the target */
  21828. name: string;
  21829. /**
  21830. * Gets or sets the list of animations
  21831. */
  21832. animations: Animation[];
  21833. private _scene;
  21834. private _positions;
  21835. private _normals;
  21836. private _tangents;
  21837. private _uvs;
  21838. private _influence;
  21839. private _uniqueId;
  21840. /**
  21841. * Observable raised when the influence changes
  21842. */
  21843. onInfluenceChanged: Observable<boolean>;
  21844. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21845. /**
  21846. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21847. */
  21848. influence: number;
  21849. /**
  21850. * Gets or sets the id of the morph Target
  21851. */
  21852. id: string;
  21853. private _animationPropertiesOverride;
  21854. /**
  21855. * Gets or sets the animation properties override
  21856. */
  21857. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21858. /**
  21859. * Creates a new MorphTarget
  21860. * @param name defines the name of the target
  21861. * @param influence defines the influence to use
  21862. * @param scene defines the scene the morphtarget belongs to
  21863. */
  21864. constructor(
  21865. /** defines the name of the target */
  21866. name: string, influence?: number, scene?: Nullable<Scene>);
  21867. /**
  21868. * Gets the unique ID of this manager
  21869. */
  21870. readonly uniqueId: number;
  21871. /**
  21872. * Gets a boolean defining if the target contains position data
  21873. */
  21874. readonly hasPositions: boolean;
  21875. /**
  21876. * Gets a boolean defining if the target contains normal data
  21877. */
  21878. readonly hasNormals: boolean;
  21879. /**
  21880. * Gets a boolean defining if the target contains tangent data
  21881. */
  21882. readonly hasTangents: boolean;
  21883. /**
  21884. * Gets a boolean defining if the target contains texture coordinates data
  21885. */
  21886. readonly hasUVs: boolean;
  21887. /**
  21888. * Affects position data to this target
  21889. * @param data defines the position data to use
  21890. */
  21891. setPositions(data: Nullable<FloatArray>): void;
  21892. /**
  21893. * Gets the position data stored in this target
  21894. * @returns a FloatArray containing the position data (or null if not present)
  21895. */
  21896. getPositions(): Nullable<FloatArray>;
  21897. /**
  21898. * Affects normal data to this target
  21899. * @param data defines the normal data to use
  21900. */
  21901. setNormals(data: Nullable<FloatArray>): void;
  21902. /**
  21903. * Gets the normal data stored in this target
  21904. * @returns a FloatArray containing the normal data (or null if not present)
  21905. */
  21906. getNormals(): Nullable<FloatArray>;
  21907. /**
  21908. * Affects tangent data to this target
  21909. * @param data defines the tangent data to use
  21910. */
  21911. setTangents(data: Nullable<FloatArray>): void;
  21912. /**
  21913. * Gets the tangent data stored in this target
  21914. * @returns a FloatArray containing the tangent data (or null if not present)
  21915. */
  21916. getTangents(): Nullable<FloatArray>;
  21917. /**
  21918. * Affects texture coordinates data to this target
  21919. * @param data defines the texture coordinates data to use
  21920. */
  21921. setUVs(data: Nullable<FloatArray>): void;
  21922. /**
  21923. * Gets the texture coordinates data stored in this target
  21924. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21925. */
  21926. getUVs(): Nullable<FloatArray>;
  21927. /**
  21928. * Clone the current target
  21929. * @returns a new MorphTarget
  21930. */
  21931. clone(): MorphTarget;
  21932. /**
  21933. * Serializes the current target into a Serialization object
  21934. * @returns the serialized object
  21935. */
  21936. serialize(): any;
  21937. /**
  21938. * Returns the string "MorphTarget"
  21939. * @returns "MorphTarget"
  21940. */
  21941. getClassName(): string;
  21942. /**
  21943. * Creates a new target from serialized data
  21944. * @param serializationObject defines the serialized data to use
  21945. * @returns a new MorphTarget
  21946. */
  21947. static Parse(serializationObject: any): MorphTarget;
  21948. /**
  21949. * Creates a MorphTarget from mesh data
  21950. * @param mesh defines the source mesh
  21951. * @param name defines the name to use for the new target
  21952. * @param influence defines the influence to attach to the target
  21953. * @returns a new MorphTarget
  21954. */
  21955. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21956. }
  21957. }
  21958. declare module BABYLON {
  21959. /**
  21960. * This class is used to deform meshes using morphing between different targets
  21961. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21962. */
  21963. export class MorphTargetManager {
  21964. private _targets;
  21965. private _targetInfluenceChangedObservers;
  21966. private _targetDataLayoutChangedObservers;
  21967. private _activeTargets;
  21968. private _scene;
  21969. private _influences;
  21970. private _supportsNormals;
  21971. private _supportsTangents;
  21972. private _supportsUVs;
  21973. private _vertexCount;
  21974. private _uniqueId;
  21975. private _tempInfluences;
  21976. /**
  21977. * Gets or sets a boolean indicating if normals must be morphed
  21978. */
  21979. enableNormalMorphing: boolean;
  21980. /**
  21981. * Gets or sets a boolean indicating if tangents must be morphed
  21982. */
  21983. enableTangentMorphing: boolean;
  21984. /**
  21985. * Gets or sets a boolean indicating if UV must be morphed
  21986. */
  21987. enableUVMorphing: boolean;
  21988. /**
  21989. * Creates a new MorphTargetManager
  21990. * @param scene defines the current scene
  21991. */
  21992. constructor(scene?: Nullable<Scene>);
  21993. /**
  21994. * Gets the unique ID of this manager
  21995. */
  21996. readonly uniqueId: number;
  21997. /**
  21998. * Gets the number of vertices handled by this manager
  21999. */
  22000. readonly vertexCount: number;
  22001. /**
  22002. * Gets a boolean indicating if this manager supports morphing of normals
  22003. */
  22004. readonly supportsNormals: boolean;
  22005. /**
  22006. * Gets a boolean indicating if this manager supports morphing of tangents
  22007. */
  22008. readonly supportsTangents: boolean;
  22009. /**
  22010. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22011. */
  22012. readonly supportsUVs: boolean;
  22013. /**
  22014. * Gets the number of targets stored in this manager
  22015. */
  22016. readonly numTargets: number;
  22017. /**
  22018. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22019. */
  22020. readonly numInfluencers: number;
  22021. /**
  22022. * Gets the list of influences (one per target)
  22023. */
  22024. readonly influences: Float32Array;
  22025. /**
  22026. * Gets the active target at specified index. An active target is a target with an influence > 0
  22027. * @param index defines the index to check
  22028. * @returns the requested target
  22029. */
  22030. getActiveTarget(index: number): MorphTarget;
  22031. /**
  22032. * Gets the target at specified index
  22033. * @param index defines the index to check
  22034. * @returns the requested target
  22035. */
  22036. getTarget(index: number): MorphTarget;
  22037. /**
  22038. * Add a new target to this manager
  22039. * @param target defines the target to add
  22040. */
  22041. addTarget(target: MorphTarget): void;
  22042. /**
  22043. * Removes a target from the manager
  22044. * @param target defines the target to remove
  22045. */
  22046. removeTarget(target: MorphTarget): void;
  22047. /**
  22048. * Clone the current manager
  22049. * @returns a new MorphTargetManager
  22050. */
  22051. clone(): MorphTargetManager;
  22052. /**
  22053. * Serializes the current manager into a Serialization object
  22054. * @returns the serialized object
  22055. */
  22056. serialize(): any;
  22057. private _syncActiveTargets;
  22058. /**
  22059. * Syncrhonize the targets with all the meshes using this morph target manager
  22060. */
  22061. synchronize(): void;
  22062. /**
  22063. * Creates a new MorphTargetManager from serialized data
  22064. * @param serializationObject defines the serialized data
  22065. * @param scene defines the hosting scene
  22066. * @returns the new MorphTargetManager
  22067. */
  22068. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22069. }
  22070. }
  22071. declare module BABYLON {
  22072. /**
  22073. * Class used to represent a specific level of detail of a mesh
  22074. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22075. */
  22076. export class MeshLODLevel {
  22077. /** Defines the distance where this level should start being displayed */
  22078. distance: number;
  22079. /** Defines the mesh to use to render this level */
  22080. mesh: Nullable<Mesh>;
  22081. /**
  22082. * Creates a new LOD level
  22083. * @param distance defines the distance where this level should star being displayed
  22084. * @param mesh defines the mesh to use to render this level
  22085. */
  22086. constructor(
  22087. /** Defines the distance where this level should start being displayed */
  22088. distance: number,
  22089. /** Defines the mesh to use to render this level */
  22090. mesh: Nullable<Mesh>);
  22091. }
  22092. }
  22093. declare module BABYLON {
  22094. /**
  22095. * Mesh representing the gorund
  22096. */
  22097. export class GroundMesh extends Mesh {
  22098. /** If octree should be generated */
  22099. generateOctree: boolean;
  22100. private _heightQuads;
  22101. /** @hidden */ private _subdivisionsX: number;
  22102. /** @hidden */ private _subdivisionsY: number;
  22103. /** @hidden */ private _width: number;
  22104. /** @hidden */ private _height: number;
  22105. /** @hidden */ private _minX: number;
  22106. /** @hidden */ private _maxX: number;
  22107. /** @hidden */ private _minZ: number;
  22108. /** @hidden */ private _maxZ: number;
  22109. constructor(name: string, scene: Scene);
  22110. /**
  22111. * "GroundMesh"
  22112. * @returns "GroundMesh"
  22113. */
  22114. getClassName(): string;
  22115. /**
  22116. * The minimum of x and y subdivisions
  22117. */
  22118. readonly subdivisions: number;
  22119. /**
  22120. * X subdivisions
  22121. */
  22122. readonly subdivisionsX: number;
  22123. /**
  22124. * Y subdivisions
  22125. */
  22126. readonly subdivisionsY: number;
  22127. /**
  22128. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22129. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22130. * @param chunksCount the number of subdivisions for x and y
  22131. * @param octreeBlocksSize (Default: 32)
  22132. */
  22133. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22134. /**
  22135. * Returns a height (y) value in the Worl system :
  22136. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22137. * @param x x coordinate
  22138. * @param z z coordinate
  22139. * @returns the ground y position if (x, z) are outside the ground surface.
  22140. */
  22141. getHeightAtCoordinates(x: number, z: number): number;
  22142. /**
  22143. * Returns a normalized vector (Vector3) orthogonal to the ground
  22144. * at the ground coordinates (x, z) expressed in the World system.
  22145. * @param x x coordinate
  22146. * @param z z coordinate
  22147. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22148. */
  22149. getNormalAtCoordinates(x: number, z: number): Vector3;
  22150. /**
  22151. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22152. * at the ground coordinates (x, z) expressed in the World system.
  22153. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22154. * @param x x coordinate
  22155. * @param z z coordinate
  22156. * @param ref vector to store the result
  22157. * @returns the GroundMesh.
  22158. */
  22159. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22160. /**
  22161. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22162. * if the ground has been updated.
  22163. * This can be used in the render loop.
  22164. * @returns the GroundMesh.
  22165. */
  22166. updateCoordinateHeights(): GroundMesh;
  22167. private _getFacetAt;
  22168. private _initHeightQuads;
  22169. private _computeHeightQuads;
  22170. /**
  22171. * Serializes this ground mesh
  22172. * @param serializationObject object to write serialization to
  22173. */
  22174. serialize(serializationObject: any): void;
  22175. /**
  22176. * Parses a serialized ground mesh
  22177. * @param parsedMesh the serialized mesh
  22178. * @param scene the scene to create the ground mesh in
  22179. * @returns the created ground mesh
  22180. */
  22181. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22182. }
  22183. }
  22184. declare module BABYLON {
  22185. /**
  22186. * Interface for Physics-Joint data
  22187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22188. */
  22189. export interface PhysicsJointData {
  22190. /**
  22191. * The main pivot of the joint
  22192. */
  22193. mainPivot?: Vector3;
  22194. /**
  22195. * The connected pivot of the joint
  22196. */
  22197. connectedPivot?: Vector3;
  22198. /**
  22199. * The main axis of the joint
  22200. */
  22201. mainAxis?: Vector3;
  22202. /**
  22203. * The connected axis of the joint
  22204. */
  22205. connectedAxis?: Vector3;
  22206. /**
  22207. * The collision of the joint
  22208. */
  22209. collision?: boolean;
  22210. /**
  22211. * Native Oimo/Cannon/Energy data
  22212. */
  22213. nativeParams?: any;
  22214. }
  22215. /**
  22216. * This is a holder class for the physics joint created by the physics plugin
  22217. * It holds a set of functions to control the underlying joint
  22218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22219. */
  22220. export class PhysicsJoint {
  22221. /**
  22222. * The type of the physics joint
  22223. */
  22224. type: number;
  22225. /**
  22226. * The data for the physics joint
  22227. */
  22228. jointData: PhysicsJointData;
  22229. private _physicsJoint;
  22230. protected _physicsPlugin: IPhysicsEnginePlugin;
  22231. /**
  22232. * Initializes the physics joint
  22233. * @param type The type of the physics joint
  22234. * @param jointData The data for the physics joint
  22235. */
  22236. constructor(
  22237. /**
  22238. * The type of the physics joint
  22239. */
  22240. type: number,
  22241. /**
  22242. * The data for the physics joint
  22243. */
  22244. jointData: PhysicsJointData);
  22245. /**
  22246. * Gets the physics joint
  22247. */
  22248. /**
  22249. * Sets the physics joint
  22250. */
  22251. physicsJoint: any;
  22252. /**
  22253. * Sets the physics plugin
  22254. */
  22255. physicsPlugin: IPhysicsEnginePlugin;
  22256. /**
  22257. * Execute a function that is physics-plugin specific.
  22258. * @param {Function} func the function that will be executed.
  22259. * It accepts two parameters: the physics world and the physics joint
  22260. */
  22261. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22262. /**
  22263. * Distance-Joint type
  22264. */
  22265. static DistanceJoint: number;
  22266. /**
  22267. * Hinge-Joint type
  22268. */
  22269. static HingeJoint: number;
  22270. /**
  22271. * Ball-and-Socket joint type
  22272. */
  22273. static BallAndSocketJoint: number;
  22274. /**
  22275. * Wheel-Joint type
  22276. */
  22277. static WheelJoint: number;
  22278. /**
  22279. * Slider-Joint type
  22280. */
  22281. static SliderJoint: number;
  22282. /**
  22283. * Prismatic-Joint type
  22284. */
  22285. static PrismaticJoint: number;
  22286. /**
  22287. * Universal-Joint type
  22288. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22289. */
  22290. static UniversalJoint: number;
  22291. /**
  22292. * Hinge-Joint 2 type
  22293. */
  22294. static Hinge2Joint: number;
  22295. /**
  22296. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22297. */
  22298. static PointToPointJoint: number;
  22299. /**
  22300. * Spring-Joint type
  22301. */
  22302. static SpringJoint: number;
  22303. /**
  22304. * Lock-Joint type
  22305. */
  22306. static LockJoint: number;
  22307. }
  22308. /**
  22309. * A class representing a physics distance joint
  22310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22311. */
  22312. export class DistanceJoint extends PhysicsJoint {
  22313. /**
  22314. *
  22315. * @param jointData The data for the Distance-Joint
  22316. */
  22317. constructor(jointData: DistanceJointData);
  22318. /**
  22319. * Update the predefined distance.
  22320. * @param maxDistance The maximum preferred distance
  22321. * @param minDistance The minimum preferred distance
  22322. */
  22323. updateDistance(maxDistance: number, minDistance?: number): void;
  22324. }
  22325. /**
  22326. * Represents a Motor-Enabled Joint
  22327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22328. */
  22329. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22330. /**
  22331. * Initializes the Motor-Enabled Joint
  22332. * @param type The type of the joint
  22333. * @param jointData The physica joint data for the joint
  22334. */
  22335. constructor(type: number, jointData: PhysicsJointData);
  22336. /**
  22337. * Set the motor values.
  22338. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22339. * @param force the force to apply
  22340. * @param maxForce max force for this motor.
  22341. */
  22342. setMotor(force?: number, maxForce?: number): void;
  22343. /**
  22344. * Set the motor's limits.
  22345. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22346. * @param upperLimit The upper limit of the motor
  22347. * @param lowerLimit The lower limit of the motor
  22348. */
  22349. setLimit(upperLimit: number, lowerLimit?: number): void;
  22350. }
  22351. /**
  22352. * This class represents a single physics Hinge-Joint
  22353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22354. */
  22355. export class HingeJoint extends MotorEnabledJoint {
  22356. /**
  22357. * Initializes the Hinge-Joint
  22358. * @param jointData The joint data for the Hinge-Joint
  22359. */
  22360. constructor(jointData: PhysicsJointData);
  22361. /**
  22362. * Set the motor values.
  22363. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22364. * @param {number} force the force to apply
  22365. * @param {number} maxForce max force for this motor.
  22366. */
  22367. setMotor(force?: number, maxForce?: number): void;
  22368. /**
  22369. * Set the motor's limits.
  22370. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22371. * @param upperLimit The upper limit of the motor
  22372. * @param lowerLimit The lower limit of the motor
  22373. */
  22374. setLimit(upperLimit: number, lowerLimit?: number): void;
  22375. }
  22376. /**
  22377. * This class represents a dual hinge physics joint (same as wheel joint)
  22378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22379. */
  22380. export class Hinge2Joint extends MotorEnabledJoint {
  22381. /**
  22382. * Initializes the Hinge2-Joint
  22383. * @param jointData The joint data for the Hinge2-Joint
  22384. */
  22385. constructor(jointData: PhysicsJointData);
  22386. /**
  22387. * Set the motor values.
  22388. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22389. * @param {number} targetSpeed the speed the motor is to reach
  22390. * @param {number} maxForce max force for this motor.
  22391. * @param {motorIndex} the motor's index, 0 or 1.
  22392. */
  22393. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22394. /**
  22395. * Set the motor limits.
  22396. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22397. * @param {number} upperLimit the upper limit
  22398. * @param {number} lowerLimit lower limit
  22399. * @param {motorIndex} the motor's index, 0 or 1.
  22400. */
  22401. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22402. }
  22403. /**
  22404. * Interface for a motor enabled joint
  22405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22406. */
  22407. export interface IMotorEnabledJoint {
  22408. /**
  22409. * Physics joint
  22410. */
  22411. physicsJoint: any;
  22412. /**
  22413. * Sets the motor of the motor-enabled joint
  22414. * @param force The force of the motor
  22415. * @param maxForce The maximum force of the motor
  22416. * @param motorIndex The index of the motor
  22417. */
  22418. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22419. /**
  22420. * Sets the limit of the motor
  22421. * @param upperLimit The upper limit of the motor
  22422. * @param lowerLimit The lower limit of the motor
  22423. * @param motorIndex The index of the motor
  22424. */
  22425. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22426. }
  22427. /**
  22428. * Joint data for a Distance-Joint
  22429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22430. */
  22431. export interface DistanceJointData extends PhysicsJointData {
  22432. /**
  22433. * Max distance the 2 joint objects can be apart
  22434. */
  22435. maxDistance: number;
  22436. }
  22437. /**
  22438. * Joint data from a spring joint
  22439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22440. */
  22441. export interface SpringJointData extends PhysicsJointData {
  22442. /**
  22443. * Length of the spring
  22444. */
  22445. length: number;
  22446. /**
  22447. * Stiffness of the spring
  22448. */
  22449. stiffness: number;
  22450. /**
  22451. * Damping of the spring
  22452. */
  22453. damping: number;
  22454. /** this callback will be called when applying the force to the impostors. */
  22455. forceApplicationCallback: () => void;
  22456. }
  22457. }
  22458. declare module BABYLON {
  22459. /**
  22460. * Holds the data for the raycast result
  22461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22462. */
  22463. export class PhysicsRaycastResult {
  22464. private _hasHit;
  22465. private _hitDistance;
  22466. private _hitNormalWorld;
  22467. private _hitPointWorld;
  22468. private _rayFromWorld;
  22469. private _rayToWorld;
  22470. /**
  22471. * Gets if there was a hit
  22472. */
  22473. readonly hasHit: boolean;
  22474. /**
  22475. * Gets the distance from the hit
  22476. */
  22477. readonly hitDistance: number;
  22478. /**
  22479. * Gets the hit normal/direction in the world
  22480. */
  22481. readonly hitNormalWorld: Vector3;
  22482. /**
  22483. * Gets the hit point in the world
  22484. */
  22485. readonly hitPointWorld: Vector3;
  22486. /**
  22487. * Gets the ray "start point" of the ray in the world
  22488. */
  22489. readonly rayFromWorld: Vector3;
  22490. /**
  22491. * Gets the ray "end point" of the ray in the world
  22492. */
  22493. readonly rayToWorld: Vector3;
  22494. /**
  22495. * Sets the hit data (normal & point in world space)
  22496. * @param hitNormalWorld defines the normal in world space
  22497. * @param hitPointWorld defines the point in world space
  22498. */
  22499. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22500. /**
  22501. * Sets the distance from the start point to the hit point
  22502. * @param distance
  22503. */
  22504. setHitDistance(distance: number): void;
  22505. /**
  22506. * Calculates the distance manually
  22507. */
  22508. calculateHitDistance(): void;
  22509. /**
  22510. * Resets all the values to default
  22511. * @param from The from point on world space
  22512. * @param to The to point on world space
  22513. */
  22514. reset(from?: Vector3, to?: Vector3): void;
  22515. }
  22516. /**
  22517. * Interface for the size containing width and height
  22518. */
  22519. interface IXYZ {
  22520. /**
  22521. * X
  22522. */
  22523. x: number;
  22524. /**
  22525. * Y
  22526. */
  22527. y: number;
  22528. /**
  22529. * Z
  22530. */
  22531. z: number;
  22532. }
  22533. }
  22534. declare module BABYLON {
  22535. /**
  22536. * Interface used to describe a physics joint
  22537. */
  22538. export interface PhysicsImpostorJoint {
  22539. /** Defines the main impostor to which the joint is linked */
  22540. mainImpostor: PhysicsImpostor;
  22541. /** Defines the impostor that is connected to the main impostor using this joint */
  22542. connectedImpostor: PhysicsImpostor;
  22543. /** Defines the joint itself */
  22544. joint: PhysicsJoint;
  22545. }
  22546. /** @hidden */
  22547. export interface IPhysicsEnginePlugin {
  22548. world: any;
  22549. name: string;
  22550. setGravity(gravity: Vector3): void;
  22551. setTimeStep(timeStep: number): void;
  22552. getTimeStep(): number;
  22553. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22554. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22555. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22556. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22557. removePhysicsBody(impostor: PhysicsImpostor): void;
  22558. generateJoint(joint: PhysicsImpostorJoint): void;
  22559. removeJoint(joint: PhysicsImpostorJoint): void;
  22560. isSupported(): boolean;
  22561. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22562. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22563. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22564. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22565. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22566. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22567. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22568. getBodyMass(impostor: PhysicsImpostor): number;
  22569. getBodyFriction(impostor: PhysicsImpostor): number;
  22570. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22571. getBodyRestitution(impostor: PhysicsImpostor): number;
  22572. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22573. getBodyPressure?(impostor: PhysicsImpostor): number;
  22574. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22575. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22576. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22577. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22578. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22579. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22580. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22581. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22582. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22583. sleepBody(impostor: PhysicsImpostor): void;
  22584. wakeUpBody(impostor: PhysicsImpostor): void;
  22585. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22586. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22587. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22588. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22589. getRadius(impostor: PhysicsImpostor): number;
  22590. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22591. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22592. dispose(): void;
  22593. }
  22594. /**
  22595. * Interface used to define a physics engine
  22596. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22597. */
  22598. export interface IPhysicsEngine {
  22599. /**
  22600. * Gets the gravity vector used by the simulation
  22601. */
  22602. gravity: Vector3;
  22603. /**
  22604. * Sets the gravity vector used by the simulation
  22605. * @param gravity defines the gravity vector to use
  22606. */
  22607. setGravity(gravity: Vector3): void;
  22608. /**
  22609. * Set the time step of the physics engine.
  22610. * Default is 1/60.
  22611. * To slow it down, enter 1/600 for example.
  22612. * To speed it up, 1/30
  22613. * @param newTimeStep the new timestep to apply to this world.
  22614. */
  22615. setTimeStep(newTimeStep: number): void;
  22616. /**
  22617. * Get the time step of the physics engine.
  22618. * @returns the current time step
  22619. */
  22620. getTimeStep(): number;
  22621. /**
  22622. * Release all resources
  22623. */
  22624. dispose(): void;
  22625. /**
  22626. * Gets the name of the current physics plugin
  22627. * @returns the name of the plugin
  22628. */
  22629. getPhysicsPluginName(): string;
  22630. /**
  22631. * Adding a new impostor for the impostor tracking.
  22632. * This will be done by the impostor itself.
  22633. * @param impostor the impostor to add
  22634. */
  22635. addImpostor(impostor: PhysicsImpostor): void;
  22636. /**
  22637. * Remove an impostor from the engine.
  22638. * This impostor and its mesh will not longer be updated by the physics engine.
  22639. * @param impostor the impostor to remove
  22640. */
  22641. removeImpostor(impostor: PhysicsImpostor): void;
  22642. /**
  22643. * Add a joint to the physics engine
  22644. * @param mainImpostor defines the main impostor to which the joint is added.
  22645. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22646. * @param joint defines the joint that will connect both impostors.
  22647. */
  22648. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22649. /**
  22650. * Removes a joint from the simulation
  22651. * @param mainImpostor defines the impostor used with the joint
  22652. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22653. * @param joint defines the joint to remove
  22654. */
  22655. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22656. /**
  22657. * Gets the current plugin used to run the simulation
  22658. * @returns current plugin
  22659. */
  22660. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22661. /**
  22662. * Gets the list of physic impostors
  22663. * @returns an array of PhysicsImpostor
  22664. */
  22665. getImpostors(): Array<PhysicsImpostor>;
  22666. /**
  22667. * Gets the impostor for a physics enabled object
  22668. * @param object defines the object impersonated by the impostor
  22669. * @returns the PhysicsImpostor or null if not found
  22670. */
  22671. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22672. /**
  22673. * Gets the impostor for a physics body object
  22674. * @param body defines physics body used by the impostor
  22675. * @returns the PhysicsImpostor or null if not found
  22676. */
  22677. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22678. /**
  22679. * Does a raycast in the physics world
  22680. * @param from when should the ray start?
  22681. * @param to when should the ray end?
  22682. * @returns PhysicsRaycastResult
  22683. */
  22684. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22685. /**
  22686. * Called by the scene. No need to call it.
  22687. * @param delta defines the timespam between frames
  22688. */ private _step(delta: number): void;
  22689. }
  22690. }
  22691. declare module BABYLON {
  22692. /**
  22693. * The interface for the physics imposter parameters
  22694. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22695. */
  22696. export interface PhysicsImpostorParameters {
  22697. /**
  22698. * The mass of the physics imposter
  22699. */
  22700. mass: number;
  22701. /**
  22702. * The friction of the physics imposter
  22703. */
  22704. friction?: number;
  22705. /**
  22706. * The coefficient of restitution of the physics imposter
  22707. */
  22708. restitution?: number;
  22709. /**
  22710. * The native options of the physics imposter
  22711. */
  22712. nativeOptions?: any;
  22713. /**
  22714. * Specifies if the parent should be ignored
  22715. */
  22716. ignoreParent?: boolean;
  22717. /**
  22718. * Specifies if bi-directional transformations should be disabled
  22719. */
  22720. disableBidirectionalTransformation?: boolean;
  22721. /**
  22722. * The pressure inside the physics imposter, soft object only
  22723. */
  22724. pressure?: number;
  22725. /**
  22726. * The stiffness the physics imposter, soft object only
  22727. */
  22728. stiffness?: number;
  22729. /**
  22730. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22731. */
  22732. velocityIterations?: number;
  22733. /**
  22734. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22735. */
  22736. positionIterations?: number;
  22737. /**
  22738. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22739. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22740. * Add to fix multiple points
  22741. */
  22742. fixedPoints?: number;
  22743. /**
  22744. * The collision margin around a soft object
  22745. */
  22746. margin?: number;
  22747. /**
  22748. * The collision margin around a soft object
  22749. */
  22750. damping?: number;
  22751. /**
  22752. * The path for a rope based on an extrusion
  22753. */
  22754. path?: any;
  22755. /**
  22756. * The shape of an extrusion used for a rope based on an extrusion
  22757. */
  22758. shape?: any;
  22759. }
  22760. /**
  22761. * Interface for a physics-enabled object
  22762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22763. */
  22764. export interface IPhysicsEnabledObject {
  22765. /**
  22766. * The position of the physics-enabled object
  22767. */
  22768. position: Vector3;
  22769. /**
  22770. * The rotation of the physics-enabled object
  22771. */
  22772. rotationQuaternion: Nullable<Quaternion>;
  22773. /**
  22774. * The scale of the physics-enabled object
  22775. */
  22776. scaling: Vector3;
  22777. /**
  22778. * The rotation of the physics-enabled object
  22779. */
  22780. rotation?: Vector3;
  22781. /**
  22782. * The parent of the physics-enabled object
  22783. */
  22784. parent?: any;
  22785. /**
  22786. * The bounding info of the physics-enabled object
  22787. * @returns The bounding info of the physics-enabled object
  22788. */
  22789. getBoundingInfo(): BoundingInfo;
  22790. /**
  22791. * Computes the world matrix
  22792. * @param force Specifies if the world matrix should be computed by force
  22793. * @returns A world matrix
  22794. */
  22795. computeWorldMatrix(force: boolean): Matrix;
  22796. /**
  22797. * Gets the world matrix
  22798. * @returns A world matrix
  22799. */
  22800. getWorldMatrix?(): Matrix;
  22801. /**
  22802. * Gets the child meshes
  22803. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22804. * @returns An array of abstract meshes
  22805. */
  22806. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22807. /**
  22808. * Gets the vertex data
  22809. * @param kind The type of vertex data
  22810. * @returns A nullable array of numbers, or a float32 array
  22811. */
  22812. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22813. /**
  22814. * Gets the indices from the mesh
  22815. * @returns A nullable array of index arrays
  22816. */
  22817. getIndices?(): Nullable<IndicesArray>;
  22818. /**
  22819. * Gets the scene from the mesh
  22820. * @returns the indices array or null
  22821. */
  22822. getScene?(): Scene;
  22823. /**
  22824. * Gets the absolute position from the mesh
  22825. * @returns the absolute position
  22826. */
  22827. getAbsolutePosition(): Vector3;
  22828. /**
  22829. * Gets the absolute pivot point from the mesh
  22830. * @returns the absolute pivot point
  22831. */
  22832. getAbsolutePivotPoint(): Vector3;
  22833. /**
  22834. * Rotates the mesh
  22835. * @param axis The axis of rotation
  22836. * @param amount The amount of rotation
  22837. * @param space The space of the rotation
  22838. * @returns The rotation transform node
  22839. */
  22840. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22841. /**
  22842. * Translates the mesh
  22843. * @param axis The axis of translation
  22844. * @param distance The distance of translation
  22845. * @param space The space of the translation
  22846. * @returns The transform node
  22847. */
  22848. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22849. /**
  22850. * Sets the absolute position of the mesh
  22851. * @param absolutePosition The absolute position of the mesh
  22852. * @returns The transform node
  22853. */
  22854. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22855. /**
  22856. * Gets the class name of the mesh
  22857. * @returns The class name
  22858. */
  22859. getClassName(): string;
  22860. }
  22861. /**
  22862. * Represents a physics imposter
  22863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22864. */
  22865. export class PhysicsImpostor {
  22866. /**
  22867. * The physics-enabled object used as the physics imposter
  22868. */
  22869. object: IPhysicsEnabledObject;
  22870. /**
  22871. * The type of the physics imposter
  22872. */
  22873. type: number;
  22874. private _options;
  22875. private _scene?;
  22876. /**
  22877. * The default object size of the imposter
  22878. */
  22879. static DEFAULT_OBJECT_SIZE: Vector3;
  22880. /**
  22881. * The identity quaternion of the imposter
  22882. */
  22883. static IDENTITY_QUATERNION: Quaternion;
  22884. /** @hidden */ private _pluginData: any;
  22885. private _physicsEngine;
  22886. private _physicsBody;
  22887. private _bodyUpdateRequired;
  22888. private _onBeforePhysicsStepCallbacks;
  22889. private _onAfterPhysicsStepCallbacks;
  22890. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22891. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22892. otherImpostors: Array<PhysicsImpostor>;
  22893. }>;
  22894. private _deltaPosition;
  22895. private _deltaRotation;
  22896. private _deltaRotationConjugated;
  22897. /** @hidden */ private _isFromLine: boolean;
  22898. private _parent;
  22899. private _isDisposed;
  22900. private static _tmpVecs;
  22901. private static _tmpQuat;
  22902. /**
  22903. * Specifies if the physics imposter is disposed
  22904. */
  22905. readonly isDisposed: boolean;
  22906. /**
  22907. * Gets the mass of the physics imposter
  22908. */
  22909. mass: number;
  22910. /**
  22911. * Gets the coefficient of friction
  22912. */
  22913. /**
  22914. * Sets the coefficient of friction
  22915. */
  22916. friction: number;
  22917. /**
  22918. * Gets the coefficient of restitution
  22919. */
  22920. /**
  22921. * Sets the coefficient of restitution
  22922. */
  22923. restitution: number;
  22924. /**
  22925. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22926. */
  22927. /**
  22928. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22929. */
  22930. pressure: number;
  22931. /**
  22932. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22933. */
  22934. /**
  22935. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22936. */
  22937. stiffness: number;
  22938. /**
  22939. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22940. */
  22941. /**
  22942. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22943. */
  22944. velocityIterations: number;
  22945. /**
  22946. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22947. */
  22948. /**
  22949. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22950. */
  22951. positionIterations: number;
  22952. /**
  22953. * The unique id of the physics imposter
  22954. * set by the physics engine when adding this impostor to the array
  22955. */
  22956. uniqueId: number;
  22957. /**
  22958. * @hidden
  22959. */
  22960. soft: boolean;
  22961. /**
  22962. * @hidden
  22963. */
  22964. segments: number;
  22965. private _joints;
  22966. /**
  22967. * Initializes the physics imposter
  22968. * @param object The physics-enabled object used as the physics imposter
  22969. * @param type The type of the physics imposter
  22970. * @param _options The options for the physics imposter
  22971. * @param _scene The Babylon scene
  22972. */
  22973. constructor(
  22974. /**
  22975. * The physics-enabled object used as the physics imposter
  22976. */
  22977. object: IPhysicsEnabledObject,
  22978. /**
  22979. * The type of the physics imposter
  22980. */
  22981. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22982. /**
  22983. * This function will completly initialize this impostor.
  22984. * It will create a new body - but only if this mesh has no parent.
  22985. * If it has, this impostor will not be used other than to define the impostor
  22986. * of the child mesh.
  22987. * @hidden
  22988. */ private _init(): void;
  22989. private _getPhysicsParent;
  22990. /**
  22991. * Should a new body be generated.
  22992. * @returns boolean specifying if body initialization is required
  22993. */
  22994. isBodyInitRequired(): boolean;
  22995. /**
  22996. * Sets the updated scaling
  22997. * @param updated Specifies if the scaling is updated
  22998. */
  22999. setScalingUpdated(): void;
  23000. /**
  23001. * Force a regeneration of this or the parent's impostor's body.
  23002. * Use under cautious - This will remove all joints already implemented.
  23003. */
  23004. forceUpdate(): void;
  23005. /**
  23006. * Gets the body that holds this impostor. Either its own, or its parent.
  23007. */
  23008. /**
  23009. * Set the physics body. Used mainly by the physics engine/plugin
  23010. */
  23011. physicsBody: any;
  23012. /**
  23013. * Get the parent of the physics imposter
  23014. * @returns Physics imposter or null
  23015. */
  23016. /**
  23017. * Sets the parent of the physics imposter
  23018. */
  23019. parent: Nullable<PhysicsImpostor>;
  23020. /**
  23021. * Resets the update flags
  23022. */
  23023. resetUpdateFlags(): void;
  23024. /**
  23025. * Gets the object extend size
  23026. * @returns the object extend size
  23027. */
  23028. getObjectExtendSize(): Vector3;
  23029. /**
  23030. * Gets the object center
  23031. * @returns The object center
  23032. */
  23033. getObjectCenter(): Vector3;
  23034. /**
  23035. * Get a specific parametes from the options parameter
  23036. * @param paramName The object parameter name
  23037. * @returns The object parameter
  23038. */
  23039. getParam(paramName: string): any;
  23040. /**
  23041. * Sets a specific parameter in the options given to the physics plugin
  23042. * @param paramName The parameter name
  23043. * @param value The value of the parameter
  23044. */
  23045. setParam(paramName: string, value: number): void;
  23046. /**
  23047. * Specifically change the body's mass option. Won't recreate the physics body object
  23048. * @param mass The mass of the physics imposter
  23049. */
  23050. setMass(mass: number): void;
  23051. /**
  23052. * Gets the linear velocity
  23053. * @returns linear velocity or null
  23054. */
  23055. getLinearVelocity(): Nullable<Vector3>;
  23056. /**
  23057. * Sets the linear velocity
  23058. * @param velocity linear velocity or null
  23059. */
  23060. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23061. /**
  23062. * Gets the angular velocity
  23063. * @returns angular velocity or null
  23064. */
  23065. getAngularVelocity(): Nullable<Vector3>;
  23066. /**
  23067. * Sets the angular velocity
  23068. * @param velocity The velocity or null
  23069. */
  23070. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23071. /**
  23072. * Execute a function with the physics plugin native code
  23073. * Provide a function the will have two variables - the world object and the physics body object
  23074. * @param func The function to execute with the physics plugin native code
  23075. */
  23076. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23077. /**
  23078. * Register a function that will be executed before the physics world is stepping forward
  23079. * @param func The function to execute before the physics world is stepped forward
  23080. */
  23081. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23082. /**
  23083. * Unregister a function that will be executed before the physics world is stepping forward
  23084. * @param func The function to execute before the physics world is stepped forward
  23085. */
  23086. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23087. /**
  23088. * Register a function that will be executed after the physics step
  23089. * @param func The function to execute after physics step
  23090. */
  23091. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23092. /**
  23093. * Unregisters a function that will be executed after the physics step
  23094. * @param func The function to execute after physics step
  23095. */
  23096. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23097. /**
  23098. * register a function that will be executed when this impostor collides against a different body
  23099. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23100. * @param func Callback that is executed on collision
  23101. */
  23102. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23103. /**
  23104. * Unregisters the physics imposter on contact
  23105. * @param collideAgainst The physics object to collide against
  23106. * @param func Callback to execute on collision
  23107. */
  23108. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23109. private _tmpQuat;
  23110. private _tmpQuat2;
  23111. /**
  23112. * Get the parent rotation
  23113. * @returns The parent rotation
  23114. */
  23115. getParentsRotation(): Quaternion;
  23116. /**
  23117. * this function is executed by the physics engine.
  23118. */
  23119. beforeStep: () => void;
  23120. /**
  23121. * this function is executed by the physics engine
  23122. */
  23123. afterStep: () => void;
  23124. /**
  23125. * Legacy collision detection event support
  23126. */
  23127. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23128. /**
  23129. * event and body object due to cannon's event-based architecture.
  23130. */
  23131. onCollide: (e: {
  23132. body: any;
  23133. }) => void;
  23134. /**
  23135. * Apply a force
  23136. * @param force The force to apply
  23137. * @param contactPoint The contact point for the force
  23138. * @returns The physics imposter
  23139. */
  23140. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23141. /**
  23142. * Apply an impulse
  23143. * @param force The impulse force
  23144. * @param contactPoint The contact point for the impulse force
  23145. * @returns The physics imposter
  23146. */
  23147. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23148. /**
  23149. * A help function to create a joint
  23150. * @param otherImpostor A physics imposter used to create a joint
  23151. * @param jointType The type of joint
  23152. * @param jointData The data for the joint
  23153. * @returns The physics imposter
  23154. */
  23155. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23156. /**
  23157. * Add a joint to this impostor with a different impostor
  23158. * @param otherImpostor A physics imposter used to add a joint
  23159. * @param joint The joint to add
  23160. * @returns The physics imposter
  23161. */
  23162. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23163. /**
  23164. * Add an anchor to a cloth impostor
  23165. * @param otherImpostor rigid impostor to anchor to
  23166. * @param width ratio across width from 0 to 1
  23167. * @param height ratio up height from 0 to 1
  23168. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23169. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23170. * @returns impostor the soft imposter
  23171. */
  23172. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23173. /**
  23174. * Add a hook to a rope impostor
  23175. * @param otherImpostor rigid impostor to anchor to
  23176. * @param length ratio across rope from 0 to 1
  23177. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23178. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23179. * @returns impostor the rope imposter
  23180. */
  23181. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23182. /**
  23183. * Will keep this body still, in a sleep mode.
  23184. * @returns the physics imposter
  23185. */
  23186. sleep(): PhysicsImpostor;
  23187. /**
  23188. * Wake the body up.
  23189. * @returns The physics imposter
  23190. */
  23191. wakeUp(): PhysicsImpostor;
  23192. /**
  23193. * Clones the physics imposter
  23194. * @param newObject The physics imposter clones to this physics-enabled object
  23195. * @returns A nullable physics imposter
  23196. */
  23197. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23198. /**
  23199. * Disposes the physics imposter
  23200. */
  23201. dispose(): void;
  23202. /**
  23203. * Sets the delta position
  23204. * @param position The delta position amount
  23205. */
  23206. setDeltaPosition(position: Vector3): void;
  23207. /**
  23208. * Sets the delta rotation
  23209. * @param rotation The delta rotation amount
  23210. */
  23211. setDeltaRotation(rotation: Quaternion): void;
  23212. /**
  23213. * Gets the box size of the physics imposter and stores the result in the input parameter
  23214. * @param result Stores the box size
  23215. * @returns The physics imposter
  23216. */
  23217. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23218. /**
  23219. * Gets the radius of the physics imposter
  23220. * @returns Radius of the physics imposter
  23221. */
  23222. getRadius(): number;
  23223. /**
  23224. * Sync a bone with this impostor
  23225. * @param bone The bone to sync to the impostor.
  23226. * @param boneMesh The mesh that the bone is influencing.
  23227. * @param jointPivot The pivot of the joint / bone in local space.
  23228. * @param distToJoint Optional distance from the impostor to the joint.
  23229. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23230. */
  23231. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23232. /**
  23233. * Sync impostor to a bone
  23234. * @param bone The bone that the impostor will be synced to.
  23235. * @param boneMesh The mesh that the bone is influencing.
  23236. * @param jointPivot The pivot of the joint / bone in local space.
  23237. * @param distToJoint Optional distance from the impostor to the joint.
  23238. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23239. * @param boneAxis Optional vector3 axis the bone is aligned with
  23240. */
  23241. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23242. /**
  23243. * No-Imposter type
  23244. */
  23245. static NoImpostor: number;
  23246. /**
  23247. * Sphere-Imposter type
  23248. */
  23249. static SphereImpostor: number;
  23250. /**
  23251. * Box-Imposter type
  23252. */
  23253. static BoxImpostor: number;
  23254. /**
  23255. * Plane-Imposter type
  23256. */
  23257. static PlaneImpostor: number;
  23258. /**
  23259. * Mesh-imposter type
  23260. */
  23261. static MeshImpostor: number;
  23262. /**
  23263. * Capsule-Impostor type (Ammo.js plugin only)
  23264. */
  23265. static CapsuleImpostor: number;
  23266. /**
  23267. * Cylinder-Imposter type
  23268. */
  23269. static CylinderImpostor: number;
  23270. /**
  23271. * Particle-Imposter type
  23272. */
  23273. static ParticleImpostor: number;
  23274. /**
  23275. * Heightmap-Imposter type
  23276. */
  23277. static HeightmapImpostor: number;
  23278. /**
  23279. * ConvexHull-Impostor type (Ammo.js plugin only)
  23280. */
  23281. static ConvexHullImpostor: number;
  23282. /**
  23283. * Rope-Imposter type
  23284. */
  23285. static RopeImpostor: number;
  23286. /**
  23287. * Cloth-Imposter type
  23288. */
  23289. static ClothImpostor: number;
  23290. /**
  23291. * Softbody-Imposter type
  23292. */
  23293. static SoftbodyImpostor: number;
  23294. }
  23295. }
  23296. declare module BABYLON {
  23297. /**
  23298. * @hidden
  23299. **/
  23300. export class _CreationDataStorage {
  23301. closePath?: boolean;
  23302. closeArray?: boolean;
  23303. idx: number[];
  23304. dashSize: number;
  23305. gapSize: number;
  23306. path3D: Path3D;
  23307. pathArray: Vector3[][];
  23308. arc: number;
  23309. radius: number;
  23310. cap: number;
  23311. tessellation: number;
  23312. }
  23313. /**
  23314. * @hidden
  23315. **/ private class _InstanceDataStorage {
  23316. visibleInstances: any;
  23317. batchCache: _InstancesBatch;
  23318. instancesBufferSize: number;
  23319. instancesBuffer: Nullable<Buffer>;
  23320. instancesData: Float32Array;
  23321. overridenInstanceCount: number;
  23322. isFrozen: boolean;
  23323. previousBatch: Nullable<_InstancesBatch>;
  23324. hardwareInstancedRendering: boolean;
  23325. sideOrientation: number;
  23326. manualUpdate: boolean;
  23327. }
  23328. /**
  23329. * @hidden
  23330. **/
  23331. export class _InstancesBatch {
  23332. mustReturn: boolean;
  23333. visibleInstances: Nullable<InstancedMesh[]>[];
  23334. renderSelf: boolean[];
  23335. hardwareInstancedRendering: boolean[];
  23336. }
  23337. /**
  23338. * Class used to represent renderable models
  23339. */
  23340. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23341. /**
  23342. * Mesh side orientation : usually the external or front surface
  23343. */
  23344. static readonly FRONTSIDE: number;
  23345. /**
  23346. * Mesh side orientation : usually the internal or back surface
  23347. */
  23348. static readonly BACKSIDE: number;
  23349. /**
  23350. * Mesh side orientation : both internal and external or front and back surfaces
  23351. */
  23352. static readonly DOUBLESIDE: number;
  23353. /**
  23354. * Mesh side orientation : by default, `FRONTSIDE`
  23355. */
  23356. static readonly DEFAULTSIDE: number;
  23357. /**
  23358. * Mesh cap setting : no cap
  23359. */
  23360. static readonly NO_CAP: number;
  23361. /**
  23362. * Mesh cap setting : one cap at the beginning of the mesh
  23363. */
  23364. static readonly CAP_START: number;
  23365. /**
  23366. * Mesh cap setting : one cap at the end of the mesh
  23367. */
  23368. static readonly CAP_END: number;
  23369. /**
  23370. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23371. */
  23372. static readonly CAP_ALL: number;
  23373. /**
  23374. * Mesh pattern setting : no flip or rotate
  23375. */
  23376. static readonly NO_FLIP: number;
  23377. /**
  23378. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23379. */
  23380. static readonly FLIP_TILE: number;
  23381. /**
  23382. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23383. */
  23384. static readonly ROTATE_TILE: number;
  23385. /**
  23386. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23387. */
  23388. static readonly FLIP_ROW: number;
  23389. /**
  23390. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23391. */
  23392. static readonly ROTATE_ROW: number;
  23393. /**
  23394. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23395. */
  23396. static readonly FLIP_N_ROTATE_TILE: number;
  23397. /**
  23398. * Mesh pattern setting : rotate pattern and rotate
  23399. */
  23400. static readonly FLIP_N_ROTATE_ROW: number;
  23401. /**
  23402. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23403. */
  23404. static readonly CENTER: number;
  23405. /**
  23406. * Mesh tile positioning : part tiles on left
  23407. */
  23408. static readonly LEFT: number;
  23409. /**
  23410. * Mesh tile positioning : part tiles on right
  23411. */
  23412. static readonly RIGHT: number;
  23413. /**
  23414. * Mesh tile positioning : part tiles on top
  23415. */
  23416. static readonly TOP: number;
  23417. /**
  23418. * Mesh tile positioning : part tiles on bottom
  23419. */
  23420. static readonly BOTTOM: number;
  23421. /**
  23422. * Gets the default side orientation.
  23423. * @param orientation the orientation to value to attempt to get
  23424. * @returns the default orientation
  23425. * @hidden
  23426. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23427. private _internalMeshDataInfo;
  23428. /**
  23429. * An event triggered before rendering the mesh
  23430. */
  23431. readonly onBeforeRenderObservable: Observable<Mesh>;
  23432. /**
  23433. * An event triggered before binding the mesh
  23434. */
  23435. readonly onBeforeBindObservable: Observable<Mesh>;
  23436. /**
  23437. * An event triggered after rendering the mesh
  23438. */
  23439. readonly onAfterRenderObservable: Observable<Mesh>;
  23440. /**
  23441. * An event triggered before drawing the mesh
  23442. */
  23443. readonly onBeforeDrawObservable: Observable<Mesh>;
  23444. private _onBeforeDrawObserver;
  23445. /**
  23446. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23447. */
  23448. onBeforeDraw: () => void;
  23449. readonly hasInstances: boolean;
  23450. /**
  23451. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23452. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23453. */
  23454. delayLoadState: number;
  23455. /**
  23456. * Gets the list of instances created from this mesh
  23457. * it is not supposed to be modified manually.
  23458. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23459. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23460. */
  23461. instances: InstancedMesh[];
  23462. /**
  23463. * Gets the file containing delay loading data for this mesh
  23464. */
  23465. delayLoadingFile: string;
  23466. /** @hidden */ private _binaryInfo: any;
  23467. /**
  23468. * User defined function used to change how LOD level selection is done
  23469. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23470. */
  23471. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23472. /**
  23473. * Gets or sets the morph target manager
  23474. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23475. */
  23476. morphTargetManager: Nullable<MorphTargetManager>;
  23477. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23478. /** @hidden */ private _geometry: Nullable<Geometry>;
  23479. /** @hidden */ private _delayInfo: Array<string>;
  23480. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23481. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23482. private _effectiveMaterial;
  23483. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23484. /** @hidden */ private _originalBuilderSideOrientation: number;
  23485. /**
  23486. * Use this property to change the original side orientation defined at construction time
  23487. */
  23488. overrideMaterialSideOrientation: Nullable<number>;
  23489. /**
  23490. * Gets the source mesh (the one used to clone this one from)
  23491. */
  23492. readonly source: Nullable<Mesh>;
  23493. /**
  23494. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23495. */
  23496. isUnIndexed: boolean;
  23497. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  23498. readonly worldMatrixInstancedBuffer: Float32Array;
  23499. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  23500. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  23501. /**
  23502. * @constructor
  23503. * @param name The value used by scene.getMeshByName() to do a lookup.
  23504. * @param scene The scene to add this mesh to.
  23505. * @param parent The parent of this mesh, if it has one
  23506. * @param source An optional Mesh from which geometry is shared, cloned.
  23507. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23508. * When false, achieved by calling a clone(), also passing False.
  23509. * This will make creation of children, recursive.
  23510. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23511. */
  23512. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23513. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  23514. doNotInstantiate: boolean;
  23515. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  23516. /**
  23517. * Gets the class name
  23518. * @returns the string "Mesh".
  23519. */
  23520. getClassName(): string;
  23521. /** @hidden */ protected readonly _isMesh: boolean;
  23522. /**
  23523. * Returns a description of this mesh
  23524. * @param fullDetails define if full details about this mesh must be used
  23525. * @returns a descriptive string representing this mesh
  23526. */
  23527. toString(fullDetails?: boolean): string;
  23528. /** @hidden */ private _unBindEffect(): void;
  23529. /**
  23530. * Gets a boolean indicating if this mesh has LOD
  23531. */
  23532. readonly hasLODLevels: boolean;
  23533. /**
  23534. * Gets the list of MeshLODLevel associated with the current mesh
  23535. * @returns an array of MeshLODLevel
  23536. */
  23537. getLODLevels(): MeshLODLevel[];
  23538. private _sortLODLevels;
  23539. /**
  23540. * Add a mesh as LOD level triggered at the given distance.
  23541. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23542. * @param distance The distance from the center of the object to show this level
  23543. * @param mesh The mesh to be added as LOD level (can be null)
  23544. * @return This mesh (for chaining)
  23545. */
  23546. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23547. /**
  23548. * Returns the LOD level mesh at the passed distance or null if not found.
  23549. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23550. * @param distance The distance from the center of the object to show this level
  23551. * @returns a Mesh or `null`
  23552. */
  23553. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23554. /**
  23555. * Remove a mesh from the LOD array
  23556. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23557. * @param mesh defines the mesh to be removed
  23558. * @return This mesh (for chaining)
  23559. */
  23560. removeLODLevel(mesh: Mesh): Mesh;
  23561. /**
  23562. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23563. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23564. * @param camera defines the camera to use to compute distance
  23565. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23566. * @return This mesh (for chaining)
  23567. */
  23568. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23569. /**
  23570. * Gets the mesh internal Geometry object
  23571. */
  23572. readonly geometry: Nullable<Geometry>;
  23573. /**
  23574. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23575. * @returns the total number of vertices
  23576. */
  23577. getTotalVertices(): number;
  23578. /**
  23579. * Returns the content of an associated vertex buffer
  23580. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23581. * - VertexBuffer.PositionKind
  23582. * - VertexBuffer.UVKind
  23583. * - VertexBuffer.UV2Kind
  23584. * - VertexBuffer.UV3Kind
  23585. * - VertexBuffer.UV4Kind
  23586. * - VertexBuffer.UV5Kind
  23587. * - VertexBuffer.UV6Kind
  23588. * - VertexBuffer.ColorKind
  23589. * - VertexBuffer.MatricesIndicesKind
  23590. * - VertexBuffer.MatricesIndicesExtraKind
  23591. * - VertexBuffer.MatricesWeightsKind
  23592. * - VertexBuffer.MatricesWeightsExtraKind
  23593. * @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
  23594. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23595. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23596. */
  23597. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23598. /**
  23599. * Returns the mesh VertexBuffer object from the requested `kind`
  23600. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23601. * - VertexBuffer.PositionKind
  23602. * - VertexBuffer.NormalKind
  23603. * - VertexBuffer.UVKind
  23604. * - VertexBuffer.UV2Kind
  23605. * - VertexBuffer.UV3Kind
  23606. * - VertexBuffer.UV4Kind
  23607. * - VertexBuffer.UV5Kind
  23608. * - VertexBuffer.UV6Kind
  23609. * - VertexBuffer.ColorKind
  23610. * - VertexBuffer.MatricesIndicesKind
  23611. * - VertexBuffer.MatricesIndicesExtraKind
  23612. * - VertexBuffer.MatricesWeightsKind
  23613. * - VertexBuffer.MatricesWeightsExtraKind
  23614. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23615. */
  23616. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23617. /**
  23618. * Tests if a specific vertex buffer is associated with this mesh
  23619. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23620. * - VertexBuffer.PositionKind
  23621. * - VertexBuffer.NormalKind
  23622. * - VertexBuffer.UVKind
  23623. * - VertexBuffer.UV2Kind
  23624. * - VertexBuffer.UV3Kind
  23625. * - VertexBuffer.UV4Kind
  23626. * - VertexBuffer.UV5Kind
  23627. * - VertexBuffer.UV6Kind
  23628. * - VertexBuffer.ColorKind
  23629. * - VertexBuffer.MatricesIndicesKind
  23630. * - VertexBuffer.MatricesIndicesExtraKind
  23631. * - VertexBuffer.MatricesWeightsKind
  23632. * - VertexBuffer.MatricesWeightsExtraKind
  23633. * @returns a boolean
  23634. */
  23635. isVerticesDataPresent(kind: string): boolean;
  23636. /**
  23637. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23638. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23639. * - VertexBuffer.PositionKind
  23640. * - VertexBuffer.UVKind
  23641. * - VertexBuffer.UV2Kind
  23642. * - VertexBuffer.UV3Kind
  23643. * - VertexBuffer.UV4Kind
  23644. * - VertexBuffer.UV5Kind
  23645. * - VertexBuffer.UV6Kind
  23646. * - VertexBuffer.ColorKind
  23647. * - VertexBuffer.MatricesIndicesKind
  23648. * - VertexBuffer.MatricesIndicesExtraKind
  23649. * - VertexBuffer.MatricesWeightsKind
  23650. * - VertexBuffer.MatricesWeightsExtraKind
  23651. * @returns a boolean
  23652. */
  23653. isVertexBufferUpdatable(kind: string): boolean;
  23654. /**
  23655. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23656. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23657. * - VertexBuffer.PositionKind
  23658. * - VertexBuffer.NormalKind
  23659. * - VertexBuffer.UVKind
  23660. * - VertexBuffer.UV2Kind
  23661. * - VertexBuffer.UV3Kind
  23662. * - VertexBuffer.UV4Kind
  23663. * - VertexBuffer.UV5Kind
  23664. * - VertexBuffer.UV6Kind
  23665. * - VertexBuffer.ColorKind
  23666. * - VertexBuffer.MatricesIndicesKind
  23667. * - VertexBuffer.MatricesIndicesExtraKind
  23668. * - VertexBuffer.MatricesWeightsKind
  23669. * - VertexBuffer.MatricesWeightsExtraKind
  23670. * @returns an array of strings
  23671. */
  23672. getVerticesDataKinds(): string[];
  23673. /**
  23674. * Returns a positive integer : the total number of indices in this mesh geometry.
  23675. * @returns the numner of indices or zero if the mesh has no geometry.
  23676. */
  23677. getTotalIndices(): number;
  23678. /**
  23679. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23680. * @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.
  23681. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23682. * @returns the indices array or an empty array if the mesh has no geometry
  23683. */
  23684. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23685. readonly isBlocked: boolean;
  23686. /**
  23687. * Determine if the current mesh is ready to be rendered
  23688. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23689. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23690. * @returns true if all associated assets are ready (material, textures, shaders)
  23691. */
  23692. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23693. /**
  23694. * 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.
  23695. */
  23696. readonly areNormalsFrozen: boolean;
  23697. /**
  23698. * 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.
  23699. * @returns the current mesh
  23700. */
  23701. freezeNormals(): Mesh;
  23702. /**
  23703. * 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
  23704. * @returns the current mesh
  23705. */
  23706. unfreezeNormals(): Mesh;
  23707. /**
  23708. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23709. */
  23710. overridenInstanceCount: number;
  23711. /** @hidden */ private _preActivate(): Mesh;
  23712. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23713. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23714. /**
  23715. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23716. * This means the mesh underlying bounding box and sphere are recomputed.
  23717. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23718. * @returns the current mesh
  23719. */
  23720. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23721. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23722. /**
  23723. * This function will subdivide the mesh into multiple submeshes
  23724. * @param count defines the expected number of submeshes
  23725. */
  23726. subdivide(count: number): void;
  23727. /**
  23728. * Copy a FloatArray into a specific associated vertex buffer
  23729. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23730. * - VertexBuffer.PositionKind
  23731. * - VertexBuffer.UVKind
  23732. * - VertexBuffer.UV2Kind
  23733. * - VertexBuffer.UV3Kind
  23734. * - VertexBuffer.UV4Kind
  23735. * - VertexBuffer.UV5Kind
  23736. * - VertexBuffer.UV6Kind
  23737. * - VertexBuffer.ColorKind
  23738. * - VertexBuffer.MatricesIndicesKind
  23739. * - VertexBuffer.MatricesIndicesExtraKind
  23740. * - VertexBuffer.MatricesWeightsKind
  23741. * - VertexBuffer.MatricesWeightsExtraKind
  23742. * @param data defines the data source
  23743. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23744. * @param stride defines the data stride size (can be null)
  23745. * @returns the current mesh
  23746. */
  23747. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23748. /**
  23749. * Delete a vertex buffer associated with this mesh
  23750. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  23751. * - VertexBuffer.PositionKind
  23752. * - VertexBuffer.UVKind
  23753. * - VertexBuffer.UV2Kind
  23754. * - VertexBuffer.UV3Kind
  23755. * - VertexBuffer.UV4Kind
  23756. * - VertexBuffer.UV5Kind
  23757. * - VertexBuffer.UV6Kind
  23758. * - VertexBuffer.ColorKind
  23759. * - VertexBuffer.MatricesIndicesKind
  23760. * - VertexBuffer.MatricesIndicesExtraKind
  23761. * - VertexBuffer.MatricesWeightsKind
  23762. * - VertexBuffer.MatricesWeightsExtraKind
  23763. */
  23764. removeVerticesData(kind: string): void;
  23765. /**
  23766. * Flags an associated vertex buffer as updatable
  23767. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23768. * - VertexBuffer.PositionKind
  23769. * - VertexBuffer.UVKind
  23770. * - VertexBuffer.UV2Kind
  23771. * - VertexBuffer.UV3Kind
  23772. * - VertexBuffer.UV4Kind
  23773. * - VertexBuffer.UV5Kind
  23774. * - VertexBuffer.UV6Kind
  23775. * - VertexBuffer.ColorKind
  23776. * - VertexBuffer.MatricesIndicesKind
  23777. * - VertexBuffer.MatricesIndicesExtraKind
  23778. * - VertexBuffer.MatricesWeightsKind
  23779. * - VertexBuffer.MatricesWeightsExtraKind
  23780. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23781. */
  23782. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23783. /**
  23784. * Sets the mesh global Vertex Buffer
  23785. * @param buffer defines the buffer to use
  23786. * @returns the current mesh
  23787. */
  23788. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23789. /**
  23790. * Update a specific associated vertex buffer
  23791. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23792. * - VertexBuffer.PositionKind
  23793. * - VertexBuffer.UVKind
  23794. * - VertexBuffer.UV2Kind
  23795. * - VertexBuffer.UV3Kind
  23796. * - VertexBuffer.UV4Kind
  23797. * - VertexBuffer.UV5Kind
  23798. * - VertexBuffer.UV6Kind
  23799. * - VertexBuffer.ColorKind
  23800. * - VertexBuffer.MatricesIndicesKind
  23801. * - VertexBuffer.MatricesIndicesExtraKind
  23802. * - VertexBuffer.MatricesWeightsKind
  23803. * - VertexBuffer.MatricesWeightsExtraKind
  23804. * @param data defines the data source
  23805. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23806. * @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)
  23807. * @returns the current mesh
  23808. */
  23809. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23810. /**
  23811. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23812. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23813. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23814. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23815. * @returns the current mesh
  23816. */
  23817. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23818. /**
  23819. * Creates a un-shared specific occurence of the geometry for the mesh.
  23820. * @returns the current mesh
  23821. */
  23822. makeGeometryUnique(): Mesh;
  23823. /**
  23824. * Set the index buffer of this mesh
  23825. * @param indices defines the source data
  23826. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23827. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23828. * @returns the current mesh
  23829. */
  23830. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23831. /**
  23832. * Update the current index buffer
  23833. * @param indices defines the source data
  23834. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23835. * @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)
  23836. * @returns the current mesh
  23837. */
  23838. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23839. /**
  23840. * Invert the geometry to move from a right handed system to a left handed one.
  23841. * @returns the current mesh
  23842. */
  23843. toLeftHanded(): Mesh;
  23844. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23845. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23846. /**
  23847. * Registers for this mesh a javascript function called just before the rendering process
  23848. * @param func defines the function to call before rendering this mesh
  23849. * @returns the current mesh
  23850. */
  23851. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23852. /**
  23853. * Disposes a previously registered javascript function called before the rendering
  23854. * @param func defines the function to remove
  23855. * @returns the current mesh
  23856. */
  23857. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23858. /**
  23859. * Registers for this mesh a javascript function called just after the rendering is complete
  23860. * @param func defines the function to call after rendering this mesh
  23861. * @returns the current mesh
  23862. */
  23863. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23864. /**
  23865. * Disposes a previously registered javascript function called after the rendering.
  23866. * @param func defines the function to remove
  23867. * @returns the current mesh
  23868. */
  23869. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23870. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23871. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23872. /** @hidden */ private _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  23873. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23874. /** @hidden */ private _rebuild(): void;
  23875. /** @hidden */ private _freeze(): void;
  23876. /** @hidden */ private _unFreeze(): void;
  23877. /**
  23878. * 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
  23879. * @param subMesh defines the subMesh to render
  23880. * @param enableAlphaMode defines if alpha mode can be changed
  23881. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  23882. * @returns the current mesh
  23883. */
  23884. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  23885. private _onBeforeDraw;
  23886. /**
  23887. * Renormalize the mesh and patch it up if there are no weights
  23888. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23889. * However in the case of zero weights then we set just a single influence to 1.
  23890. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23891. */
  23892. cleanMatrixWeights(): void;
  23893. private normalizeSkinFourWeights;
  23894. private normalizeSkinWeightsAndExtra;
  23895. /**
  23896. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23897. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23898. * the user know there was an issue with importing the mesh
  23899. * @returns a validation object with skinned, valid and report string
  23900. */
  23901. validateSkinning(): {
  23902. skinned: boolean;
  23903. valid: boolean;
  23904. report: string;
  23905. };
  23906. /** @hidden */ private _checkDelayState(): Mesh;
  23907. private _queueLoad;
  23908. /**
  23909. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23910. * A mesh is in the frustum if its bounding box intersects the frustum
  23911. * @param frustumPlanes defines the frustum to test
  23912. * @returns true if the mesh is in the frustum planes
  23913. */
  23914. isInFrustum(frustumPlanes: Plane[]): boolean;
  23915. /**
  23916. * Sets the mesh material by the material or multiMaterial `id` property
  23917. * @param id is a string identifying the material or the multiMaterial
  23918. * @returns the current mesh
  23919. */
  23920. setMaterialByID(id: string): Mesh;
  23921. /**
  23922. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23923. * @returns an array of IAnimatable
  23924. */
  23925. getAnimatables(): IAnimatable[];
  23926. /**
  23927. * Modifies the mesh geometry according to the passed transformation matrix.
  23928. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23929. * The mesh normals are modified using the same transformation.
  23930. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23931. * @param transform defines the transform matrix to use
  23932. * @see http://doc.babylonjs.com/resources/baking_transformations
  23933. * @returns the current mesh
  23934. */
  23935. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23936. /**
  23937. * Modifies the mesh geometry according to its own current World Matrix.
  23938. * The mesh World Matrix is then reset.
  23939. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23940. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23941. * @see http://doc.babylonjs.com/resources/baking_transformations
  23942. * @returns the current mesh
  23943. */
  23944. bakeCurrentTransformIntoVertices(): Mesh;
  23945. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23946. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23947. /** @hidden */ private _generatePointsArray(): boolean;
  23948. /**
  23949. * Returns a new Mesh object generated from the current mesh properties.
  23950. * This method must not get confused with createInstance()
  23951. * @param name is a string, the name given to the new mesh
  23952. * @param newParent can be any Node object (default `null`)
  23953. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23954. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23955. * @returns a new mesh
  23956. */
  23957. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23958. /**
  23959. * Releases resources associated with this mesh.
  23960. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23961. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23962. */
  23963. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23964. /** @hidden */ private _disposeInstanceSpecificData(): void;
  23965. /**
  23966. * Modifies the mesh geometry according to a displacement map.
  23967. * 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.
  23968. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23969. * @param url is a string, the URL from the image file is to be downloaded.
  23970. * @param minHeight is the lower limit of the displacement.
  23971. * @param maxHeight is the upper limit of the displacement.
  23972. * @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.
  23973. * @param uvOffset is an optional vector2 used to offset UV.
  23974. * @param uvScale is an optional vector2 used to scale UV.
  23975. * @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.
  23976. * @returns the Mesh.
  23977. */
  23978. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23979. /**
  23980. * Modifies the mesh geometry according to a displacementMap buffer.
  23981. * 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.
  23982. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23983. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23984. * @param heightMapWidth is the width of the buffer image.
  23985. * @param heightMapHeight is the height of the buffer image.
  23986. * @param minHeight is the lower limit of the displacement.
  23987. * @param maxHeight is the upper limit of the displacement.
  23988. * @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.
  23989. * @param uvOffset is an optional vector2 used to offset UV.
  23990. * @param uvScale is an optional vector2 used to scale UV.
  23991. * @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.
  23992. * @returns the Mesh.
  23993. */
  23994. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23995. /**
  23996. * Modify the mesh to get a flat shading rendering.
  23997. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23998. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23999. * @returns current mesh
  24000. */
  24001. convertToFlatShadedMesh(): Mesh;
  24002. /**
  24003. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24004. * In other words, more vertices, no more indices and a single bigger VBO.
  24005. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24006. * @returns current mesh
  24007. */
  24008. convertToUnIndexedMesh(): Mesh;
  24009. /**
  24010. * Inverses facet orientations.
  24011. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24012. * @param flipNormals will also inverts the normals
  24013. * @returns current mesh
  24014. */
  24015. flipFaces(flipNormals?: boolean): Mesh;
  24016. /**
  24017. * Increase the number of facets and hence vertices in a mesh
  24018. * Vertex normals are interpolated from existing vertex normals
  24019. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24020. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24021. */
  24022. increaseVertices(numberPerEdge: number): void;
  24023. /**
  24024. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24025. * This will undo any application of covertToFlatShadedMesh
  24026. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24027. */
  24028. forceSharedVertices(): void;
  24029. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24030. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24031. /**
  24032. * Creates a new InstancedMesh object from the mesh model.
  24033. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24034. * @param name defines the name of the new instance
  24035. * @returns a new InstancedMesh
  24036. */
  24037. createInstance(name: string): InstancedMesh;
  24038. /**
  24039. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24040. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24041. * @returns the current mesh
  24042. */
  24043. synchronizeInstances(): Mesh;
  24044. /**
  24045. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24046. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24047. * This should be used together with the simplification to avoid disappearing triangles.
  24048. * @param successCallback an optional success callback to be called after the optimization finished.
  24049. * @returns the current mesh
  24050. */
  24051. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24052. /**
  24053. * Serialize current mesh
  24054. * @param serializationObject defines the object which will receive the serialization data
  24055. */
  24056. serialize(serializationObject: any): void;
  24057. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  24058. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24059. /**
  24060. * Returns a new Mesh object parsed from the source provided.
  24061. * @param parsedMesh is the source
  24062. * @param scene defines the hosting scene
  24063. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24064. * @returns a new Mesh
  24065. */
  24066. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24067. /**
  24068. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24069. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24070. * @param name defines the name of the mesh to create
  24071. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24072. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24073. * @param closePath creates a seam between the first and the last points of each path of the path array
  24074. * @param offset is taken in account only if the `pathArray` is containing a single path
  24075. * @param scene defines the hosting scene
  24076. * @param updatable defines if the mesh must be flagged as updatable
  24077. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24078. * @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)
  24079. * @returns a new Mesh
  24080. */
  24081. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24082. /**
  24083. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24084. * @param name defines the name of the mesh to create
  24085. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24086. * @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
  24087. * @param scene defines the hosting scene
  24088. * @param updatable defines if the mesh must be flagged as updatable
  24089. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24090. * @returns a new Mesh
  24091. */
  24092. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24093. /**
  24094. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24095. * @param name defines the name of the mesh to create
  24096. * @param size sets the size (float) of each box side (default 1)
  24097. * @param scene defines the hosting scene
  24098. * @param updatable defines if the mesh must be flagged as updatable
  24099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24100. * @returns a new Mesh
  24101. */
  24102. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24103. /**
  24104. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24105. * @param name defines the name of the mesh to create
  24106. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24107. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24108. * @param scene defines the hosting scene
  24109. * @param updatable defines if the mesh must be flagged as updatable
  24110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24111. * @returns a new Mesh
  24112. */
  24113. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24114. /**
  24115. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24116. * @param name defines the name of the mesh to create
  24117. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24118. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24119. * @param scene defines the hosting scene
  24120. * @returns a new Mesh
  24121. */
  24122. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24123. /**
  24124. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24125. * @param name defines the name of the mesh to create
  24126. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24127. * @param diameterTop set the top cap diameter (floats, default 1)
  24128. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24129. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24130. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24131. * @param scene defines the hosting scene
  24132. * @param updatable defines if the mesh must be flagged as updatable
  24133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24134. * @returns a new Mesh
  24135. */
  24136. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24137. /**
  24138. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24139. * @param name defines the name of the mesh to create
  24140. * @param diameter sets the diameter size (float) of the torus (default 1)
  24141. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24142. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24143. * @param scene defines the hosting scene
  24144. * @param updatable defines if the mesh must be flagged as updatable
  24145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24146. * @returns a new Mesh
  24147. */
  24148. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24149. /**
  24150. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24151. * @param name defines the name of the mesh to create
  24152. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24153. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24154. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24155. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24156. * @param p the number of windings on X axis (positive integers, default 2)
  24157. * @param q the number of windings on Y axis (positive integers, default 3)
  24158. * @param scene defines the hosting scene
  24159. * @param updatable defines if the mesh must be flagged as updatable
  24160. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24161. * @returns a new Mesh
  24162. */
  24163. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24164. /**
  24165. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24166. * @param name defines the name of the mesh to create
  24167. * @param points is an array successive Vector3
  24168. * @param scene defines the hosting scene
  24169. * @param updatable defines if the mesh must be flagged as updatable
  24170. * @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).
  24171. * @returns a new Mesh
  24172. */
  24173. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24174. /**
  24175. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24176. * @param name defines the name of the mesh to create
  24177. * @param points is an array successive Vector3
  24178. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24179. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24180. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24181. * @param scene defines the hosting scene
  24182. * @param updatable defines if the mesh must be flagged as updatable
  24183. * @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)
  24184. * @returns a new Mesh
  24185. */
  24186. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24187. /**
  24188. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24189. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24190. * 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.
  24191. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24192. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24193. * Remember you can only change the shape positions, not their number when updating a polygon.
  24194. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24195. * @param name defines the name of the mesh to create
  24196. * @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
  24197. * @param scene defines the hosting scene
  24198. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24199. * @param updatable defines if the mesh must be flagged as updatable
  24200. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24201. * @param earcutInjection can be used to inject your own earcut reference
  24202. * @returns a new Mesh
  24203. */
  24204. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24205. /**
  24206. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24207. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24208. * @param name defines the name of the mesh to create
  24209. * @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
  24210. * @param depth defines the height of extrusion
  24211. * @param scene defines the hosting scene
  24212. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24213. * @param updatable defines if the mesh must be flagged as updatable
  24214. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24215. * @param earcutInjection can be used to inject your own earcut reference
  24216. * @returns a new Mesh
  24217. */
  24218. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24219. /**
  24220. * Creates an extruded shape mesh.
  24221. * 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
  24222. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24223. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24224. * @param name defines the name of the mesh to create
  24225. * @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
  24226. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24227. * @param scale is the value to scale the shape
  24228. * @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
  24229. * @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
  24230. * @param scene defines the hosting scene
  24231. * @param updatable defines if the mesh must be flagged as updatable
  24232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24233. * @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)
  24234. * @returns a new Mesh
  24235. */
  24236. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24237. /**
  24238. * Creates an custom extruded shape mesh.
  24239. * The custom extrusion is a parametric shape.
  24240. * It has no predefined shape. Its final shape will depend on the input parameters.
  24241. * Please consider using the same method from the MeshBuilder class instead
  24242. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24243. * @param name defines the name of the mesh to create
  24244. * @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
  24245. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24246. * @param scaleFunction is a custom Javascript function called on each path point
  24247. * @param rotationFunction is a custom Javascript function called on each path point
  24248. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24249. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24250. * @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
  24251. * @param scene defines the hosting scene
  24252. * @param updatable defines if the mesh must be flagged as updatable
  24253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24254. * @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)
  24255. * @returns a new Mesh
  24256. */
  24257. 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;
  24258. /**
  24259. * Creates lathe mesh.
  24260. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24261. * Please consider using the same method from the MeshBuilder class instead
  24262. * @param name defines the name of the mesh to create
  24263. * @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
  24264. * @param radius is the radius value of the lathe
  24265. * @param tessellation is the side number of the lathe.
  24266. * @param scene defines the hosting scene
  24267. * @param updatable defines if the mesh must be flagged as updatable
  24268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24269. * @returns a new Mesh
  24270. */
  24271. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24272. /**
  24273. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24274. * @param name defines the name of the mesh to create
  24275. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24276. * @param scene defines the hosting scene
  24277. * @param updatable defines if the mesh must be flagged as updatable
  24278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24279. * @returns a new Mesh
  24280. */
  24281. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24282. /**
  24283. * Creates a ground mesh.
  24284. * Please consider using the same method from the MeshBuilder class instead
  24285. * @param name defines the name of the mesh to create
  24286. * @param width set the width of the ground
  24287. * @param height set the height of the ground
  24288. * @param subdivisions sets the number of subdivisions per side
  24289. * @param scene defines the hosting scene
  24290. * @param updatable defines if the mesh must be flagged as updatable
  24291. * @returns a new Mesh
  24292. */
  24293. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24294. /**
  24295. * Creates a tiled ground mesh.
  24296. * Please consider using the same method from the MeshBuilder class instead
  24297. * @param name defines the name of the mesh to create
  24298. * @param xmin set the ground minimum X coordinate
  24299. * @param zmin set the ground minimum Y coordinate
  24300. * @param xmax set the ground maximum X coordinate
  24301. * @param zmax set the ground maximum Z coordinate
  24302. * @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
  24303. * @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
  24304. * @param scene defines the hosting scene
  24305. * @param updatable defines if the mesh must be flagged as updatable
  24306. * @returns a new Mesh
  24307. */
  24308. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24309. w: number;
  24310. h: number;
  24311. }, precision: {
  24312. w: number;
  24313. h: number;
  24314. }, scene: Scene, updatable?: boolean): Mesh;
  24315. /**
  24316. * Creates a ground mesh from a height map.
  24317. * Please consider using the same method from the MeshBuilder class instead
  24318. * @see http://doc.babylonjs.com/babylon101/height_map
  24319. * @param name defines the name of the mesh to create
  24320. * @param url sets the URL of the height map image resource
  24321. * @param width set the ground width size
  24322. * @param height set the ground height size
  24323. * @param subdivisions sets the number of subdivision per side
  24324. * @param minHeight is the minimum altitude on the ground
  24325. * @param maxHeight is the maximum altitude on the ground
  24326. * @param scene defines the hosting scene
  24327. * @param updatable defines if the mesh must be flagged as updatable
  24328. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24329. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24330. * @returns a new Mesh
  24331. */
  24332. 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;
  24333. /**
  24334. * Creates a tube mesh.
  24335. * The tube is a parametric shape.
  24336. * It has no predefined shape. Its final shape will depend on the input parameters.
  24337. * Please consider using the same method from the MeshBuilder class instead
  24338. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24339. * @param name defines the name of the mesh to create
  24340. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24341. * @param radius sets the tube radius size
  24342. * @param tessellation is the number of sides on the tubular surface
  24343. * @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
  24344. * @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
  24345. * @param scene defines the hosting scene
  24346. * @param updatable defines if the mesh must be flagged as updatable
  24347. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24348. * @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)
  24349. * @returns a new Mesh
  24350. */
  24351. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24352. (i: number, distance: number): number;
  24353. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24354. /**
  24355. * Creates a polyhedron mesh.
  24356. * Please consider using the same method from the MeshBuilder class instead.
  24357. * * 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
  24358. * * The parameter `size` (positive float, default 1) sets the polygon size
  24359. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24360. * * 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`
  24361. * * 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
  24362. * * 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)`)
  24363. * * 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
  24364. * * 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
  24365. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24366. * * 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
  24367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24368. * @param name defines the name of the mesh to create
  24369. * @param options defines the options used to create the mesh
  24370. * @param scene defines the hosting scene
  24371. * @returns a new Mesh
  24372. */
  24373. static CreatePolyhedron(name: string, options: {
  24374. type?: number;
  24375. size?: number;
  24376. sizeX?: number;
  24377. sizeY?: number;
  24378. sizeZ?: number;
  24379. custom?: any;
  24380. faceUV?: Vector4[];
  24381. faceColors?: Color4[];
  24382. updatable?: boolean;
  24383. sideOrientation?: number;
  24384. }, scene: Scene): Mesh;
  24385. /**
  24386. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24387. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24388. * * 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`)
  24389. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24390. * * 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
  24391. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24392. * * 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
  24393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24394. * @param name defines the name of the mesh
  24395. * @param options defines the options used to create the mesh
  24396. * @param scene defines the hosting scene
  24397. * @returns a new Mesh
  24398. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24399. */
  24400. static CreateIcoSphere(name: string, options: {
  24401. radius?: number;
  24402. flat?: boolean;
  24403. subdivisions?: number;
  24404. sideOrientation?: number;
  24405. updatable?: boolean;
  24406. }, scene: Scene): Mesh;
  24407. /**
  24408. * Creates a decal mesh.
  24409. * Please consider using the same method from the MeshBuilder class instead.
  24410. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24411. * @param name defines the name of the mesh
  24412. * @param sourceMesh defines the mesh receiving the decal
  24413. * @param position sets the position of the decal in world coordinates
  24414. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24415. * @param size sets the decal scaling
  24416. * @param angle sets the angle to rotate the decal
  24417. * @returns a new Mesh
  24418. */
  24419. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24420. /**
  24421. * Prepare internal position array for software CPU skinning
  24422. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24423. */
  24424. setPositionsForCPUSkinning(): Float32Array;
  24425. /**
  24426. * Prepare internal normal array for software CPU skinning
  24427. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24428. */
  24429. setNormalsForCPUSkinning(): Float32Array;
  24430. /**
  24431. * Updates the vertex buffer by applying transformation from the bones
  24432. * @param skeleton defines the skeleton to apply to current mesh
  24433. * @returns the current mesh
  24434. */
  24435. applySkeleton(skeleton: Skeleton): Mesh;
  24436. /**
  24437. * 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
  24438. * @param meshes defines the list of meshes to scan
  24439. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24440. */
  24441. static MinMax(meshes: AbstractMesh[]): {
  24442. min: Vector3;
  24443. max: Vector3;
  24444. };
  24445. /**
  24446. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24447. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24448. * @returns a vector3
  24449. */
  24450. static Center(meshesOrMinMaxVector: {
  24451. min: Vector3;
  24452. max: Vector3;
  24453. } | AbstractMesh[]): Vector3;
  24454. /**
  24455. * Merge the array of meshes into a single mesh for performance reasons.
  24456. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24457. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24458. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24459. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24460. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24461. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24462. * @returns a new mesh
  24463. */
  24464. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24465. /** @hidden */
  24466. addInstance(instance: InstancedMesh): void;
  24467. /** @hidden */
  24468. removeInstance(instance: InstancedMesh): void;
  24469. }
  24470. }
  24471. declare module BABYLON {
  24472. /**
  24473. * This is the base class of all the camera used in the application.
  24474. * @see http://doc.babylonjs.com/features/cameras
  24475. */
  24476. export class Camera extends Node {
  24477. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24478. /**
  24479. * This is the default projection mode used by the cameras.
  24480. * It helps recreating a feeling of perspective and better appreciate depth.
  24481. * This is the best way to simulate real life cameras.
  24482. */
  24483. static readonly PERSPECTIVE_CAMERA: number;
  24484. /**
  24485. * This helps creating camera with an orthographic mode.
  24486. * 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.
  24487. */
  24488. static readonly ORTHOGRAPHIC_CAMERA: number;
  24489. /**
  24490. * This is the default FOV mode for perspective cameras.
  24491. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24492. */
  24493. static readonly FOVMODE_VERTICAL_FIXED: number;
  24494. /**
  24495. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24496. */
  24497. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24498. /**
  24499. * This specifies ther is no need for a camera rig.
  24500. * Basically only one eye is rendered corresponding to the camera.
  24501. */
  24502. static readonly RIG_MODE_NONE: number;
  24503. /**
  24504. * Simulates a camera Rig with one blue eye and one red eye.
  24505. * This can be use with 3d blue and red glasses.
  24506. */
  24507. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24508. /**
  24509. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24510. */
  24511. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24512. /**
  24513. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24514. */
  24515. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24516. /**
  24517. * Defines that both eyes of the camera will be rendered over under each other.
  24518. */
  24519. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24520. /**
  24521. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24522. */
  24523. static readonly RIG_MODE_VR: number;
  24524. /**
  24525. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24526. */
  24527. static readonly RIG_MODE_WEBVR: number;
  24528. /**
  24529. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24530. */
  24531. static readonly RIG_MODE_CUSTOM: number;
  24532. /**
  24533. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24534. */
  24535. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24536. /**
  24537. * Define the input manager associated with the camera.
  24538. */
  24539. inputs: CameraInputsManager<Camera>;
  24540. /** @hidden */ private _position: Vector3;
  24541. /**
  24542. * Define the current local position of the camera in the scene
  24543. */
  24544. position: Vector3;
  24545. /**
  24546. * The vector the camera should consider as up.
  24547. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24548. */
  24549. upVector: Vector3;
  24550. /**
  24551. * Define the current limit on the left side for an orthographic camera
  24552. * In scene unit
  24553. */
  24554. orthoLeft: Nullable<number>;
  24555. /**
  24556. * Define the current limit on the right side for an orthographic camera
  24557. * In scene unit
  24558. */
  24559. orthoRight: Nullable<number>;
  24560. /**
  24561. * Define the current limit on the bottom side for an orthographic camera
  24562. * In scene unit
  24563. */
  24564. orthoBottom: Nullable<number>;
  24565. /**
  24566. * Define the current limit on the top side for an orthographic camera
  24567. * In scene unit
  24568. */
  24569. orthoTop: Nullable<number>;
  24570. /**
  24571. * Field Of View is set in Radians. (default is 0.8)
  24572. */
  24573. fov: number;
  24574. /**
  24575. * Define the minimum distance the camera can see from.
  24576. * This is important to note that the depth buffer are not infinite and the closer it starts
  24577. * the more your scene might encounter depth fighting issue.
  24578. */
  24579. minZ: number;
  24580. /**
  24581. * Define the maximum distance the camera can see to.
  24582. * This is important to note that the depth buffer are not infinite and the further it end
  24583. * the more your scene might encounter depth fighting issue.
  24584. */
  24585. maxZ: number;
  24586. /**
  24587. * Define the default inertia of the camera.
  24588. * This helps giving a smooth feeling to the camera movement.
  24589. */
  24590. inertia: number;
  24591. /**
  24592. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24593. */
  24594. mode: number;
  24595. /**
  24596. * Define wether the camera is intermediate.
  24597. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24598. */
  24599. isIntermediate: boolean;
  24600. /**
  24601. * Define the viewport of the camera.
  24602. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24603. */
  24604. viewport: Viewport;
  24605. /**
  24606. * Restricts the camera to viewing objects with the same layerMask.
  24607. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24608. */
  24609. layerMask: number;
  24610. /**
  24611. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24612. */
  24613. fovMode: number;
  24614. /**
  24615. * Rig mode of the camera.
  24616. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24617. * This is normally controlled byt the camera themselves as internal use.
  24618. */
  24619. cameraRigMode: number;
  24620. /**
  24621. * Defines the distance between both "eyes" in case of a RIG
  24622. */
  24623. interaxialDistance: number;
  24624. /**
  24625. * Defines if stereoscopic rendering is done side by side or over under.
  24626. */
  24627. isStereoscopicSideBySide: boolean;
  24628. /**
  24629. * 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
  24630. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24631. * else in the scene. (Eg. security camera)
  24632. *
  24633. * 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)
  24634. */
  24635. customRenderTargets: RenderTargetTexture[];
  24636. /**
  24637. * When set, the camera will render to this render target instead of the default canvas
  24638. *
  24639. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24640. */
  24641. outputRenderTarget: Nullable<RenderTargetTexture>;
  24642. /**
  24643. * Observable triggered when the camera view matrix has changed.
  24644. */
  24645. onViewMatrixChangedObservable: Observable<Camera>;
  24646. /**
  24647. * Observable triggered when the camera Projection matrix has changed.
  24648. */
  24649. onProjectionMatrixChangedObservable: Observable<Camera>;
  24650. /**
  24651. * Observable triggered when the inputs have been processed.
  24652. */
  24653. onAfterCheckInputsObservable: Observable<Camera>;
  24654. /**
  24655. * Observable triggered when reset has been called and applied to the camera.
  24656. */
  24657. onRestoreStateObservable: Observable<Camera>;
  24658. /** @hidden */ private _cameraRigParams: any;
  24659. /** @hidden */ private _rigCameras: Camera[];
  24660. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24661. protected _webvrViewMatrix: Matrix;
  24662. /** @hidden */ private _skipRendering: boolean;
  24663. /** @hidden */ private _projectionMatrix: Matrix;
  24664. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24665. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24666. protected _globalPosition: Vector3;
  24667. /** @hidden */ private _computedViewMatrix: Matrix;
  24668. private _doNotComputeProjectionMatrix;
  24669. private _transformMatrix;
  24670. private _frustumPlanes;
  24671. private _refreshFrustumPlanes;
  24672. private _storedFov;
  24673. private _stateStored;
  24674. /**
  24675. * Instantiates a new camera object.
  24676. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24677. * @see http://doc.babylonjs.com/features/cameras
  24678. * @param name Defines the name of the camera in the scene
  24679. * @param position Defines the position of the camera
  24680. * @param scene Defines the scene the camera belongs too
  24681. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24682. */
  24683. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24684. /**
  24685. * Store current camera state (fov, position, etc..)
  24686. * @returns the camera
  24687. */
  24688. storeState(): Camera;
  24689. /**
  24690. * Restores the camera state values if it has been stored. You must call storeState() first
  24691. */
  24692. protected _restoreStateValues(): boolean;
  24693. /**
  24694. * Restored camera state. You must call storeState() first.
  24695. * @returns true if restored and false otherwise
  24696. */
  24697. restoreState(): boolean;
  24698. /**
  24699. * Gets the class name of the camera.
  24700. * @returns the class name
  24701. */
  24702. getClassName(): string;
  24703. /** @hidden */ protected readonly _isCamera: boolean;
  24704. /**
  24705. * Gets a string representation of the camera useful for debug purpose.
  24706. * @param fullDetails Defines that a more verboe level of logging is required
  24707. * @returns the string representation
  24708. */
  24709. toString(fullDetails?: boolean): string;
  24710. /**
  24711. * Gets the current world space position of the camera.
  24712. */
  24713. readonly globalPosition: Vector3;
  24714. /**
  24715. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24716. * @returns the active meshe list
  24717. */
  24718. getActiveMeshes(): SmartArray<AbstractMesh>;
  24719. /**
  24720. * Check wether a mesh is part of the current active mesh list of the camera
  24721. * @param mesh Defines the mesh to check
  24722. * @returns true if active, false otherwise
  24723. */
  24724. isActiveMesh(mesh: Mesh): boolean;
  24725. /**
  24726. * Is this camera ready to be used/rendered
  24727. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24728. * @return true if the camera is ready
  24729. */
  24730. isReady(completeCheck?: boolean): boolean;
  24731. /** @hidden */ private _initCache(): void;
  24732. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24733. /** @hidden */ private _isSynchronized(): boolean;
  24734. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24735. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24736. /**
  24737. * Attach the input controls to a specific dom element to get the input from.
  24738. * @param element Defines the element the controls should be listened from
  24739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24740. */
  24741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24742. /**
  24743. * Detach the current controls from the specified dom element.
  24744. * @param element Defines the element to stop listening the inputs from
  24745. */
  24746. detachControl(element: HTMLElement): void;
  24747. /**
  24748. * Update the camera state according to the different inputs gathered during the frame.
  24749. */
  24750. update(): void;
  24751. /** @hidden */ private _checkInputs(): void;
  24752. /** @hidden */
  24753. readonly rigCameras: Camera[];
  24754. /**
  24755. * Gets the post process used by the rig cameras
  24756. */
  24757. readonly rigPostProcess: Nullable<PostProcess>;
  24758. /**
  24759. * Internal, gets the first post proces.
  24760. * @returns the first post process to be run on this camera.
  24761. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24762. private _cascadePostProcessesToRigCams;
  24763. /**
  24764. * Attach a post process to the camera.
  24765. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24766. * @param postProcess The post process to attach to the camera
  24767. * @param insertAt The position of the post process in case several of them are in use in the scene
  24768. * @returns the position the post process has been inserted at
  24769. */
  24770. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24771. /**
  24772. * Detach a post process to the camera.
  24773. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24774. * @param postProcess The post process to detach from the camera
  24775. */
  24776. detachPostProcess(postProcess: PostProcess): void;
  24777. /**
  24778. * Gets the current world matrix of the camera
  24779. */
  24780. getWorldMatrix(): Matrix;
  24781. /** @hidden */ private _getViewMatrix(): Matrix;
  24782. /**
  24783. * Gets the current view matrix of the camera.
  24784. * @param force forces the camera to recompute the matrix without looking at the cached state
  24785. * @returns the view matrix
  24786. */
  24787. getViewMatrix(force?: boolean): Matrix;
  24788. /**
  24789. * Freeze the projection matrix.
  24790. * It will prevent the cache check of the camera projection compute and can speed up perf
  24791. * if no parameter of the camera are meant to change
  24792. * @param projection Defines manually a projection if necessary
  24793. */
  24794. freezeProjectionMatrix(projection?: Matrix): void;
  24795. /**
  24796. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24797. */
  24798. unfreezeProjectionMatrix(): void;
  24799. /**
  24800. * Gets the current projection matrix of the camera.
  24801. * @param force forces the camera to recompute the matrix without looking at the cached state
  24802. * @returns the projection matrix
  24803. */
  24804. getProjectionMatrix(force?: boolean): Matrix;
  24805. /**
  24806. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24807. * @returns a Matrix
  24808. */
  24809. getTransformationMatrix(): Matrix;
  24810. private _updateFrustumPlanes;
  24811. /**
  24812. * Checks if a cullable object (mesh...) is in the camera frustum
  24813. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24814. * @param target The object to check
  24815. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24816. * @returns true if the object is in frustum otherwise false
  24817. */
  24818. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24819. /**
  24820. * Checks if a cullable object (mesh...) is in the camera frustum
  24821. * Unlike isInFrustum this cheks the full bounding box
  24822. * @param target The object to check
  24823. * @returns true if the object is in frustum otherwise false
  24824. */
  24825. isCompletelyInFrustum(target: ICullable): boolean;
  24826. /**
  24827. * Gets a ray in the forward direction from the camera.
  24828. * @param length Defines the length of the ray to create
  24829. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24830. * @param origin Defines the start point of the ray which defaults to the camera position
  24831. * @returns the forward ray
  24832. */
  24833. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24834. /**
  24835. * Releases resources associated with this node.
  24836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24838. */
  24839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24840. /** @hidden */ private _isLeftCamera: boolean;
  24841. /**
  24842. * Gets the left camera of a rig setup in case of Rigged Camera
  24843. */
  24844. readonly isLeftCamera: boolean;
  24845. /** @hidden */ private _isRightCamera: boolean;
  24846. /**
  24847. * Gets the right camera of a rig setup in case of Rigged Camera
  24848. */
  24849. readonly isRightCamera: boolean;
  24850. /**
  24851. * Gets the left camera of a rig setup in case of Rigged Camera
  24852. */
  24853. readonly leftCamera: Nullable<FreeCamera>;
  24854. /**
  24855. * Gets the right camera of a rig setup in case of Rigged Camera
  24856. */
  24857. readonly rightCamera: Nullable<FreeCamera>;
  24858. /**
  24859. * Gets the left camera target of a rig setup in case of Rigged Camera
  24860. * @returns the target position
  24861. */
  24862. getLeftTarget(): Nullable<Vector3>;
  24863. /**
  24864. * Gets the right camera target of a rig setup in case of Rigged Camera
  24865. * @returns the target position
  24866. */
  24867. getRightTarget(): Nullable<Vector3>;
  24868. /**
  24869. * @hidden
  24870. */
  24871. setCameraRigMode(mode: number, rigParams: any): void;
  24872. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24873. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24874. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24875. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24876. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24877. protected _updateCameraRotationMatrix(): void;
  24878. protected _updateWebVRCameraRotationMatrix(): void;
  24879. /**
  24880. * This function MUST be overwritten by the different WebVR cameras available.
  24881. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24882. * @hidden
  24883. */ private _getWebVRProjectionMatrix(): Matrix;
  24884. /**
  24885. * This function MUST be overwritten by the different WebVR cameras available.
  24886. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24887. * @hidden
  24888. */ private _getWebVRViewMatrix(): Matrix;
  24889. /** @hidden */
  24890. setCameraRigParameter(name: string, value: any): void;
  24891. /**
  24892. * needs to be overridden by children so sub has required properties to be copied
  24893. * @hidden
  24894. */
  24895. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24896. /**
  24897. * May need to be overridden by children
  24898. * @hidden
  24899. */ private _updateRigCameras(): void;
  24900. /** @hidden */ private _setupInputs(): void;
  24901. /**
  24902. * Serialiaze the camera setup to a json represention
  24903. * @returns the JSON representation
  24904. */
  24905. serialize(): any;
  24906. /**
  24907. * Clones the current camera.
  24908. * @param name The cloned camera name
  24909. * @returns the cloned camera
  24910. */
  24911. clone(name: string): Camera;
  24912. /**
  24913. * Gets the direction of the camera relative to a given local axis.
  24914. * @param localAxis Defines the reference axis to provide a relative direction.
  24915. * @return the direction
  24916. */
  24917. getDirection(localAxis: Vector3): Vector3;
  24918. /**
  24919. * Returns the current camera absolute rotation
  24920. */
  24921. readonly absoluteRotation: Quaternion;
  24922. /**
  24923. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24924. * @param localAxis Defines the reference axis to provide a relative direction.
  24925. * @param result Defines the vector to store the result in
  24926. */
  24927. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24928. /**
  24929. * Gets a camera constructor for a given camera type
  24930. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24931. * @param name The name of the camera the result will be able to instantiate
  24932. * @param scene The scene the result will construct the camera in
  24933. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24934. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24935. * @returns a factory method to construc the camera
  24936. */
  24937. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24938. /**
  24939. * Compute the world matrix of the camera.
  24940. * @returns the camera world matrix
  24941. */
  24942. computeWorldMatrix(): Matrix;
  24943. /**
  24944. * Parse a JSON and creates the camera from the parsed information
  24945. * @param parsedCamera The JSON to parse
  24946. * @param scene The scene to instantiate the camera in
  24947. * @returns the newly constructed camera
  24948. */
  24949. static Parse(parsedCamera: any, scene: Scene): Camera;
  24950. }
  24951. }
  24952. declare module BABYLON {
  24953. /**
  24954. * Class containing static functions to help procedurally build meshes
  24955. */
  24956. export class DiscBuilder {
  24957. /**
  24958. * Creates a plane polygonal mesh. By default, this is a disc
  24959. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24960. * * 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
  24961. * * 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
  24962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24963. * * 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
  24964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24965. * @param name defines the name of the mesh
  24966. * @param options defines the options used to create the mesh
  24967. * @param scene defines the hosting scene
  24968. * @returns the plane polygonal mesh
  24969. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24970. */
  24971. static CreateDisc(name: string, options: {
  24972. radius?: number;
  24973. tessellation?: number;
  24974. arc?: number;
  24975. updatable?: boolean;
  24976. sideOrientation?: number;
  24977. frontUVs?: Vector4;
  24978. backUVs?: Vector4;
  24979. }, scene?: Nullable<Scene>): Mesh;
  24980. }
  24981. }
  24982. declare module BABYLON {
  24983. /**
  24984. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24985. *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.
  24986. * The SPS is also a particle system. It provides some methods to manage the particles.
  24987. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24988. *
  24989. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24990. */
  24991. export class SolidParticleSystem implements IDisposable {
  24992. /**
  24993. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24994. * Example : var p = SPS.particles[i];
  24995. */
  24996. particles: SolidParticle[];
  24997. /**
  24998. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24999. */
  25000. nbParticles: number;
  25001. /**
  25002. * If the particles must ever face the camera (default false). Useful for planar particles.
  25003. */
  25004. billboard: boolean;
  25005. /**
  25006. * Recompute normals when adding a shape
  25007. */
  25008. recomputeNormals: boolean;
  25009. /**
  25010. * This a counter ofr your own usage. It's not set by any SPS functions.
  25011. */
  25012. counter: number;
  25013. /**
  25014. * The SPS name. This name is also given to the underlying mesh.
  25015. */
  25016. name: string;
  25017. /**
  25018. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25019. */
  25020. mesh: Mesh;
  25021. /**
  25022. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25023. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25024. */
  25025. vars: any;
  25026. /**
  25027. * This array is populated when the SPS is set as 'pickable'.
  25028. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25029. * Each element of this array is an object `{idx: int, faceId: int}`.
  25030. * `idx` is the picked particle index in the `SPS.particles` array
  25031. * `faceId` is the picked face index counted within this particle.
  25032. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25033. */
  25034. pickedParticles: {
  25035. idx: number;
  25036. faceId: number;
  25037. }[];
  25038. /**
  25039. * This array is populated when `enableDepthSort` is set to true.
  25040. * Each element of this array is an instance of the class DepthSortedParticle.
  25041. */
  25042. depthSortedParticles: DepthSortedParticle[];
  25043. /**
  25044. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25045. * @hidden
  25046. */ private _bSphereOnly: boolean;
  25047. /**
  25048. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25049. * @hidden
  25050. */ private _bSphereRadiusFactor: number;
  25051. private _scene;
  25052. private _positions;
  25053. private _indices;
  25054. private _normals;
  25055. private _colors;
  25056. private _uvs;
  25057. private _indices32;
  25058. private _positions32;
  25059. private _normals32;
  25060. private _fixedNormal32;
  25061. private _colors32;
  25062. private _uvs32;
  25063. private _index;
  25064. private _updatable;
  25065. private _pickable;
  25066. private _isVisibilityBoxLocked;
  25067. private _alwaysVisible;
  25068. private _depthSort;
  25069. private _expandable;
  25070. private _shapeCounter;
  25071. private _copy;
  25072. private _color;
  25073. private _computeParticleColor;
  25074. private _computeParticleTexture;
  25075. private _computeParticleRotation;
  25076. private _computeParticleVertex;
  25077. private _computeBoundingBox;
  25078. private _depthSortParticles;
  25079. private _camera;
  25080. private _mustUnrotateFixedNormals;
  25081. private _particlesIntersect;
  25082. private _needs32Bits;
  25083. private _isNotBuilt;
  25084. private _lastParticleId;
  25085. private _idxOfId;
  25086. /**
  25087. * Creates a SPS (Solid Particle System) object.
  25088. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25089. * @param scene (Scene) is the scene in which the SPS is added.
  25090. * @param options defines the options of the sps e.g.
  25091. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25092. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25093. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25094. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25095. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25096. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25097. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25098. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25099. */
  25100. constructor(name: string, scene: Scene, options?: {
  25101. updatable?: boolean;
  25102. isPickable?: boolean;
  25103. enableDepthSort?: boolean;
  25104. particleIntersection?: boolean;
  25105. boundingSphereOnly?: boolean;
  25106. bSphereRadiusFactor?: number;
  25107. expandable?: boolean;
  25108. });
  25109. /**
  25110. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25111. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25112. * @returns the created mesh
  25113. */
  25114. buildMesh(): Mesh;
  25115. /**
  25116. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25117. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25118. * Thus the particles generated from `digest()` have their property `position` set yet.
  25119. * @param mesh ( Mesh ) is the mesh to be digested
  25120. * @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
  25121. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25122. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25123. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  25124. * @returns the current SPS
  25125. */
  25126. digest(mesh: Mesh, options?: {
  25127. facetNb?: number;
  25128. number?: number;
  25129. delta?: number;
  25130. storage?: [];
  25131. }): SolidParticleSystem;
  25132. /**
  25133. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  25134. * @hidden
  25135. */
  25136. private _unrotateFixedNormals;
  25137. /**
  25138. * Resets the temporary working copy particle
  25139. * @hidden
  25140. */
  25141. private _resetCopy;
  25142. /**
  25143. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  25144. * @param p the current index in the positions array to be updated
  25145. * @param shape a Vector3 array, the shape geometry
  25146. * @param positions the positions array to be updated
  25147. * @param meshInd the shape indices array
  25148. * @param indices the indices array to be updated
  25149. * @param meshUV the shape uv array
  25150. * @param uvs the uv array to be updated
  25151. * @param meshCol the shape color array
  25152. * @param colors the color array to be updated
  25153. * @param meshNor the shape normals array
  25154. * @param normals the normals array to be updated
  25155. * @param idx the particle index
  25156. * @param idxInShape the particle index in its shape
  25157. * @param options the addShape() method passed options
  25158. * @hidden
  25159. */
  25160. private _meshBuilder;
  25161. /**
  25162. * Returns a shape Vector3 array from positions float array
  25163. * @param positions float array
  25164. * @returns a vector3 array
  25165. * @hidden
  25166. */
  25167. private _posToShape;
  25168. /**
  25169. * Returns a shapeUV array from a float uvs (array deep copy)
  25170. * @param uvs as a float array
  25171. * @returns a shapeUV array
  25172. * @hidden
  25173. */
  25174. private _uvsToShapeUV;
  25175. /**
  25176. * Adds a new particle object in the particles array
  25177. * @param idx particle index in particles array
  25178. * @param id particle id
  25179. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  25180. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  25181. * @param model particle ModelShape object
  25182. * @param shapeId model shape identifier
  25183. * @param idxInShape index of the particle in the current model
  25184. * @param bInfo model bounding info object
  25185. * @param storage target storage array, if any
  25186. * @hidden
  25187. */
  25188. private _addParticle;
  25189. /**
  25190. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25191. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25192. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25193. * @param nb (positive integer) the number of particles to be created from this model
  25194. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25195. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25196. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  25197. * @returns the number of shapes in the system
  25198. */
  25199. addShape(mesh: Mesh, nb: number, options?: {
  25200. positionFunction?: any;
  25201. vertexFunction?: any;
  25202. storage?: [];
  25203. }): number;
  25204. /**
  25205. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  25206. * @hidden
  25207. */
  25208. private _rebuildParticle;
  25209. /**
  25210. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25211. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  25212. * @returns the SPS.
  25213. */
  25214. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25215. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25216. * Returns an array with the removed particles.
  25217. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  25218. * The SPS can't be empty so at least one particle needs to remain in place.
  25219. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25220. * @param start index of the first particle to remove
  25221. * @param end index of the last particle to remove (included)
  25222. * @returns an array populated with the removed particles
  25223. */
  25224. removeParticles(start: number, end: number): SolidParticle[];
  25225. /**
  25226. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  25227. * @param solidParticleArray an array populated with Solid Particles objects
  25228. * @returns the SPS
  25229. */
  25230. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  25231. /**
  25232. * Creates a new particle and modifies the SPS mesh geometry :
  25233. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  25234. * - calls _addParticle() to populate the particle array
  25235. * factorized code from addShape() and insertParticlesFromArray()
  25236. * @param idx particle index in the particles array
  25237. * @param i particle index in its shape
  25238. * @param modelShape particle ModelShape object
  25239. * @param shape shape vertex array
  25240. * @param meshInd shape indices array
  25241. * @param meshUV shape uv array
  25242. * @param meshCol shape color array
  25243. * @param meshNor shape normals array
  25244. * @param bbInfo shape bounding info
  25245. * @param storage target particle storage
  25246. * @options addShape() passed options
  25247. * @hidden
  25248. */
  25249. private _insertNewParticle;
  25250. /**
  25251. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25252. * This method calls `updateParticle()` for each particle of the SPS.
  25253. * For an animated SPS, it is usually called within the render loop.
  25254. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  25255. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25256. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25257. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25258. * @returns the SPS.
  25259. */
  25260. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25261. /**
  25262. * Disposes the SPS.
  25263. */
  25264. dispose(): void;
  25265. /**
  25266. * Returns a SolidParticle object from its identifier : particle.id
  25267. * @param id (integer) the particle Id
  25268. * @returns the searched particle or null if not found in the SPS.
  25269. */
  25270. getParticleById(id: number): Nullable<SolidParticle>;
  25271. /**
  25272. * Returns a new array populated with the particles having the passed shapeId.
  25273. * @param shapeId (integer) the shape identifier
  25274. * @returns a new solid particle array
  25275. */
  25276. getParticlesByShapeId(shapeId: number): SolidParticle[];
  25277. /**
  25278. * Populates the passed array "ref" with the particles having the passed shapeId.
  25279. * @param shapeId the shape identifier
  25280. * @returns the SPS
  25281. * @param ref
  25282. */
  25283. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  25284. /**
  25285. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25286. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25287. * @returns the SPS.
  25288. */
  25289. refreshVisibleSize(): SolidParticleSystem;
  25290. /**
  25291. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25292. * @param size the size (float) of the visibility box
  25293. * note : this doesn't lock the SPS mesh bounding box.
  25294. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25295. */
  25296. setVisibilityBox(size: number): void;
  25297. /**
  25298. * Gets whether the SPS as always visible or not
  25299. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25300. */
  25301. /**
  25302. * Sets the SPS as always visible or not
  25303. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25304. */
  25305. isAlwaysVisible: boolean;
  25306. /**
  25307. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25308. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25309. */
  25310. /**
  25311. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25312. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25313. */
  25314. isVisibilityBoxLocked: boolean;
  25315. /**
  25316. * Tells to `setParticles()` to compute the particle rotations or not.
  25317. * Default value : true. The SPS is faster when it's set to false.
  25318. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25319. */
  25320. /**
  25321. * Gets if `setParticles()` computes the particle rotations or not.
  25322. * Default value : true. The SPS is faster when it's set to false.
  25323. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25324. */
  25325. computeParticleRotation: boolean;
  25326. /**
  25327. * Tells to `setParticles()` to compute the particle colors or not.
  25328. * Default value : true. The SPS is faster when it's set to false.
  25329. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25330. */
  25331. /**
  25332. * Gets if `setParticles()` computes the particle colors or not.
  25333. * Default value : true. The SPS is faster when it's set to false.
  25334. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25335. */
  25336. computeParticleColor: boolean;
  25337. /**
  25338. * Gets if `setParticles()` computes the particle textures or not.
  25339. * Default value : true. The SPS is faster when it's set to false.
  25340. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25341. */
  25342. computeParticleTexture: boolean;
  25343. /**
  25344. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25345. * Default value : false. The SPS is faster when it's set to false.
  25346. * Note : the particle custom vertex positions aren't stored values.
  25347. */
  25348. /**
  25349. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25350. * Default value : false. The SPS is faster when it's set to false.
  25351. * Note : the particle custom vertex positions aren't stored values.
  25352. */
  25353. computeParticleVertex: boolean;
  25354. /**
  25355. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25356. */
  25357. /**
  25358. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25359. */
  25360. computeBoundingBox: boolean;
  25361. /**
  25362. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25363. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25364. * Default : `true`
  25365. */
  25366. /**
  25367. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25368. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25369. * Default : `true`
  25370. */
  25371. depthSortParticles: boolean;
  25372. /**
  25373. * Gets if the SPS is created as expandable at construction time.
  25374. * Default : `false`
  25375. */
  25376. readonly expandable: boolean;
  25377. /**
  25378. * This function does nothing. It may be overwritten to set all the particle first values.
  25379. * The SPS doesn't call this function, you may have to call it by your own.
  25380. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25381. */
  25382. initParticles(): void;
  25383. /**
  25384. * This function does nothing. It may be overwritten to recycle a particle.
  25385. * The SPS doesn't call this function, you may have to call it by your own.
  25386. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25387. * @param particle The particle to recycle
  25388. * @returns the recycled particle
  25389. */
  25390. recycleParticle(particle: SolidParticle): SolidParticle;
  25391. /**
  25392. * Updates a particle : this function should be overwritten by the user.
  25393. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25394. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25395. * @example : just set a particle position or velocity and recycle conditions
  25396. * @param particle The particle to update
  25397. * @returns the updated particle
  25398. */
  25399. updateParticle(particle: SolidParticle): SolidParticle;
  25400. /**
  25401. * Updates a vertex of a particle : it can be overwritten by the user.
  25402. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25403. * @param particle the current particle
  25404. * @param vertex the current index of the current particle
  25405. * @param pt the index of the current vertex in the particle shape
  25406. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25407. * @example : just set a vertex particle position
  25408. * @returns the updated vertex
  25409. */
  25410. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25411. /**
  25412. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25413. * This does nothing and may be overwritten by the user.
  25414. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25415. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25416. * @param update the boolean update value actually passed to setParticles()
  25417. */
  25418. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25419. /**
  25420. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25421. * This will be passed three parameters.
  25422. * This does nothing and may be overwritten by the user.
  25423. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25424. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25425. * @param update the boolean update value actually passed to setParticles()
  25426. */
  25427. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25428. }
  25429. }
  25430. declare module BABYLON {
  25431. /**
  25432. * Represents one particle of a solid particle system.
  25433. */
  25434. export class SolidParticle {
  25435. /**
  25436. * particle global index
  25437. */
  25438. idx: number;
  25439. /**
  25440. * particle identifier
  25441. */
  25442. id: number;
  25443. /**
  25444. * The color of the particle
  25445. */
  25446. color: Nullable<Color4>;
  25447. /**
  25448. * The world space position of the particle.
  25449. */
  25450. position: Vector3;
  25451. /**
  25452. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25453. */
  25454. rotation: Vector3;
  25455. /**
  25456. * The world space rotation quaternion of the particle.
  25457. */
  25458. rotationQuaternion: Nullable<Quaternion>;
  25459. /**
  25460. * The scaling of the particle.
  25461. */
  25462. scaling: Vector3;
  25463. /**
  25464. * The uvs of the particle.
  25465. */
  25466. uvs: Vector4;
  25467. /**
  25468. * The current speed of the particle.
  25469. */
  25470. velocity: Vector3;
  25471. /**
  25472. * The pivot point in the particle local space.
  25473. */
  25474. pivot: Vector3;
  25475. /**
  25476. * Must the particle be translated from its pivot point in its local space ?
  25477. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25478. * Default : false
  25479. */
  25480. translateFromPivot: boolean;
  25481. /**
  25482. * Is the particle active or not ?
  25483. */
  25484. alive: boolean;
  25485. /**
  25486. * Is the particle visible or not ?
  25487. */
  25488. isVisible: boolean;
  25489. /**
  25490. * Index of this particle in the global "positions" array (Internal use)
  25491. * @hidden
  25492. */ private _pos: number;
  25493. /**
  25494. * @hidden Index of this particle in the global "indices" array (Internal use)
  25495. */ private _ind: number;
  25496. /**
  25497. * @hidden ModelShape of this particle (Internal use)
  25498. */ private _model: ModelShape;
  25499. /**
  25500. * ModelShape id of this particle
  25501. */
  25502. shapeId: number;
  25503. /**
  25504. * Index of the particle in its shape id
  25505. */
  25506. idxInShape: number;
  25507. /**
  25508. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25509. */ private _modelBoundingInfo: BoundingInfo;
  25510. /**
  25511. * @hidden Particle BoundingInfo object (Internal use)
  25512. */ private _boundingInfo: BoundingInfo;
  25513. /**
  25514. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25515. */ private _sps: SolidParticleSystem;
  25516. /**
  25517. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25518. */ private _stillInvisible: boolean;
  25519. /**
  25520. * @hidden Last computed particle rotation matrix
  25521. */ private _rotationMatrix: number[];
  25522. /**
  25523. * Parent particle Id, if any.
  25524. * Default null.
  25525. */
  25526. parentId: Nullable<number>;
  25527. /**
  25528. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25529. * The possible values are :
  25530. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25531. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25532. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25533. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25534. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25535. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25536. * */
  25537. cullingStrategy: number;
  25538. /**
  25539. * @hidden Internal global position in the SPS.
  25540. */ private _globalPosition: Vector3;
  25541. /**
  25542. * Creates a Solid Particle object.
  25543. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25544. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  25545. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  25546. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25547. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25548. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25549. * @param shapeId (integer) is the model shape identifier in the SPS.
  25550. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25551. * @param sps defines the sps it is associated to
  25552. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25553. */
  25554. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25555. /**
  25556. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  25557. * @param target the particle target
  25558. * @returns the current particle
  25559. */
  25560. copyToRef(target: SolidParticle): SolidParticle;
  25561. /**
  25562. * Legacy support, changed scale to scaling
  25563. */
  25564. /**
  25565. * Legacy support, changed scale to scaling
  25566. */
  25567. scale: Vector3;
  25568. /**
  25569. * Legacy support, changed quaternion to rotationQuaternion
  25570. */
  25571. /**
  25572. * Legacy support, changed quaternion to rotationQuaternion
  25573. */
  25574. quaternion: Nullable<Quaternion>;
  25575. /**
  25576. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25577. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25578. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25579. * @returns true if it intersects
  25580. */
  25581. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25582. /**
  25583. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25584. * A particle is in the frustum if its bounding box intersects the frustum
  25585. * @param frustumPlanes defines the frustum to test
  25586. * @returns true if the particle is in the frustum planes
  25587. */
  25588. isInFrustum(frustumPlanes: Plane[]): boolean;
  25589. /**
  25590. * get the rotation matrix of the particle
  25591. * @hidden
  25592. */
  25593. getRotationMatrix(m: Matrix): void;
  25594. }
  25595. /**
  25596. * Represents the shape of the model used by one particle of a solid particle system.
  25597. * SPS internal tool, don't use it manually.
  25598. */
  25599. export class ModelShape {
  25600. /**
  25601. * The shape id
  25602. * @hidden
  25603. */
  25604. shapeID: number;
  25605. /**
  25606. * flat array of model positions (internal use)
  25607. * @hidden
  25608. */ private _shape: Vector3[];
  25609. /**
  25610. * flat array of model UVs (internal use)
  25611. * @hidden
  25612. */ private _shapeUV: number[];
  25613. /**
  25614. * color array of the model
  25615. * @hidden
  25616. */ private _shapeColors: number[];
  25617. /**
  25618. * indices array of the model
  25619. * @hidden
  25620. */ private _indices: number[];
  25621. /**
  25622. * normals array of the model
  25623. * @hidden
  25624. */ private _normals: number[];
  25625. /**
  25626. * length of the shape in the model indices array (internal use)
  25627. * @hidden
  25628. */ private _indicesLength: number;
  25629. /**
  25630. * Custom position function (internal use)
  25631. * @hidden
  25632. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25633. /**
  25634. * Custom vertex function (internal use)
  25635. * @hidden
  25636. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25637. /**
  25638. * 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.
  25639. * SPS internal tool, don't use it manually.
  25640. * @hidden
  25641. */
  25642. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25643. }
  25644. /**
  25645. * Represents a Depth Sorted Particle in the solid particle system.
  25646. */
  25647. export class DepthSortedParticle {
  25648. /**
  25649. * Index of the particle in the "indices" array
  25650. */
  25651. ind: number;
  25652. /**
  25653. * Length of the particle shape in the "indices" array
  25654. */
  25655. indicesLength: number;
  25656. /**
  25657. * Squared distance from the particle to the camera
  25658. */
  25659. sqDistance: number;
  25660. }
  25661. }
  25662. declare module BABYLON {
  25663. /**
  25664. * @hidden
  25665. */
  25666. 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>>;
  25667. }
  25668. }
  25669. declare module BABYLON {
  25670. /** @hidden */ private class _FacetDataStorage {
  25671. facetPositions: Vector3[];
  25672. facetNormals: Vector3[];
  25673. facetPartitioning: number[][];
  25674. facetNb: number;
  25675. partitioningSubdivisions: number;
  25676. partitioningBBoxRatio: number;
  25677. facetDataEnabled: boolean;
  25678. facetParameters: any;
  25679. bbSize: Vector3;
  25680. subDiv: {
  25681. max: number;
  25682. X: number;
  25683. Y: number;
  25684. Z: number;
  25685. };
  25686. facetDepthSort: boolean;
  25687. facetDepthSortEnabled: boolean;
  25688. depthSortedIndices: IndicesArray;
  25689. depthSortedFacets: {
  25690. ind: number;
  25691. sqDistance: number;
  25692. }[];
  25693. facetDepthSortFunction: (f1: {
  25694. ind: number;
  25695. sqDistance: number;
  25696. }, f2: {
  25697. ind: number;
  25698. sqDistance: number;
  25699. }) => number;
  25700. facetDepthSortFrom: Vector3;
  25701. facetDepthSortOrigin: Vector3;
  25702. invertedMatrix: Matrix;
  25703. }
  25704. /**
  25705. * @hidden
  25706. **/ 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; private _actAsRegularMesh: boolean;
  25707. }
  25708. /**
  25709. * Class used to store all common mesh properties
  25710. */
  25711. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25712. /** No occlusion */
  25713. static OCCLUSION_TYPE_NONE: number;
  25714. /** Occlusion set to optimisitic */
  25715. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25716. /** Occlusion set to strict */
  25717. static OCCLUSION_TYPE_STRICT: number;
  25718. /** Use an accurante occlusion algorithm */
  25719. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25720. /** Use a conservative occlusion algorithm */
  25721. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25722. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25723. * Test order :
  25724. * Is the bounding sphere outside the frustum ?
  25725. * If not, are the bounding box vertices outside the frustum ?
  25726. * It not, then the cullable object is in the frustum.
  25727. */
  25728. static readonly CULLINGSTRATEGY_STANDARD: number;
  25729. /** Culling strategy : Bounding Sphere Only.
  25730. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25731. * It's also less accurate than the standard because some not visible objects can still be selected.
  25732. * Test : is the bounding sphere outside the frustum ?
  25733. * If not, then the cullable object is in the frustum.
  25734. */
  25735. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25736. /** Culling strategy : Optimistic Inclusion.
  25737. * This in an inclusion test first, then the standard exclusion test.
  25738. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25739. * 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.
  25740. * Anyway, it's as accurate as the standard strategy.
  25741. * Test :
  25742. * Is the cullable object bounding sphere center in the frustum ?
  25743. * If not, apply the default culling strategy.
  25744. */
  25745. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25746. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25747. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25748. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25749. * 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.
  25750. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25751. * Test :
  25752. * Is the cullable object bounding sphere center in the frustum ?
  25753. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25754. */
  25755. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25756. /**
  25757. * No billboard
  25758. */
  25759. static readonly BILLBOARDMODE_NONE: number;
  25760. /** Billboard on X axis */
  25761. static readonly BILLBOARDMODE_X: number;
  25762. /** Billboard on Y axis */
  25763. static readonly BILLBOARDMODE_Y: number;
  25764. /** Billboard on Z axis */
  25765. static readonly BILLBOARDMODE_Z: number;
  25766. /** Billboard on all axes */
  25767. static readonly BILLBOARDMODE_ALL: number;
  25768. /** Billboard on using position instead of orientation */
  25769. static readonly BILLBOARDMODE_USE_POSITION: number;
  25770. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25771. /**
  25772. * The culling strategy to use to check whether the mesh must be rendered or not.
  25773. * This value can be changed at any time and will be used on the next render mesh selection.
  25774. * The possible values are :
  25775. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25776. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25777. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25778. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25779. * Please read each static variable documentation to get details about the culling process.
  25780. * */
  25781. cullingStrategy: number;
  25782. /**
  25783. * Gets the number of facets in the mesh
  25784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25785. */
  25786. readonly facetNb: number;
  25787. /**
  25788. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25790. */
  25791. partitioningSubdivisions: number;
  25792. /**
  25793. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25794. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25795. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25796. */
  25797. partitioningBBoxRatio: number;
  25798. /**
  25799. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25800. * Works only for updatable meshes.
  25801. * Doesn't work with multi-materials
  25802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25803. */
  25804. mustDepthSortFacets: boolean;
  25805. /**
  25806. * The location (Vector3) where the facet depth sort must be computed from.
  25807. * By default, the active camera position.
  25808. * Used only when facet depth sort is enabled
  25809. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25810. */
  25811. facetDepthSortFrom: Vector3;
  25812. /**
  25813. * gets a boolean indicating if facetData is enabled
  25814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25815. */
  25816. readonly isFacetDataEnabled: boolean;
  25817. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25818. /**
  25819. * An event triggered when this mesh collides with another one
  25820. */
  25821. onCollideObservable: Observable<AbstractMesh>;
  25822. /** Set a function to call when this mesh collides with another one */
  25823. onCollide: () => void;
  25824. /**
  25825. * An event triggered when the collision's position changes
  25826. */
  25827. onCollisionPositionChangeObservable: Observable<Vector3>;
  25828. /** Set a function to call when the collision's position changes */
  25829. onCollisionPositionChange: () => void;
  25830. /**
  25831. * An event triggered when material is changed
  25832. */
  25833. onMaterialChangedObservable: Observable<AbstractMesh>;
  25834. /**
  25835. * Gets or sets the orientation for POV movement & rotation
  25836. */
  25837. definedFacingForward: boolean;
  25838. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25839. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25840. /**
  25841. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25842. */
  25843. /**
  25844. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25845. */
  25846. visibility: number;
  25847. /** Gets or sets the alpha index used to sort transparent meshes
  25848. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25849. */
  25850. alphaIndex: number;
  25851. /**
  25852. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25853. */
  25854. isVisible: boolean;
  25855. /**
  25856. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25857. */
  25858. isPickable: boolean;
  25859. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25860. showSubMeshesBoundingBox: boolean;
  25861. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25862. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25863. */
  25864. isBlocker: boolean;
  25865. /**
  25866. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25867. */
  25868. enablePointerMoveEvents: boolean;
  25869. /**
  25870. * Specifies the rendering group id for this mesh (0 by default)
  25871. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25872. */
  25873. renderingGroupId: number;
  25874. private _material;
  25875. /** Gets or sets current material */
  25876. material: Nullable<Material>;
  25877. /**
  25878. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25879. * @see http://doc.babylonjs.com/babylon101/shadows
  25880. */
  25881. receiveShadows: boolean;
  25882. /** Defines color to use when rendering outline */
  25883. outlineColor: Color3;
  25884. /** Define width to use when rendering outline */
  25885. outlineWidth: number;
  25886. /** Defines color to use when rendering overlay */
  25887. overlayColor: Color3;
  25888. /** Defines alpha to use when rendering overlay */
  25889. overlayAlpha: number;
  25890. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25891. hasVertexAlpha: boolean;
  25892. /** 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) */
  25893. useVertexColors: boolean;
  25894. /**
  25895. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25896. */
  25897. computeBonesUsingShaders: boolean;
  25898. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25899. numBoneInfluencers: number;
  25900. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25901. applyFog: boolean;
  25902. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25903. useOctreeForRenderingSelection: boolean;
  25904. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25905. useOctreeForPicking: boolean;
  25906. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25907. useOctreeForCollisions: boolean;
  25908. /**
  25909. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25910. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25911. */
  25912. layerMask: number;
  25913. /**
  25914. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25915. */
  25916. alwaysSelectAsActiveMesh: boolean;
  25917. /**
  25918. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25919. */
  25920. doNotSyncBoundingInfo: boolean;
  25921. /**
  25922. * Gets or sets the current action manager
  25923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25924. */
  25925. actionManager: Nullable<AbstractActionManager>;
  25926. private _meshCollisionData;
  25927. /**
  25928. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25930. */
  25931. ellipsoid: Vector3;
  25932. /**
  25933. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25934. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25935. */
  25936. ellipsoidOffset: Vector3;
  25937. /**
  25938. * Gets or sets a collision mask used to mask collisions (default is -1).
  25939. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25940. */
  25941. collisionMask: number;
  25942. /**
  25943. * Gets or sets the current collision group mask (-1 by default).
  25944. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25945. */
  25946. collisionGroup: number;
  25947. /**
  25948. * Defines edge width used when edgesRenderer is enabled
  25949. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25950. */
  25951. edgesWidth: number;
  25952. /**
  25953. * Defines edge color used when edgesRenderer is enabled
  25954. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25955. */
  25956. edgesColor: Color4;
  25957. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25958. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25959. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25960. /** @hidden */ private _renderId: number;
  25961. /**
  25962. * Gets or sets the list of subMeshes
  25963. * @see http://doc.babylonjs.com/how_to/multi_materials
  25964. */
  25965. subMeshes: SubMesh[];
  25966. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25967. /** @hidden */ private _unIndexed: boolean;
  25968. /** @hidden */ private _lightSources: Light[];
  25969. /** Gets the list of lights affecting that mesh */
  25970. readonly lightSources: Light[];
  25971. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25972. /** @hidden */ private _waitingData: {
  25973. lods: Nullable<any>;
  25974. actions: Nullable<any>;
  25975. freezeWorldMatrix: Nullable<boolean>;
  25976. };
  25977. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25978. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25979. /**
  25980. * Gets or sets a skeleton to apply skining transformations
  25981. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25982. */
  25983. skeleton: Nullable<Skeleton>;
  25984. /**
  25985. * An event triggered when the mesh is rebuilt.
  25986. */
  25987. onRebuildObservable: Observable<AbstractMesh>;
  25988. /**
  25989. * Creates a new AbstractMesh
  25990. * @param name defines the name of the mesh
  25991. * @param scene defines the hosting scene
  25992. */
  25993. constructor(name: string, scene?: Nullable<Scene>);
  25994. /**
  25995. * Returns the string "AbstractMesh"
  25996. * @returns "AbstractMesh"
  25997. */
  25998. getClassName(): string;
  25999. /**
  26000. * Gets a string representation of the current mesh
  26001. * @param fullDetails defines a boolean indicating if full details must be included
  26002. * @returns a string representation of the current mesh
  26003. */
  26004. toString(fullDetails?: boolean): string;
  26005. /**
  26006. * @hidden
  26007. */
  26008. protected _getEffectiveParent(): Nullable<Node>;
  26009. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26010. /** @hidden */ private _rebuild(): void;
  26011. /** @hidden */ private _resyncLightSources(): void;
  26012. /** @hidden */ private _resyncLighSource(light: Light): void;
  26013. /** @hidden */ private _unBindEffect(): void;
  26014. /** @hidden */ private _removeLightSource(light: Light, dispose: boolean): void;
  26015. private _markSubMeshesAsDirty;
  26016. /** @hidden */ private _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26017. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  26018. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  26019. /**
  26020. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26021. */
  26022. scaling: Vector3;
  26023. /**
  26024. * Returns true if the mesh is blocked. Implemented by child classes
  26025. */
  26026. readonly isBlocked: boolean;
  26027. /**
  26028. * Returns the mesh itself by default. Implemented by child classes
  26029. * @param camera defines the camera to use to pick the right LOD level
  26030. * @returns the currentAbstractMesh
  26031. */
  26032. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26033. /**
  26034. * Returns 0 by default. Implemented by child classes
  26035. * @returns an integer
  26036. */
  26037. getTotalVertices(): number;
  26038. /**
  26039. * Returns a positive integer : the total number of indices in this mesh geometry.
  26040. * @returns the numner of indices or zero if the mesh has no geometry.
  26041. */
  26042. getTotalIndices(): number;
  26043. /**
  26044. * Returns null by default. Implemented by child classes
  26045. * @returns null
  26046. */
  26047. getIndices(): Nullable<IndicesArray>;
  26048. /**
  26049. * Returns the array of the requested vertex data kind. Implemented by child classes
  26050. * @param kind defines the vertex data kind to use
  26051. * @returns null
  26052. */
  26053. getVerticesData(kind: string): Nullable<FloatArray>;
  26054. /**
  26055. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26056. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26057. * Note that a new underlying VertexBuffer object is created each call.
  26058. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26059. * @param kind defines vertex data kind:
  26060. * * VertexBuffer.PositionKind
  26061. * * VertexBuffer.UVKind
  26062. * * VertexBuffer.UV2Kind
  26063. * * VertexBuffer.UV3Kind
  26064. * * VertexBuffer.UV4Kind
  26065. * * VertexBuffer.UV5Kind
  26066. * * VertexBuffer.UV6Kind
  26067. * * VertexBuffer.ColorKind
  26068. * * VertexBuffer.MatricesIndicesKind
  26069. * * VertexBuffer.MatricesIndicesExtraKind
  26070. * * VertexBuffer.MatricesWeightsKind
  26071. * * VertexBuffer.MatricesWeightsExtraKind
  26072. * @param data defines the data source
  26073. * @param updatable defines if the data must be flagged as updatable (or static)
  26074. * @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
  26075. * @returns the current mesh
  26076. */
  26077. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26078. /**
  26079. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26080. * If the mesh has no geometry, it is simply returned as it is.
  26081. * @param kind defines vertex data kind:
  26082. * * VertexBuffer.PositionKind
  26083. * * VertexBuffer.UVKind
  26084. * * VertexBuffer.UV2Kind
  26085. * * VertexBuffer.UV3Kind
  26086. * * VertexBuffer.UV4Kind
  26087. * * VertexBuffer.UV5Kind
  26088. * * VertexBuffer.UV6Kind
  26089. * * VertexBuffer.ColorKind
  26090. * * VertexBuffer.MatricesIndicesKind
  26091. * * VertexBuffer.MatricesIndicesExtraKind
  26092. * * VertexBuffer.MatricesWeightsKind
  26093. * * VertexBuffer.MatricesWeightsExtraKind
  26094. * @param data defines the data source
  26095. * @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
  26096. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26097. * @returns the current mesh
  26098. */
  26099. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26100. /**
  26101. * Sets the mesh indices,
  26102. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26103. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26104. * @param totalVertices Defines the total number of vertices
  26105. * @returns the current mesh
  26106. */
  26107. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26108. /**
  26109. * Gets a boolean indicating if specific vertex data is present
  26110. * @param kind defines the vertex data kind to use
  26111. * @returns true is data kind is present
  26112. */
  26113. isVerticesDataPresent(kind: string): boolean;
  26114. /**
  26115. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26116. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26117. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26118. * @returns a BoundingInfo
  26119. */
  26120. getBoundingInfo(): BoundingInfo;
  26121. /**
  26122. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26123. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26124. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26125. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26126. * @returns the current mesh
  26127. */
  26128. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26129. /**
  26130. * Overwrite the current bounding info
  26131. * @param boundingInfo defines the new bounding info
  26132. * @returns the current mesh
  26133. */
  26134. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26135. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26136. readonly useBones: boolean;
  26137. /** @hidden */ private _preActivate(): void;
  26138. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  26139. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  26140. /** @hidden */ private _postActivate(): void;
  26141. /** @hidden */ private _freeze(): void;
  26142. /** @hidden */ private _unFreeze(): void;
  26143. /**
  26144. * Gets the current world matrix
  26145. * @returns a Matrix
  26146. */
  26147. getWorldMatrix(): Matrix;
  26148. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26149. /**
  26150. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26151. */
  26152. readonly isAnInstance: boolean;
  26153. /**
  26154. * Gets a boolean indicating if this mesh has instances
  26155. */
  26156. readonly hasInstances: boolean;
  26157. /**
  26158. * Perform relative position change from the point of view of behind the front of the mesh.
  26159. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26160. * Supports definition of mesh facing forward or backward
  26161. * @param amountRight defines the distance on the right axis
  26162. * @param amountUp defines the distance on the up axis
  26163. * @param amountForward defines the distance on the forward axis
  26164. * @returns the current mesh
  26165. */
  26166. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26167. /**
  26168. * Calculate relative position change from the point of view of behind the front of the mesh.
  26169. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26170. * Supports definition of mesh facing forward or backward
  26171. * @param amountRight defines the distance on the right axis
  26172. * @param amountUp defines the distance on the up axis
  26173. * @param amountForward defines the distance on the forward axis
  26174. * @returns the new displacement vector
  26175. */
  26176. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26177. /**
  26178. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26179. * Supports definition of mesh facing forward or backward
  26180. * @param flipBack defines the flip
  26181. * @param twirlClockwise defines the twirl
  26182. * @param tiltRight defines the tilt
  26183. * @returns the current mesh
  26184. */
  26185. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26186. /**
  26187. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26188. * Supports definition of mesh facing forward or backward.
  26189. * @param flipBack defines the flip
  26190. * @param twirlClockwise defines the twirl
  26191. * @param tiltRight defines the tilt
  26192. * @returns the new rotation vector
  26193. */
  26194. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26195. /**
  26196. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26197. * This means the mesh underlying bounding box and sphere are recomputed.
  26198. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26199. * @returns the current mesh
  26200. */
  26201. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26202. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26203. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26204. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  26205. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26206. /** @hidden */
  26207. protected _afterComputeWorldMatrix(): void;
  26208. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  26209. /**
  26210. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26211. * A mesh is in the frustum if its bounding box intersects the frustum
  26212. * @param frustumPlanes defines the frustum to test
  26213. * @returns true if the mesh is in the frustum planes
  26214. */
  26215. isInFrustum(frustumPlanes: Plane[]): boolean;
  26216. /**
  26217. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26218. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26219. * @param frustumPlanes defines the frustum to test
  26220. * @returns true if the mesh is completely in the frustum planes
  26221. */
  26222. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26223. /**
  26224. * True if the mesh intersects another mesh or a SolidParticle object
  26225. * @param mesh defines a target mesh or SolidParticle to test
  26226. * @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)
  26227. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26228. * @returns true if there is an intersection
  26229. */
  26230. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26231. /**
  26232. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26233. * @param point defines the point to test
  26234. * @returns true if there is an intersection
  26235. */
  26236. intersectsPoint(point: Vector3): boolean;
  26237. /**
  26238. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26239. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26240. */
  26241. checkCollisions: boolean;
  26242. /**
  26243. * Gets Collider object used to compute collisions (not physics)
  26244. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26245. */
  26246. readonly collider: Nullable<Collider>;
  26247. /**
  26248. * Move the mesh using collision engine
  26249. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26250. * @param displacement defines the requested displacement vector
  26251. * @returns the current mesh
  26252. */
  26253. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26254. private _onCollisionPositionChange;
  26255. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26256. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26257. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  26258. /** @hidden */ private _generatePointsArray(): boolean;
  26259. /**
  26260. * Checks if the passed Ray intersects with the mesh
  26261. * @param ray defines the ray to use
  26262. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26263. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26264. * @returns the picking info
  26265. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26266. */
  26267. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26268. /**
  26269. * Clones the current mesh
  26270. * @param name defines the mesh name
  26271. * @param newParent defines the new mesh parent
  26272. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26273. * @returns the new mesh
  26274. */
  26275. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26276. /**
  26277. * Disposes all the submeshes of the current meshnp
  26278. * @returns the current mesh
  26279. */
  26280. releaseSubMeshes(): AbstractMesh;
  26281. /**
  26282. * Releases resources associated with this abstract mesh.
  26283. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26284. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26285. */
  26286. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26287. /**
  26288. * Adds the passed mesh as a child to the current mesh
  26289. * @param mesh defines the child mesh
  26290. * @returns the current mesh
  26291. */
  26292. addChild(mesh: AbstractMesh): AbstractMesh;
  26293. /**
  26294. * Removes the passed mesh from the current mesh children list
  26295. * @param mesh defines the child mesh
  26296. * @returns the current mesh
  26297. */
  26298. removeChild(mesh: AbstractMesh): AbstractMesh;
  26299. /** @hidden */
  26300. private _initFacetData;
  26301. /**
  26302. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26303. * This method can be called within the render loop.
  26304. * 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
  26305. * @returns the current mesh
  26306. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26307. */
  26308. updateFacetData(): AbstractMesh;
  26309. /**
  26310. * Returns the facetLocalNormals array.
  26311. * The normals are expressed in the mesh local spac
  26312. * @returns an array of Vector3
  26313. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26314. */
  26315. getFacetLocalNormals(): Vector3[];
  26316. /**
  26317. * Returns the facetLocalPositions array.
  26318. * The facet positions are expressed in the mesh local space
  26319. * @returns an array of Vector3
  26320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26321. */
  26322. getFacetLocalPositions(): Vector3[];
  26323. /**
  26324. * Returns the facetLocalPartioning array
  26325. * @returns an array of array of numbers
  26326. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26327. */
  26328. getFacetLocalPartitioning(): number[][];
  26329. /**
  26330. * Returns the i-th facet position in the world system.
  26331. * This method allocates a new Vector3 per call
  26332. * @param i defines the facet index
  26333. * @returns a new Vector3
  26334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26335. */
  26336. getFacetPosition(i: number): Vector3;
  26337. /**
  26338. * Sets the reference Vector3 with the i-th facet position in the world system
  26339. * @param i defines the facet index
  26340. * @param ref defines the target vector
  26341. * @returns the current mesh
  26342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26343. */
  26344. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26345. /**
  26346. * Returns the i-th facet normal in the world system.
  26347. * This method allocates a new Vector3 per call
  26348. * @param i defines the facet index
  26349. * @returns a new Vector3
  26350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26351. */
  26352. getFacetNormal(i: number): Vector3;
  26353. /**
  26354. * Sets the reference Vector3 with the i-th facet normal in the world system
  26355. * @param i defines the facet index
  26356. * @param ref defines the target vector
  26357. * @returns the current mesh
  26358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26359. */
  26360. getFacetNormalToRef(i: number, ref: Vector3): this;
  26361. /**
  26362. * 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)
  26363. * @param x defines x coordinate
  26364. * @param y defines y coordinate
  26365. * @param z defines z coordinate
  26366. * @returns the array of facet indexes
  26367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26368. */
  26369. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26370. /**
  26371. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26372. * @param projected sets as the (x,y,z) world projection on the facet
  26373. * @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
  26374. * @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
  26375. * @param x defines x coordinate
  26376. * @param y defines y coordinate
  26377. * @param z defines z coordinate
  26378. * @returns the face index if found (or null instead)
  26379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26380. */
  26381. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26382. /**
  26383. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26384. * @param projected sets as the (x,y,z) local projection on the facet
  26385. * @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
  26386. * @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
  26387. * @param x defines x coordinate
  26388. * @param y defines y coordinate
  26389. * @param z defines z coordinate
  26390. * @returns the face index if found (or null instead)
  26391. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26392. */
  26393. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26394. /**
  26395. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26396. * @returns the parameters
  26397. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26398. */
  26399. getFacetDataParameters(): any;
  26400. /**
  26401. * Disables the feature FacetData and frees the related memory
  26402. * @returns the current mesh
  26403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26404. */
  26405. disableFacetData(): AbstractMesh;
  26406. /**
  26407. * Updates the AbstractMesh indices array
  26408. * @param indices defines the data source
  26409. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26410. * @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)
  26411. * @returns the current mesh
  26412. */
  26413. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26414. /**
  26415. * Creates new normals data for the mesh
  26416. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26417. * @returns the current mesh
  26418. */
  26419. createNormals(updatable: boolean): AbstractMesh;
  26420. /**
  26421. * Align the mesh with a normal
  26422. * @param normal defines the normal to use
  26423. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26424. * @returns the current mesh
  26425. */
  26426. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26427. /** @hidden */ private _checkOcclusionQuery(): boolean;
  26428. /**
  26429. * Disables the mesh edge rendering mode
  26430. * @returns the currentAbstractMesh
  26431. */
  26432. disableEdgesRendering(): AbstractMesh;
  26433. /**
  26434. * Enables the edge rendering mode on the mesh.
  26435. * This mode makes the mesh edges visible
  26436. * @param epsilon defines the maximal distance between two angles to detect a face
  26437. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26438. * @returns the currentAbstractMesh
  26439. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26440. */
  26441. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26442. }
  26443. }
  26444. declare module BABYLON {
  26445. /**
  26446. * Interface used to define ActionEvent
  26447. */
  26448. export interface IActionEvent {
  26449. /** The mesh or sprite that triggered the action */
  26450. source: any;
  26451. /** The X mouse cursor position at the time of the event */
  26452. pointerX: number;
  26453. /** The Y mouse cursor position at the time of the event */
  26454. pointerY: number;
  26455. /** The mesh that is currently pointed at (can be null) */
  26456. meshUnderPointer: Nullable<AbstractMesh>;
  26457. /** the original (browser) event that triggered the ActionEvent */
  26458. sourceEvent?: any;
  26459. /** additional data for the event */
  26460. additionalData?: any;
  26461. }
  26462. /**
  26463. * ActionEvent is the event being sent when an action is triggered.
  26464. */
  26465. export class ActionEvent implements IActionEvent {
  26466. /** The mesh or sprite that triggered the action */
  26467. source: any;
  26468. /** The X mouse cursor position at the time of the event */
  26469. pointerX: number;
  26470. /** The Y mouse cursor position at the time of the event */
  26471. pointerY: number;
  26472. /** The mesh that is currently pointed at (can be null) */
  26473. meshUnderPointer: Nullable<AbstractMesh>;
  26474. /** the original (browser) event that triggered the ActionEvent */
  26475. sourceEvent?: any;
  26476. /** additional data for the event */
  26477. additionalData?: any;
  26478. /**
  26479. * Creates a new ActionEvent
  26480. * @param source The mesh or sprite that triggered the action
  26481. * @param pointerX The X mouse cursor position at the time of the event
  26482. * @param pointerY The Y mouse cursor position at the time of the event
  26483. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26484. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26485. * @param additionalData additional data for the event
  26486. */
  26487. constructor(
  26488. /** The mesh or sprite that triggered the action */
  26489. source: any,
  26490. /** The X mouse cursor position at the time of the event */
  26491. pointerX: number,
  26492. /** The Y mouse cursor position at the time of the event */
  26493. pointerY: number,
  26494. /** The mesh that is currently pointed at (can be null) */
  26495. meshUnderPointer: Nullable<AbstractMesh>,
  26496. /** the original (browser) event that triggered the ActionEvent */
  26497. sourceEvent?: any,
  26498. /** additional data for the event */
  26499. additionalData?: any);
  26500. /**
  26501. * Helper function to auto-create an ActionEvent from a source mesh.
  26502. * @param source The source mesh that triggered the event
  26503. * @param evt The original (browser) event
  26504. * @param additionalData additional data for the event
  26505. * @returns the new ActionEvent
  26506. */
  26507. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26508. /**
  26509. * Helper function to auto-create an ActionEvent from a source sprite
  26510. * @param source The source sprite that triggered the event
  26511. * @param scene Scene associated with the sprite
  26512. * @param evt The original (browser) event
  26513. * @param additionalData additional data for the event
  26514. * @returns the new ActionEvent
  26515. */
  26516. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26517. /**
  26518. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26519. * @param scene the scene where the event occurred
  26520. * @param evt The original (browser) event
  26521. * @returns the new ActionEvent
  26522. */
  26523. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26524. /**
  26525. * Helper function to auto-create an ActionEvent from a primitive
  26526. * @param prim defines the target primitive
  26527. * @param pointerPos defines the pointer position
  26528. * @param evt The original (browser) event
  26529. * @param additionalData additional data for the event
  26530. * @returns the new ActionEvent
  26531. */
  26532. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26533. }
  26534. }
  26535. declare module BABYLON {
  26536. /**
  26537. * Abstract class used to decouple action Manager from scene and meshes.
  26538. * Do not instantiate.
  26539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26540. */
  26541. export abstract class AbstractActionManager implements IDisposable {
  26542. /** Gets the list of active triggers */
  26543. static Triggers: {
  26544. [key: string]: number;
  26545. };
  26546. /** Gets the cursor to use when hovering items */
  26547. hoverCursor: string;
  26548. /** Gets the list of actions */
  26549. actions: IAction[];
  26550. /**
  26551. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26552. */
  26553. isRecursive: boolean;
  26554. /**
  26555. * Releases all associated resources
  26556. */
  26557. abstract dispose(): void;
  26558. /**
  26559. * Does this action manager has pointer triggers
  26560. */
  26561. abstract readonly hasPointerTriggers: boolean;
  26562. /**
  26563. * Does this action manager has pick triggers
  26564. */
  26565. abstract readonly hasPickTriggers: boolean;
  26566. /**
  26567. * Process a specific trigger
  26568. * @param trigger defines the trigger to process
  26569. * @param evt defines the event details to be processed
  26570. */
  26571. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26572. /**
  26573. * Does this action manager handles actions of any of the given triggers
  26574. * @param triggers defines the triggers to be tested
  26575. * @return a boolean indicating whether one (or more) of the triggers is handled
  26576. */
  26577. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26578. /**
  26579. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26580. * speed.
  26581. * @param triggerA defines the trigger to be tested
  26582. * @param triggerB defines the trigger to be tested
  26583. * @return a boolean indicating whether one (or more) of the triggers is handled
  26584. */
  26585. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26586. /**
  26587. * Does this action manager handles actions of a given trigger
  26588. * @param trigger defines the trigger to be tested
  26589. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26590. * @return whether the trigger is handled
  26591. */
  26592. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26593. /**
  26594. * Serialize this manager to a JSON object
  26595. * @param name defines the property name to store this manager
  26596. * @returns a JSON representation of this manager
  26597. */
  26598. abstract serialize(name: string): any;
  26599. /**
  26600. * Registers an action to this action manager
  26601. * @param action defines the action to be registered
  26602. * @return the action amended (prepared) after registration
  26603. */
  26604. abstract registerAction(action: IAction): Nullable<IAction>;
  26605. /**
  26606. * Unregisters an action to this action manager
  26607. * @param action defines the action to be unregistered
  26608. * @return a boolean indicating whether the action has been unregistered
  26609. */
  26610. abstract unregisterAction(action: IAction): Boolean;
  26611. /**
  26612. * Does exist one action manager with at least one trigger
  26613. **/
  26614. static readonly HasTriggers: boolean;
  26615. /**
  26616. * Does exist one action manager with at least one pick trigger
  26617. **/
  26618. static readonly HasPickTriggers: boolean;
  26619. /**
  26620. * Does exist one action manager that handles actions of a given trigger
  26621. * @param trigger defines the trigger to be tested
  26622. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26623. **/
  26624. static HasSpecificTrigger(trigger: number): boolean;
  26625. }
  26626. }
  26627. declare module BABYLON {
  26628. /**
  26629. * Defines how a node can be built from a string name.
  26630. */
  26631. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26632. /**
  26633. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26634. */
  26635. export class Node implements IBehaviorAware<Node> {
  26636. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26637. private static _NodeConstructors;
  26638. /**
  26639. * Add a new node constructor
  26640. * @param type defines the type name of the node to construct
  26641. * @param constructorFunc defines the constructor function
  26642. */
  26643. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26644. /**
  26645. * Returns a node constructor based on type name
  26646. * @param type defines the type name
  26647. * @param name defines the new node name
  26648. * @param scene defines the hosting scene
  26649. * @param options defines optional options to transmit to constructors
  26650. * @returns the new constructor or null
  26651. */
  26652. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26653. /**
  26654. * Gets or sets the name of the node
  26655. */
  26656. name: string;
  26657. /**
  26658. * Gets or sets the id of the node
  26659. */
  26660. id: string;
  26661. /**
  26662. * Gets or sets the unique id of the node
  26663. */
  26664. uniqueId: number;
  26665. /**
  26666. * Gets or sets a string used to store user defined state for the node
  26667. */
  26668. state: string;
  26669. /**
  26670. * Gets or sets an object used to store user defined information for the node
  26671. */
  26672. metadata: any;
  26673. /**
  26674. * For internal use only. Please do not use.
  26675. */
  26676. reservedDataStore: any;
  26677. /**
  26678. * List of inspectable custom properties (used by the Inspector)
  26679. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26680. */
  26681. inspectableCustomProperties: IInspectable[];
  26682. private _doNotSerialize;
  26683. /**
  26684. * Gets or sets a boolean used to define if the node must be serialized
  26685. */
  26686. doNotSerialize: boolean;
  26687. /** @hidden */ private _isDisposed: boolean;
  26688. /**
  26689. * Gets a list of Animations associated with the node
  26690. */
  26691. animations: Animation[];
  26692. protected _ranges: {
  26693. [name: string]: Nullable<AnimationRange>;
  26694. };
  26695. /**
  26696. * Callback raised when the node is ready to be used
  26697. */
  26698. onReady: Nullable<(node: Node) => void>;
  26699. private _isEnabled;
  26700. private _isParentEnabled;
  26701. private _isReady;
  26702. /** @hidden */ private _currentRenderId: number;
  26703. private _parentUpdateId;
  26704. /** @hidden */ private _childUpdateId: number;
  26705. /** @hidden */ private _waitingParentId: Nullable<string>;
  26706. /** @hidden */ private _scene: Scene;
  26707. /** @hidden */ private _cache: any;
  26708. private _parentNode;
  26709. private _children;
  26710. /** @hidden */ private _worldMatrix: Matrix;
  26711. /** @hidden */ private _worldMatrixDeterminant: number;
  26712. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26713. /** @hidden */
  26714. private _sceneRootNodesIndex;
  26715. /**
  26716. * Gets a boolean indicating if the node has been disposed
  26717. * @returns true if the node was disposed
  26718. */
  26719. isDisposed(): boolean;
  26720. /**
  26721. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26722. * @see https://doc.babylonjs.com/how_to/parenting
  26723. */
  26724. parent: Nullable<Node>;
  26725. /** @hidden */ private _addToSceneRootNodes(): void;
  26726. /** @hidden */ private _removeFromSceneRootNodes(): void;
  26727. private _animationPropertiesOverride;
  26728. /**
  26729. * Gets or sets the animation properties override
  26730. */
  26731. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26732. /**
  26733. * Gets a string idenfifying the name of the class
  26734. * @returns "Node" string
  26735. */
  26736. getClassName(): string;
  26737. /** @hidden */ protected readonly _isNode: boolean;
  26738. /**
  26739. * An event triggered when the mesh is disposed
  26740. */
  26741. onDisposeObservable: Observable<Node>;
  26742. private _onDisposeObserver;
  26743. /**
  26744. * Sets a callback that will be raised when the node will be disposed
  26745. */
  26746. onDispose: () => void;
  26747. /**
  26748. * Creates a new Node
  26749. * @param name the name and id to be given to this node
  26750. * @param scene the scene this node will be added to
  26751. */
  26752. constructor(name: string, scene?: Nullable<Scene>);
  26753. /**
  26754. * Gets the scene of the node
  26755. * @returns a scene
  26756. */
  26757. getScene(): Scene;
  26758. /**
  26759. * Gets the engine of the node
  26760. * @returns a Engine
  26761. */
  26762. getEngine(): Engine;
  26763. private _behaviors;
  26764. /**
  26765. * Attach a behavior to the node
  26766. * @see http://doc.babylonjs.com/features/behaviour
  26767. * @param behavior defines the behavior to attach
  26768. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26769. * @returns the current Node
  26770. */
  26771. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26772. /**
  26773. * Remove an attached behavior
  26774. * @see http://doc.babylonjs.com/features/behaviour
  26775. * @param behavior defines the behavior to attach
  26776. * @returns the current Node
  26777. */
  26778. removeBehavior(behavior: Behavior<Node>): Node;
  26779. /**
  26780. * Gets the list of attached behaviors
  26781. * @see http://doc.babylonjs.com/features/behaviour
  26782. */
  26783. readonly behaviors: Behavior<Node>[];
  26784. /**
  26785. * Gets an attached behavior by name
  26786. * @param name defines the name of the behavior to look for
  26787. * @see http://doc.babylonjs.com/features/behaviour
  26788. * @returns null if behavior was not found else the requested behavior
  26789. */
  26790. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26791. /**
  26792. * Returns the latest update of the World matrix
  26793. * @returns a Matrix
  26794. */
  26795. getWorldMatrix(): Matrix;
  26796. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26797. /**
  26798. * Returns directly the latest state of the mesh World matrix.
  26799. * A Matrix is returned.
  26800. */
  26801. readonly worldMatrixFromCache: Matrix;
  26802. /** @hidden */ private _initCache(): void;
  26803. /** @hidden */
  26804. updateCache(force?: boolean): void;
  26805. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26806. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26807. /** @hidden */ private _isSynchronized(): boolean;
  26808. /** @hidden */ private _markSyncedWithParent(): void;
  26809. /** @hidden */
  26810. isSynchronizedWithParent(): boolean;
  26811. /** @hidden */
  26812. isSynchronized(): boolean;
  26813. /**
  26814. * Is this node ready to be used/rendered
  26815. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26816. * @return true if the node is ready
  26817. */
  26818. isReady(completeCheck?: boolean): boolean;
  26819. /**
  26820. * Is this node enabled?
  26821. * 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
  26822. * @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
  26823. * @return whether this node (and its parent) is enabled
  26824. */
  26825. isEnabled(checkAncestors?: boolean): boolean;
  26826. /** @hidden */
  26827. protected _syncParentEnabledState(): void;
  26828. /**
  26829. * Set the enabled state of this node
  26830. * @param value defines the new enabled state
  26831. */
  26832. setEnabled(value: boolean): void;
  26833. /**
  26834. * Is this node a descendant of the given node?
  26835. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26836. * @param ancestor defines the parent node to inspect
  26837. * @returns a boolean indicating if this node is a descendant of the given node
  26838. */
  26839. isDescendantOf(ancestor: Node): boolean;
  26840. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26841. /**
  26842. * Will return all nodes that have this node as ascendant
  26843. * @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
  26844. * @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
  26845. * @return all children nodes of all types
  26846. */
  26847. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26848. /**
  26849. * Get all child-meshes of this node
  26850. * @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)
  26851. * @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
  26852. * @returns an array of AbstractMesh
  26853. */
  26854. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26855. /**
  26856. * Get all direct children of this node
  26857. * @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
  26858. * @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)
  26859. * @returns an array of Node
  26860. */
  26861. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26862. /** @hidden */ private _setReady(state: boolean): void;
  26863. /**
  26864. * Get an animation by name
  26865. * @param name defines the name of the animation to look for
  26866. * @returns null if not found else the requested animation
  26867. */
  26868. getAnimationByName(name: string): Nullable<Animation>;
  26869. /**
  26870. * Creates an animation range for this node
  26871. * @param name defines the name of the range
  26872. * @param from defines the starting key
  26873. * @param to defines the end key
  26874. */
  26875. createAnimationRange(name: string, from: number, to: number): void;
  26876. /**
  26877. * Delete a specific animation range
  26878. * @param name defines the name of the range to delete
  26879. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26880. */
  26881. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26882. /**
  26883. * Get an animation range by name
  26884. * @param name defines the name of the animation range to look for
  26885. * @returns null if not found else the requested animation range
  26886. */
  26887. getAnimationRange(name: string): Nullable<AnimationRange>;
  26888. /**
  26889. * Gets the list of all animation ranges defined on this node
  26890. * @returns an array
  26891. */
  26892. getAnimationRanges(): Nullable<AnimationRange>[];
  26893. /**
  26894. * Will start the animation sequence
  26895. * @param name defines the range frames for animation sequence
  26896. * @param loop defines if the animation should loop (false by default)
  26897. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26898. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26899. * @returns the object created for this animation. If range does not exist, it will return null
  26900. */
  26901. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26902. /**
  26903. * Serialize animation ranges into a JSON compatible object
  26904. * @returns serialization object
  26905. */
  26906. serializeAnimationRanges(): any;
  26907. /**
  26908. * Computes the world matrix of the node
  26909. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26910. * @returns the world matrix
  26911. */
  26912. computeWorldMatrix(force?: boolean): Matrix;
  26913. /**
  26914. * Releases resources associated with this node.
  26915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26917. */
  26918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26919. /**
  26920. * Parse animation range data from a serialization object and store them into a given node
  26921. * @param node defines where to store the animation ranges
  26922. * @param parsedNode defines the serialization object to read data from
  26923. * @param scene defines the hosting scene
  26924. */
  26925. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26926. /**
  26927. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26928. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26929. * @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
  26930. * @returns the new bounding vectors
  26931. */
  26932. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26933. min: Vector3;
  26934. max: Vector3;
  26935. };
  26936. }
  26937. }
  26938. declare module BABYLON {
  26939. /**
  26940. * @hidden
  26941. */
  26942. export class _IAnimationState {
  26943. key: number;
  26944. repeatCount: number;
  26945. workValue?: any;
  26946. loopMode?: number;
  26947. offsetValue?: any;
  26948. highLimitValue?: any;
  26949. }
  26950. /**
  26951. * Class used to store any kind of animation
  26952. */
  26953. export class Animation {
  26954. /**Name of the animation */
  26955. name: string;
  26956. /**Property to animate */
  26957. targetProperty: string;
  26958. /**The frames per second of the animation */
  26959. framePerSecond: number;
  26960. /**The data type of the animation */
  26961. dataType: number;
  26962. /**The loop mode of the animation */
  26963. loopMode?: number | undefined;
  26964. /**Specifies if blending should be enabled */
  26965. enableBlending?: boolean | undefined;
  26966. /**
  26967. * Use matrix interpolation instead of using direct key value when animating matrices
  26968. */
  26969. static AllowMatricesInterpolation: boolean;
  26970. /**
  26971. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26972. */
  26973. static AllowMatrixDecomposeForInterpolation: boolean;
  26974. /**
  26975. * Stores the key frames of the animation
  26976. */
  26977. private _keys;
  26978. /**
  26979. * Stores the easing function of the animation
  26980. */
  26981. private _easingFunction;
  26982. /**
  26983. * @hidden Internal use only
  26984. */ private _runtimeAnimations: RuntimeAnimation[];
  26985. /**
  26986. * The set of event that will be linked to this animation
  26987. */
  26988. private _events;
  26989. /**
  26990. * Stores an array of target property paths
  26991. */
  26992. targetPropertyPath: string[];
  26993. /**
  26994. * Stores the blending speed of the animation
  26995. */
  26996. blendingSpeed: number;
  26997. /**
  26998. * Stores the animation ranges for the animation
  26999. */
  27000. private _ranges;
  27001. /**
  27002. * @hidden Internal use
  27003. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27004. /**
  27005. * Sets up an animation
  27006. * @param property The property to animate
  27007. * @param animationType The animation type to apply
  27008. * @param framePerSecond The frames per second of the animation
  27009. * @param easingFunction The easing function used in the animation
  27010. * @returns The created animation
  27011. */
  27012. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27013. /**
  27014. * Create and start an animation on a node
  27015. * @param name defines the name of the global animation that will be run on all nodes
  27016. * @param node defines the root node where the animation will take place
  27017. * @param targetProperty defines property to animate
  27018. * @param framePerSecond defines the number of frame per second yo use
  27019. * @param totalFrame defines the number of frames in total
  27020. * @param from defines the initial value
  27021. * @param to defines the final value
  27022. * @param loopMode defines which loop mode you want to use (off by default)
  27023. * @param easingFunction defines the easing function to use (linear by default)
  27024. * @param onAnimationEnd defines the callback to call when animation end
  27025. * @returns the animatable created for this animation
  27026. */
  27027. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27028. /**
  27029. * Create and start an animation on a node and its descendants
  27030. * @param name defines the name of the global animation that will be run on all nodes
  27031. * @param node defines the root node where the animation will take place
  27032. * @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
  27033. * @param targetProperty defines property to animate
  27034. * @param framePerSecond defines the number of frame per second to use
  27035. * @param totalFrame defines the number of frames in total
  27036. * @param from defines the initial value
  27037. * @param to defines the final value
  27038. * @param loopMode defines which loop mode you want to use (off by default)
  27039. * @param easingFunction defines the easing function to use (linear by default)
  27040. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27041. * @returns the list of animatables created for all nodes
  27042. * @example https://www.babylonjs-playground.com/#MH0VLI
  27043. */
  27044. 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[]>;
  27045. /**
  27046. * Creates a new animation, merges it with the existing animations and starts it
  27047. * @param name Name of the animation
  27048. * @param node Node which contains the scene that begins the animations
  27049. * @param targetProperty Specifies which property to animate
  27050. * @param framePerSecond The frames per second of the animation
  27051. * @param totalFrame The total number of frames
  27052. * @param from The frame at the beginning of the animation
  27053. * @param to The frame at the end of the animation
  27054. * @param loopMode Specifies the loop mode of the animation
  27055. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27056. * @param onAnimationEnd Callback to run once the animation is complete
  27057. * @returns Nullable animation
  27058. */
  27059. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27060. /**
  27061. * Transition property of an host to the target Value
  27062. * @param property The property to transition
  27063. * @param targetValue The target Value of the property
  27064. * @param host The object where the property to animate belongs
  27065. * @param scene Scene used to run the animation
  27066. * @param frameRate Framerate (in frame/s) to use
  27067. * @param transition The transition type we want to use
  27068. * @param duration The duration of the animation, in milliseconds
  27069. * @param onAnimationEnd Callback trigger at the end of the animation
  27070. * @returns Nullable animation
  27071. */
  27072. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27073. /**
  27074. * Return the array of runtime animations currently using this animation
  27075. */
  27076. readonly runtimeAnimations: RuntimeAnimation[];
  27077. /**
  27078. * Specifies if any of the runtime animations are currently running
  27079. */
  27080. readonly hasRunningRuntimeAnimations: boolean;
  27081. /**
  27082. * Initializes the animation
  27083. * @param name Name of the animation
  27084. * @param targetProperty Property to animate
  27085. * @param framePerSecond The frames per second of the animation
  27086. * @param dataType The data type of the animation
  27087. * @param loopMode The loop mode of the animation
  27088. * @param enableBlending Specifies if blending should be enabled
  27089. */
  27090. constructor(
  27091. /**Name of the animation */
  27092. name: string,
  27093. /**Property to animate */
  27094. targetProperty: string,
  27095. /**The frames per second of the animation */
  27096. framePerSecond: number,
  27097. /**The data type of the animation */
  27098. dataType: number,
  27099. /**The loop mode of the animation */
  27100. loopMode?: number | undefined,
  27101. /**Specifies if blending should be enabled */
  27102. enableBlending?: boolean | undefined);
  27103. /**
  27104. * Converts the animation to a string
  27105. * @param fullDetails support for multiple levels of logging within scene loading
  27106. * @returns String form of the animation
  27107. */
  27108. toString(fullDetails?: boolean): string;
  27109. /**
  27110. * Add an event to this animation
  27111. * @param event Event to add
  27112. */
  27113. addEvent(event: AnimationEvent): void;
  27114. /**
  27115. * Remove all events found at the given frame
  27116. * @param frame The frame to remove events from
  27117. */
  27118. removeEvents(frame: number): void;
  27119. /**
  27120. * Retrieves all the events from the animation
  27121. * @returns Events from the animation
  27122. */
  27123. getEvents(): AnimationEvent[];
  27124. /**
  27125. * Creates an animation range
  27126. * @param name Name of the animation range
  27127. * @param from Starting frame of the animation range
  27128. * @param to Ending frame of the animation
  27129. */
  27130. createRange(name: string, from: number, to: number): void;
  27131. /**
  27132. * Deletes an animation range by name
  27133. * @param name Name of the animation range to delete
  27134. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27135. */
  27136. deleteRange(name: string, deleteFrames?: boolean): void;
  27137. /**
  27138. * Gets the animation range by name, or null if not defined
  27139. * @param name Name of the animation range
  27140. * @returns Nullable animation range
  27141. */
  27142. getRange(name: string): Nullable<AnimationRange>;
  27143. /**
  27144. * Gets the key frames from the animation
  27145. * @returns The key frames of the animation
  27146. */
  27147. getKeys(): Array<IAnimationKey>;
  27148. /**
  27149. * Gets the highest frame rate of the animation
  27150. * @returns Highest frame rate of the animation
  27151. */
  27152. getHighestFrame(): number;
  27153. /**
  27154. * Gets the easing function of the animation
  27155. * @returns Easing function of the animation
  27156. */
  27157. getEasingFunction(): IEasingFunction;
  27158. /**
  27159. * Sets the easing function of the animation
  27160. * @param easingFunction A custom mathematical formula for animation
  27161. */
  27162. setEasingFunction(easingFunction: EasingFunction): void;
  27163. /**
  27164. * Interpolates a scalar linearly
  27165. * @param startValue Start value of the animation curve
  27166. * @param endValue End value of the animation curve
  27167. * @param gradient Scalar amount to interpolate
  27168. * @returns Interpolated scalar value
  27169. */
  27170. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27171. /**
  27172. * Interpolates a scalar cubically
  27173. * @param startValue Start value of the animation curve
  27174. * @param outTangent End tangent of the animation
  27175. * @param endValue End value of the animation curve
  27176. * @param inTangent Start tangent of the animation curve
  27177. * @param gradient Scalar amount to interpolate
  27178. * @returns Interpolated scalar value
  27179. */
  27180. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27181. /**
  27182. * Interpolates a quaternion using a spherical linear interpolation
  27183. * @param startValue Start value of the animation curve
  27184. * @param endValue End value of the animation curve
  27185. * @param gradient Scalar amount to interpolate
  27186. * @returns Interpolated quaternion value
  27187. */
  27188. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27189. /**
  27190. * Interpolates a quaternion cubically
  27191. * @param startValue Start value of the animation curve
  27192. * @param outTangent End tangent of the animation curve
  27193. * @param endValue End value of the animation curve
  27194. * @param inTangent Start tangent of the animation curve
  27195. * @param gradient Scalar amount to interpolate
  27196. * @returns Interpolated quaternion value
  27197. */
  27198. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27199. /**
  27200. * Interpolates a Vector3 linearl
  27201. * @param startValue Start value of the animation curve
  27202. * @param endValue End value of the animation curve
  27203. * @param gradient Scalar amount to interpolate
  27204. * @returns Interpolated scalar value
  27205. */
  27206. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27207. /**
  27208. * Interpolates a Vector3 cubically
  27209. * @param startValue Start value of the animation curve
  27210. * @param outTangent End tangent of the animation
  27211. * @param endValue End value of the animation curve
  27212. * @param inTangent Start tangent of the animation curve
  27213. * @param gradient Scalar amount to interpolate
  27214. * @returns InterpolatedVector3 value
  27215. */
  27216. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27217. /**
  27218. * Interpolates a Vector2 linearly
  27219. * @param startValue Start value of the animation curve
  27220. * @param endValue End value of the animation curve
  27221. * @param gradient Scalar amount to interpolate
  27222. * @returns Interpolated Vector2 value
  27223. */
  27224. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27225. /**
  27226. * Interpolates a Vector2 cubically
  27227. * @param startValue Start value of the animation curve
  27228. * @param outTangent End tangent of the animation
  27229. * @param endValue End value of the animation curve
  27230. * @param inTangent Start tangent of the animation curve
  27231. * @param gradient Scalar amount to interpolate
  27232. * @returns Interpolated Vector2 value
  27233. */
  27234. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27235. /**
  27236. * Interpolates a size linearly
  27237. * @param startValue Start value of the animation curve
  27238. * @param endValue End value of the animation curve
  27239. * @param gradient Scalar amount to interpolate
  27240. * @returns Interpolated Size value
  27241. */
  27242. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27243. /**
  27244. * Interpolates a Color3 linearly
  27245. * @param startValue Start value of the animation curve
  27246. * @param endValue End value of the animation curve
  27247. * @param gradient Scalar amount to interpolate
  27248. * @returns Interpolated Color3 value
  27249. */
  27250. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27251. /**
  27252. * Interpolates a Color4 linearly
  27253. * @param startValue Start value of the animation curve
  27254. * @param endValue End value of the animation curve
  27255. * @param gradient Scalar amount to interpolate
  27256. * @returns Interpolated Color3 value
  27257. */
  27258. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  27259. /**
  27260. * @hidden Internal use only
  27261. */ private _getKeyValue(value: any): any;
  27262. /**
  27263. * @hidden Internal use only
  27264. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  27265. /**
  27266. * Defines the function to use to interpolate matrices
  27267. * @param startValue defines the start matrix
  27268. * @param endValue defines the end matrix
  27269. * @param gradient defines the gradient between both matrices
  27270. * @param result defines an optional target matrix where to store the interpolation
  27271. * @returns the interpolated matrix
  27272. */
  27273. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27274. /**
  27275. * Makes a copy of the animation
  27276. * @returns Cloned animation
  27277. */
  27278. clone(): Animation;
  27279. /**
  27280. * Sets the key frames of the animation
  27281. * @param values The animation key frames to set
  27282. */
  27283. setKeys(values: Array<IAnimationKey>): void;
  27284. /**
  27285. * Serializes the animation to an object
  27286. * @returns Serialized object
  27287. */
  27288. serialize(): any;
  27289. /**
  27290. * Float animation type
  27291. */
  27292. static readonly ANIMATIONTYPE_FLOAT: number;
  27293. /**
  27294. * Vector3 animation type
  27295. */
  27296. static readonly ANIMATIONTYPE_VECTOR3: number;
  27297. /**
  27298. * Quaternion animation type
  27299. */
  27300. static readonly ANIMATIONTYPE_QUATERNION: number;
  27301. /**
  27302. * Matrix animation type
  27303. */
  27304. static readonly ANIMATIONTYPE_MATRIX: number;
  27305. /**
  27306. * Color3 animation type
  27307. */
  27308. static readonly ANIMATIONTYPE_COLOR3: number;
  27309. /**
  27310. * Color3 animation type
  27311. */
  27312. static readonly ANIMATIONTYPE_COLOR4: number;
  27313. /**
  27314. * Vector2 animation type
  27315. */
  27316. static readonly ANIMATIONTYPE_VECTOR2: number;
  27317. /**
  27318. * Size animation type
  27319. */
  27320. static readonly ANIMATIONTYPE_SIZE: number;
  27321. /**
  27322. * Relative Loop Mode
  27323. */
  27324. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27325. /**
  27326. * Cycle Loop Mode
  27327. */
  27328. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27329. /**
  27330. * Constant Loop Mode
  27331. */
  27332. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27333. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  27334. /**
  27335. * Parses an animation object and creates an animation
  27336. * @param parsedAnimation Parsed animation object
  27337. * @returns Animation object
  27338. */
  27339. static Parse(parsedAnimation: any): Animation;
  27340. /**
  27341. * Appends the serialized animations from the source animations
  27342. * @param source Source containing the animations
  27343. * @param destination Target to store the animations
  27344. */
  27345. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27346. }
  27347. }
  27348. declare module BABYLON {
  27349. /**
  27350. * Interface containing an array of animations
  27351. */
  27352. export interface IAnimatable {
  27353. /**
  27354. * Array of animations
  27355. */
  27356. animations: Nullable<Array<Animation>>;
  27357. }
  27358. }
  27359. declare module BABYLON {
  27360. /**
  27361. * This represents all the required information to add a fresnel effect on a material:
  27362. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27363. */
  27364. export class FresnelParameters {
  27365. private _isEnabled;
  27366. /**
  27367. * Define if the fresnel effect is enable or not.
  27368. */
  27369. isEnabled: boolean;
  27370. /**
  27371. * Define the color used on edges (grazing angle)
  27372. */
  27373. leftColor: Color3;
  27374. /**
  27375. * Define the color used on center
  27376. */
  27377. rightColor: Color3;
  27378. /**
  27379. * Define bias applied to computed fresnel term
  27380. */
  27381. bias: number;
  27382. /**
  27383. * Defined the power exponent applied to fresnel term
  27384. */
  27385. power: number;
  27386. /**
  27387. * Clones the current fresnel and its valuues
  27388. * @returns a clone fresnel configuration
  27389. */
  27390. clone(): FresnelParameters;
  27391. /**
  27392. * Serializes the current fresnel parameters to a JSON representation.
  27393. * @return the JSON serialization
  27394. */
  27395. serialize(): any;
  27396. /**
  27397. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27398. * @param parsedFresnelParameters Define the JSON representation
  27399. * @returns the parsed parameters
  27400. */
  27401. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27402. }
  27403. }
  27404. declare module BABYLON {
  27405. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27406. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27407. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27408. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27409. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27410. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27411. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27412. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27413. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27414. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27415. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27416. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27417. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27418. /**
  27419. * Decorator used to define property that can be serialized as reference to a camera
  27420. * @param sourceName defines the name of the property to decorate
  27421. */
  27422. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27423. /**
  27424. * Class used to help serialization objects
  27425. */
  27426. export class SerializationHelper {
  27427. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27428. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27429. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27430. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27431. /**
  27432. * Appends the serialized animations from the source animations
  27433. * @param source Source containing the animations
  27434. * @param destination Target to store the animations
  27435. */
  27436. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27437. /**
  27438. * Static function used to serialized a specific entity
  27439. * @param entity defines the entity to serialize
  27440. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27441. * @returns a JSON compatible object representing the serialization of the entity
  27442. */
  27443. static Serialize<T>(entity: T, serializationObject?: any): any;
  27444. /**
  27445. * Creates a new entity from a serialization data object
  27446. * @param creationFunction defines a function used to instanciated the new entity
  27447. * @param source defines the source serialization data
  27448. * @param scene defines the hosting scene
  27449. * @param rootUrl defines the root url for resources
  27450. * @returns a new entity
  27451. */
  27452. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27453. /**
  27454. * Clones an object
  27455. * @param creationFunction defines the function used to instanciate the new object
  27456. * @param source defines the source object
  27457. * @returns the cloned object
  27458. */
  27459. static Clone<T>(creationFunction: () => T, source: T): T;
  27460. /**
  27461. * Instanciates a new object based on a source one (some data will be shared between both object)
  27462. * @param creationFunction defines the function used to instanciate the new object
  27463. * @param source defines the source object
  27464. * @returns the new object
  27465. */
  27466. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27467. }
  27468. }
  27469. declare module BABYLON {
  27470. /**
  27471. * Class used to manipulate GUIDs
  27472. */
  27473. export class GUID {
  27474. /**
  27475. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27476. * Be aware Math.random() could cause collisions, but:
  27477. * "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"
  27478. * @returns a pseudo random id
  27479. */
  27480. static RandomId(): string;
  27481. }
  27482. }
  27483. declare module BABYLON {
  27484. /**
  27485. * Base class of all the textures in babylon.
  27486. * It groups all the common properties the materials, post process, lights... might need
  27487. * in order to make a correct use of the texture.
  27488. */
  27489. export class BaseTexture implements IAnimatable {
  27490. /**
  27491. * Default anisotropic filtering level for the application.
  27492. * It is set to 4 as a good tradeoff between perf and quality.
  27493. */
  27494. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27495. /**
  27496. * Gets or sets the unique id of the texture
  27497. */
  27498. uniqueId: number;
  27499. /**
  27500. * Define the name of the texture.
  27501. */
  27502. name: string;
  27503. /**
  27504. * Gets or sets an object used to store user defined information.
  27505. */
  27506. metadata: any;
  27507. /**
  27508. * For internal use only. Please do not use.
  27509. */
  27510. reservedDataStore: any;
  27511. private _hasAlpha;
  27512. /**
  27513. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27514. */
  27515. hasAlpha: boolean;
  27516. /**
  27517. * Defines if the alpha value should be determined via the rgb values.
  27518. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27519. */
  27520. getAlphaFromRGB: boolean;
  27521. /**
  27522. * Intensity or strength of the texture.
  27523. * It is commonly used by materials to fine tune the intensity of the texture
  27524. */
  27525. level: number;
  27526. /**
  27527. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27528. * This is part of the texture as textures usually maps to one uv set.
  27529. */
  27530. coordinatesIndex: number;
  27531. private _coordinatesMode;
  27532. /**
  27533. * How a texture is mapped.
  27534. *
  27535. * | Value | Type | Description |
  27536. * | ----- | ----------------------------------- | ----------- |
  27537. * | 0 | EXPLICIT_MODE | |
  27538. * | 1 | SPHERICAL_MODE | |
  27539. * | 2 | PLANAR_MODE | |
  27540. * | 3 | CUBIC_MODE | |
  27541. * | 4 | PROJECTION_MODE | |
  27542. * | 5 | SKYBOX_MODE | |
  27543. * | 6 | INVCUBIC_MODE | |
  27544. * | 7 | EQUIRECTANGULAR_MODE | |
  27545. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27546. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27547. */
  27548. coordinatesMode: number;
  27549. /**
  27550. * | Value | Type | Description |
  27551. * | ----- | ------------------ | ----------- |
  27552. * | 0 | CLAMP_ADDRESSMODE | |
  27553. * | 1 | WRAP_ADDRESSMODE | |
  27554. * | 2 | MIRROR_ADDRESSMODE | |
  27555. */
  27556. wrapU: number;
  27557. /**
  27558. * | Value | Type | Description |
  27559. * | ----- | ------------------ | ----------- |
  27560. * | 0 | CLAMP_ADDRESSMODE | |
  27561. * | 1 | WRAP_ADDRESSMODE | |
  27562. * | 2 | MIRROR_ADDRESSMODE | |
  27563. */
  27564. wrapV: number;
  27565. /**
  27566. * | Value | Type | Description |
  27567. * | ----- | ------------------ | ----------- |
  27568. * | 0 | CLAMP_ADDRESSMODE | |
  27569. * | 1 | WRAP_ADDRESSMODE | |
  27570. * | 2 | MIRROR_ADDRESSMODE | |
  27571. */
  27572. wrapR: number;
  27573. /**
  27574. * With compliant hardware and browser (supporting anisotropic filtering)
  27575. * this defines the level of anisotropic filtering in the texture.
  27576. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27577. */
  27578. anisotropicFilteringLevel: number;
  27579. /**
  27580. * Define if the texture is a cube texture or if false a 2d texture.
  27581. */
  27582. isCube: boolean;
  27583. /**
  27584. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27585. */
  27586. is3D: boolean;
  27587. /**
  27588. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  27589. */
  27590. is2DArray: boolean;
  27591. /**
  27592. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27593. * HDR texture are usually stored in linear space.
  27594. * This only impacts the PBR and Background materials
  27595. */
  27596. gammaSpace: boolean;
  27597. /**
  27598. * Gets or sets whether or not the texture contains RGBD data.
  27599. */
  27600. isRGBD: boolean;
  27601. /**
  27602. * Is Z inverted in the texture (useful in a cube texture).
  27603. */
  27604. invertZ: boolean;
  27605. /**
  27606. * Are mip maps generated for this texture or not.
  27607. */
  27608. readonly noMipmap: boolean;
  27609. /**
  27610. * @hidden
  27611. */
  27612. lodLevelInAlpha: boolean;
  27613. /**
  27614. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27615. */
  27616. lodGenerationOffset: number;
  27617. /**
  27618. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27619. */
  27620. lodGenerationScale: number;
  27621. /**
  27622. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27623. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27624. * average roughness values.
  27625. */
  27626. linearSpecularLOD: boolean;
  27627. /**
  27628. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27629. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27630. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27631. */
  27632. irradianceTexture: Nullable<BaseTexture>;
  27633. /**
  27634. * Define if the texture is a render target.
  27635. */
  27636. isRenderTarget: boolean;
  27637. /**
  27638. * Define the unique id of the texture in the scene.
  27639. */
  27640. readonly uid: string;
  27641. /**
  27642. * Return a string representation of the texture.
  27643. * @returns the texture as a string
  27644. */
  27645. toString(): string;
  27646. /**
  27647. * Get the class name of the texture.
  27648. * @returns "BaseTexture"
  27649. */
  27650. getClassName(): string;
  27651. /**
  27652. * Define the list of animation attached to the texture.
  27653. */
  27654. animations: Animation[];
  27655. /**
  27656. * An event triggered when the texture is disposed.
  27657. */
  27658. onDisposeObservable: Observable<BaseTexture>;
  27659. private _onDisposeObserver;
  27660. /**
  27661. * Callback triggered when the texture has been disposed.
  27662. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27663. */
  27664. onDispose: () => void;
  27665. /**
  27666. * Define the current state of the loading sequence when in delayed load mode.
  27667. */
  27668. delayLoadState: number;
  27669. private _scene;
  27670. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27671. private _uid;
  27672. /**
  27673. * Define if the texture is preventinga material to render or not.
  27674. * If not and the texture is not ready, the engine will use a default black texture instead.
  27675. */
  27676. readonly isBlocking: boolean;
  27677. /**
  27678. * Instantiates a new BaseTexture.
  27679. * Base class of all the textures in babylon.
  27680. * It groups all the common properties the materials, post process, lights... might need
  27681. * in order to make a correct use of the texture.
  27682. * @param scene Define the scene the texture blongs to
  27683. */
  27684. constructor(scene: Nullable<Scene>);
  27685. /**
  27686. * Get the scene the texture belongs to.
  27687. * @returns the scene or null if undefined
  27688. */
  27689. getScene(): Nullable<Scene>;
  27690. /**
  27691. * Get the texture transform matrix used to offset tile the texture for istance.
  27692. * @returns the transformation matrix
  27693. */
  27694. getTextureMatrix(): Matrix;
  27695. /**
  27696. * Get the texture reflection matrix used to rotate/transform the reflection.
  27697. * @returns the reflection matrix
  27698. */
  27699. getReflectionTextureMatrix(): Matrix;
  27700. /**
  27701. * Get the underlying lower level texture from Babylon.
  27702. * @returns the insternal texture
  27703. */
  27704. getInternalTexture(): Nullable<InternalTexture>;
  27705. /**
  27706. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27707. * @returns true if ready or not blocking
  27708. */
  27709. isReadyOrNotBlocking(): boolean;
  27710. /**
  27711. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27712. * @returns true if fully ready
  27713. */
  27714. isReady(): boolean;
  27715. private _cachedSize;
  27716. /**
  27717. * Get the size of the texture.
  27718. * @returns the texture size.
  27719. */
  27720. getSize(): ISize;
  27721. /**
  27722. * Get the base size of the texture.
  27723. * It can be different from the size if the texture has been resized for POT for instance
  27724. * @returns the base size
  27725. */
  27726. getBaseSize(): ISize;
  27727. /**
  27728. * Update the sampling mode of the texture.
  27729. * Default is Trilinear mode.
  27730. *
  27731. * | Value | Type | Description |
  27732. * | ----- | ------------------ | ----------- |
  27733. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27734. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27735. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27736. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27737. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27738. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27739. * | 7 | NEAREST_LINEAR | |
  27740. * | 8 | NEAREST_NEAREST | |
  27741. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27742. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27743. * | 11 | LINEAR_LINEAR | |
  27744. * | 12 | LINEAR_NEAREST | |
  27745. *
  27746. * > _mag_: magnification filter (close to the viewer)
  27747. * > _min_: minification filter (far from the viewer)
  27748. * > _mip_: filter used between mip map levels
  27749. *@param samplingMode Define the new sampling mode of the texture
  27750. */
  27751. updateSamplingMode(samplingMode: number): void;
  27752. /**
  27753. * Scales the texture if is `canRescale()`
  27754. * @param ratio the resize factor we want to use to rescale
  27755. */
  27756. scale(ratio: number): void;
  27757. /**
  27758. * Get if the texture can rescale.
  27759. */
  27760. readonly canRescale: boolean;
  27761. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27762. /** @hidden */ private _rebuild(): void;
  27763. /**
  27764. * Triggers the load sequence in delayed load mode.
  27765. */
  27766. delayLoad(): void;
  27767. /**
  27768. * Clones the texture.
  27769. * @returns the cloned texture
  27770. */
  27771. clone(): Nullable<BaseTexture>;
  27772. /**
  27773. * Get the texture underlying type (INT, FLOAT...)
  27774. */
  27775. readonly textureType: number;
  27776. /**
  27777. * Get the texture underlying format (RGB, RGBA...)
  27778. */
  27779. readonly textureFormat: number;
  27780. /**
  27781. * Indicates that textures need to be re-calculated for all materials
  27782. */
  27783. protected _markAllSubMeshesAsTexturesDirty(): void;
  27784. /**
  27785. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27786. * This will returns an RGBA array buffer containing either in values (0-255) or
  27787. * float values (0-1) depending of the underlying buffer type.
  27788. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27789. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27790. * @param buffer defines a user defined buffer to fill with data (can be null)
  27791. * @returns The Array buffer containing the pixels data.
  27792. */
  27793. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27794. /**
  27795. * Release and destroy the underlying lower level texture aka internalTexture.
  27796. */
  27797. releaseInternalTexture(): void;
  27798. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27799. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27800. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27801. /**
  27802. * Dispose the texture and release its associated resources.
  27803. */
  27804. dispose(): void;
  27805. /**
  27806. * Serialize the texture into a JSON representation that can be parsed later on.
  27807. * @returns the JSON representation of the texture
  27808. */
  27809. serialize(): any;
  27810. /**
  27811. * Helper function to be called back once a list of texture contains only ready textures.
  27812. * @param textures Define the list of textures to wait for
  27813. * @param callback Define the callback triggered once the entire list will be ready
  27814. */
  27815. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27816. }
  27817. }
  27818. declare module BABYLON {
  27819. /**
  27820. * Options to be used when creating an effect.
  27821. */
  27822. export interface IEffectCreationOptions {
  27823. /**
  27824. * Atrributes that will be used in the shader.
  27825. */
  27826. attributes: string[];
  27827. /**
  27828. * Uniform varible names that will be set in the shader.
  27829. */
  27830. uniformsNames: string[];
  27831. /**
  27832. * Uniform buffer varible names that will be set in the shader.
  27833. */
  27834. uniformBuffersNames: string[];
  27835. /**
  27836. * Sampler texture variable names that will be set in the shader.
  27837. */
  27838. samplers: string[];
  27839. /**
  27840. * Define statements that will be set in the shader.
  27841. */
  27842. defines: any;
  27843. /**
  27844. * Possible fallbacks for this effect to improve performance when needed.
  27845. */
  27846. fallbacks: Nullable<IEffectFallbacks>;
  27847. /**
  27848. * Callback that will be called when the shader is compiled.
  27849. */
  27850. onCompiled: Nullable<(effect: Effect) => void>;
  27851. /**
  27852. * Callback that will be called if an error occurs during shader compilation.
  27853. */
  27854. onError: Nullable<(effect: Effect, errors: string) => void>;
  27855. /**
  27856. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27857. */
  27858. indexParameters?: any;
  27859. /**
  27860. * Max number of lights that can be used in the shader.
  27861. */
  27862. maxSimultaneousLights?: number;
  27863. /**
  27864. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27865. */
  27866. transformFeedbackVaryings?: Nullable<string[]>;
  27867. }
  27868. /**
  27869. * Effect containing vertex and fragment shader that can be executed on an object.
  27870. */
  27871. export class Effect implements IDisposable {
  27872. /**
  27873. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27874. */
  27875. static ShadersRepository: string;
  27876. /**
  27877. * Name of the effect.
  27878. */
  27879. name: any;
  27880. /**
  27881. * String container all the define statements that should be set on the shader.
  27882. */
  27883. defines: string;
  27884. /**
  27885. * Callback that will be called when the shader is compiled.
  27886. */
  27887. onCompiled: Nullable<(effect: Effect) => void>;
  27888. /**
  27889. * Callback that will be called if an error occurs during shader compilation.
  27890. */
  27891. onError: Nullable<(effect: Effect, errors: string) => void>;
  27892. /**
  27893. * Callback that will be called when effect is bound.
  27894. */
  27895. onBind: Nullable<(effect: Effect) => void>;
  27896. /**
  27897. * Unique ID of the effect.
  27898. */
  27899. uniqueId: number;
  27900. /**
  27901. * Observable that will be called when the shader is compiled.
  27902. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27903. */
  27904. onCompileObservable: Observable<Effect>;
  27905. /**
  27906. * Observable that will be called if an error occurs during shader compilation.
  27907. */
  27908. onErrorObservable: Observable<Effect>;
  27909. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27910. /**
  27911. * Observable that will be called when effect is bound.
  27912. */
  27913. readonly onBindObservable: Observable<Effect>;
  27914. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27915. private static _uniqueIdSeed;
  27916. private _engine;
  27917. private _uniformBuffersNames;
  27918. private _uniformsNames;
  27919. private _samplerList;
  27920. private _samplers;
  27921. private _isReady;
  27922. private _compilationError;
  27923. private _allFallbacksProcessed;
  27924. private _attributesNames;
  27925. private _attributes;
  27926. private _uniforms;
  27927. /**
  27928. * Key for the effect.
  27929. * @hidden
  27930. */ private _key: string;
  27931. private _indexParameters;
  27932. private _fallbacks;
  27933. private _vertexSourceCode;
  27934. private _fragmentSourceCode;
  27935. private _vertexSourceCodeOverride;
  27936. private _fragmentSourceCodeOverride;
  27937. private _transformFeedbackVaryings;
  27938. /**
  27939. * Compiled shader to webGL program.
  27940. * @hidden
  27941. */ private _pipelineContext: Nullable<IPipelineContext>;
  27942. private _valueCache;
  27943. private static _baseCache;
  27944. /**
  27945. * Instantiates an effect.
  27946. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27947. * @param baseName Name of the effect.
  27948. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27949. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27950. * @param samplers List of sampler variables that will be passed to the shader.
  27951. * @param engine Engine to be used to render the effect
  27952. * @param defines Define statements to be added to the shader.
  27953. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27954. * @param onCompiled Callback that will be called when the shader is compiled.
  27955. * @param onError Callback that will be called if an error occurs during shader compilation.
  27956. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27957. */
  27958. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  27959. private _useFinalCode;
  27960. /**
  27961. * Unique key for this effect
  27962. */
  27963. readonly key: string;
  27964. /**
  27965. * If the effect has been compiled and prepared.
  27966. * @returns if the effect is compiled and prepared.
  27967. */
  27968. isReady(): boolean;
  27969. private _isReadyInternal;
  27970. /**
  27971. * The engine the effect was initialized with.
  27972. * @returns the engine.
  27973. */
  27974. getEngine(): Engine;
  27975. /**
  27976. * The pipeline context for this effect
  27977. * @returns the associated pipeline context
  27978. */
  27979. getPipelineContext(): Nullable<IPipelineContext>;
  27980. /**
  27981. * The set of names of attribute variables for the shader.
  27982. * @returns An array of attribute names.
  27983. */
  27984. getAttributesNames(): string[];
  27985. /**
  27986. * Returns the attribute at the given index.
  27987. * @param index The index of the attribute.
  27988. * @returns The location of the attribute.
  27989. */
  27990. getAttributeLocation(index: number): number;
  27991. /**
  27992. * Returns the attribute based on the name of the variable.
  27993. * @param name of the attribute to look up.
  27994. * @returns the attribute location.
  27995. */
  27996. getAttributeLocationByName(name: string): number;
  27997. /**
  27998. * The number of attributes.
  27999. * @returns the numnber of attributes.
  28000. */
  28001. getAttributesCount(): number;
  28002. /**
  28003. * Gets the index of a uniform variable.
  28004. * @param uniformName of the uniform to look up.
  28005. * @returns the index.
  28006. */
  28007. getUniformIndex(uniformName: string): number;
  28008. /**
  28009. * Returns the attribute based on the name of the variable.
  28010. * @param uniformName of the uniform to look up.
  28011. * @returns the location of the uniform.
  28012. */
  28013. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28014. /**
  28015. * Returns an array of sampler variable names
  28016. * @returns The array of sampler variable neames.
  28017. */
  28018. getSamplers(): string[];
  28019. /**
  28020. * The error from the last compilation.
  28021. * @returns the error string.
  28022. */
  28023. getCompilationError(): string;
  28024. /**
  28025. * Gets a boolean indicating that all fallbacks were used during compilation
  28026. * @returns true if all fallbacks were used
  28027. */
  28028. allFallbacksProcessed(): boolean;
  28029. /**
  28030. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28031. * @param func The callback to be used.
  28032. */
  28033. executeWhenCompiled(func: (effect: Effect) => void): void;
  28034. private _checkIsReady;
  28035. private _loadShader;
  28036. /**
  28037. * Recompiles the webGL program
  28038. * @param vertexSourceCode The source code for the vertex shader.
  28039. * @param fragmentSourceCode The source code for the fragment shader.
  28040. * @param onCompiled Callback called when completed.
  28041. * @param onError Callback called on error.
  28042. * @hidden
  28043. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28044. /**
  28045. * Prepares the effect
  28046. * @hidden
  28047. */ private _prepareEffect(): void;
  28048. private _processCompilationErrors;
  28049. /**
  28050. * Checks if the effect is supported. (Must be called after compilation)
  28051. */
  28052. readonly isSupported: boolean;
  28053. /**
  28054. * Binds a texture to the engine to be used as output of the shader.
  28055. * @param channel Name of the output variable.
  28056. * @param texture Texture to bind.
  28057. * @hidden
  28058. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  28059. /**
  28060. * Sets a texture on the engine to be used in the shader.
  28061. * @param channel Name of the sampler variable.
  28062. * @param texture Texture to set.
  28063. */
  28064. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28065. /**
  28066. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28067. * @param channel Name of the sampler variable.
  28068. * @param texture Texture to set.
  28069. */
  28070. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28071. /**
  28072. * Sets an array of textures on the engine to be used in the shader.
  28073. * @param channel Name of the variable.
  28074. * @param textures Textures to set.
  28075. */
  28076. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28077. /**
  28078. * 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)
  28079. * @param channel Name of the sampler variable.
  28080. * @param postProcess Post process to get the input texture from.
  28081. */
  28082. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28083. /**
  28084. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28085. * 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)
  28086. * @param channel Name of the sampler variable.
  28087. * @param postProcess Post process to get the output texture from.
  28088. */
  28089. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28090. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28091. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28092. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28093. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28094. /**
  28095. * Binds a buffer to a uniform.
  28096. * @param buffer Buffer to bind.
  28097. * @param name Name of the uniform variable to bind to.
  28098. */
  28099. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28100. /**
  28101. * Binds block to a uniform.
  28102. * @param blockName Name of the block to bind.
  28103. * @param index Index to bind.
  28104. */
  28105. bindUniformBlock(blockName: string, index: number): void;
  28106. /**
  28107. * Sets an interger value on a uniform variable.
  28108. * @param uniformName Name of the variable.
  28109. * @param value Value to be set.
  28110. * @returns this effect.
  28111. */
  28112. setInt(uniformName: string, value: number): Effect;
  28113. /**
  28114. * Sets an int array on a uniform variable.
  28115. * @param uniformName Name of the variable.
  28116. * @param array array to be set.
  28117. * @returns this effect.
  28118. */
  28119. setIntArray(uniformName: string, array: Int32Array): Effect;
  28120. /**
  28121. * 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)
  28122. * @param uniformName Name of the variable.
  28123. * @param array array to be set.
  28124. * @returns this effect.
  28125. */
  28126. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28127. /**
  28128. * 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)
  28129. * @param uniformName Name of the variable.
  28130. * @param array array to be set.
  28131. * @returns this effect.
  28132. */
  28133. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28134. /**
  28135. * 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)
  28136. * @param uniformName Name of the variable.
  28137. * @param array array to be set.
  28138. * @returns this effect.
  28139. */
  28140. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28141. /**
  28142. * Sets an float array on a uniform variable.
  28143. * @param uniformName Name of the variable.
  28144. * @param array array to be set.
  28145. * @returns this effect.
  28146. */
  28147. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28148. /**
  28149. * 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)
  28150. * @param uniformName Name of the variable.
  28151. * @param array array to be set.
  28152. * @returns this effect.
  28153. */
  28154. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28155. /**
  28156. * 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)
  28157. * @param uniformName Name of the variable.
  28158. * @param array array to be set.
  28159. * @returns this effect.
  28160. */
  28161. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28162. /**
  28163. * 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)
  28164. * @param uniformName Name of the variable.
  28165. * @param array array to be set.
  28166. * @returns this effect.
  28167. */
  28168. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28169. /**
  28170. * Sets an array on a uniform variable.
  28171. * @param uniformName Name of the variable.
  28172. * @param array array to be set.
  28173. * @returns this effect.
  28174. */
  28175. setArray(uniformName: string, array: number[]): Effect;
  28176. /**
  28177. * 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)
  28178. * @param uniformName Name of the variable.
  28179. * @param array array to be set.
  28180. * @returns this effect.
  28181. */
  28182. setArray2(uniformName: string, array: number[]): Effect;
  28183. /**
  28184. * 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)
  28185. * @param uniformName Name of the variable.
  28186. * @param array array to be set.
  28187. * @returns this effect.
  28188. */
  28189. setArray3(uniformName: string, array: number[]): Effect;
  28190. /**
  28191. * 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)
  28192. * @param uniformName Name of the variable.
  28193. * @param array array to be set.
  28194. * @returns this effect.
  28195. */
  28196. setArray4(uniformName: string, array: number[]): Effect;
  28197. /**
  28198. * Sets matrices on a uniform variable.
  28199. * @param uniformName Name of the variable.
  28200. * @param matrices matrices to be set.
  28201. * @returns this effect.
  28202. */
  28203. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28204. /**
  28205. * Sets matrix on a uniform variable.
  28206. * @param uniformName Name of the variable.
  28207. * @param matrix matrix to be set.
  28208. * @returns this effect.
  28209. */
  28210. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28211. /**
  28212. * 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)
  28213. * @param uniformName Name of the variable.
  28214. * @param matrix matrix to be set.
  28215. * @returns this effect.
  28216. */
  28217. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28218. /**
  28219. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28220. * @param uniformName Name of the variable.
  28221. * @param matrix matrix to be set.
  28222. * @returns this effect.
  28223. */
  28224. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28225. /**
  28226. * Sets a float on a uniform variable.
  28227. * @param uniformName Name of the variable.
  28228. * @param value value to be set.
  28229. * @returns this effect.
  28230. */
  28231. setFloat(uniformName: string, value: number): Effect;
  28232. /**
  28233. * Sets a boolean on a uniform variable.
  28234. * @param uniformName Name of the variable.
  28235. * @param bool value to be set.
  28236. * @returns this effect.
  28237. */
  28238. setBool(uniformName: string, bool: boolean): Effect;
  28239. /**
  28240. * Sets a Vector2 on a uniform variable.
  28241. * @param uniformName Name of the variable.
  28242. * @param vector2 vector2 to be set.
  28243. * @returns this effect.
  28244. */
  28245. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28246. /**
  28247. * Sets a float2 on a uniform variable.
  28248. * @param uniformName Name of the variable.
  28249. * @param x First float in float2.
  28250. * @param y Second float in float2.
  28251. * @returns this effect.
  28252. */
  28253. setFloat2(uniformName: string, x: number, y: number): Effect;
  28254. /**
  28255. * Sets a Vector3 on a uniform variable.
  28256. * @param uniformName Name of the variable.
  28257. * @param vector3 Value to be set.
  28258. * @returns this effect.
  28259. */
  28260. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28261. /**
  28262. * Sets a float3 on a uniform variable.
  28263. * @param uniformName Name of the variable.
  28264. * @param x First float in float3.
  28265. * @param y Second float in float3.
  28266. * @param z Third float in float3.
  28267. * @returns this effect.
  28268. */
  28269. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28270. /**
  28271. * Sets a Vector4 on a uniform variable.
  28272. * @param uniformName Name of the variable.
  28273. * @param vector4 Value to be set.
  28274. * @returns this effect.
  28275. */
  28276. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28277. /**
  28278. * Sets a float4 on a uniform variable.
  28279. * @param uniformName Name of the variable.
  28280. * @param x First float in float4.
  28281. * @param y Second float in float4.
  28282. * @param z Third float in float4.
  28283. * @param w Fourth float in float4.
  28284. * @returns this effect.
  28285. */
  28286. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28287. /**
  28288. * Sets a Color3 on a uniform variable.
  28289. * @param uniformName Name of the variable.
  28290. * @param color3 Value to be set.
  28291. * @returns this effect.
  28292. */
  28293. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28294. /**
  28295. * Sets a Color4 on a uniform variable.
  28296. * @param uniformName Name of the variable.
  28297. * @param color3 Value to be set.
  28298. * @param alpha Alpha value to be set.
  28299. * @returns this effect.
  28300. */
  28301. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28302. /**
  28303. * Sets a Color4 on a uniform variable
  28304. * @param uniformName defines the name of the variable
  28305. * @param color4 defines the value to be set
  28306. * @returns this effect.
  28307. */
  28308. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28309. /** Release all associated resources */
  28310. dispose(): void;
  28311. /**
  28312. * This function will add a new shader to the shader store
  28313. * @param name the name of the shader
  28314. * @param pixelShader optional pixel shader content
  28315. * @param vertexShader optional vertex shader content
  28316. */
  28317. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28318. /**
  28319. * Store of each shader (The can be looked up using effect.key)
  28320. */
  28321. static ShadersStore: {
  28322. [key: string]: string;
  28323. };
  28324. /**
  28325. * Store of each included file for a shader (The can be looked up using effect.key)
  28326. */
  28327. static IncludesShadersStore: {
  28328. [key: string]: string;
  28329. };
  28330. /**
  28331. * Resets the cache of effects.
  28332. */
  28333. static ResetCache(): void;
  28334. }
  28335. }
  28336. declare module BABYLON {
  28337. /**
  28338. * Interface used to describe the capabilities of the engine relatively to the current browser
  28339. */
  28340. export interface EngineCapabilities {
  28341. /** Maximum textures units per fragment shader */
  28342. maxTexturesImageUnits: number;
  28343. /** Maximum texture units per vertex shader */
  28344. maxVertexTextureImageUnits: number;
  28345. /** Maximum textures units in the entire pipeline */
  28346. maxCombinedTexturesImageUnits: number;
  28347. /** Maximum texture size */
  28348. maxTextureSize: number;
  28349. /** Maximum cube texture size */
  28350. maxCubemapTextureSize: number;
  28351. /** Maximum render texture size */
  28352. maxRenderTextureSize: number;
  28353. /** Maximum number of vertex attributes */
  28354. maxVertexAttribs: number;
  28355. /** Maximum number of varyings */
  28356. maxVaryingVectors: number;
  28357. /** Maximum number of uniforms per vertex shader */
  28358. maxVertexUniformVectors: number;
  28359. /** Maximum number of uniforms per fragment shader */
  28360. maxFragmentUniformVectors: number;
  28361. /** Defines if standard derivates (dx/dy) are supported */
  28362. standardDerivatives: boolean;
  28363. /** Defines if s3tc texture compression is supported */
  28364. s3tc?: WEBGL_compressed_texture_s3tc;
  28365. /** Defines if pvrtc texture compression is supported */
  28366. pvrtc: any;
  28367. /** Defines if etc1 texture compression is supported */
  28368. etc1: any;
  28369. /** Defines if etc2 texture compression is supported */
  28370. etc2: any;
  28371. /** Defines if astc texture compression is supported */
  28372. astc: any;
  28373. /** Defines if float textures are supported */
  28374. textureFloat: boolean;
  28375. /** Defines if vertex array objects are supported */
  28376. vertexArrayObject: boolean;
  28377. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28378. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  28379. /** Gets the maximum level of anisotropy supported */
  28380. maxAnisotropy: number;
  28381. /** Defines if instancing is supported */
  28382. instancedArrays: boolean;
  28383. /** Defines if 32 bits indices are supported */
  28384. uintIndices: boolean;
  28385. /** Defines if high precision shaders are supported */
  28386. highPrecisionShaderSupported: boolean;
  28387. /** Defines if depth reading in the fragment shader is supported */
  28388. fragmentDepthSupported: boolean;
  28389. /** Defines if float texture linear filtering is supported*/
  28390. textureFloatLinearFiltering: boolean;
  28391. /** Defines if rendering to float textures is supported */
  28392. textureFloatRender: boolean;
  28393. /** Defines if half float textures are supported*/
  28394. textureHalfFloat: boolean;
  28395. /** Defines if half float texture linear filtering is supported*/
  28396. textureHalfFloatLinearFiltering: boolean;
  28397. /** Defines if rendering to half float textures is supported */
  28398. textureHalfFloatRender: boolean;
  28399. /** Defines if textureLOD shader command is supported */
  28400. textureLOD: boolean;
  28401. /** Defines if draw buffers extension is supported */
  28402. drawBuffersExtension: boolean;
  28403. /** Defines if depth textures are supported */
  28404. depthTextureExtension: boolean;
  28405. /** Defines if float color buffer are supported */
  28406. colorBufferFloat: boolean;
  28407. /** Gets disjoint timer query extension (null if not supported) */
  28408. timerQuery?: EXT_disjoint_timer_query;
  28409. /** Defines if timestamp can be used with timer query */
  28410. canUseTimestampForTimerQuery: boolean;
  28411. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28412. multiview?: any;
  28413. /** Function used to let the system compiles shaders in background */
  28414. parallelShaderCompile?: {
  28415. COMPLETION_STATUS_KHR: number;
  28416. };
  28417. /** Max number of texture samples for MSAA */
  28418. maxMSAASamples: number;
  28419. /** Defines if the blend min max extension is supported */
  28420. blendMinMax: boolean;
  28421. }
  28422. }
  28423. declare module BABYLON {
  28424. /**
  28425. * @hidden
  28426. **/
  28427. export class DepthCullingState {
  28428. private _isDepthTestDirty;
  28429. private _isDepthMaskDirty;
  28430. private _isDepthFuncDirty;
  28431. private _isCullFaceDirty;
  28432. private _isCullDirty;
  28433. private _isZOffsetDirty;
  28434. private _isFrontFaceDirty;
  28435. private _depthTest;
  28436. private _depthMask;
  28437. private _depthFunc;
  28438. private _cull;
  28439. private _cullFace;
  28440. private _zOffset;
  28441. private _frontFace;
  28442. /**
  28443. * Initializes the state.
  28444. */
  28445. constructor();
  28446. readonly isDirty: boolean;
  28447. zOffset: number;
  28448. cullFace: Nullable<number>;
  28449. cull: Nullable<boolean>;
  28450. depthFunc: Nullable<number>;
  28451. depthMask: boolean;
  28452. depthTest: boolean;
  28453. frontFace: Nullable<number>;
  28454. reset(): void;
  28455. apply(gl: WebGLRenderingContext): void;
  28456. }
  28457. }
  28458. declare module BABYLON {
  28459. /**
  28460. * @hidden
  28461. **/
  28462. export class StencilState {
  28463. /** 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 */
  28464. static readonly ALWAYS: number;
  28465. /** Passed to stencilOperation to specify that stencil value must be kept */
  28466. static readonly KEEP: number;
  28467. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28468. static readonly REPLACE: number;
  28469. private _isStencilTestDirty;
  28470. private _isStencilMaskDirty;
  28471. private _isStencilFuncDirty;
  28472. private _isStencilOpDirty;
  28473. private _stencilTest;
  28474. private _stencilMask;
  28475. private _stencilFunc;
  28476. private _stencilFuncRef;
  28477. private _stencilFuncMask;
  28478. private _stencilOpStencilFail;
  28479. private _stencilOpDepthFail;
  28480. private _stencilOpStencilDepthPass;
  28481. readonly isDirty: boolean;
  28482. stencilFunc: number;
  28483. stencilFuncRef: number;
  28484. stencilFuncMask: number;
  28485. stencilOpStencilFail: number;
  28486. stencilOpDepthFail: number;
  28487. stencilOpStencilDepthPass: number;
  28488. stencilMask: number;
  28489. stencilTest: boolean;
  28490. constructor();
  28491. reset(): void;
  28492. apply(gl: WebGLRenderingContext): void;
  28493. }
  28494. }
  28495. declare module BABYLON {
  28496. /**
  28497. * @hidden
  28498. **/
  28499. export class AlphaState {
  28500. private _isAlphaBlendDirty;
  28501. private _isBlendFunctionParametersDirty;
  28502. private _isBlendEquationParametersDirty;
  28503. private _isBlendConstantsDirty;
  28504. private _alphaBlend;
  28505. private _blendFunctionParameters;
  28506. private _blendEquationParameters;
  28507. private _blendConstants;
  28508. /**
  28509. * Initializes the state.
  28510. */
  28511. constructor();
  28512. readonly isDirty: boolean;
  28513. alphaBlend: boolean;
  28514. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28515. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28516. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28517. reset(): void;
  28518. apply(gl: WebGLRenderingContext): void;
  28519. }
  28520. }
  28521. declare module BABYLON {
  28522. /** @hidden */
  28523. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28524. attributeProcessor(attribute: string): string;
  28525. varyingProcessor(varying: string, isFragment: boolean): string;
  28526. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28527. }
  28528. }
  28529. declare module BABYLON {
  28530. /**
  28531. * Interface for attribute information associated with buffer instanciation
  28532. */
  28533. export interface InstancingAttributeInfo {
  28534. /**
  28535. * Index/offset of the attribute in the vertex shader
  28536. */
  28537. index: number;
  28538. /**
  28539. * size of the attribute, 1, 2, 3 or 4
  28540. */
  28541. attributeSize: number;
  28542. /**
  28543. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28544. * default is FLOAT
  28545. */
  28546. attributeType: number;
  28547. /**
  28548. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28549. */
  28550. normalized: boolean;
  28551. /**
  28552. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28553. */
  28554. offset: number;
  28555. /**
  28556. * Name of the GLSL attribute, for debugging purpose only
  28557. */
  28558. attributeName: string;
  28559. }
  28560. }
  28561. declare module BABYLON {
  28562. interface ThinEngine {
  28563. /**
  28564. * Update a video texture
  28565. * @param texture defines the texture to update
  28566. * @param video defines the video element to use
  28567. * @param invertY defines if data must be stored with Y axis inverted
  28568. */
  28569. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28570. }
  28571. }
  28572. declare module BABYLON {
  28573. /**
  28574. * Settings for finer control over video usage
  28575. */
  28576. export interface VideoTextureSettings {
  28577. /**
  28578. * Applies `autoplay` to video, if specified
  28579. */
  28580. autoPlay?: boolean;
  28581. /**
  28582. * Applies `loop` to video, if specified
  28583. */
  28584. loop?: boolean;
  28585. /**
  28586. * Automatically updates internal texture from video at every frame in the render loop
  28587. */
  28588. autoUpdateTexture: boolean;
  28589. /**
  28590. * Image src displayed during the video loading or until the user interacts with the video.
  28591. */
  28592. poster?: string;
  28593. }
  28594. /**
  28595. * If you want to display a video in your scene, this is the special texture for that.
  28596. * This special texture works similar to other textures, with the exception of a few parameters.
  28597. * @see https://doc.babylonjs.com/how_to/video_texture
  28598. */
  28599. export class VideoTexture extends Texture {
  28600. /**
  28601. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28602. */
  28603. readonly autoUpdateTexture: boolean;
  28604. /**
  28605. * The video instance used by the texture internally
  28606. */
  28607. readonly video: HTMLVideoElement;
  28608. private _onUserActionRequestedObservable;
  28609. /**
  28610. * Event triggerd when a dom action is required by the user to play the video.
  28611. * This happens due to recent changes in browser policies preventing video to auto start.
  28612. */
  28613. readonly onUserActionRequestedObservable: Observable<Texture>;
  28614. private _generateMipMaps;
  28615. private _engine;
  28616. private _stillImageCaptured;
  28617. private _displayingPosterTexture;
  28618. private _settings;
  28619. private _createInternalTextureOnEvent;
  28620. private _frameId;
  28621. /**
  28622. * Creates a video texture.
  28623. * If you want to display a video in your scene, this is the special texture for that.
  28624. * This special texture works similar to other textures, with the exception of a few parameters.
  28625. * @see https://doc.babylonjs.com/how_to/video_texture
  28626. * @param name optional name, will detect from video source, if not defined
  28627. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28628. * @param scene is obviously the current scene.
  28629. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28630. * @param invertY is false by default but can be used to invert video on Y axis
  28631. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28632. * @param settings allows finer control over video usage
  28633. */
  28634. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28635. private _getName;
  28636. private _getVideo;
  28637. private _createInternalTexture;
  28638. private reset;
  28639. /**
  28640. * @hidden Internal method to initiate `update`.
  28641. */ private _rebuild(): void;
  28642. /**
  28643. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28644. */
  28645. update(): void;
  28646. /**
  28647. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28648. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28649. */
  28650. updateTexture(isVisible: boolean): void;
  28651. protected _updateInternalTexture: () => void;
  28652. /**
  28653. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28654. * @param url New url.
  28655. */
  28656. updateURL(url: string): void;
  28657. /**
  28658. * Dispose the texture and release its associated resources.
  28659. */
  28660. dispose(): void;
  28661. /**
  28662. * Creates a video texture straight from a stream.
  28663. * @param scene Define the scene the texture should be created in
  28664. * @param stream Define the stream the texture should be created from
  28665. * @returns The created video texture as a promise
  28666. */
  28667. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28668. /**
  28669. * Creates a video texture straight from your WebCam video feed.
  28670. * @param scene Define the scene the texture should be created in
  28671. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28672. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28673. * @returns The created video texture as a promise
  28674. */
  28675. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28676. minWidth: number;
  28677. maxWidth: number;
  28678. minHeight: number;
  28679. maxHeight: number;
  28680. deviceId: string;
  28681. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28682. /**
  28683. * Creates a video texture straight from your WebCam video feed.
  28684. * @param scene Define the scene the texture should be created in
  28685. * @param onReady Define a callback to triggered once the texture will be ready
  28686. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28687. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28688. */
  28689. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28690. minWidth: number;
  28691. maxWidth: number;
  28692. minHeight: number;
  28693. maxHeight: number;
  28694. deviceId: string;
  28695. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28696. }
  28697. }
  28698. declare module BABYLON {
  28699. /**
  28700. * Defines the interface used by objects working like Scene
  28701. * @hidden
  28702. */
  28703. interface ISceneLike { private _addPendingData(data: any): void; private _removePendingData(data: any): void;
  28704. offlineProvider: IOfflineProvider;
  28705. }
  28706. /** Interface defining initialization parameters for Engine class */
  28707. export interface EngineOptions extends WebGLContextAttributes {
  28708. /**
  28709. * Defines if the engine should no exceed a specified device ratio
  28710. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28711. */
  28712. limitDeviceRatio?: number;
  28713. /**
  28714. * Defines if webvr should be enabled automatically
  28715. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28716. */
  28717. autoEnableWebVR?: boolean;
  28718. /**
  28719. * Defines if webgl2 should be turned off even if supported
  28720. * @see http://doc.babylonjs.com/features/webgl2
  28721. */
  28722. disableWebGL2Support?: boolean;
  28723. /**
  28724. * Defines if webaudio should be initialized as well
  28725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28726. */
  28727. audioEngine?: boolean;
  28728. /**
  28729. * Defines if animations should run using a deterministic lock step
  28730. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28731. */
  28732. deterministicLockstep?: boolean;
  28733. /** Defines the maximum steps to use with deterministic lock step mode */
  28734. lockstepMaxSteps?: number;
  28735. /**
  28736. * Defines that engine should ignore context lost events
  28737. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28738. */
  28739. doNotHandleContextLost?: boolean;
  28740. /**
  28741. * Defines that engine should ignore modifying touch action attribute and style
  28742. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28743. */
  28744. doNotHandleTouchAction?: boolean;
  28745. /**
  28746. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28747. */
  28748. useHighPrecisionFloats?: boolean;
  28749. }
  28750. /**
  28751. * The base engine class (root of all engines)
  28752. */
  28753. export class ThinEngine {
  28754. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28755. static ExceptionList: ({
  28756. key: string;
  28757. capture: string;
  28758. captureConstraint: number;
  28759. targets: string[];
  28760. } | {
  28761. key: string;
  28762. capture: null;
  28763. captureConstraint: null;
  28764. targets: string[];
  28765. })[];
  28766. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  28767. /**
  28768. * Returns the current npm package of the sdk
  28769. */
  28770. static readonly NpmPackage: string;
  28771. /**
  28772. * Returns the current version of the framework
  28773. */
  28774. static readonly Version: string;
  28775. /**
  28776. * Returns a string describing the current engine
  28777. */
  28778. readonly description: string;
  28779. /**
  28780. * Gets or sets the epsilon value used by collision engine
  28781. */
  28782. static CollisionsEpsilon: number;
  28783. /**
  28784. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28785. */
  28786. static ShadersRepository: string;
  28787. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  28788. /**
  28789. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28790. */
  28791. forcePOTTextures: boolean;
  28792. /**
  28793. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28794. */
  28795. isFullscreen: boolean;
  28796. /**
  28797. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28798. */
  28799. cullBackFaces: boolean;
  28800. /**
  28801. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28802. */
  28803. renderEvenInBackground: boolean;
  28804. /**
  28805. * Gets or sets a boolean indicating that cache can be kept between frames
  28806. */
  28807. preventCacheWipeBetweenFrames: boolean;
  28808. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28809. validateShaderPrograms: boolean;
  28810. /**
  28811. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28812. */
  28813. disableUniformBuffers: boolean;
  28814. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  28815. /**
  28816. * Gets a boolean indicating that the engine supports uniform buffers
  28817. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28818. */
  28819. readonly supportsUniformBuffers: boolean;
  28820. /** @hidden */ private _gl: WebGLRenderingContext;
  28821. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  28822. protected _windowIsBackground: boolean;
  28823. protected _webGLVersion: number;
  28824. protected _creationOptions: EngineOptions;
  28825. protected _highPrecisionShadersAllowed: boolean;
  28826. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  28827. /**
  28828. * Gets a boolean indicating that only power of 2 textures are supported
  28829. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28830. */
  28831. readonly needPOTTextures: boolean;
  28832. /** @hidden */ private _badOS: boolean;
  28833. /** @hidden */ private _badDesktopOS: boolean;
  28834. private _hardwareScalingLevel;
  28835. /** @hidden */ private _caps: EngineCapabilities;
  28836. private _isStencilEnable;
  28837. protected _colorWrite: boolean;
  28838. private _glVersion;
  28839. private _glRenderer;
  28840. private _glVendor;
  28841. /** @hidden */ private _videoTextureSupported: boolean;
  28842. protected _renderingQueueLaunched: boolean;
  28843. protected _activeRenderLoops: (() => void)[];
  28844. /**
  28845. * Observable signaled when a context lost event is raised
  28846. */
  28847. onContextLostObservable: Observable<ThinEngine>;
  28848. /**
  28849. * Observable signaled when a context restored event is raised
  28850. */
  28851. onContextRestoredObservable: Observable<ThinEngine>;
  28852. private _onContextLost;
  28853. private _onContextRestored;
  28854. protected _contextWasLost: boolean;
  28855. /** @hidden */ private _doNotHandleContextLost: boolean;
  28856. /**
  28857. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28858. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28859. */
  28860. doNotHandleContextLost: boolean;
  28861. /**
  28862. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28863. */
  28864. disableVertexArrayObjects: boolean;
  28865. /** @hidden */
  28866. protected _depthCullingState: DepthCullingState;
  28867. /** @hidden */
  28868. protected _stencilState: StencilState;
  28869. /** @hidden */
  28870. protected _alphaState: AlphaState;
  28871. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  28872. /** @hidden */
  28873. protected _activeChannel: number;
  28874. private _currentTextureChannel;
  28875. /** @hidden */
  28876. protected _boundTexturesCache: {
  28877. [key: string]: Nullable<InternalTexture>;
  28878. };
  28879. /** @hidden */
  28880. protected _currentEffect: Nullable<Effect>;
  28881. /** @hidden */
  28882. protected _currentProgram: Nullable<WebGLProgram>;
  28883. private _compiledEffects;
  28884. private _vertexAttribArraysEnabled;
  28885. /** @hidden */
  28886. protected _cachedViewport: Nullable<IViewportLike>;
  28887. private _cachedVertexArrayObject;
  28888. /** @hidden */
  28889. protected _cachedVertexBuffers: any;
  28890. /** @hidden */
  28891. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28892. /** @hidden */
  28893. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28894. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  28895. private _uintIndicesCurrentlySet;
  28896. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  28897. /** @hidden */
  28898. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28899. private _currentBufferPointers;
  28900. private _currentInstanceLocations;
  28901. private _currentInstanceBuffers;
  28902. private _textureUnits;
  28903. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  28904. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  28905. /** @hidden */ private _boundRenderFunction: any;
  28906. private _vaoRecordInProgress;
  28907. private _mustWipeVertexAttributes;
  28908. private _emptyTexture;
  28909. private _emptyCubeTexture;
  28910. private _emptyTexture3D;
  28911. private _emptyTexture2DArray;
  28912. /** @hidden */ private _frameHandler: number;
  28913. private _nextFreeTextureSlots;
  28914. private _maxSimultaneousTextures;
  28915. private _activeRequests;
  28916. protected _texturesSupported: string[];
  28917. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  28918. protected readonly _supportsHardwareTextureRescaling: boolean;
  28919. /**
  28920. * Gets the list of texture formats supported
  28921. */
  28922. readonly texturesSupported: Array<string>;
  28923. /**
  28924. * Gets the list of texture formats in use
  28925. */
  28926. readonly textureFormatInUse: Nullable<string>;
  28927. /**
  28928. * Gets the current viewport
  28929. */
  28930. readonly currentViewport: Nullable<IViewportLike>;
  28931. /**
  28932. * Gets the default empty texture
  28933. */
  28934. readonly emptyTexture: InternalTexture;
  28935. /**
  28936. * Gets the default empty 3D texture
  28937. */
  28938. readonly emptyTexture3D: InternalTexture;
  28939. /**
  28940. * Gets the default empty 2D array texture
  28941. */
  28942. readonly emptyTexture2DArray: InternalTexture;
  28943. /**
  28944. * Gets the default empty cube texture
  28945. */
  28946. readonly emptyCubeTexture: InternalTexture;
  28947. /**
  28948. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28949. */
  28950. readonly premultipliedAlpha: boolean;
  28951. /**
  28952. * Observable event triggered before each texture is initialized
  28953. */
  28954. onBeforeTextureInitObservable: Observable<Texture>;
  28955. /**
  28956. * Creates a new engine
  28957. * @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
  28958. * @param antialias defines enable antialiasing (default: false)
  28959. * @param options defines further options to be sent to the getContext() function
  28960. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28961. */
  28962. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28963. private _rebuildInternalTextures;
  28964. private _rebuildEffects;
  28965. /**
  28966. * Gets a boolean indicating if all created effects are ready
  28967. * @returns true if all effects are ready
  28968. */
  28969. areAllEffectsReady(): boolean;
  28970. protected _rebuildBuffers(): void;
  28971. private _initGLContext;
  28972. /**
  28973. * Gets version of the current webGL context
  28974. */
  28975. readonly webGLVersion: number;
  28976. /**
  28977. * Gets a string idenfifying the name of the class
  28978. * @returns "Engine" string
  28979. */
  28980. getClassName(): string;
  28981. /**
  28982. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28983. */
  28984. readonly isStencilEnable: boolean;
  28985. /** @hidden */ private _prepareWorkingCanvas(): void;
  28986. /**
  28987. * Reset the texture cache to empty state
  28988. */
  28989. resetTextureCache(): void;
  28990. /**
  28991. * Gets an object containing information about the current webGL context
  28992. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28993. */
  28994. getGlInfo(): {
  28995. vendor: string;
  28996. renderer: string;
  28997. version: string;
  28998. };
  28999. /**
  29000. * Defines the hardware scaling level.
  29001. * By default the hardware scaling level is computed from the window device ratio.
  29002. * 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.
  29003. * @param level defines the level to use
  29004. */
  29005. setHardwareScalingLevel(level: number): void;
  29006. /**
  29007. * Gets the current hardware scaling level.
  29008. * By default the hardware scaling level is computed from the window device ratio.
  29009. * 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.
  29010. * @returns a number indicating the current hardware scaling level
  29011. */
  29012. getHardwareScalingLevel(): number;
  29013. /**
  29014. * Gets the list of loaded textures
  29015. * @returns an array containing all loaded textures
  29016. */
  29017. getLoadedTexturesCache(): InternalTexture[];
  29018. /**
  29019. * Gets the object containing all engine capabilities
  29020. * @returns the EngineCapabilities object
  29021. */
  29022. getCaps(): EngineCapabilities;
  29023. /**
  29024. * stop executing a render loop function and remove it from the execution array
  29025. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29026. */
  29027. stopRenderLoop(renderFunction?: () => void): void;
  29028. /** @hidden */ private _renderLoop(): void;
  29029. /**
  29030. * Gets the HTML canvas attached with the current webGL context
  29031. * @returns a HTML canvas
  29032. */
  29033. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29034. /**
  29035. * Gets host window
  29036. * @returns the host window object
  29037. */
  29038. getHostWindow(): Nullable<Window>;
  29039. /**
  29040. * Gets the current render width
  29041. * @param useScreen defines if screen size must be used (or the current render target if any)
  29042. * @returns a number defining the current render width
  29043. */
  29044. getRenderWidth(useScreen?: boolean): number;
  29045. /**
  29046. * Gets the current render height
  29047. * @param useScreen defines if screen size must be used (or the current render target if any)
  29048. * @returns a number defining the current render height
  29049. */
  29050. getRenderHeight(useScreen?: boolean): number;
  29051. /**
  29052. * Can be used to override the current requestAnimationFrame requester.
  29053. * @hidden
  29054. */
  29055. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29056. /**
  29057. * Register and execute a render loop. The engine can have more than one render function
  29058. * @param renderFunction defines the function to continuously execute
  29059. */
  29060. runRenderLoop(renderFunction: () => void): void;
  29061. /**
  29062. * Clear the current render buffer or the current render target (if any is set up)
  29063. * @param color defines the color to use
  29064. * @param backBuffer defines if the back buffer must be cleared
  29065. * @param depth defines if the depth buffer must be cleared
  29066. * @param stencil defines if the stencil buffer must be cleared
  29067. */
  29068. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29069. private _viewportCached;
  29070. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  29071. /**
  29072. * Set the WebGL's viewport
  29073. * @param viewport defines the viewport element to be used
  29074. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29075. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29076. */
  29077. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29078. /**
  29079. * Begin a new frame
  29080. */
  29081. beginFrame(): void;
  29082. /**
  29083. * Enf the current frame
  29084. */
  29085. endFrame(): void;
  29086. /**
  29087. * Resize the view according to the canvas' size
  29088. */
  29089. resize(): void;
  29090. /**
  29091. * Force a specific size of the canvas
  29092. * @param width defines the new canvas' width
  29093. * @param height defines the new canvas' height
  29094. */
  29095. setSize(width: number, height: number): void;
  29096. /**
  29097. * Binds the frame buffer to the specified texture.
  29098. * @param texture The texture to render to or null for the default canvas
  29099. * @param faceIndex The face of the texture to render to in case of cube texture
  29100. * @param requiredWidth The width of the target to render to
  29101. * @param requiredHeight The height of the target to render to
  29102. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29103. * @param depthStencilTexture The depth stencil texture to use to render
  29104. * @param lodLevel defines le lod level to bind to the frame buffer
  29105. */
  29106. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29107. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29108. /**
  29109. * Unbind the current render target texture from the webGL context
  29110. * @param texture defines the render target texture to unbind
  29111. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29112. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29113. */
  29114. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29115. /**
  29116. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29117. */
  29118. flushFramebuffer(): void;
  29119. /**
  29120. * Unbind the current render target and bind the default framebuffer
  29121. */
  29122. restoreDefaultFramebuffer(): void;
  29123. /** @hidden */
  29124. protected _resetVertexBufferBinding(): void;
  29125. /**
  29126. * Creates a vertex buffer
  29127. * @param data the data for the vertex buffer
  29128. * @returns the new WebGL static buffer
  29129. */
  29130. createVertexBuffer(data: DataArray): DataBuffer;
  29131. private _createVertexBuffer;
  29132. /**
  29133. * Creates a dynamic vertex buffer
  29134. * @param data the data for the dynamic vertex buffer
  29135. * @returns the new WebGL dynamic buffer
  29136. */
  29137. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29138. protected _resetIndexBufferBinding(): void;
  29139. /**
  29140. * Creates a new index buffer
  29141. * @param indices defines the content of the index buffer
  29142. * @param updatable defines if the index buffer must be updatable
  29143. * @returns a new webGL buffer
  29144. */
  29145. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29146. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29147. /**
  29148. * Bind a webGL buffer to the webGL context
  29149. * @param buffer defines the buffer to bind
  29150. */
  29151. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29152. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29153. private bindBuffer;
  29154. /**
  29155. * update the bound buffer with the given data
  29156. * @param data defines the data to update
  29157. */
  29158. updateArrayBuffer(data: Float32Array): void;
  29159. private _vertexAttribPointer;
  29160. private _bindIndexBufferWithCache;
  29161. private _bindVertexBuffersAttributes;
  29162. /**
  29163. * Records a vertex array object
  29164. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29165. * @param vertexBuffers defines the list of vertex buffers to store
  29166. * @param indexBuffer defines the index buffer to store
  29167. * @param effect defines the effect to store
  29168. * @returns the new vertex array object
  29169. */
  29170. recordVertexArrayObject(vertexBuffers: {
  29171. [key: string]: VertexBuffer;
  29172. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29173. /**
  29174. * Bind a specific vertex array object
  29175. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29176. * @param vertexArrayObject defines the vertex array object to bind
  29177. * @param indexBuffer defines the index buffer to bind
  29178. */
  29179. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29180. /**
  29181. * Bind webGl buffers directly to the webGL context
  29182. * @param vertexBuffer defines the vertex buffer to bind
  29183. * @param indexBuffer defines the index buffer to bind
  29184. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29185. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29186. * @param effect defines the effect associated with the vertex buffer
  29187. */
  29188. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29189. private _unbindVertexArrayObject;
  29190. /**
  29191. * Bind a list of vertex buffers to the webGL context
  29192. * @param vertexBuffers defines the list of vertex buffers to bind
  29193. * @param indexBuffer defines the index buffer to bind
  29194. * @param effect defines the effect associated with the vertex buffers
  29195. */
  29196. bindBuffers(vertexBuffers: {
  29197. [key: string]: Nullable<VertexBuffer>;
  29198. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29199. /**
  29200. * Unbind all instance attributes
  29201. */
  29202. unbindInstanceAttributes(): void;
  29203. /**
  29204. * Release and free the memory of a vertex array object
  29205. * @param vao defines the vertex array object to delete
  29206. */
  29207. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29208. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  29209. protected _deleteBuffer(buffer: DataBuffer): void;
  29210. /**
  29211. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29212. * @param instancesBuffer defines the webGL buffer to update and bind
  29213. * @param data defines the data to store in the buffer
  29214. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29215. */
  29216. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29217. /**
  29218. * Apply all cached states (depth, culling, stencil and alpha)
  29219. */
  29220. applyStates(): void;
  29221. /**
  29222. * Send a draw order
  29223. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29224. * @param indexStart defines the starting index
  29225. * @param indexCount defines the number of index to draw
  29226. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29227. */
  29228. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29229. /**
  29230. * Draw a list of points
  29231. * @param verticesStart defines the index of first vertex to draw
  29232. * @param verticesCount defines the count of vertices to draw
  29233. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29234. */
  29235. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29236. /**
  29237. * Draw a list of unindexed primitives
  29238. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29239. * @param verticesStart defines the index of first vertex to draw
  29240. * @param verticesCount defines the count of vertices to draw
  29241. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29242. */
  29243. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29244. /**
  29245. * Draw a list of indexed primitives
  29246. * @param fillMode defines the primitive to use
  29247. * @param indexStart defines the starting index
  29248. * @param indexCount defines the number of index to draw
  29249. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29250. */
  29251. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29252. /**
  29253. * Draw a list of unindexed primitives
  29254. * @param fillMode defines the primitive to use
  29255. * @param verticesStart defines the index of first vertex to draw
  29256. * @param verticesCount defines the count of vertices to draw
  29257. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29258. */
  29259. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29260. private _drawMode;
  29261. /** @hidden */
  29262. protected _reportDrawCall(): void;
  29263. /** @hidden */ private _releaseEffect(effect: Effect): void;
  29264. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29265. /**
  29266. * Create a new effect (used to store vertex/fragment shaders)
  29267. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29268. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29269. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29270. * @param samplers defines an array of string used to represent textures
  29271. * @param defines defines the string containing the defines to use to compile the shaders
  29272. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29273. * @param onCompiled defines a function to call when the effect creation is successful
  29274. * @param onError defines a function to call when the effect creation has failed
  29275. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29276. * @returns the new Effect
  29277. */
  29278. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29279. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29280. private _compileShader;
  29281. private _compileRawShader;
  29282. /**
  29283. * Directly creates a webGL program
  29284. * @param pipelineContext defines the pipeline context to attach to
  29285. * @param vertexCode defines the vertex shader code to use
  29286. * @param fragmentCode defines the fragment shader code to use
  29287. * @param context defines the webGL context to use (if not set, the current one will be used)
  29288. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29289. * @returns the new webGL program
  29290. */
  29291. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29292. /**
  29293. * Creates a webGL program
  29294. * @param pipelineContext defines the pipeline context to attach to
  29295. * @param vertexCode defines the vertex shader code to use
  29296. * @param fragmentCode defines the fragment shader code to use
  29297. * @param defines defines the string containing the defines to use to compile the shaders
  29298. * @param context defines the webGL context to use (if not set, the current one will be used)
  29299. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29300. * @returns the new webGL program
  29301. */
  29302. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29303. /**
  29304. * Creates a new pipeline context
  29305. * @returns the new pipeline
  29306. */
  29307. createPipelineContext(): IPipelineContext;
  29308. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29309. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29310. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29311. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29312. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29313. /**
  29314. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29315. * @param pipelineContext defines the pipeline context to use
  29316. * @param uniformsNames defines the list of uniform names
  29317. * @returns an array of webGL uniform locations
  29318. */
  29319. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29320. /**
  29321. * Gets the lsit of active attributes for a given webGL program
  29322. * @param pipelineContext defines the pipeline context to use
  29323. * @param attributesNames defines the list of attribute names to get
  29324. * @returns an array of indices indicating the offset of each attribute
  29325. */
  29326. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29327. /**
  29328. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29329. * @param effect defines the effect to activate
  29330. */
  29331. enableEffect(effect: Nullable<Effect>): void;
  29332. /**
  29333. * Set the value of an uniform to a number (int)
  29334. * @param uniform defines the webGL uniform location where to store the value
  29335. * @param value defines the int number to store
  29336. */
  29337. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29338. /**
  29339. * Set the value of an uniform to an array of int32
  29340. * @param uniform defines the webGL uniform location where to store the value
  29341. * @param array defines the array of int32 to store
  29342. */
  29343. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29344. /**
  29345. * Set the value of an uniform to an array of int32 (stored as vec2)
  29346. * @param uniform defines the webGL uniform location where to store the value
  29347. * @param array defines the array of int32 to store
  29348. */
  29349. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29350. /**
  29351. * Set the value of an uniform to an array of int32 (stored as vec3)
  29352. * @param uniform defines the webGL uniform location where to store the value
  29353. * @param array defines the array of int32 to store
  29354. */
  29355. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29356. /**
  29357. * Set the value of an uniform to an array of int32 (stored as vec4)
  29358. * @param uniform defines the webGL uniform location where to store the value
  29359. * @param array defines the array of int32 to store
  29360. */
  29361. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29362. /**
  29363. * Set the value of an uniform to an array of number
  29364. * @param uniform defines the webGL uniform location where to store the value
  29365. * @param array defines the array of number to store
  29366. */
  29367. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29368. /**
  29369. * Set the value of an uniform to an array of number (stored as vec2)
  29370. * @param uniform defines the webGL uniform location where to store the value
  29371. * @param array defines the array of number to store
  29372. */
  29373. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29374. /**
  29375. * Set the value of an uniform to an array of number (stored as vec3)
  29376. * @param uniform defines the webGL uniform location where to store the value
  29377. * @param array defines the array of number to store
  29378. */
  29379. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29380. /**
  29381. * Set the value of an uniform to an array of number (stored as vec4)
  29382. * @param uniform defines the webGL uniform location where to store the value
  29383. * @param array defines the array of number to store
  29384. */
  29385. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29386. /**
  29387. * Set the value of an uniform to an array of float32 (stored as matrices)
  29388. * @param uniform defines the webGL uniform location where to store the value
  29389. * @param matrices defines the array of float32 to store
  29390. */
  29391. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29392. /**
  29393. * Set the value of an uniform to a matrix (3x3)
  29394. * @param uniform defines the webGL uniform location where to store the value
  29395. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29396. */
  29397. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29398. /**
  29399. * Set the value of an uniform to a matrix (2x2)
  29400. * @param uniform defines the webGL uniform location where to store the value
  29401. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29402. */
  29403. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29404. /**
  29405. * Set the value of an uniform to a number (float)
  29406. * @param uniform defines the webGL uniform location where to store the value
  29407. * @param value defines the float number to store
  29408. */
  29409. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29410. /**
  29411. * Set the value of an uniform to a vec2
  29412. * @param uniform defines the webGL uniform location where to store the value
  29413. * @param x defines the 1st component of the value
  29414. * @param y defines the 2nd component of the value
  29415. */
  29416. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29417. /**
  29418. * Set the value of an uniform to a vec3
  29419. * @param uniform defines the webGL uniform location where to store the value
  29420. * @param x defines the 1st component of the value
  29421. * @param y defines the 2nd component of the value
  29422. * @param z defines the 3rd component of the value
  29423. */
  29424. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29425. /**
  29426. * Set the value of an uniform to a vec4
  29427. * @param uniform defines the webGL uniform location where to store the value
  29428. * @param x defines the 1st component of the value
  29429. * @param y defines the 2nd component of the value
  29430. * @param z defines the 3rd component of the value
  29431. * @param w defines the 4th component of the value
  29432. */
  29433. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29434. /**
  29435. * Gets the depth culling state manager
  29436. */
  29437. readonly depthCullingState: DepthCullingState;
  29438. /**
  29439. * Gets the alpha state manager
  29440. */
  29441. readonly alphaState: AlphaState;
  29442. /**
  29443. * Gets the stencil state manager
  29444. */
  29445. readonly stencilState: StencilState;
  29446. /**
  29447. * Clears the list of texture accessible through engine.
  29448. * This can help preventing texture load conflict due to name collision.
  29449. */
  29450. clearInternalTexturesCache(): void;
  29451. /**
  29452. * Force the entire cache to be cleared
  29453. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29454. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29455. */
  29456. wipeCaches(bruteForce?: boolean): void;
  29457. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29458. min: number;
  29459. mag: number;
  29460. };
  29461. /** @hidden */ private _createTexture(): WebGLTexture;
  29462. /**
  29463. * Usually called from Texture.ts.
  29464. * Passed information to create a WebGLTexture
  29465. * @param urlArg defines a value which contains one of the following:
  29466. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29467. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29468. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29469. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29470. * @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)
  29471. * @param scene needed for loading to the correct scene
  29472. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29473. * @param onLoad optional callback to be called upon successful completion
  29474. * @param onError optional callback to be called upon failure
  29475. * @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
  29476. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29477. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29478. * @param forcedExtension defines the extension to use to pick the right loader
  29479. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29480. * @param mimeType defines an optional mime type
  29481. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29482. */
  29483. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  29484. /**
  29485. * @hidden
  29486. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29487. /**
  29488. * Creates a raw texture
  29489. * @param data defines the data to store in the texture
  29490. * @param width defines the width of the texture
  29491. * @param height defines the height of the texture
  29492. * @param format defines the format of the data
  29493. * @param generateMipMaps defines if the engine should generate the mip levels
  29494. * @param invertY defines if data must be stored with Y axis inverted
  29495. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29496. * @param compression defines the compression used (null by default)
  29497. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29498. * @returns the raw texture inside an InternalTexture
  29499. */
  29500. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29501. /**
  29502. * Creates a new raw cube texture
  29503. * @param data defines the array of data to use to create each face
  29504. * @param size defines the size of the textures
  29505. * @param format defines the format of the data
  29506. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29507. * @param generateMipMaps defines if the engine should generate the mip levels
  29508. * @param invertY defines if data must be stored with Y axis inverted
  29509. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29510. * @param compression defines the compression used (null by default)
  29511. * @returns the cube texture as an InternalTexture
  29512. */
  29513. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29514. /**
  29515. * Creates a new raw 3D texture
  29516. * @param data defines the data used to create the texture
  29517. * @param width defines the width of the texture
  29518. * @param height defines the height of the texture
  29519. * @param depth defines the depth of the texture
  29520. * @param format defines the format of the texture
  29521. * @param generateMipMaps defines if the engine must generate mip levels
  29522. * @param invertY defines if data must be stored with Y axis inverted
  29523. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29524. * @param compression defines the compressed used (can be null)
  29525. * @param textureType defines the compressed used (can be null)
  29526. * @returns a new raw 3D texture (stored in an InternalTexture)
  29527. */
  29528. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29529. /**
  29530. * Creates a new raw 2D array texture
  29531. * @param data defines the data used to create the texture
  29532. * @param width defines the width of the texture
  29533. * @param height defines the height of the texture
  29534. * @param depth defines the number of layers of the texture
  29535. * @param format defines the format of the texture
  29536. * @param generateMipMaps defines if the engine must generate mip levels
  29537. * @param invertY defines if data must be stored with Y axis inverted
  29538. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29539. * @param compression defines the compressed used (can be null)
  29540. * @param textureType defines the compressed used (can be null)
  29541. * @returns a new raw 2D array texture (stored in an InternalTexture)
  29542. */
  29543. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29544. private _unpackFlipYCached;
  29545. /**
  29546. * In case you are sharing the context with other applications, it might
  29547. * be interested to not cache the unpack flip y state to ensure a consistent
  29548. * value would be set.
  29549. */
  29550. enableUnpackFlipYCached: boolean;
  29551. /** @hidden */ private _unpackFlipY(value: boolean): void;
  29552. /** @hidden */ private _getUnpackAlignement(): number;
  29553. /**
  29554. * Update the sampling mode of a given texture
  29555. * @param samplingMode defines the required sampling mode
  29556. * @param texture defines the texture to update
  29557. */
  29558. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29559. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29560. width: number;
  29561. height: number;
  29562. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29563. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29564. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29565. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29566. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29567. private _prepareWebGLTexture;
  29568. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29569. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  29570. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  29571. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29572. protected _setProgram(program: WebGLProgram): void;
  29573. protected _boundUniforms: {
  29574. [key: number]: WebGLUniformLocation;
  29575. };
  29576. /**
  29577. * Binds an effect to the webGL context
  29578. * @param effect defines the effect to bind
  29579. */
  29580. bindSamplers(effect: Effect): void;
  29581. private _activateCurrentTexture;
  29582. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29583. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29584. /**
  29585. * Unbind all textures from the webGL context
  29586. */
  29587. unbindAllTextures(): void;
  29588. /**
  29589. * Sets a texture to the according uniform.
  29590. * @param channel The texture channel
  29591. * @param uniform The uniform to set
  29592. * @param texture The texture to apply
  29593. */
  29594. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29595. private _bindSamplerUniformToChannel;
  29596. private _getTextureWrapMode;
  29597. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29598. /**
  29599. * Sets an array of texture to the webGL context
  29600. * @param channel defines the channel where the texture array must be set
  29601. * @param uniform defines the associated uniform location
  29602. * @param textures defines the array of textures to bind
  29603. */
  29604. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29605. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29606. private _setTextureParameterFloat;
  29607. private _setTextureParameterInteger;
  29608. /**
  29609. * Unbind all vertex attributes from the webGL context
  29610. */
  29611. unbindAllAttributes(): void;
  29612. /**
  29613. * 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
  29614. */
  29615. releaseEffects(): void;
  29616. /**
  29617. * Dispose and release all associated resources
  29618. */
  29619. dispose(): void;
  29620. /**
  29621. * Attach a new callback raised when context lost event is fired
  29622. * @param callback defines the callback to call
  29623. */
  29624. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29625. /**
  29626. * Attach a new callback raised when context restored event is fired
  29627. * @param callback defines the callback to call
  29628. */
  29629. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29630. /**
  29631. * Get the current error code of the webGL context
  29632. * @returns the error code
  29633. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29634. */
  29635. getError(): number;
  29636. private _canRenderToFloatFramebuffer;
  29637. private _canRenderToHalfFloatFramebuffer;
  29638. private _canRenderToFramebuffer;
  29639. /** @hidden */ private _getWebGLTextureType(type: number): number;
  29640. /** @hidden */ private _getInternalFormat(format: number): number;
  29641. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29642. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  29643. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  29644. /**
  29645. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29646. * @returns true if the engine can be created
  29647. * @ignorenaming
  29648. */
  29649. static isSupported(): boolean;
  29650. /**
  29651. * Find the next highest power of two.
  29652. * @param x Number to start search from.
  29653. * @return Next highest power of two.
  29654. */
  29655. static CeilingPOT(x: number): number;
  29656. /**
  29657. * Find the next lowest power of two.
  29658. * @param x Number to start search from.
  29659. * @return Next lowest power of two.
  29660. */
  29661. static FloorPOT(x: number): number;
  29662. /**
  29663. * Find the nearest power of two.
  29664. * @param x Number to start search from.
  29665. * @return Next nearest power of two.
  29666. */
  29667. static NearestPOT(x: number): number;
  29668. /**
  29669. * Get the closest exponent of two
  29670. * @param value defines the value to approximate
  29671. * @param max defines the maximum value to return
  29672. * @param mode defines how to define the closest value
  29673. * @returns closest exponent of two of the given value
  29674. */
  29675. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29676. /**
  29677. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29678. * @param func - the function to be called
  29679. * @param requester - the object that will request the next frame. Falls back to window.
  29680. * @returns frame number
  29681. */
  29682. static QueueNewFrame(func: () => void, requester?: any): number;
  29683. }
  29684. }
  29685. declare module BABYLON {
  29686. /**
  29687. * Class representing spherical harmonics coefficients to the 3rd degree
  29688. */
  29689. export class SphericalHarmonics {
  29690. /**
  29691. * Defines whether or not the harmonics have been prescaled for rendering.
  29692. */
  29693. preScaled: boolean;
  29694. /**
  29695. * The l0,0 coefficients of the spherical harmonics
  29696. */
  29697. l00: Vector3;
  29698. /**
  29699. * The l1,-1 coefficients of the spherical harmonics
  29700. */
  29701. l1_1: Vector3;
  29702. /**
  29703. * The l1,0 coefficients of the spherical harmonics
  29704. */
  29705. l10: Vector3;
  29706. /**
  29707. * The l1,1 coefficients of the spherical harmonics
  29708. */
  29709. l11: Vector3;
  29710. /**
  29711. * The l2,-2 coefficients of the spherical harmonics
  29712. */
  29713. l2_2: Vector3;
  29714. /**
  29715. * The l2,-1 coefficients of the spherical harmonics
  29716. */
  29717. l2_1: Vector3;
  29718. /**
  29719. * The l2,0 coefficients of the spherical harmonics
  29720. */
  29721. l20: Vector3;
  29722. /**
  29723. * The l2,1 coefficients of the spherical harmonics
  29724. */
  29725. l21: Vector3;
  29726. /**
  29727. * The l2,2 coefficients of the spherical harmonics
  29728. */
  29729. l22: Vector3;
  29730. /**
  29731. * Adds a light to the spherical harmonics
  29732. * @param direction the direction of the light
  29733. * @param color the color of the light
  29734. * @param deltaSolidAngle the delta solid angle of the light
  29735. */
  29736. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  29737. /**
  29738. * Scales the spherical harmonics by the given amount
  29739. * @param scale the amount to scale
  29740. */
  29741. scaleInPlace(scale: number): void;
  29742. /**
  29743. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  29744. *
  29745. * ```
  29746. * E_lm = A_l * L_lm
  29747. * ```
  29748. *
  29749. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  29750. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  29751. * the scaling factors are given in equation 9.
  29752. */
  29753. convertIncidentRadianceToIrradiance(): void;
  29754. /**
  29755. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  29756. *
  29757. * ```
  29758. * L = (1/pi) * E * rho
  29759. * ```
  29760. *
  29761. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  29762. */
  29763. convertIrradianceToLambertianRadiance(): void;
  29764. /**
  29765. * Integrates the reconstruction coefficients directly in to the SH preventing further
  29766. * required operations at run time.
  29767. *
  29768. * This is simply done by scaling back the SH with Ylm constants parameter.
  29769. * The trigonometric part being applied by the shader at run time.
  29770. */
  29771. preScaleForRendering(): void;
  29772. /**
  29773. * Constructs a spherical harmonics from an array.
  29774. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  29775. * @returns the spherical harmonics
  29776. */
  29777. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  29778. /**
  29779. * Gets the spherical harmonics from polynomial
  29780. * @param polynomial the spherical polynomial
  29781. * @returns the spherical harmonics
  29782. */
  29783. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  29784. }
  29785. /**
  29786. * Class representing spherical polynomial coefficients to the 3rd degree
  29787. */
  29788. export class SphericalPolynomial {
  29789. private _harmonics;
  29790. /**
  29791. * The spherical harmonics used to create the polynomials.
  29792. */
  29793. readonly preScaledHarmonics: SphericalHarmonics;
  29794. /**
  29795. * The x coefficients of the spherical polynomial
  29796. */
  29797. x: Vector3;
  29798. /**
  29799. * The y coefficients of the spherical polynomial
  29800. */
  29801. y: Vector3;
  29802. /**
  29803. * The z coefficients of the spherical polynomial
  29804. */
  29805. z: Vector3;
  29806. /**
  29807. * The xx coefficients of the spherical polynomial
  29808. */
  29809. xx: Vector3;
  29810. /**
  29811. * The yy coefficients of the spherical polynomial
  29812. */
  29813. yy: Vector3;
  29814. /**
  29815. * The zz coefficients of the spherical polynomial
  29816. */
  29817. zz: Vector3;
  29818. /**
  29819. * The xy coefficients of the spherical polynomial
  29820. */
  29821. xy: Vector3;
  29822. /**
  29823. * The yz coefficients of the spherical polynomial
  29824. */
  29825. yz: Vector3;
  29826. /**
  29827. * The zx coefficients of the spherical polynomial
  29828. */
  29829. zx: Vector3;
  29830. /**
  29831. * Adds an ambient color to the spherical polynomial
  29832. * @param color the color to add
  29833. */
  29834. addAmbient(color: Color3): void;
  29835. /**
  29836. * Scales the spherical polynomial by the given amount
  29837. * @param scale the amount to scale
  29838. */
  29839. scaleInPlace(scale: number): void;
  29840. /**
  29841. * Gets the spherical polynomial from harmonics
  29842. * @param harmonics the spherical harmonics
  29843. * @returns the spherical polynomial
  29844. */
  29845. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  29846. /**
  29847. * Constructs a spherical polynomial from an array.
  29848. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  29849. * @returns the spherical polynomial
  29850. */
  29851. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  29852. }
  29853. }
  29854. declare module BABYLON {
  29855. /**
  29856. * Defines the source of the internal texture
  29857. */
  29858. export enum InternalTextureSource {
  29859. /**
  29860. * The source of the texture data is unknown
  29861. */
  29862. Unknown = 0,
  29863. /**
  29864. * Texture data comes from an URL
  29865. */
  29866. Url = 1,
  29867. /**
  29868. * Texture data is only used for temporary storage
  29869. */
  29870. Temp = 2,
  29871. /**
  29872. * Texture data comes from raw data (ArrayBuffer)
  29873. */
  29874. Raw = 3,
  29875. /**
  29876. * Texture content is dynamic (video or dynamic texture)
  29877. */
  29878. Dynamic = 4,
  29879. /**
  29880. * Texture content is generated by rendering to it
  29881. */
  29882. RenderTarget = 5,
  29883. /**
  29884. * Texture content is part of a multi render target process
  29885. */
  29886. MultiRenderTarget = 6,
  29887. /**
  29888. * Texture data comes from a cube data file
  29889. */
  29890. Cube = 7,
  29891. /**
  29892. * Texture data comes from a raw cube data
  29893. */
  29894. CubeRaw = 8,
  29895. /**
  29896. * Texture data come from a prefiltered cube data file
  29897. */
  29898. CubePrefiltered = 9,
  29899. /**
  29900. * Texture content is raw 3D data
  29901. */
  29902. Raw3D = 10,
  29903. /**
  29904. * Texture content is raw 2D array data
  29905. */
  29906. Raw2DArray = 11,
  29907. /**
  29908. * Texture content is a depth texture
  29909. */
  29910. Depth = 12,
  29911. /**
  29912. * Texture data comes from a raw cube data encoded with RGBD
  29913. */
  29914. CubeRawRGBD = 13
  29915. }
  29916. /**
  29917. * Class used to store data associated with WebGL texture data for the engine
  29918. * This class should not be used directly
  29919. */
  29920. export class InternalTexture {
  29921. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  29922. /**
  29923. * Defines if the texture is ready
  29924. */
  29925. isReady: boolean;
  29926. /**
  29927. * Defines if the texture is a cube texture
  29928. */
  29929. isCube: boolean;
  29930. /**
  29931. * Defines if the texture contains 3D data
  29932. */
  29933. is3D: boolean;
  29934. /**
  29935. * Defines if the texture contains 2D array data
  29936. */
  29937. is2DArray: boolean;
  29938. /**
  29939. * Defines if the texture contains multiview data
  29940. */
  29941. isMultiview: boolean;
  29942. /**
  29943. * Gets the URL used to load this texture
  29944. */
  29945. url: string;
  29946. /**
  29947. * Gets the sampling mode of the texture
  29948. */
  29949. samplingMode: number;
  29950. /**
  29951. * Gets a boolean indicating if the texture needs mipmaps generation
  29952. */
  29953. generateMipMaps: boolean;
  29954. /**
  29955. * Gets the number of samples used by the texture (WebGL2+ only)
  29956. */
  29957. samples: number;
  29958. /**
  29959. * Gets the type of the texture (int, float...)
  29960. */
  29961. type: number;
  29962. /**
  29963. * Gets the format of the texture (RGB, RGBA...)
  29964. */
  29965. format: number;
  29966. /**
  29967. * Observable called when the texture is loaded
  29968. */
  29969. onLoadedObservable: Observable<InternalTexture>;
  29970. /**
  29971. * Gets the width of the texture
  29972. */
  29973. width: number;
  29974. /**
  29975. * Gets the height of the texture
  29976. */
  29977. height: number;
  29978. /**
  29979. * Gets the depth of the texture
  29980. */
  29981. depth: number;
  29982. /**
  29983. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  29984. */
  29985. baseWidth: number;
  29986. /**
  29987. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  29988. */
  29989. baseHeight: number;
  29990. /**
  29991. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  29992. */
  29993. baseDepth: number;
  29994. /**
  29995. * Gets a boolean indicating if the texture is inverted on Y axis
  29996. */
  29997. invertY: boolean;
  29998. /** @hidden */ private _invertVScale: boolean;
  29999. /** @hidden */ private _associatedChannel: number;
  30000. /** @hidden */ private _source: InternalTextureSource;
  30001. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30002. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  30003. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  30004. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30005. /** @hidden */ private _size: number;
  30006. /** @hidden */ private _extension: string;
  30007. /** @hidden */ private _files: Nullable<string[]>;
  30008. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30009. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30010. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  30011. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30012. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30013. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30014. /** @hidden */ private _attachments: Nullable<number[]>;
  30015. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  30016. /** @hidden */ private _cachedWrapU: Nullable<number>;
  30017. /** @hidden */ private _cachedWrapV: Nullable<number>;
  30018. /** @hidden */ private _cachedWrapR: Nullable<number>;
  30019. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  30020. /** @hidden */ private _isDisabled: boolean;
  30021. /** @hidden */ private _compression: Nullable<string>;
  30022. /** @hidden */ private _generateStencilBuffer: boolean;
  30023. /** @hidden */ private _generateDepthBuffer: boolean;
  30024. /** @hidden */ private _comparisonFunction: number;
  30025. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30026. /** @hidden */ private _lodGenerationScale: number;
  30027. /** @hidden */ private _lodGenerationOffset: number;
  30028. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  30029. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  30030. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  30031. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  30032. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  30033. /** @hidden */ private _isRGBD: boolean;
  30034. /** @hidden */ private _linearSpecularLOD: boolean;
  30035. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  30036. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  30037. /** @hidden */ private _references: number;
  30038. private _engine;
  30039. /**
  30040. * Gets the Engine the texture belongs to.
  30041. * @returns The babylon engine
  30042. */
  30043. getEngine(): ThinEngine;
  30044. /**
  30045. * Gets the data source type of the texture
  30046. */
  30047. readonly source: InternalTextureSource;
  30048. /**
  30049. * Creates a new InternalTexture
  30050. * @param engine defines the engine to use
  30051. * @param source defines the type of data that will be used
  30052. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30053. */
  30054. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30055. /**
  30056. * Increments the number of references (ie. the number of Texture that point to it)
  30057. */
  30058. incrementReferences(): void;
  30059. /**
  30060. * Change the size of the texture (not the size of the content)
  30061. * @param width defines the new width
  30062. * @param height defines the new height
  30063. * @param depth defines the new depth (1 by default)
  30064. */
  30065. updateSize(width: int, height: int, depth?: int): void;
  30066. /** @hidden */ private _rebuild(): void;
  30067. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  30068. /**
  30069. * Dispose the current allocated resources
  30070. */
  30071. dispose(): void;
  30072. }
  30073. }
  30074. declare module BABYLON {
  30075. /**
  30076. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30078. */
  30079. export class Analyser {
  30080. /**
  30081. * Gets or sets the smoothing
  30082. * @ignorenaming
  30083. */
  30084. SMOOTHING: number;
  30085. /**
  30086. * Gets or sets the FFT table size
  30087. * @ignorenaming
  30088. */
  30089. FFT_SIZE: number;
  30090. /**
  30091. * Gets or sets the bar graph amplitude
  30092. * @ignorenaming
  30093. */
  30094. BARGRAPHAMPLITUDE: number;
  30095. /**
  30096. * Gets or sets the position of the debug canvas
  30097. * @ignorenaming
  30098. */
  30099. DEBUGCANVASPOS: {
  30100. x: number;
  30101. y: number;
  30102. };
  30103. /**
  30104. * Gets or sets the debug canvas size
  30105. * @ignorenaming
  30106. */
  30107. DEBUGCANVASSIZE: {
  30108. width: number;
  30109. height: number;
  30110. };
  30111. private _byteFreqs;
  30112. private _byteTime;
  30113. private _floatFreqs;
  30114. private _webAudioAnalyser;
  30115. private _debugCanvas;
  30116. private _debugCanvasContext;
  30117. private _scene;
  30118. private _registerFunc;
  30119. private _audioEngine;
  30120. /**
  30121. * Creates a new analyser
  30122. * @param scene defines hosting scene
  30123. */
  30124. constructor(scene: Scene);
  30125. /**
  30126. * Get the number of data values you will have to play with for the visualization
  30127. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30128. * @returns a number
  30129. */
  30130. getFrequencyBinCount(): number;
  30131. /**
  30132. * Gets the current frequency data as a byte array
  30133. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30134. * @returns a Uint8Array
  30135. */
  30136. getByteFrequencyData(): Uint8Array;
  30137. /**
  30138. * Gets the current waveform as a byte array
  30139. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30140. * @returns a Uint8Array
  30141. */
  30142. getByteTimeDomainData(): Uint8Array;
  30143. /**
  30144. * Gets the current frequency data as a float array
  30145. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30146. * @returns a Float32Array
  30147. */
  30148. getFloatFrequencyData(): Float32Array;
  30149. /**
  30150. * Renders the debug canvas
  30151. */
  30152. drawDebugCanvas(): void;
  30153. /**
  30154. * Stops rendering the debug canvas and removes it
  30155. */
  30156. stopDebugCanvas(): void;
  30157. /**
  30158. * Connects two audio nodes
  30159. * @param inputAudioNode defines first node to connect
  30160. * @param outputAudioNode defines second node to connect
  30161. */
  30162. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30163. /**
  30164. * Releases all associated resources
  30165. */
  30166. dispose(): void;
  30167. }
  30168. }
  30169. declare module BABYLON {
  30170. /**
  30171. * This represents an audio engine and it is responsible
  30172. * to play, synchronize and analyse sounds throughout the application.
  30173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30174. */
  30175. export interface IAudioEngine extends IDisposable {
  30176. /**
  30177. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30178. */
  30179. readonly canUseWebAudio: boolean;
  30180. /**
  30181. * Gets the current AudioContext if available.
  30182. */
  30183. readonly audioContext: Nullable<AudioContext>;
  30184. /**
  30185. * The master gain node defines the global audio volume of your audio engine.
  30186. */
  30187. readonly masterGain: GainNode;
  30188. /**
  30189. * Gets whether or not mp3 are supported by your browser.
  30190. */
  30191. readonly isMP3supported: boolean;
  30192. /**
  30193. * Gets whether or not ogg are supported by your browser.
  30194. */
  30195. readonly isOGGsupported: boolean;
  30196. /**
  30197. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30198. * @ignoreNaming
  30199. */
  30200. WarnedWebAudioUnsupported: boolean;
  30201. /**
  30202. * Defines if the audio engine relies on a custom unlocked button.
  30203. * In this case, the embedded button will not be displayed.
  30204. */
  30205. useCustomUnlockedButton: boolean;
  30206. /**
  30207. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30208. */
  30209. readonly unlocked: boolean;
  30210. /**
  30211. * Event raised when audio has been unlocked on the browser.
  30212. */
  30213. onAudioUnlockedObservable: Observable<AudioEngine>;
  30214. /**
  30215. * Event raised when audio has been locked on the browser.
  30216. */
  30217. onAudioLockedObservable: Observable<AudioEngine>;
  30218. /**
  30219. * Flags the audio engine in Locked state.
  30220. * This happens due to new browser policies preventing audio to autoplay.
  30221. */
  30222. lock(): void;
  30223. /**
  30224. * Unlocks the audio engine once a user action has been done on the dom.
  30225. * This is helpful to resume play once browser policies have been satisfied.
  30226. */
  30227. unlock(): void;
  30228. }
  30229. /**
  30230. * This represents the default audio engine used in babylon.
  30231. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30233. */
  30234. export class AudioEngine implements IAudioEngine {
  30235. private _audioContext;
  30236. private _audioContextInitialized;
  30237. private _muteButton;
  30238. private _hostElement;
  30239. /**
  30240. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30241. */
  30242. canUseWebAudio: boolean;
  30243. /**
  30244. * The master gain node defines the global audio volume of your audio engine.
  30245. */
  30246. masterGain: GainNode;
  30247. /**
  30248. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30249. * @ignoreNaming
  30250. */
  30251. WarnedWebAudioUnsupported: boolean;
  30252. /**
  30253. * Gets whether or not mp3 are supported by your browser.
  30254. */
  30255. isMP3supported: boolean;
  30256. /**
  30257. * Gets whether or not ogg are supported by your browser.
  30258. */
  30259. isOGGsupported: boolean;
  30260. /**
  30261. * Gets whether audio has been unlocked on the device.
  30262. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30263. * a user interaction has happened.
  30264. */
  30265. unlocked: boolean;
  30266. /**
  30267. * Defines if the audio engine relies on a custom unlocked button.
  30268. * In this case, the embedded button will not be displayed.
  30269. */
  30270. useCustomUnlockedButton: boolean;
  30271. /**
  30272. * Event raised when audio has been unlocked on the browser.
  30273. */
  30274. onAudioUnlockedObservable: Observable<AudioEngine>;
  30275. /**
  30276. * Event raised when audio has been locked on the browser.
  30277. */
  30278. onAudioLockedObservable: Observable<AudioEngine>;
  30279. /**
  30280. * Gets the current AudioContext if available.
  30281. */
  30282. readonly audioContext: Nullable<AudioContext>;
  30283. private _connectedAnalyser;
  30284. /**
  30285. * Instantiates a new audio engine.
  30286. *
  30287. * There should be only one per page as some browsers restrict the number
  30288. * of audio contexts you can create.
  30289. * @param hostElement defines the host element where to display the mute icon if necessary
  30290. */
  30291. constructor(hostElement?: Nullable<HTMLElement>);
  30292. /**
  30293. * Flags the audio engine in Locked state.
  30294. * This happens due to new browser policies preventing audio to autoplay.
  30295. */
  30296. lock(): void;
  30297. /**
  30298. * Unlocks the audio engine once a user action has been done on the dom.
  30299. * This is helpful to resume play once browser policies have been satisfied.
  30300. */
  30301. unlock(): void;
  30302. private _resumeAudioContext;
  30303. private _initializeAudioContext;
  30304. private _tryToRun;
  30305. private _triggerRunningState;
  30306. private _triggerSuspendedState;
  30307. private _displayMuteButton;
  30308. private _moveButtonToTopLeft;
  30309. private _onResize;
  30310. private _hideMuteButton;
  30311. /**
  30312. * Destroy and release the resources associated with the audio ccontext.
  30313. */
  30314. dispose(): void;
  30315. /**
  30316. * Gets the global volume sets on the master gain.
  30317. * @returns the global volume if set or -1 otherwise
  30318. */
  30319. getGlobalVolume(): number;
  30320. /**
  30321. * Sets the global volume of your experience (sets on the master gain).
  30322. * @param newVolume Defines the new global volume of the application
  30323. */
  30324. setGlobalVolume(newVolume: number): void;
  30325. /**
  30326. * Connect the audio engine to an audio analyser allowing some amazing
  30327. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30329. * @param analyser The analyser to connect to the engine
  30330. */
  30331. connectToAnalyser(analyser: Analyser): void;
  30332. }
  30333. }
  30334. declare module BABYLON {
  30335. /**
  30336. * Interface used to present a loading screen while loading a scene
  30337. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30338. */
  30339. export interface ILoadingScreen {
  30340. /**
  30341. * Function called to display the loading screen
  30342. */
  30343. displayLoadingUI: () => void;
  30344. /**
  30345. * Function called to hide the loading screen
  30346. */
  30347. hideLoadingUI: () => void;
  30348. /**
  30349. * Gets or sets the color to use for the background
  30350. */
  30351. loadingUIBackgroundColor: string;
  30352. /**
  30353. * Gets or sets the text to display while loading
  30354. */
  30355. loadingUIText: string;
  30356. }
  30357. /**
  30358. * Class used for the default loading screen
  30359. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30360. */
  30361. export class DefaultLoadingScreen implements ILoadingScreen {
  30362. private _renderingCanvas;
  30363. private _loadingText;
  30364. private _loadingDivBackgroundColor;
  30365. private _loadingDiv;
  30366. private _loadingTextDiv;
  30367. /** Gets or sets the logo url to use for the default loading screen */
  30368. static DefaultLogoUrl: string;
  30369. /** Gets or sets the spinner url to use for the default loading screen */
  30370. static DefaultSpinnerUrl: string;
  30371. /**
  30372. * Creates a new default loading screen
  30373. * @param _renderingCanvas defines the canvas used to render the scene
  30374. * @param _loadingText defines the default text to display
  30375. * @param _loadingDivBackgroundColor defines the default background color
  30376. */
  30377. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30378. /**
  30379. * Function called to display the loading screen
  30380. */
  30381. displayLoadingUI(): void;
  30382. /**
  30383. * Function called to hide the loading screen
  30384. */
  30385. hideLoadingUI(): void;
  30386. /**
  30387. * Gets or sets the text to display while loading
  30388. */
  30389. loadingUIText: string;
  30390. /**
  30391. * Gets or sets the color to use for the background
  30392. */
  30393. loadingUIBackgroundColor: string;
  30394. private _resizeLoadingUI;
  30395. }
  30396. }
  30397. declare module BABYLON {
  30398. /**
  30399. * Interface for any object that can request an animation frame
  30400. */
  30401. export interface ICustomAnimationFrameRequester {
  30402. /**
  30403. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30404. */
  30405. renderFunction?: Function;
  30406. /**
  30407. * Called to request the next frame to render to
  30408. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30409. */
  30410. requestAnimationFrame: Function;
  30411. /**
  30412. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30413. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30414. */
  30415. requestID?: number;
  30416. }
  30417. }
  30418. declare module BABYLON {
  30419. /**
  30420. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30421. */
  30422. export class PerformanceMonitor {
  30423. private _enabled;
  30424. private _rollingFrameTime;
  30425. private _lastFrameTimeMs;
  30426. /**
  30427. * constructor
  30428. * @param frameSampleSize The number of samples required to saturate the sliding window
  30429. */
  30430. constructor(frameSampleSize?: number);
  30431. /**
  30432. * Samples current frame
  30433. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30434. */
  30435. sampleFrame(timeMs?: number): void;
  30436. /**
  30437. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30438. */
  30439. readonly averageFrameTime: number;
  30440. /**
  30441. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30442. */
  30443. readonly averageFrameTimeVariance: number;
  30444. /**
  30445. * Returns the frame time of the most recent frame
  30446. */
  30447. readonly instantaneousFrameTime: number;
  30448. /**
  30449. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30450. */
  30451. readonly averageFPS: number;
  30452. /**
  30453. * Returns the average framerate in frames per second using the most recent frame time
  30454. */
  30455. readonly instantaneousFPS: number;
  30456. /**
  30457. * Returns true if enough samples have been taken to completely fill the sliding window
  30458. */
  30459. readonly isSaturated: boolean;
  30460. /**
  30461. * Enables contributions to the sliding window sample set
  30462. */
  30463. enable(): void;
  30464. /**
  30465. * Disables contributions to the sliding window sample set
  30466. * Samples will not be interpolated over the disabled period
  30467. */
  30468. disable(): void;
  30469. /**
  30470. * Returns true if sampling is enabled
  30471. */
  30472. readonly isEnabled: boolean;
  30473. /**
  30474. * Resets performance monitor
  30475. */
  30476. reset(): void;
  30477. }
  30478. /**
  30479. * RollingAverage
  30480. *
  30481. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30482. */
  30483. export class RollingAverage {
  30484. /**
  30485. * Current average
  30486. */
  30487. average: number;
  30488. /**
  30489. * Current variance
  30490. */
  30491. variance: number;
  30492. protected _samples: Array<number>;
  30493. protected _sampleCount: number;
  30494. protected _pos: number;
  30495. protected _m2: number;
  30496. /**
  30497. * constructor
  30498. * @param length The number of samples required to saturate the sliding window
  30499. */
  30500. constructor(length: number);
  30501. /**
  30502. * Adds a sample to the sample set
  30503. * @param v The sample value
  30504. */
  30505. add(v: number): void;
  30506. /**
  30507. * Returns previously added values or null if outside of history or outside the sliding window domain
  30508. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30509. * @return Value previously recorded with add() or null if outside of range
  30510. */
  30511. history(i: number): number;
  30512. /**
  30513. * Returns true if enough samples have been taken to completely fill the sliding window
  30514. * @return true if sample-set saturated
  30515. */
  30516. isSaturated(): boolean;
  30517. /**
  30518. * Resets the rolling average (equivalent to 0 samples taken so far)
  30519. */
  30520. reset(): void;
  30521. /**
  30522. * Wraps a value around the sample range boundaries
  30523. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30524. * @return Wrapped position in sample range
  30525. */
  30526. protected _wrapPosition(i: number): number;
  30527. }
  30528. }
  30529. declare module BABYLON {
  30530. /**
  30531. * This class is used to track a performance counter which is number based.
  30532. * The user has access to many properties which give statistics of different nature.
  30533. *
  30534. * The implementer can track two kinds of Performance Counter: time and count.
  30535. * 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.
  30536. * 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.
  30537. */
  30538. export class PerfCounter {
  30539. /**
  30540. * Gets or sets a global boolean to turn on and off all the counters
  30541. */
  30542. static Enabled: boolean;
  30543. /**
  30544. * Returns the smallest value ever
  30545. */
  30546. readonly min: number;
  30547. /**
  30548. * Returns the biggest value ever
  30549. */
  30550. readonly max: number;
  30551. /**
  30552. * Returns the average value since the performance counter is running
  30553. */
  30554. readonly average: number;
  30555. /**
  30556. * Returns the average value of the last second the counter was monitored
  30557. */
  30558. readonly lastSecAverage: number;
  30559. /**
  30560. * Returns the current value
  30561. */
  30562. readonly current: number;
  30563. /**
  30564. * Gets the accumulated total
  30565. */
  30566. readonly total: number;
  30567. /**
  30568. * Gets the total value count
  30569. */
  30570. readonly count: number;
  30571. /**
  30572. * Creates a new counter
  30573. */
  30574. constructor();
  30575. /**
  30576. * Call this method to start monitoring a new frame.
  30577. * 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.
  30578. */
  30579. fetchNewFrame(): void;
  30580. /**
  30581. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30582. * @param newCount the count value to add to the monitored count
  30583. * @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.
  30584. */
  30585. addCount(newCount: number, fetchResult: boolean): void;
  30586. /**
  30587. * Start monitoring this performance counter
  30588. */
  30589. beginMonitoring(): void;
  30590. /**
  30591. * Compute the time lapsed since the previous beginMonitoring() call.
  30592. * @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
  30593. */
  30594. endMonitoring(newFrame?: boolean): void;
  30595. private _fetchResult;
  30596. private _startMonitoringTime;
  30597. private _min;
  30598. private _max;
  30599. private _average;
  30600. private _current;
  30601. private _totalValueCount;
  30602. private _totalAccumulated;
  30603. private _lastSecAverage;
  30604. private _lastSecAccumulated;
  30605. private _lastSecTime;
  30606. private _lastSecValueCount;
  30607. }
  30608. }
  30609. declare module BABYLON {
  30610. /**
  30611. * Defines the interface used by display changed events
  30612. */
  30613. export interface IDisplayChangedEventArgs {
  30614. /** Gets the vrDisplay object (if any) */
  30615. vrDisplay: Nullable<any>;
  30616. /** Gets a boolean indicating if webVR is supported */
  30617. vrSupported: boolean;
  30618. }
  30619. /**
  30620. * Defines the interface used by objects containing a viewport (like a camera)
  30621. */
  30622. interface IViewportOwnerLike {
  30623. /**
  30624. * Gets or sets the viewport
  30625. */
  30626. viewport: IViewportLike;
  30627. }
  30628. /**
  30629. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30630. */
  30631. export class Engine extends ThinEngine {
  30632. /** Defines that alpha blending is disabled */
  30633. static readonly ALPHA_DISABLE: number;
  30634. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30635. static readonly ALPHA_ADD: number;
  30636. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30637. static readonly ALPHA_COMBINE: number;
  30638. /** Defines that alpha blending to DEST - SRC * DEST */
  30639. static readonly ALPHA_SUBTRACT: number;
  30640. /** Defines that alpha blending to SRC * DEST */
  30641. static readonly ALPHA_MULTIPLY: number;
  30642. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30643. static readonly ALPHA_MAXIMIZED: number;
  30644. /** Defines that alpha blending to SRC + DEST */
  30645. static readonly ALPHA_ONEONE: number;
  30646. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30647. static readonly ALPHA_PREMULTIPLIED: number;
  30648. /**
  30649. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30650. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30651. */
  30652. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30653. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30654. static readonly ALPHA_INTERPOLATE: number;
  30655. /**
  30656. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30657. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30658. */
  30659. static readonly ALPHA_SCREENMODE: number;
  30660. /** Defines that the ressource is not delayed*/
  30661. static readonly DELAYLOADSTATE_NONE: number;
  30662. /** Defines that the ressource was successfully delay loaded */
  30663. static readonly DELAYLOADSTATE_LOADED: number;
  30664. /** Defines that the ressource is currently delay loading */
  30665. static readonly DELAYLOADSTATE_LOADING: number;
  30666. /** Defines that the ressource is delayed and has not started loading */
  30667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30669. static readonly NEVER: number;
  30670. /** 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 */
  30671. static readonly ALWAYS: number;
  30672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30673. static readonly LESS: number;
  30674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30675. static readonly EQUAL: number;
  30676. /** 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 */
  30677. static readonly LEQUAL: number;
  30678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30679. static readonly GREATER: number;
  30680. /** 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 */
  30681. static readonly GEQUAL: number;
  30682. /** 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 */
  30683. static readonly NOTEQUAL: number;
  30684. /** Passed to stencilOperation to specify that stencil value must be kept */
  30685. static readonly KEEP: number;
  30686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30687. static readonly REPLACE: number;
  30688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30689. static readonly INCR: number;
  30690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30691. static readonly DECR: number;
  30692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30693. static readonly INVERT: number;
  30694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30695. static readonly INCR_WRAP: number;
  30696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30697. static readonly DECR_WRAP: number;
  30698. /** Texture is not repeating outside of 0..1 UVs */
  30699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30700. /** Texture is repeating outside of 0..1 UVs */
  30701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30702. /** Texture is repeating and mirrored */
  30703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30704. /** ALPHA */
  30705. static readonly TEXTUREFORMAT_ALPHA: number;
  30706. /** LUMINANCE */
  30707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30708. /** LUMINANCE_ALPHA */
  30709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30710. /** RGB */
  30711. static readonly TEXTUREFORMAT_RGB: number;
  30712. /** RGBA */
  30713. static readonly TEXTUREFORMAT_RGBA: number;
  30714. /** RED */
  30715. static readonly TEXTUREFORMAT_RED: number;
  30716. /** RED (2nd reference) */
  30717. static readonly TEXTUREFORMAT_R: number;
  30718. /** RG */
  30719. static readonly TEXTUREFORMAT_RG: number;
  30720. /** RED_INTEGER */
  30721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30722. /** RED_INTEGER (2nd reference) */
  30723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30724. /** RG_INTEGER */
  30725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30726. /** RGB_INTEGER */
  30727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30728. /** RGBA_INTEGER */
  30729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30730. /** UNSIGNED_BYTE */
  30731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30732. /** UNSIGNED_BYTE (2nd reference) */
  30733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30734. /** FLOAT */
  30735. static readonly TEXTURETYPE_FLOAT: number;
  30736. /** HALF_FLOAT */
  30737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30738. /** BYTE */
  30739. static readonly TEXTURETYPE_BYTE: number;
  30740. /** SHORT */
  30741. static readonly TEXTURETYPE_SHORT: number;
  30742. /** UNSIGNED_SHORT */
  30743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30744. /** INT */
  30745. static readonly TEXTURETYPE_INT: number;
  30746. /** UNSIGNED_INT */
  30747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30748. /** UNSIGNED_SHORT_4_4_4_4 */
  30749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30750. /** UNSIGNED_SHORT_5_5_5_1 */
  30751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30752. /** UNSIGNED_SHORT_5_6_5 */
  30753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30754. /** UNSIGNED_INT_2_10_10_10_REV */
  30755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30756. /** UNSIGNED_INT_24_8 */
  30757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30758. /** UNSIGNED_INT_10F_11F_11F_REV */
  30759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30760. /** UNSIGNED_INT_5_9_9_9_REV */
  30761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30764. /** nearest is mag = nearest and min = nearest and mip = linear */
  30765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30766. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30767. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30768. /** Trilinear is mag = linear and min = linear and mip = linear */
  30769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30770. /** nearest is mag = nearest and min = nearest and mip = linear */
  30771. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30773. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30774. /** Trilinear is mag = linear and min = linear and mip = linear */
  30775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30776. /** mag = nearest and min = nearest and mip = nearest */
  30777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30778. /** mag = nearest and min = linear and mip = nearest */
  30779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30780. /** mag = nearest and min = linear and mip = linear */
  30781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30782. /** mag = nearest and min = linear and mip = none */
  30783. static readonly TEXTURE_NEAREST_LINEAR: number;
  30784. /** mag = nearest and min = nearest and mip = none */
  30785. static readonly TEXTURE_NEAREST_NEAREST: number;
  30786. /** mag = linear and min = nearest and mip = nearest */
  30787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30788. /** mag = linear and min = nearest and mip = linear */
  30789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30790. /** mag = linear and min = linear and mip = none */
  30791. static readonly TEXTURE_LINEAR_LINEAR: number;
  30792. /** mag = linear and min = nearest and mip = none */
  30793. static readonly TEXTURE_LINEAR_NEAREST: number;
  30794. /** Explicit coordinates mode */
  30795. static readonly TEXTURE_EXPLICIT_MODE: number;
  30796. /** Spherical coordinates mode */
  30797. static readonly TEXTURE_SPHERICAL_MODE: number;
  30798. /** Planar coordinates mode */
  30799. static readonly TEXTURE_PLANAR_MODE: number;
  30800. /** Cubic coordinates mode */
  30801. static readonly TEXTURE_CUBIC_MODE: number;
  30802. /** Projection coordinates mode */
  30803. static readonly TEXTURE_PROJECTION_MODE: number;
  30804. /** Skybox coordinates mode */
  30805. static readonly TEXTURE_SKYBOX_MODE: number;
  30806. /** Inverse Cubic coordinates mode */
  30807. static readonly TEXTURE_INVCUBIC_MODE: number;
  30808. /** Equirectangular coordinates mode */
  30809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30810. /** Equirectangular Fixed coordinates mode */
  30811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30812. /** Equirectangular Fixed Mirrored coordinates mode */
  30813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30815. static readonly SCALEMODE_FLOOR: number;
  30816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30817. static readonly SCALEMODE_NEAREST: number;
  30818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30819. static readonly SCALEMODE_CEILING: number;
  30820. /**
  30821. * Returns the current npm package of the sdk
  30822. */
  30823. static readonly NpmPackage: string;
  30824. /**
  30825. * Returns the current version of the framework
  30826. */
  30827. static readonly Version: string;
  30828. /** Gets the list of created engines */
  30829. static readonly Instances: Engine[];
  30830. /**
  30831. * Gets the latest created engine
  30832. */
  30833. static readonly LastCreatedEngine: Nullable<Engine>;
  30834. /**
  30835. * Gets the latest created scene
  30836. */
  30837. static readonly LastCreatedScene: Nullable<Scene>;
  30838. /**
  30839. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30840. * @param flag defines which part of the materials must be marked as dirty
  30841. * @param predicate defines a predicate used to filter which materials should be affected
  30842. */
  30843. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30844. /**
  30845. * Method called to create the default loading screen.
  30846. * This can be overriden in your own app.
  30847. * @param canvas The rendering canvas element
  30848. * @returns The loading screen
  30849. */
  30850. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30851. /**
  30852. * Method called to create the default rescale post process on each engine.
  30853. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30854. /**
  30855. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30856. **/
  30857. enableOfflineSupport: boolean;
  30858. /**
  30859. * 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)
  30860. **/
  30861. disableManifestCheck: boolean;
  30862. /**
  30863. * Gets the list of created scenes
  30864. */
  30865. scenes: Scene[];
  30866. /**
  30867. * Event raised when a new scene is created
  30868. */
  30869. onNewSceneAddedObservable: Observable<Scene>;
  30870. /**
  30871. * Gets the list of created postprocesses
  30872. */
  30873. postProcesses: PostProcess[];
  30874. /**
  30875. * Gets a boolean indicating if the pointer is currently locked
  30876. */
  30877. isPointerLock: boolean;
  30878. /**
  30879. * Observable event triggered each time the rendering canvas is resized
  30880. */
  30881. onResizeObservable: Observable<Engine>;
  30882. /**
  30883. * Observable event triggered each time the canvas loses focus
  30884. */
  30885. onCanvasBlurObservable: Observable<Engine>;
  30886. /**
  30887. * Observable event triggered each time the canvas gains focus
  30888. */
  30889. onCanvasFocusObservable: Observable<Engine>;
  30890. /**
  30891. * Observable event triggered each time the canvas receives pointerout event
  30892. */
  30893. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30894. /**
  30895. * Observable raised when the engine begins a new frame
  30896. */
  30897. onBeginFrameObservable: Observable<Engine>;
  30898. /**
  30899. * If set, will be used to request the next animation frame for the render loop
  30900. */
  30901. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30902. /**
  30903. * Observable raised when the engine ends the current frame
  30904. */
  30905. onEndFrameObservable: Observable<Engine>;
  30906. /**
  30907. * Observable raised when the engine is about to compile a shader
  30908. */
  30909. onBeforeShaderCompilationObservable: Observable<Engine>;
  30910. /**
  30911. * Observable raised when the engine has jsut compiled a shader
  30912. */
  30913. onAfterShaderCompilationObservable: Observable<Engine>;
  30914. /**
  30915. * Gets the audio engine
  30916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30917. * @ignorenaming
  30918. */
  30919. static audioEngine: IAudioEngine;
  30920. /**
  30921. * Default AudioEngine factory responsible of creating the Audio Engine.
  30922. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30923. */
  30924. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30925. /**
  30926. * Default offline support factory responsible of creating a tool used to store data locally.
  30927. * By default, this will create a Database object if the workload has been embedded.
  30928. */
  30929. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30930. private _loadingScreen;
  30931. private _pointerLockRequested;
  30932. private _dummyFramebuffer;
  30933. private _rescalePostProcess;
  30934. /** @hidden */
  30935. protected _alphaMode: number;
  30936. /** @hidden */
  30937. protected _alphaEquation: number;
  30938. private _deterministicLockstep;
  30939. private _lockstepMaxSteps;
  30940. protected readonly _supportsHardwareTextureRescaling: boolean;
  30941. private _fps;
  30942. private _deltaTime;
  30943. /** @hidden */ private _drawCalls: PerfCounter;
  30944. /**
  30945. * Turn this value on if you want to pause FPS computation when in background
  30946. */
  30947. disablePerformanceMonitorInBackground: boolean;
  30948. private _performanceMonitor;
  30949. /**
  30950. * Gets the performance monitor attached to this engine
  30951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30952. */
  30953. readonly performanceMonitor: PerformanceMonitor;
  30954. private _onFocus;
  30955. private _onBlur;
  30956. private _onCanvasPointerOut;
  30957. private _onCanvasBlur;
  30958. private _onCanvasFocus;
  30959. private _onFullscreenChange;
  30960. private _onPointerLockChange;
  30961. /**
  30962. * Gets the HTML element used to attach event listeners
  30963. * @returns a HTML element
  30964. */
  30965. getInputElement(): Nullable<HTMLElement>;
  30966. /**
  30967. * Creates a new engine
  30968. * @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
  30969. * @param antialias defines enable antialiasing (default: false)
  30970. * @param options defines further options to be sent to the getContext() function
  30971. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30972. */
  30973. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30974. /**
  30975. * Gets current aspect ratio
  30976. * @param viewportOwner defines the camera to use to get the aspect ratio
  30977. * @param useScreen defines if screen size must be used (or the current render target if any)
  30978. * @returns a number defining the aspect ratio
  30979. */
  30980. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30981. /**
  30982. * Gets current screen aspect ratio
  30983. * @returns a number defining the aspect ratio
  30984. */
  30985. getScreenAspectRatio(): number;
  30986. /**
  30987. * Gets host document
  30988. * @returns the host document object
  30989. */
  30990. getHostDocument(): Document;
  30991. /**
  30992. * Gets the client rect of the HTML canvas attached with the current webGL context
  30993. * @returns a client rectanglee
  30994. */
  30995. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30996. /**
  30997. * Gets the client rect of the HTML element used for events
  30998. * @returns a client rectanglee
  30999. */
  31000. getInputElementClientRect(): Nullable<ClientRect>;
  31001. /**
  31002. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31003. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31004. * @returns true if engine is in deterministic lock step mode
  31005. */
  31006. isDeterministicLockStep(): boolean;
  31007. /**
  31008. * Gets the max steps when engine is running in deterministic lock step
  31009. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31010. * @returns the max steps
  31011. */
  31012. getLockstepMaxSteps(): number;
  31013. /**
  31014. * Force the mipmap generation for the given render target texture
  31015. * @param texture defines the render target texture to use
  31016. */
  31017. generateMipMapsForCubemap(texture: InternalTexture): void;
  31018. /** States */
  31019. /**
  31020. * Set various states to the webGL context
  31021. * @param culling defines backface culling state
  31022. * @param zOffset defines the value to apply to zOffset (0 by default)
  31023. * @param force defines if states must be applied even if cache is up to date
  31024. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31025. */
  31026. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31027. /**
  31028. * Set the z offset to apply to current rendering
  31029. * @param value defines the offset to apply
  31030. */
  31031. setZOffset(value: number): void;
  31032. /**
  31033. * Gets the current value of the zOffset
  31034. * @returns the current zOffset state
  31035. */
  31036. getZOffset(): number;
  31037. /**
  31038. * Enable or disable depth buffering
  31039. * @param enable defines the state to set
  31040. */
  31041. setDepthBuffer(enable: boolean): void;
  31042. /**
  31043. * Gets a boolean indicating if depth writing is enabled
  31044. * @returns the current depth writing state
  31045. */
  31046. getDepthWrite(): boolean;
  31047. /**
  31048. * Enable or disable depth writing
  31049. * @param enable defines the state to set
  31050. */
  31051. setDepthWrite(enable: boolean): void;
  31052. /**
  31053. * Enable or disable color writing
  31054. * @param enable defines the state to set
  31055. */
  31056. setColorWrite(enable: boolean): void;
  31057. /**
  31058. * Gets a boolean indicating if color writing is enabled
  31059. * @returns the current color writing state
  31060. */
  31061. getColorWrite(): boolean;
  31062. /**
  31063. * Sets alpha constants used by some alpha blending modes
  31064. * @param r defines the red component
  31065. * @param g defines the green component
  31066. * @param b defines the blue component
  31067. * @param a defines the alpha component
  31068. */
  31069. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31070. /**
  31071. * Sets the current alpha mode
  31072. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31073. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31074. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31075. */
  31076. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31077. /**
  31078. * Gets the current alpha mode
  31079. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31080. * @returns the current alpha mode
  31081. */
  31082. getAlphaMode(): number;
  31083. /**
  31084. * Sets the current alpha equation
  31085. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31086. */
  31087. setAlphaEquation(equation: number): void;
  31088. /**
  31089. * Gets the current alpha equation.
  31090. * @returns the current alpha equation
  31091. */
  31092. getAlphaEquation(): number;
  31093. /**
  31094. * Gets a boolean indicating if stencil buffer is enabled
  31095. * @returns the current stencil buffer state
  31096. */
  31097. getStencilBuffer(): boolean;
  31098. /**
  31099. * Enable or disable the stencil buffer
  31100. * @param enable defines if the stencil buffer must be enabled or disabled
  31101. */
  31102. setStencilBuffer(enable: boolean): void;
  31103. /**
  31104. * Gets the current stencil mask
  31105. * @returns a number defining the new stencil mask to use
  31106. */
  31107. getStencilMask(): number;
  31108. /**
  31109. * Sets the current stencil mask
  31110. * @param mask defines the new stencil mask to use
  31111. */
  31112. setStencilMask(mask: number): void;
  31113. /**
  31114. * Gets the current stencil function
  31115. * @returns a number defining the stencil function to use
  31116. */
  31117. getStencilFunction(): number;
  31118. /**
  31119. * Gets the current stencil reference value
  31120. * @returns a number defining the stencil reference value to use
  31121. */
  31122. getStencilFunctionReference(): number;
  31123. /**
  31124. * Gets the current stencil mask
  31125. * @returns a number defining the stencil mask to use
  31126. */
  31127. getStencilFunctionMask(): number;
  31128. /**
  31129. * Sets the current stencil function
  31130. * @param stencilFunc defines the new stencil function to use
  31131. */
  31132. setStencilFunction(stencilFunc: number): void;
  31133. /**
  31134. * Sets the current stencil reference
  31135. * @param reference defines the new stencil reference to use
  31136. */
  31137. setStencilFunctionReference(reference: number): void;
  31138. /**
  31139. * Sets the current stencil mask
  31140. * @param mask defines the new stencil mask to use
  31141. */
  31142. setStencilFunctionMask(mask: number): void;
  31143. /**
  31144. * Gets the current stencil operation when stencil fails
  31145. * @returns a number defining stencil operation to use when stencil fails
  31146. */
  31147. getStencilOperationFail(): number;
  31148. /**
  31149. * Gets the current stencil operation when depth fails
  31150. * @returns a number defining stencil operation to use when depth fails
  31151. */
  31152. getStencilOperationDepthFail(): number;
  31153. /**
  31154. * Gets the current stencil operation when stencil passes
  31155. * @returns a number defining stencil operation to use when stencil passes
  31156. */
  31157. getStencilOperationPass(): number;
  31158. /**
  31159. * Sets the stencil operation to use when stencil fails
  31160. * @param operation defines the stencil operation to use when stencil fails
  31161. */
  31162. setStencilOperationFail(operation: number): void;
  31163. /**
  31164. * Sets the stencil operation to use when depth fails
  31165. * @param operation defines the stencil operation to use when depth fails
  31166. */
  31167. setStencilOperationDepthFail(operation: number): void;
  31168. /**
  31169. * Sets the stencil operation to use when stencil passes
  31170. * @param operation defines the stencil operation to use when stencil passes
  31171. */
  31172. setStencilOperationPass(operation: number): void;
  31173. /**
  31174. * Sets a boolean indicating if the dithering state is enabled or disabled
  31175. * @param value defines the dithering state
  31176. */
  31177. setDitheringState(value: boolean): void;
  31178. /**
  31179. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31180. * @param value defines the rasterizer state
  31181. */
  31182. setRasterizerState(value: boolean): void;
  31183. /**
  31184. * Gets the current depth function
  31185. * @returns a number defining the depth function
  31186. */
  31187. getDepthFunction(): Nullable<number>;
  31188. /**
  31189. * Sets the current depth function
  31190. * @param depthFunc defines the function to use
  31191. */
  31192. setDepthFunction(depthFunc: number): void;
  31193. /**
  31194. * Sets the current depth function to GREATER
  31195. */
  31196. setDepthFunctionToGreater(): void;
  31197. /**
  31198. * Sets the current depth function to GEQUAL
  31199. */
  31200. setDepthFunctionToGreaterOrEqual(): void;
  31201. /**
  31202. * Sets the current depth function to LESS
  31203. */
  31204. setDepthFunctionToLess(): void;
  31205. /**
  31206. * Sets the current depth function to LEQUAL
  31207. */
  31208. setDepthFunctionToLessOrEqual(): void;
  31209. private _cachedStencilBuffer;
  31210. private _cachedStencilFunction;
  31211. private _cachedStencilMask;
  31212. private _cachedStencilOperationPass;
  31213. private _cachedStencilOperationFail;
  31214. private _cachedStencilOperationDepthFail;
  31215. private _cachedStencilReference;
  31216. /**
  31217. * Caches the the state of the stencil buffer
  31218. */
  31219. cacheStencilState(): void;
  31220. /**
  31221. * Restores the state of the stencil buffer
  31222. */
  31223. restoreStencilState(): void;
  31224. /**
  31225. * Directly set the WebGL Viewport
  31226. * @param x defines the x coordinate of the viewport (in screen space)
  31227. * @param y defines the y coordinate of the viewport (in screen space)
  31228. * @param width defines the width of the viewport (in screen space)
  31229. * @param height defines the height of the viewport (in screen space)
  31230. * @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
  31231. */
  31232. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31233. /**
  31234. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31235. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31236. * @param y defines the y-coordinate of the corner of the clear rectangle
  31237. * @param width defines the width of the clear rectangle
  31238. * @param height defines the height of the clear rectangle
  31239. * @param clearColor defines the clear color
  31240. */
  31241. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31242. /**
  31243. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31244. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31245. * @param y defines the y-coordinate of the corner of the clear rectangle
  31246. * @param width defines the width of the clear rectangle
  31247. * @param height defines the height of the clear rectangle
  31248. */
  31249. enableScissor(x: number, y: number, width: number, height: number): void;
  31250. /**
  31251. * Disable previously set scissor test rectangle
  31252. */
  31253. disableScissor(): void;
  31254. protected _reportDrawCall(): void;
  31255. /**
  31256. * Initializes a webVR display and starts listening to display change events
  31257. * The onVRDisplayChangedObservable will be notified upon these changes
  31258. * @returns The onVRDisplayChangedObservable
  31259. */
  31260. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31261. /** @hidden */ private _prepareVRComponent(): void;
  31262. /** @hidden */ private _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31263. /** @hidden */ private _submitVRFrame(): void;
  31264. /**
  31265. * Call this function to leave webVR mode
  31266. * Will do nothing if webVR is not supported or if there is no webVR device
  31267. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31268. */
  31269. disableVR(): void;
  31270. /**
  31271. * Gets a boolean indicating that the system is in VR mode and is presenting
  31272. * @returns true if VR mode is engaged
  31273. */
  31274. isVRPresenting(): boolean;
  31275. /** @hidden */ private _requestVRFrame(): void;
  31276. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31277. /**
  31278. * Gets the source code of the vertex shader associated with a specific webGL program
  31279. * @param program defines the program to use
  31280. * @returns a string containing the source code of the vertex shader associated with the program
  31281. */
  31282. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31283. /**
  31284. * Gets the source code of the fragment shader associated with a specific webGL program
  31285. * @param program defines the program to use
  31286. * @returns a string containing the source code of the fragment shader associated with the program
  31287. */
  31288. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31289. /**
  31290. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31291. * @param x defines the x coordinate of the rectangle where pixels must be read
  31292. * @param y defines the y coordinate of the rectangle where pixels must be read
  31293. * @param width defines the width of the rectangle where pixels must be read
  31294. * @param height defines the height of the rectangle where pixels must be read
  31295. * @returns a Uint8Array containing RGBA colors
  31296. */
  31297. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31298. /**
  31299. * Sets a depth stencil texture from a render target to the according uniform.
  31300. * @param channel The texture channel
  31301. * @param uniform The uniform to set
  31302. * @param texture The render target texture containing the depth stencil texture to apply
  31303. */
  31304. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31305. /**
  31306. * Sets a texture to the webGL context from a postprocess
  31307. * @param channel defines the channel to use
  31308. * @param postProcess defines the source postprocess
  31309. */
  31310. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31311. /**
  31312. * Binds the output of the passed in post process to the texture channel specified
  31313. * @param channel The channel the texture should be bound to
  31314. * @param postProcess The post process which's output should be bound
  31315. */
  31316. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31317. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31318. protected _rebuildBuffers(): void;
  31319. /** @hidden */ private _renderFrame(): void; private _renderLoop(): void;
  31320. /** @hidden */ private _renderViews(): boolean;
  31321. /**
  31322. * Toggle full screen mode
  31323. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31324. */
  31325. switchFullscreen(requestPointerLock: boolean): void;
  31326. /**
  31327. * Enters full screen mode
  31328. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31329. */
  31330. enterFullscreen(requestPointerLock: boolean): void;
  31331. /**
  31332. * Exits full screen mode
  31333. */
  31334. exitFullscreen(): void;
  31335. /**
  31336. * Enters Pointerlock mode
  31337. */
  31338. enterPointerlock(): void;
  31339. /**
  31340. * Exits Pointerlock mode
  31341. */
  31342. exitPointerlock(): void;
  31343. /**
  31344. * Begin a new frame
  31345. */
  31346. beginFrame(): void;
  31347. /**
  31348. * Enf the current frame
  31349. */
  31350. endFrame(): void;
  31351. resize(): void;
  31352. /**
  31353. * Set the compressed texture format to use, based on the formats you have, and the formats
  31354. * supported by the hardware / browser.
  31355. *
  31356. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31357. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31358. * to API arguments needed to compressed textures. This puts the burden on the container
  31359. * generator to house the arcane code for determining these for current & future formats.
  31360. *
  31361. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31362. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31363. *
  31364. * Note: The result of this call is not taken into account when a texture is base64.
  31365. *
  31366. * @param formatsAvailable defines the list of those format families you have created
  31367. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31368. *
  31369. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31370. * @returns The extension selected.
  31371. */
  31372. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31373. /**
  31374. * Force a specific size of the canvas
  31375. * @param width defines the new canvas' width
  31376. * @param height defines the new canvas' height
  31377. */
  31378. setSize(width: number, height: number): void;
  31379. /**
  31380. * Updates a dynamic vertex buffer.
  31381. * @param vertexBuffer the vertex buffer to update
  31382. * @param data the data used to update the vertex buffer
  31383. * @param byteOffset the byte offset of the data
  31384. * @param byteLength the byte length of the data
  31385. */
  31386. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31387. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31388. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram; private _releaseTexture(texture: InternalTexture): void;
  31389. /**
  31390. * @hidden
  31391. * Rescales a texture
  31392. * @param source input texutre
  31393. * @param destination destination texture
  31394. * @param scene scene to use to render the resize
  31395. * @param internalFormat format to use when resizing
  31396. * @param onComplete callback to be called when resize has completed
  31397. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31398. /**
  31399. * Gets the current framerate
  31400. * @returns a number representing the framerate
  31401. */
  31402. getFps(): number;
  31403. /**
  31404. * Gets the time spent between current and previous frame
  31405. * @returns a number representing the delta time in ms
  31406. */
  31407. getDeltaTime(): number;
  31408. private _measureFps;
  31409. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  31410. /**
  31411. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31412. * @param renderTarget The render target to set the frame buffer for
  31413. */
  31414. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31415. /**
  31416. * Update a dynamic index buffer
  31417. * @param indexBuffer defines the target index buffer
  31418. * @param indices defines the data to update
  31419. * @param offset defines the offset in the target index buffer where update should start
  31420. */
  31421. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31422. /**
  31423. * Updates the sample count of a render target texture
  31424. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31425. * @param texture defines the texture to update
  31426. * @param samples defines the sample count to set
  31427. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31428. */
  31429. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31430. /**
  31431. * Updates a depth texture Comparison Mode and Function.
  31432. * If the comparison Function is equal to 0, the mode will be set to none.
  31433. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31434. * @param texture The texture to set the comparison function for
  31435. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31436. */
  31437. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31438. /**
  31439. * Creates a webGL buffer to use with instanciation
  31440. * @param capacity defines the size of the buffer
  31441. * @returns the webGL buffer
  31442. */
  31443. createInstancesBuffer(capacity: number): DataBuffer;
  31444. /**
  31445. * Delete a webGL buffer used with instanciation
  31446. * @param buffer defines the webGL buffer to delete
  31447. */
  31448. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31449. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31450. dispose(): void;
  31451. private _disableTouchAction;
  31452. /**
  31453. * Display the loading screen
  31454. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31455. */
  31456. displayLoadingUI(): void;
  31457. /**
  31458. * Hide the loading screen
  31459. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31460. */
  31461. hideLoadingUI(): void;
  31462. /**
  31463. * Gets the current loading screen object
  31464. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31465. */
  31466. /**
  31467. * Sets the current loading screen object
  31468. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31469. */
  31470. loadingScreen: ILoadingScreen;
  31471. /**
  31472. * Sets the current loading screen text
  31473. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31474. */
  31475. loadingUIText: string;
  31476. /**
  31477. * Sets the current loading screen background color
  31478. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31479. */
  31480. loadingUIBackgroundColor: string;
  31481. /** Pointerlock and fullscreen */
  31482. /**
  31483. * Ask the browser to promote the current element to pointerlock mode
  31484. * @param element defines the DOM element to promote
  31485. */ private static _RequestPointerlock(element: HTMLElement): void;
  31486. /**
  31487. * Asks the browser to exit pointerlock mode
  31488. */ private static _ExitPointerlock(): void;
  31489. /**
  31490. * Ask the browser to promote the current element to fullscreen rendering mode
  31491. * @param element defines the DOM element to promote
  31492. */ private static _RequestFullscreen(element: HTMLElement): void;
  31493. /**
  31494. * Asks the browser to exit fullscreen mode
  31495. */ private static _ExitFullscreen(): void;
  31496. }
  31497. }
  31498. declare module BABYLON {
  31499. /**
  31500. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31501. * during the life time of the application.
  31502. */
  31503. export class EngineStore {
  31504. /** Gets the list of created engines */
  31505. static Instances: Engine[];
  31506. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  31507. /**
  31508. * Gets the latest created engine
  31509. */
  31510. static readonly LastCreatedEngine: Nullable<Engine>;
  31511. /**
  31512. * Gets the latest created scene
  31513. */
  31514. static readonly LastCreatedScene: Nullable<Scene>;
  31515. /**
  31516. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31517. * @ignorenaming
  31518. */
  31519. static UseFallbackTexture: boolean;
  31520. /**
  31521. * Texture content used if a texture cannot loaded
  31522. * @ignorenaming
  31523. */
  31524. static FallbackTexture: string;
  31525. }
  31526. }
  31527. declare module BABYLON {
  31528. /**
  31529. * Helper class that provides a small promise polyfill
  31530. */
  31531. export class PromisePolyfill {
  31532. /**
  31533. * Static function used to check if the polyfill is required
  31534. * If this is the case then the function will inject the polyfill to window.Promise
  31535. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31536. */
  31537. static Apply(force?: boolean): void;
  31538. }
  31539. }
  31540. declare module BABYLON {
  31541. /**
  31542. * Interface for screenshot methods with describe argument called `size` as object with options
  31543. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31544. */
  31545. export interface IScreenshotSize {
  31546. /**
  31547. * number in pixels for canvas height
  31548. */
  31549. height?: number;
  31550. /**
  31551. * multiplier allowing render at a higher or lower resolution
  31552. * If value is defined then height and width will be ignored and taken from camera
  31553. */
  31554. precision?: number;
  31555. /**
  31556. * number in pixels for canvas width
  31557. */
  31558. width?: number;
  31559. }
  31560. }
  31561. declare module BABYLON {
  31562. interface IColor4Like {
  31563. r: float;
  31564. g: float;
  31565. b: float;
  31566. a: float;
  31567. }
  31568. /**
  31569. * Class containing a set of static utilities functions
  31570. */
  31571. export class Tools {
  31572. /**
  31573. * Gets or sets the base URL to use to load assets
  31574. */
  31575. static BaseUrl: string;
  31576. /**
  31577. * Enable/Disable Custom HTTP Request Headers globally.
  31578. * default = false
  31579. * @see CustomRequestHeaders
  31580. */
  31581. static UseCustomRequestHeaders: boolean;
  31582. /**
  31583. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31584. * i.e. when loading files, where the server/service expects an Authorization header
  31585. */
  31586. static CustomRequestHeaders: {
  31587. [key: string]: string;
  31588. };
  31589. /**
  31590. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31591. */
  31592. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31593. /**
  31594. * Default behaviour for cors in the application.
  31595. * It can be a string if the expected behavior is identical in the entire app.
  31596. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31597. */
  31598. static CorsBehavior: string | ((url: string | string[]) => string);
  31599. /**
  31600. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31601. * @ignorenaming
  31602. */
  31603. static UseFallbackTexture: boolean;
  31604. /**
  31605. * Use this object to register external classes like custom textures or material
  31606. * to allow the laoders to instantiate them
  31607. */
  31608. static RegisteredExternalClasses: {
  31609. [key: string]: Object;
  31610. };
  31611. /**
  31612. * Texture content used if a texture cannot loaded
  31613. * @ignorenaming
  31614. */
  31615. static fallbackTexture: string;
  31616. /**
  31617. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31618. * @param u defines the coordinate on X axis
  31619. * @param v defines the coordinate on Y axis
  31620. * @param width defines the width of the source data
  31621. * @param height defines the height of the source data
  31622. * @param pixels defines the source byte array
  31623. * @param color defines the output color
  31624. */
  31625. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31626. /**
  31627. * Interpolates between a and b via alpha
  31628. * @param a The lower value (returned when alpha = 0)
  31629. * @param b The upper value (returned when alpha = 1)
  31630. * @param alpha The interpolation-factor
  31631. * @return The mixed value
  31632. */
  31633. static Mix(a: number, b: number, alpha: number): number;
  31634. /**
  31635. * Tries to instantiate a new object from a given class name
  31636. * @param className defines the class name to instantiate
  31637. * @returns the new object or null if the system was not able to do the instantiation
  31638. */
  31639. static Instantiate(className: string): any;
  31640. /**
  31641. * Provides a slice function that will work even on IE
  31642. * @param data defines the array to slice
  31643. * @param start defines the start of the data (optional)
  31644. * @param end defines the end of the data (optional)
  31645. * @returns the new sliced array
  31646. */
  31647. static Slice<T>(data: T, start?: number, end?: number): T;
  31648. /**
  31649. * Polyfill for setImmediate
  31650. * @param action defines the action to execute after the current execution block
  31651. */
  31652. static SetImmediate(action: () => void): void;
  31653. /**
  31654. * Function indicating if a number is an exponent of 2
  31655. * @param value defines the value to test
  31656. * @returns true if the value is an exponent of 2
  31657. */
  31658. static IsExponentOfTwo(value: number): boolean;
  31659. private static _tmpFloatArray;
  31660. /**
  31661. * Returns the nearest 32-bit single precision float representation of a Number
  31662. * @param value A Number. If the parameter is of a different type, it will get converted
  31663. * to a number or to NaN if it cannot be converted
  31664. * @returns number
  31665. */
  31666. static FloatRound(value: number): number;
  31667. /**
  31668. * Extracts the filename from a path
  31669. * @param path defines the path to use
  31670. * @returns the filename
  31671. */
  31672. static GetFilename(path: string): string;
  31673. /**
  31674. * Extracts the "folder" part of a path (everything before the filename).
  31675. * @param uri The URI to extract the info from
  31676. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31677. * @returns The "folder" part of the path
  31678. */
  31679. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31680. /**
  31681. * Extracts text content from a DOM element hierarchy
  31682. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31683. */
  31684. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31685. /**
  31686. * Convert an angle in radians to degrees
  31687. * @param angle defines the angle to convert
  31688. * @returns the angle in degrees
  31689. */
  31690. static ToDegrees(angle: number): number;
  31691. /**
  31692. * Convert an angle in degrees to radians
  31693. * @param angle defines the angle to convert
  31694. * @returns the angle in radians
  31695. */
  31696. static ToRadians(angle: number): number;
  31697. /**
  31698. * Returns an array if obj is not an array
  31699. * @param obj defines the object to evaluate as an array
  31700. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31701. * @returns either obj directly if obj is an array or a new array containing obj
  31702. */
  31703. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31704. /**
  31705. * Gets the pointer prefix to use
  31706. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31707. */
  31708. static GetPointerPrefix(): string;
  31709. /**
  31710. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31711. * @param url define the url we are trying
  31712. * @param element define the dom element where to configure the cors policy
  31713. */
  31714. static SetCorsBehavior(url: string | string[], element: {
  31715. crossOrigin: string | null;
  31716. }): void;
  31717. /**
  31718. * Removes unwanted characters from an url
  31719. * @param url defines the url to clean
  31720. * @returns the cleaned url
  31721. */
  31722. static CleanUrl(url: string): string;
  31723. /**
  31724. * Gets or sets a function used to pre-process url before using them to load assets
  31725. */
  31726. static PreprocessUrl: (url: string) => string;
  31727. /**
  31728. * Loads an image as an HTMLImageElement.
  31729. * @param input url string, ArrayBuffer, or Blob to load
  31730. * @param onLoad callback called when the image successfully loads
  31731. * @param onError callback called when the image fails to load
  31732. * @param offlineProvider offline provider for caching
  31733. * @param mimeType optional mime type
  31734. * @returns the HTMLImageElement of the loaded image
  31735. */
  31736. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  31737. /**
  31738. * Loads a file from a url
  31739. * @param url url string, ArrayBuffer, or Blob to load
  31740. * @param onSuccess callback called when the file successfully loads
  31741. * @param onProgress callback called while file is loading (if the server supports this mode)
  31742. * @param offlineProvider defines the offline provider for caching
  31743. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31744. * @param onError callback called when the file fails to load
  31745. * @returns a file request object
  31746. */
  31747. 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;
  31748. /**
  31749. * Loads a file from a url
  31750. * @param url the file url to load
  31751. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31752. */
  31753. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31754. /**
  31755. * Load a script (identified by an url). When the url returns, the
  31756. * content of this file is added into a new script element, attached to the DOM (body element)
  31757. * @param scriptUrl defines the url of the script to laod
  31758. * @param onSuccess defines the callback called when the script is loaded
  31759. * @param onError defines the callback to call if an error occurs
  31760. * @param scriptId defines the id of the script element
  31761. */
  31762. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31763. /**
  31764. * Load an asynchronous script (identified by an url). When the url returns, the
  31765. * content of this file is added into a new script element, attached to the DOM (body element)
  31766. * @param scriptUrl defines the url of the script to laod
  31767. * @param scriptId defines the id of the script element
  31768. * @returns a promise request object
  31769. */
  31770. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31771. /**
  31772. * Loads a file from a blob
  31773. * @param fileToLoad defines the blob to use
  31774. * @param callback defines the callback to call when data is loaded
  31775. * @param progressCallback defines the callback to call during loading process
  31776. * @returns a file request object
  31777. */
  31778. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31779. /**
  31780. * Reads a file from a File object
  31781. * @param file defines the file to load
  31782. * @param onSuccess defines the callback to call when data is loaded
  31783. * @param onProgress defines the callback to call during loading process
  31784. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31785. * @param onError defines the callback to call when an error occurs
  31786. * @returns a file request object
  31787. */
  31788. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  31789. /**
  31790. * Creates a data url from a given string content
  31791. * @param content defines the content to convert
  31792. * @returns the new data url link
  31793. */
  31794. static FileAsURL(content: string): string;
  31795. /**
  31796. * Format the given number to a specific decimal format
  31797. * @param value defines the number to format
  31798. * @param decimals defines the number of decimals to use
  31799. * @returns the formatted string
  31800. */
  31801. static Format(value: number, decimals?: number): string;
  31802. /**
  31803. * Tries to copy an object by duplicating every property
  31804. * @param source defines the source object
  31805. * @param destination defines the target object
  31806. * @param doNotCopyList defines a list of properties to avoid
  31807. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31808. */
  31809. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31810. /**
  31811. * Gets a boolean indicating if the given object has no own property
  31812. * @param obj defines the object to test
  31813. * @returns true if object has no own property
  31814. */
  31815. static IsEmpty(obj: any): boolean;
  31816. /**
  31817. * Function used to register events at window level
  31818. * @param windowElement defines the Window object to use
  31819. * @param events defines the events to register
  31820. */
  31821. static RegisterTopRootEvents(windowElement: Window, events: {
  31822. name: string;
  31823. handler: Nullable<(e: FocusEvent) => any>;
  31824. }[]): void;
  31825. /**
  31826. * Function used to unregister events from window level
  31827. * @param windowElement defines the Window object to use
  31828. * @param events defines the events to unregister
  31829. */
  31830. static UnregisterTopRootEvents(windowElement: Window, events: {
  31831. name: string;
  31832. handler: Nullable<(e: FocusEvent) => any>;
  31833. }[]): void;
  31834. /**
  31835. * @ignore
  31836. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31837. /**
  31838. * Dumps the current bound framebuffer
  31839. * @param width defines the rendering width
  31840. * @param height defines the rendering height
  31841. * @param engine defines the hosting engine
  31842. * @param successCallback defines the callback triggered once the data are available
  31843. * @param mimeType defines the mime type of the result
  31844. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31845. */
  31846. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31847. /**
  31848. * Converts the canvas data to blob.
  31849. * This acts as a polyfill for browsers not supporting the to blob function.
  31850. * @param canvas Defines the canvas to extract the data from
  31851. * @param successCallback Defines the callback triggered once the data are available
  31852. * @param mimeType Defines the mime type of the result
  31853. */
  31854. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31855. /**
  31856. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31857. * @param successCallback defines the callback triggered once the data are available
  31858. * @param mimeType defines the mime type of the result
  31859. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31860. */
  31861. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31862. /**
  31863. * Downloads a blob in the browser
  31864. * @param blob defines the blob to download
  31865. * @param fileName defines the name of the downloaded file
  31866. */
  31867. static Download(blob: Blob, fileName: string): void;
  31868. /**
  31869. * Captures a screenshot of the current rendering
  31870. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31871. * @param engine defines the rendering engine
  31872. * @param camera defines the source camera
  31873. * @param size This parameter can be set to a single number or to an object with the
  31874. * following (optional) properties: precision, width, height. If a single number is passed,
  31875. * it will be used for both width and height. If an object is passed, the screenshot size
  31876. * will be derived from the parameters. The precision property is a multiplier allowing
  31877. * rendering at a higher or lower resolution
  31878. * @param successCallback defines the callback receives a single parameter which contains the
  31879. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31880. * src parameter of an <img> to display it
  31881. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31882. * Check your browser for supported MIME types
  31883. */
  31884. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31885. /**
  31886. * Captures a screenshot of the current rendering
  31887. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31888. * @param engine defines the rendering engine
  31889. * @param camera defines the source camera
  31890. * @param size This parameter can be set to a single number or to an object with the
  31891. * following (optional) properties: precision, width, height. If a single number is passed,
  31892. * it will be used for both width and height. If an object is passed, the screenshot size
  31893. * will be derived from the parameters. The precision property is a multiplier allowing
  31894. * rendering at a higher or lower resolution
  31895. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31896. * Check your browser for supported MIME types
  31897. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31898. * to the src parameter of an <img> to display it
  31899. */
  31900. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31901. /**
  31902. * Generates an image screenshot from the specified camera.
  31903. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31904. * @param engine The engine to use for rendering
  31905. * @param camera The camera to use for rendering
  31906. * @param size This parameter can be set to a single number or to an object with the
  31907. * following (optional) properties: precision, width, height. If a single number is passed,
  31908. * it will be used for both width and height. If an object is passed, the screenshot size
  31909. * will be derived from the parameters. The precision property is a multiplier allowing
  31910. * rendering at a higher or lower resolution
  31911. * @param successCallback The callback receives a single parameter which contains the
  31912. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31913. * src parameter of an <img> to display it
  31914. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31915. * Check your browser for supported MIME types
  31916. * @param samples Texture samples (default: 1)
  31917. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31918. * @param fileName A name for for the downloaded file.
  31919. */
  31920. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31921. /**
  31922. * Generates an image screenshot from the specified camera.
  31923. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31924. * @param engine The engine to use for rendering
  31925. * @param camera The camera to use for rendering
  31926. * @param size This parameter can be set to a single number or to an object with the
  31927. * following (optional) properties: precision, width, height. If a single number is passed,
  31928. * it will be used for both width and height. If an object is passed, the screenshot size
  31929. * will be derived from the parameters. The precision property is a multiplier allowing
  31930. * rendering at a higher or lower resolution
  31931. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31932. * Check your browser for supported MIME types
  31933. * @param samples Texture samples (default: 1)
  31934. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31935. * @param fileName A name for for the downloaded file.
  31936. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31937. * to the src parameter of an <img> to display it
  31938. */
  31939. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31940. /**
  31941. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31942. * Be aware Math.random() could cause collisions, but:
  31943. * "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"
  31944. * @returns a pseudo random id
  31945. */
  31946. static RandomId(): string;
  31947. /**
  31948. * Test if the given uri is a base64 string
  31949. * @param uri The uri to test
  31950. * @return True if the uri is a base64 string or false otherwise
  31951. */
  31952. static IsBase64(uri: string): boolean;
  31953. /**
  31954. * Decode the given base64 uri.
  31955. * @param uri The uri to decode
  31956. * @return The decoded base64 data.
  31957. */
  31958. static DecodeBase64(uri: string): ArrayBuffer;
  31959. /**
  31960. * Gets the absolute url.
  31961. * @param url the input url
  31962. * @return the absolute url
  31963. */
  31964. static GetAbsoluteUrl(url: string): string;
  31965. /**
  31966. * No log
  31967. */
  31968. static readonly NoneLogLevel: number;
  31969. /**
  31970. * Only message logs
  31971. */
  31972. static readonly MessageLogLevel: number;
  31973. /**
  31974. * Only warning logs
  31975. */
  31976. static readonly WarningLogLevel: number;
  31977. /**
  31978. * Only error logs
  31979. */
  31980. static readonly ErrorLogLevel: number;
  31981. /**
  31982. * All logs
  31983. */
  31984. static readonly AllLogLevel: number;
  31985. /**
  31986. * Gets a value indicating the number of loading errors
  31987. * @ignorenaming
  31988. */
  31989. static readonly errorsCount: number;
  31990. /**
  31991. * Callback called when a new log is added
  31992. */
  31993. static OnNewCacheEntry: (entry: string) => void;
  31994. /**
  31995. * Log a message to the console
  31996. * @param message defines the message to log
  31997. */
  31998. static Log(message: string): void;
  31999. /**
  32000. * Write a warning message to the console
  32001. * @param message defines the message to log
  32002. */
  32003. static Warn(message: string): void;
  32004. /**
  32005. * Write an error message to the console
  32006. * @param message defines the message to log
  32007. */
  32008. static Error(message: string): void;
  32009. /**
  32010. * Gets current log cache (list of logs)
  32011. */
  32012. static readonly LogCache: string;
  32013. /**
  32014. * Clears the log cache
  32015. */
  32016. static ClearLogCache(): void;
  32017. /**
  32018. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32019. */
  32020. static LogLevels: number;
  32021. /**
  32022. * Checks if the window object exists
  32023. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32024. */
  32025. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32026. /**
  32027. * No performance log
  32028. */
  32029. static readonly PerformanceNoneLogLevel: number;
  32030. /**
  32031. * Use user marks to log performance
  32032. */
  32033. static readonly PerformanceUserMarkLogLevel: number;
  32034. /**
  32035. * Log performance to the console
  32036. */
  32037. static readonly PerformanceConsoleLogLevel: number;
  32038. private static _performance;
  32039. /**
  32040. * Sets the current performance log level
  32041. */
  32042. static PerformanceLogLevel: number;
  32043. private static _StartPerformanceCounterDisabled;
  32044. private static _EndPerformanceCounterDisabled;
  32045. private static _StartUserMark;
  32046. private static _EndUserMark;
  32047. private static _StartPerformanceConsole;
  32048. private static _EndPerformanceConsole;
  32049. /**
  32050. * Starts a performance counter
  32051. */
  32052. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32053. /**
  32054. * Ends a specific performance coutner
  32055. */
  32056. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32057. /**
  32058. * Gets either window.performance.now() if supported or Date.now() else
  32059. */
  32060. static readonly Now: number;
  32061. /**
  32062. * This method will return the name of the class used to create the instance of the given object.
  32063. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32064. * @param object the object to get the class name from
  32065. * @param isType defines if the object is actually a type
  32066. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32067. */
  32068. static GetClassName(object: any, isType?: boolean): string;
  32069. /**
  32070. * Gets the first element of an array satisfying a given predicate
  32071. * @param array defines the array to browse
  32072. * @param predicate defines the predicate to use
  32073. * @returns null if not found or the element
  32074. */
  32075. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32076. /**
  32077. * This method will return the name of the full name of the class, including its owning module (if any).
  32078. * 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).
  32079. * @param object the object to get the class name from
  32080. * @param isType defines if the object is actually a type
  32081. * @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.
  32082. * @ignorenaming
  32083. */
  32084. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32085. /**
  32086. * Returns a promise that resolves after the given amount of time.
  32087. * @param delay Number of milliseconds to delay
  32088. * @returns Promise that resolves after the given amount of time
  32089. */
  32090. static DelayAsync(delay: number): Promise<void>;
  32091. }
  32092. /**
  32093. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32094. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32095. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32096. * @param name The name of the class, case should be preserved
  32097. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32098. */
  32099. export function className(name: string, module?: string): (target: Object) => void;
  32100. /**
  32101. * An implementation of a loop for asynchronous functions.
  32102. */
  32103. export class AsyncLoop {
  32104. /**
  32105. * Defines the number of iterations for the loop
  32106. */
  32107. iterations: number;
  32108. /**
  32109. * Defines the current index of the loop.
  32110. */
  32111. index: number;
  32112. private _done;
  32113. private _fn;
  32114. private _successCallback;
  32115. /**
  32116. * Constructor.
  32117. * @param iterations the number of iterations.
  32118. * @param func the function to run each iteration
  32119. * @param successCallback the callback that will be called upon succesful execution
  32120. * @param offset starting offset.
  32121. */
  32122. constructor(
  32123. /**
  32124. * Defines the number of iterations for the loop
  32125. */
  32126. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32127. /**
  32128. * Execute the next iteration. Must be called after the last iteration was finished.
  32129. */
  32130. executeNext(): void;
  32131. /**
  32132. * Break the loop and run the success callback.
  32133. */
  32134. breakLoop(): void;
  32135. /**
  32136. * Create and run an async loop.
  32137. * @param iterations the number of iterations.
  32138. * @param fn the function to run each iteration
  32139. * @param successCallback the callback that will be called upon succesful execution
  32140. * @param offset starting offset.
  32141. * @returns the created async loop object
  32142. */
  32143. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32144. /**
  32145. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32146. * @param iterations total number of iterations
  32147. * @param syncedIterations number of synchronous iterations in each async iteration.
  32148. * @param fn the function to call each iteration.
  32149. * @param callback a success call back that will be called when iterating stops.
  32150. * @param breakFunction a break condition (optional)
  32151. * @param timeout timeout settings for the setTimeout function. default - 0.
  32152. * @returns the created async loop object
  32153. */
  32154. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32155. }
  32156. }
  32157. declare module BABYLON {
  32158. /**
  32159. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32160. * The underlying implementation relies on an associative array to ensure the best performances.
  32161. * The value can be anything including 'null' but except 'undefined'
  32162. */
  32163. export class StringDictionary<T> {
  32164. /**
  32165. * This will clear this dictionary and copy the content from the 'source' one.
  32166. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32167. * @param source the dictionary to take the content from and copy to this dictionary
  32168. */
  32169. copyFrom(source: StringDictionary<T>): void;
  32170. /**
  32171. * Get a value based from its key
  32172. * @param key the given key to get the matching value from
  32173. * @return the value if found, otherwise undefined is returned
  32174. */
  32175. get(key: string): T | undefined;
  32176. /**
  32177. * Get a value from its key or add it if it doesn't exist.
  32178. * This method will ensure you that a given key/data will be present in the dictionary.
  32179. * @param key the given key to get the matching value from
  32180. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32181. * The factory will only be invoked if there's no data for the given key.
  32182. * @return the value corresponding to the key.
  32183. */
  32184. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32185. /**
  32186. * Get a value from its key if present in the dictionary otherwise add it
  32187. * @param key the key to get the value from
  32188. * @param val if there's no such key/value pair in the dictionary add it with this value
  32189. * @return the value corresponding to the key
  32190. */
  32191. getOrAdd(key: string, val: T): T;
  32192. /**
  32193. * Check if there's a given key in the dictionary
  32194. * @param key the key to check for
  32195. * @return true if the key is present, false otherwise
  32196. */
  32197. contains(key: string): boolean;
  32198. /**
  32199. * Add a new key and its corresponding value
  32200. * @param key the key to add
  32201. * @param value the value corresponding to the key
  32202. * @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
  32203. */
  32204. add(key: string, value: T): boolean;
  32205. /**
  32206. * Update a specific value associated to a key
  32207. * @param key defines the key to use
  32208. * @param value defines the value to store
  32209. * @returns true if the value was updated (or false if the key was not found)
  32210. */
  32211. set(key: string, value: T): boolean;
  32212. /**
  32213. * Get the element of the given key and remove it from the dictionary
  32214. * @param key defines the key to search
  32215. * @returns the value associated with the key or null if not found
  32216. */
  32217. getAndRemove(key: string): Nullable<T>;
  32218. /**
  32219. * Remove a key/value from the dictionary.
  32220. * @param key the key to remove
  32221. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32222. */
  32223. remove(key: string): boolean;
  32224. /**
  32225. * Clear the whole content of the dictionary
  32226. */
  32227. clear(): void;
  32228. /**
  32229. * Gets the current count
  32230. */
  32231. readonly count: number;
  32232. /**
  32233. * Execute a callback on each key/val of the dictionary.
  32234. * Note that you can remove any element in this dictionary in the callback implementation
  32235. * @param callback the callback to execute on a given key/value pair
  32236. */
  32237. forEach(callback: (key: string, val: T) => void): void;
  32238. /**
  32239. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32240. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32241. * Note that you can remove any element in this dictionary in the callback implementation
  32242. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32243. * @returns the first item
  32244. */
  32245. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32246. private _count;
  32247. private _data;
  32248. }
  32249. }
  32250. declare module BABYLON {
  32251. /** @hidden */
  32252. export interface ICollisionCoordinator {
  32253. createCollider(): Collider;
  32254. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32255. init(scene: Scene): void;
  32256. }
  32257. /** @hidden */
  32258. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32259. private _scene;
  32260. private _scaledPosition;
  32261. private _scaledVelocity;
  32262. private _finalPosition;
  32263. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32264. createCollider(): Collider;
  32265. init(scene: Scene): void;
  32266. private _collideWithWorld;
  32267. }
  32268. }
  32269. declare module BABYLON {
  32270. /**
  32271. * Class used to manage all inputs for the scene.
  32272. */
  32273. export class InputManager {
  32274. /** The distance in pixel that you have to move to prevent some events */
  32275. static DragMovementThreshold: number;
  32276. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32277. static LongPressDelay: number;
  32278. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32279. static DoubleClickDelay: number;
  32280. /** If you need to check double click without raising a single click at first click, enable this flag */
  32281. static ExclusiveDoubleClickMode: boolean;
  32282. private _wheelEventName;
  32283. private _onPointerMove;
  32284. private _onPointerDown;
  32285. private _onPointerUp;
  32286. private _initClickEvent;
  32287. private _initActionManager;
  32288. private _delayedSimpleClick;
  32289. private _delayedSimpleClickTimeout;
  32290. private _previousDelayedSimpleClickTimeout;
  32291. private _meshPickProceed;
  32292. private _previousButtonPressed;
  32293. private _currentPickResult;
  32294. private _previousPickResult;
  32295. private _totalPointersPressed;
  32296. private _doubleClickOccured;
  32297. private _pointerOverMesh;
  32298. private _pickedDownMesh;
  32299. private _pickedUpMesh;
  32300. private _pointerX;
  32301. private _pointerY;
  32302. private _unTranslatedPointerX;
  32303. private _unTranslatedPointerY;
  32304. private _startingPointerPosition;
  32305. private _previousStartingPointerPosition;
  32306. private _startingPointerTime;
  32307. private _previousStartingPointerTime;
  32308. private _pointerCaptures;
  32309. private _onKeyDown;
  32310. private _onKeyUp;
  32311. private _onCanvasFocusObserver;
  32312. private _onCanvasBlurObserver;
  32313. private _scene;
  32314. /**
  32315. * Creates a new InputManager
  32316. * @param scene defines the hosting scene
  32317. */
  32318. constructor(scene: Scene);
  32319. /**
  32320. * Gets the mesh that is currently under the pointer
  32321. */
  32322. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32323. /**
  32324. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32325. */
  32326. readonly unTranslatedPointer: Vector2;
  32327. /**
  32328. * Gets or sets the current on-screen X position of the pointer
  32329. */
  32330. pointerX: number;
  32331. /**
  32332. * Gets or sets the current on-screen Y position of the pointer
  32333. */
  32334. pointerY: number;
  32335. private _updatePointerPosition;
  32336. private _processPointerMove;
  32337. private _setRayOnPointerInfo;
  32338. private _checkPrePointerObservable;
  32339. /**
  32340. * Use this method to simulate a pointer move on a mesh
  32341. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32342. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32343. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32344. */
  32345. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32346. /**
  32347. * Use this method to simulate a pointer down on a mesh
  32348. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32349. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32350. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32351. */
  32352. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32353. private _processPointerDown;
  32354. /** @hidden */ private _isPointerSwiping(): boolean;
  32355. /**
  32356. * Use this method to simulate a pointer up on a mesh
  32357. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32358. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32359. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32360. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32361. */
  32362. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32363. private _processPointerUp;
  32364. /**
  32365. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32366. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32367. * @returns true if the pointer was captured
  32368. */
  32369. isPointerCaptured(pointerId?: number): boolean;
  32370. /**
  32371. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32372. * @param attachUp defines if you want to attach events to pointerup
  32373. * @param attachDown defines if you want to attach events to pointerdown
  32374. * @param attachMove defines if you want to attach events to pointermove
  32375. */
  32376. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32377. /**
  32378. * Detaches all event handlers
  32379. */
  32380. detachControl(): void;
  32381. /**
  32382. * Force the value of meshUnderPointer
  32383. * @param mesh defines the mesh to use
  32384. */
  32385. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32386. /**
  32387. * Gets the mesh under the pointer
  32388. * @returns a Mesh or null if no mesh is under the pointer
  32389. */
  32390. getPointerOverMesh(): Nullable<AbstractMesh>;
  32391. }
  32392. }
  32393. declare module BABYLON {
  32394. /**
  32395. * Helper class used to generate session unique ID
  32396. */
  32397. export class UniqueIdGenerator {
  32398. private static _UniqueIdCounter;
  32399. /**
  32400. * Gets an unique (relatively to the current scene) Id
  32401. */
  32402. static readonly UniqueId: number;
  32403. }
  32404. }
  32405. declare module BABYLON {
  32406. /**
  32407. * This class defines the direct association between an animation and a target
  32408. */
  32409. export class TargetedAnimation {
  32410. /**
  32411. * Animation to perform
  32412. */
  32413. animation: Animation;
  32414. /**
  32415. * Target to animate
  32416. */
  32417. target: any;
  32418. /**
  32419. * Serialize the object
  32420. * @returns the JSON object representing the current entity
  32421. */
  32422. serialize(): any;
  32423. }
  32424. /**
  32425. * Use this class to create coordinated animations on multiple targets
  32426. */
  32427. export class AnimationGroup implements IDisposable {
  32428. /** The name of the animation group */
  32429. name: string;
  32430. private _scene;
  32431. private _targetedAnimations;
  32432. private _animatables;
  32433. private _from;
  32434. private _to;
  32435. private _isStarted;
  32436. private _isPaused;
  32437. private _speedRatio;
  32438. private _loopAnimation;
  32439. /**
  32440. * Gets or sets the unique id of the node
  32441. */
  32442. uniqueId: number;
  32443. /**
  32444. * This observable will notify when one animation have ended
  32445. */
  32446. onAnimationEndObservable: Observable<TargetedAnimation>;
  32447. /**
  32448. * Observer raised when one animation loops
  32449. */
  32450. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32451. /**
  32452. * Observer raised when all animations have looped
  32453. */
  32454. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  32455. /**
  32456. * This observable will notify when all animations have ended.
  32457. */
  32458. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32459. /**
  32460. * This observable will notify when all animations have paused.
  32461. */
  32462. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32463. /**
  32464. * This observable will notify when all animations are playing.
  32465. */
  32466. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32467. /**
  32468. * Gets the first frame
  32469. */
  32470. readonly from: number;
  32471. /**
  32472. * Gets the last frame
  32473. */
  32474. readonly to: number;
  32475. /**
  32476. * Define if the animations are started
  32477. */
  32478. readonly isStarted: boolean;
  32479. /**
  32480. * Gets a value indicating that the current group is playing
  32481. */
  32482. readonly isPlaying: boolean;
  32483. /**
  32484. * Gets or sets the speed ratio to use for all animations
  32485. */
  32486. /**
  32487. * Gets or sets the speed ratio to use for all animations
  32488. */
  32489. speedRatio: number;
  32490. /**
  32491. * Gets or sets if all animations should loop or not
  32492. */
  32493. loopAnimation: boolean;
  32494. /**
  32495. * Gets the targeted animations for this animation group
  32496. */
  32497. readonly targetedAnimations: Array<TargetedAnimation>;
  32498. /**
  32499. * returning the list of animatables controlled by this animation group.
  32500. */
  32501. readonly animatables: Array<Animatable>;
  32502. /**
  32503. * Instantiates a new Animation Group.
  32504. * This helps managing several animations at once.
  32505. * @see http://doc.babylonjs.com/how_to/group
  32506. * @param name Defines the name of the group
  32507. * @param scene Defines the scene the group belongs to
  32508. */
  32509. constructor(
  32510. /** The name of the animation group */
  32511. name: string, scene?: Nullable<Scene>);
  32512. /**
  32513. * Add an animation (with its target) in the group
  32514. * @param animation defines the animation we want to add
  32515. * @param target defines the target of the animation
  32516. * @returns the TargetedAnimation object
  32517. */
  32518. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32519. /**
  32520. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32521. * It can add constant keys at begin or end
  32522. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32523. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32524. * @returns the animation group
  32525. */
  32526. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32527. private _animationLoopCount;
  32528. private _animationLoopFlags;
  32529. private _processLoop;
  32530. /**
  32531. * Start all animations on given targets
  32532. * @param loop defines if animations must loop
  32533. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32534. * @param from defines the from key (optional)
  32535. * @param to defines the to key (optional)
  32536. * @returns the current animation group
  32537. */
  32538. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32539. /**
  32540. * Pause all animations
  32541. * @returns the animation group
  32542. */
  32543. pause(): AnimationGroup;
  32544. /**
  32545. * Play all animations to initial state
  32546. * This function will start() the animations if they were not started or will restart() them if they were paused
  32547. * @param loop defines if animations must loop
  32548. * @returns the animation group
  32549. */
  32550. play(loop?: boolean): AnimationGroup;
  32551. /**
  32552. * Reset all animations to initial state
  32553. * @returns the animation group
  32554. */
  32555. reset(): AnimationGroup;
  32556. /**
  32557. * Restart animations from key 0
  32558. * @returns the animation group
  32559. */
  32560. restart(): AnimationGroup;
  32561. /**
  32562. * Stop all animations
  32563. * @returns the animation group
  32564. */
  32565. stop(): AnimationGroup;
  32566. /**
  32567. * Set animation weight for all animatables
  32568. * @param weight defines the weight to use
  32569. * @return the animationGroup
  32570. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32571. */
  32572. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32573. /**
  32574. * Synchronize and normalize all animatables with a source animatable
  32575. * @param root defines the root animatable to synchronize with
  32576. * @return the animationGroup
  32577. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32578. */
  32579. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32580. /**
  32581. * Goes to a specific frame in this animation group
  32582. * @param frame the frame number to go to
  32583. * @return the animationGroup
  32584. */
  32585. goToFrame(frame: number): AnimationGroup;
  32586. /**
  32587. * Dispose all associated resources
  32588. */
  32589. dispose(): void;
  32590. private _checkAnimationGroupEnded;
  32591. /**
  32592. * Clone the current animation group and returns a copy
  32593. * @param newName defines the name of the new group
  32594. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32595. * @returns the new aniamtion group
  32596. */
  32597. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32598. /**
  32599. * Serializes the animationGroup to an object
  32600. * @returns Serialized object
  32601. */
  32602. serialize(): any;
  32603. /**
  32604. * Returns a new AnimationGroup object parsed from the source provided.
  32605. * @param parsedAnimationGroup defines the source
  32606. * @param scene defines the scene that will receive the animationGroup
  32607. * @returns a new AnimationGroup
  32608. */
  32609. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32610. /**
  32611. * Returns the string "AnimationGroup"
  32612. * @returns "AnimationGroup"
  32613. */
  32614. getClassName(): string;
  32615. /**
  32616. * Creates a detailled string about the object
  32617. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32618. * @returns a string representing the object
  32619. */
  32620. toString(fullDetails?: boolean): string;
  32621. }
  32622. }
  32623. declare module BABYLON {
  32624. /**
  32625. * Define an interface for all classes that will hold resources
  32626. */
  32627. export interface IDisposable {
  32628. /**
  32629. * Releases all held resources
  32630. */
  32631. dispose(): void;
  32632. }
  32633. /** Interface defining initialization parameters for Scene class */
  32634. export interface SceneOptions {
  32635. /**
  32636. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32637. * It will improve performance when the number of geometries becomes important.
  32638. */
  32639. useGeometryUniqueIdsMap?: boolean;
  32640. /**
  32641. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32642. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32643. */
  32644. useMaterialMeshMap?: boolean;
  32645. /**
  32646. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32647. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32648. */
  32649. useClonedMeshhMap?: boolean;
  32650. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32651. virtual?: boolean;
  32652. }
  32653. /**
  32654. * Represents a scene to be rendered by the engine.
  32655. * @see http://doc.babylonjs.com/features/scene
  32656. */
  32657. export class Scene extends AbstractScene implements IAnimatable {
  32658. /** The fog is deactivated */
  32659. static readonly FOGMODE_NONE: number;
  32660. /** The fog density is following an exponential function */
  32661. static readonly FOGMODE_EXP: number;
  32662. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32663. static readonly FOGMODE_EXP2: number;
  32664. /** The fog density is following a linear function. */
  32665. static readonly FOGMODE_LINEAR: number;
  32666. /**
  32667. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32668. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32669. */
  32670. static MinDeltaTime: number;
  32671. /**
  32672. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32673. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32674. */
  32675. static MaxDeltaTime: number;
  32676. /**
  32677. * Factory used to create the default material.
  32678. * @param name The name of the material to create
  32679. * @param scene The scene to create the material for
  32680. * @returns The default material
  32681. */
  32682. static DefaultMaterialFactory(scene: Scene): Material;
  32683. /**
  32684. * Factory used to create the a collision coordinator.
  32685. * @returns The collision coordinator
  32686. */
  32687. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32688. /** @hidden */ private _inputManager: InputManager;
  32689. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32690. cameraToUseForPointers: Nullable<Camera>;
  32691. /** @hidden */ protected readonly _isScene: boolean;
  32692. /**
  32693. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32694. */
  32695. autoClear: boolean;
  32696. /**
  32697. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32698. */
  32699. autoClearDepthAndStencil: boolean;
  32700. /**
  32701. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32702. */
  32703. clearColor: Color4;
  32704. /**
  32705. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32706. */
  32707. ambientColor: Color3;
  32708. /**
  32709. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32710. * It should only be one of the following (if not the default embedded one):
  32711. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32712. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32713. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32714. * The material properties need to be setup according to the type of texture in use.
  32715. */
  32716. environmentBRDFTexture: BaseTexture;
  32717. /** @hidden */
  32718. protected _environmentTexture: Nullable<BaseTexture>;
  32719. /**
  32720. * Texture used in all pbr material as the reflection texture.
  32721. * As in the majority of the scene they are the same (exception for multi room and so on),
  32722. * this is easier to reference from here than from all the materials.
  32723. */
  32724. /**
  32725. * Texture used in all pbr material as the reflection texture.
  32726. * As in the majority of the scene they are the same (exception for multi room and so on),
  32727. * this is easier to set here than in all the materials.
  32728. */
  32729. environmentTexture: Nullable<BaseTexture>;
  32730. /** @hidden */
  32731. protected _environmentIntensity: number;
  32732. /**
  32733. * Intensity of the environment in all pbr material.
  32734. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32735. * As in the majority of the scene they are the same (exception for multi room and so on),
  32736. * this is easier to reference from here than from all the materials.
  32737. */
  32738. /**
  32739. * Intensity of the environment in all pbr material.
  32740. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32741. * As in the majority of the scene they are the same (exception for multi room and so on),
  32742. * this is easier to set here than in all the materials.
  32743. */
  32744. environmentIntensity: number;
  32745. /** @hidden */
  32746. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32747. /**
  32748. * Default image processing configuration used either in the rendering
  32749. * Forward main pass or through the imageProcessingPostProcess if present.
  32750. * As in the majority of the scene they are the same (exception for multi camera),
  32751. * this is easier to reference from here than from all the materials and post process.
  32752. *
  32753. * No setter as we it is a shared configuration, you can set the values instead.
  32754. */
  32755. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32756. private _forceWireframe;
  32757. /**
  32758. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32759. */
  32760. forceWireframe: boolean;
  32761. private _forcePointsCloud;
  32762. /**
  32763. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32764. */
  32765. forcePointsCloud: boolean;
  32766. /**
  32767. * Gets or sets the active clipplane 1
  32768. */
  32769. clipPlane: Nullable<Plane>;
  32770. /**
  32771. * Gets or sets the active clipplane 2
  32772. */
  32773. clipPlane2: Nullable<Plane>;
  32774. /**
  32775. * Gets or sets the active clipplane 3
  32776. */
  32777. clipPlane3: Nullable<Plane>;
  32778. /**
  32779. * Gets or sets the active clipplane 4
  32780. */
  32781. clipPlane4: Nullable<Plane>;
  32782. /**
  32783. * Gets or sets a boolean indicating if animations are enabled
  32784. */
  32785. animationsEnabled: boolean;
  32786. private _animationPropertiesOverride;
  32787. /**
  32788. * Gets or sets the animation properties override
  32789. */
  32790. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32791. /**
  32792. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32793. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32794. */
  32795. useConstantAnimationDeltaTime: boolean;
  32796. /**
  32797. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32798. * Please note that it requires to run a ray cast through the scene on every frame
  32799. */
  32800. constantlyUpdateMeshUnderPointer: boolean;
  32801. /**
  32802. * Defines the HTML cursor to use when hovering over interactive elements
  32803. */
  32804. hoverCursor: string;
  32805. /**
  32806. * Defines the HTML default cursor to use (empty by default)
  32807. */
  32808. defaultCursor: string;
  32809. /**
  32810. * Defines wether cursors are handled by the scene.
  32811. */
  32812. doNotHandleCursors: boolean;
  32813. /**
  32814. * This is used to call preventDefault() on pointer down
  32815. * in order to block unwanted artifacts like system double clicks
  32816. */
  32817. preventDefaultOnPointerDown: boolean;
  32818. /**
  32819. * This is used to call preventDefault() on pointer up
  32820. * in order to block unwanted artifacts like system double clicks
  32821. */
  32822. preventDefaultOnPointerUp: boolean;
  32823. /**
  32824. * Gets or sets user defined metadata
  32825. */
  32826. metadata: any;
  32827. /**
  32828. * For internal use only. Please do not use.
  32829. */
  32830. reservedDataStore: any;
  32831. /**
  32832. * Gets the name of the plugin used to load this scene (null by default)
  32833. */
  32834. loadingPluginName: string;
  32835. /**
  32836. * Use this array to add regular expressions used to disable offline support for specific urls
  32837. */
  32838. disableOfflineSupportExceptionRules: RegExp[];
  32839. /**
  32840. * An event triggered when the scene is disposed.
  32841. */
  32842. onDisposeObservable: Observable<Scene>;
  32843. private _onDisposeObserver;
  32844. /** Sets a function to be executed when this scene is disposed. */
  32845. onDispose: () => void;
  32846. /**
  32847. * An event triggered before rendering the scene (right after animations and physics)
  32848. */
  32849. onBeforeRenderObservable: Observable<Scene>;
  32850. private _onBeforeRenderObserver;
  32851. /** Sets a function to be executed before rendering this scene */
  32852. beforeRender: Nullable<() => void>;
  32853. /**
  32854. * An event triggered after rendering the scene
  32855. */
  32856. onAfterRenderObservable: Observable<Scene>;
  32857. /**
  32858. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32859. */
  32860. onAfterRenderCameraObservable: Observable<Camera>;
  32861. private _onAfterRenderObserver;
  32862. /** Sets a function to be executed after rendering this scene */
  32863. afterRender: Nullable<() => void>;
  32864. /**
  32865. * An event triggered before animating the scene
  32866. */
  32867. onBeforeAnimationsObservable: Observable<Scene>;
  32868. /**
  32869. * An event triggered after animations processing
  32870. */
  32871. onAfterAnimationsObservable: Observable<Scene>;
  32872. /**
  32873. * An event triggered before draw calls are ready to be sent
  32874. */
  32875. onBeforeDrawPhaseObservable: Observable<Scene>;
  32876. /**
  32877. * An event triggered after draw calls have been sent
  32878. */
  32879. onAfterDrawPhaseObservable: Observable<Scene>;
  32880. /**
  32881. * An event triggered when the scene is ready
  32882. */
  32883. onReadyObservable: Observable<Scene>;
  32884. /**
  32885. * An event triggered before rendering a camera
  32886. */
  32887. onBeforeCameraRenderObservable: Observable<Camera>;
  32888. private _onBeforeCameraRenderObserver;
  32889. /** Sets a function to be executed before rendering a camera*/
  32890. beforeCameraRender: () => void;
  32891. /**
  32892. * An event triggered after rendering a camera
  32893. */
  32894. onAfterCameraRenderObservable: Observable<Camera>;
  32895. private _onAfterCameraRenderObserver;
  32896. /** Sets a function to be executed after rendering a camera*/
  32897. afterCameraRender: () => void;
  32898. /**
  32899. * An event triggered when active meshes evaluation is about to start
  32900. */
  32901. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32902. /**
  32903. * An event triggered when active meshes evaluation is done
  32904. */
  32905. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32906. /**
  32907. * An event triggered when particles rendering is about to start
  32908. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32909. */
  32910. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32911. /**
  32912. * An event triggered when particles rendering is done
  32913. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32914. */
  32915. onAfterParticlesRenderingObservable: Observable<Scene>;
  32916. /**
  32917. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32918. */
  32919. onDataLoadedObservable: Observable<Scene>;
  32920. /**
  32921. * An event triggered when a camera is created
  32922. */
  32923. onNewCameraAddedObservable: Observable<Camera>;
  32924. /**
  32925. * An event triggered when a camera is removed
  32926. */
  32927. onCameraRemovedObservable: Observable<Camera>;
  32928. /**
  32929. * An event triggered when a light is created
  32930. */
  32931. onNewLightAddedObservable: Observable<Light>;
  32932. /**
  32933. * An event triggered when a light is removed
  32934. */
  32935. onLightRemovedObservable: Observable<Light>;
  32936. /**
  32937. * An event triggered when a geometry is created
  32938. */
  32939. onNewGeometryAddedObservable: Observable<Geometry>;
  32940. /**
  32941. * An event triggered when a geometry is removed
  32942. */
  32943. onGeometryRemovedObservable: Observable<Geometry>;
  32944. /**
  32945. * An event triggered when a transform node is created
  32946. */
  32947. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32948. /**
  32949. * An event triggered when a transform node is removed
  32950. */
  32951. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32952. /**
  32953. * An event triggered when a mesh is created
  32954. */
  32955. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32956. /**
  32957. * An event triggered when a mesh is removed
  32958. */
  32959. onMeshRemovedObservable: Observable<AbstractMesh>;
  32960. /**
  32961. * An event triggered when a skeleton is created
  32962. */
  32963. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32964. /**
  32965. * An event triggered when a skeleton is removed
  32966. */
  32967. onSkeletonRemovedObservable: Observable<Skeleton>;
  32968. /**
  32969. * An event triggered when a material is created
  32970. */
  32971. onNewMaterialAddedObservable: Observable<Material>;
  32972. /**
  32973. * An event triggered when a material is removed
  32974. */
  32975. onMaterialRemovedObservable: Observable<Material>;
  32976. /**
  32977. * An event triggered when a texture is created
  32978. */
  32979. onNewTextureAddedObservable: Observable<BaseTexture>;
  32980. /**
  32981. * An event triggered when a texture is removed
  32982. */
  32983. onTextureRemovedObservable: Observable<BaseTexture>;
  32984. /**
  32985. * An event triggered when render targets are about to be rendered
  32986. * Can happen multiple times per frame.
  32987. */
  32988. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32989. /**
  32990. * An event triggered when render targets were rendered.
  32991. * Can happen multiple times per frame.
  32992. */
  32993. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32994. /**
  32995. * An event triggered before calculating deterministic simulation step
  32996. */
  32997. onBeforeStepObservable: Observable<Scene>;
  32998. /**
  32999. * An event triggered after calculating deterministic simulation step
  33000. */
  33001. onAfterStepObservable: Observable<Scene>;
  33002. /**
  33003. * An event triggered when the activeCamera property is updated
  33004. */
  33005. onActiveCameraChanged: Observable<Scene>;
  33006. /**
  33007. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33008. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33009. * 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)
  33010. */
  33011. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33012. /**
  33013. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33014. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33015. * 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)
  33016. */
  33017. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33018. /**
  33019. * This Observable will when a mesh has been imported into the scene.
  33020. */
  33021. onMeshImportedObservable: Observable<AbstractMesh>;
  33022. /**
  33023. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33024. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33025. */
  33026. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33027. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33028. /**
  33029. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33030. */
  33031. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33032. /**
  33033. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33034. */
  33035. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33036. /**
  33037. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33038. */
  33039. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33040. /** Callback called when a pointer move is detected */
  33041. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33042. /** Callback called when a pointer down is detected */
  33043. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33044. /** Callback called when a pointer up is detected */
  33045. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33046. /** Callback called when a pointer pick is detected */
  33047. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33048. /**
  33049. * 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).
  33050. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33051. */
  33052. onPrePointerObservable: Observable<PointerInfoPre>;
  33053. /**
  33054. * Observable event triggered each time an input event is received from the rendering canvas
  33055. */
  33056. onPointerObservable: Observable<PointerInfo>;
  33057. /**
  33058. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33059. */
  33060. readonly unTranslatedPointer: Vector2;
  33061. /**
  33062. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33063. */
  33064. static DragMovementThreshold: number;
  33065. /**
  33066. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33067. */
  33068. static LongPressDelay: number;
  33069. /**
  33070. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33071. */
  33072. static DoubleClickDelay: number;
  33073. /** If you need to check double click without raising a single click at first click, enable this flag */
  33074. static ExclusiveDoubleClickMode: boolean;
  33075. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  33076. /**
  33077. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33078. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33079. */
  33080. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33081. /**
  33082. * Observable event triggered each time an keyboard event is received from the hosting window
  33083. */
  33084. onKeyboardObservable: Observable<KeyboardInfo>;
  33085. private _useRightHandedSystem;
  33086. /**
  33087. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33088. */
  33089. useRightHandedSystem: boolean;
  33090. private _timeAccumulator;
  33091. private _currentStepId;
  33092. private _currentInternalStep;
  33093. /**
  33094. * Sets the step Id used by deterministic lock step
  33095. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33096. * @param newStepId defines the step Id
  33097. */
  33098. setStepId(newStepId: number): void;
  33099. /**
  33100. * Gets the step Id used by deterministic lock step
  33101. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33102. * @returns the step Id
  33103. */
  33104. getStepId(): number;
  33105. /**
  33106. * Gets the internal step used by deterministic lock step
  33107. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33108. * @returns the internal step
  33109. */
  33110. getInternalStep(): number;
  33111. private _fogEnabled;
  33112. /**
  33113. * Gets or sets a boolean indicating if fog is enabled on this scene
  33114. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33115. * (Default is true)
  33116. */
  33117. fogEnabled: boolean;
  33118. private _fogMode;
  33119. /**
  33120. * Gets or sets the fog mode to use
  33121. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33122. * | mode | value |
  33123. * | --- | --- |
  33124. * | FOGMODE_NONE | 0 |
  33125. * | FOGMODE_EXP | 1 |
  33126. * | FOGMODE_EXP2 | 2 |
  33127. * | FOGMODE_LINEAR | 3 |
  33128. */
  33129. fogMode: number;
  33130. /**
  33131. * Gets or sets the fog color to use
  33132. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33133. * (Default is Color3(0.2, 0.2, 0.3))
  33134. */
  33135. fogColor: Color3;
  33136. /**
  33137. * Gets or sets the fog density to use
  33138. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33139. * (Default is 0.1)
  33140. */
  33141. fogDensity: number;
  33142. /**
  33143. * Gets or sets the fog start distance to use
  33144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33145. * (Default is 0)
  33146. */
  33147. fogStart: number;
  33148. /**
  33149. * Gets or sets the fog end distance to use
  33150. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33151. * (Default is 1000)
  33152. */
  33153. fogEnd: number;
  33154. private _shadowsEnabled;
  33155. /**
  33156. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33157. */
  33158. shadowsEnabled: boolean;
  33159. private _lightsEnabled;
  33160. /**
  33161. * Gets or sets a boolean indicating if lights are enabled on this scene
  33162. */
  33163. lightsEnabled: boolean;
  33164. /** All of the active cameras added to this scene. */
  33165. activeCameras: Camera[];
  33166. /** @hidden */ private _activeCamera: Nullable<Camera>;
  33167. /** Gets or sets the current active camera */
  33168. activeCamera: Nullable<Camera>;
  33169. private _defaultMaterial;
  33170. /** The default material used on meshes when no material is affected */
  33171. /** The default material used on meshes when no material is affected */
  33172. defaultMaterial: Material;
  33173. private _texturesEnabled;
  33174. /**
  33175. * Gets or sets a boolean indicating if textures are enabled on this scene
  33176. */
  33177. texturesEnabled: boolean;
  33178. /**
  33179. * Gets or sets a boolean indicating if particles are enabled on this scene
  33180. */
  33181. particlesEnabled: boolean;
  33182. /**
  33183. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33184. */
  33185. spritesEnabled: boolean;
  33186. private _skeletonsEnabled;
  33187. /**
  33188. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33189. */
  33190. skeletonsEnabled: boolean;
  33191. /**
  33192. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33193. */
  33194. lensFlaresEnabled: boolean;
  33195. /**
  33196. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33198. */
  33199. collisionsEnabled: boolean;
  33200. private _collisionCoordinator;
  33201. /** @hidden */
  33202. readonly collisionCoordinator: ICollisionCoordinator;
  33203. /**
  33204. * Defines the gravity applied to this scene (used only for collisions)
  33205. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33206. */
  33207. gravity: Vector3;
  33208. /**
  33209. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33210. */
  33211. postProcessesEnabled: boolean;
  33212. /**
  33213. * The list of postprocesses added to the scene
  33214. */
  33215. postProcesses: PostProcess[];
  33216. /**
  33217. * Gets the current postprocess manager
  33218. */
  33219. postProcessManager: PostProcessManager;
  33220. /**
  33221. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33222. */
  33223. renderTargetsEnabled: boolean;
  33224. /**
  33225. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33226. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33227. */
  33228. dumpNextRenderTargets: boolean;
  33229. /**
  33230. * The list of user defined render targets added to the scene
  33231. */
  33232. customRenderTargets: RenderTargetTexture[];
  33233. /**
  33234. * Defines if texture loading must be delayed
  33235. * If true, textures will only be loaded when they need to be rendered
  33236. */
  33237. useDelayedTextureLoading: boolean;
  33238. /**
  33239. * Gets the list of meshes imported to the scene through SceneLoader
  33240. */
  33241. importedMeshesFiles: String[];
  33242. /**
  33243. * Gets or sets a boolean indicating if probes are enabled on this scene
  33244. */
  33245. probesEnabled: boolean;
  33246. /**
  33247. * Gets or sets the current offline provider to use to store scene data
  33248. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33249. */
  33250. offlineProvider: IOfflineProvider;
  33251. /**
  33252. * Gets or sets the action manager associated with the scene
  33253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33254. */
  33255. actionManager: AbstractActionManager;
  33256. private _meshesForIntersections;
  33257. /**
  33258. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33259. */
  33260. proceduralTexturesEnabled: boolean;
  33261. private _engine;
  33262. private _totalVertices;
  33263. /** @hidden */ private _activeIndices: PerfCounter;
  33264. /** @hidden */ private _activeParticles: PerfCounter;
  33265. /** @hidden */ private _activeBones: PerfCounter;
  33266. private _animationRatio;
  33267. /** @hidden */ private _animationTimeLast: number;
  33268. /** @hidden */ private _animationTime: number;
  33269. /**
  33270. * Gets or sets a general scale for animation speed
  33271. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33272. */
  33273. animationTimeScale: number;
  33274. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  33275. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  33276. /** @hidden */ private _cachedVisibility: Nullable<number>;
  33277. private _renderId;
  33278. private _frameId;
  33279. private _executeWhenReadyTimeoutId;
  33280. private _intermediateRendering;
  33281. private _viewUpdateFlag;
  33282. private _projectionUpdateFlag;
  33283. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  33284. private _activeRequests;
  33285. /** @hidden */ private _pendingData: any[];
  33286. private _isDisposed;
  33287. /**
  33288. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33289. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33290. */
  33291. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33292. private _activeMeshes;
  33293. private _processedMaterials;
  33294. private _renderTargets;
  33295. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  33296. private _activeSkeletons;
  33297. private _softwareSkinnedMeshes;
  33298. private _renderingManager;
  33299. /** @hidden */ private _activeAnimatables: Animatable[];
  33300. private _transformMatrix;
  33301. private _sceneUbo;
  33302. /** @hidden */ private _viewMatrix: Matrix;
  33303. private _projectionMatrix;
  33304. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  33305. /** @hidden */ private _frustumPlanes: Plane[];
  33306. /**
  33307. * Gets the list of frustum planes (built from the active camera)
  33308. */
  33309. readonly frustumPlanes: Plane[];
  33310. /**
  33311. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33312. * This is useful if there are more lights that the maximum simulteanous authorized
  33313. */
  33314. requireLightSorting: boolean;
  33315. /** @hidden */
  33316. readonly useMaterialMeshMap: boolean;
  33317. /** @hidden */
  33318. readonly useClonedMeshhMap: boolean;
  33319. private _externalData;
  33320. private _uid;
  33321. /**
  33322. * @hidden
  33323. * Backing store of defined scene components.
  33324. */ private _components: ISceneComponent[];
  33325. /**
  33326. * @hidden
  33327. * Backing store of defined scene components.
  33328. */ private _serializableComponents: ISceneSerializableComponent[];
  33329. /**
  33330. * List of components to register on the next registration step.
  33331. */
  33332. private _transientComponents;
  33333. /**
  33334. * Registers the transient components if needed.
  33335. */
  33336. private _registerTransientComponents;
  33337. /**
  33338. * @hidden
  33339. * Add a component to the scene.
  33340. * Note that the ccomponent could be registered on th next frame if this is called after
  33341. * the register component stage.
  33342. * @param component Defines the component to add to the scene
  33343. */ private _addComponent(component: ISceneComponent): void;
  33344. /**
  33345. * @hidden
  33346. * Gets a component from the scene.
  33347. * @param name defines the name of the component to retrieve
  33348. * @returns the component or null if not present
  33349. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  33350. /**
  33351. * @hidden
  33352. * Defines the actions happening before camera updates.
  33353. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33354. /**
  33355. * @hidden
  33356. * Defines the actions happening before clear the canvas.
  33357. */ private _beforeClearStage: Stage<SimpleStageAction>;
  33358. /**
  33359. * @hidden
  33360. * Defines the actions when collecting render targets for the frame.
  33361. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33362. /**
  33363. * @hidden
  33364. * Defines the actions happening for one camera in the frame.
  33365. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33366. /**
  33367. * @hidden
  33368. * Defines the actions happening during the per mesh ready checks.
  33369. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  33370. /**
  33371. * @hidden
  33372. * Defines the actions happening before evaluate active mesh checks.
  33373. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33374. /**
  33375. * @hidden
  33376. * Defines the actions happening during the evaluate sub mesh checks.
  33377. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33378. /**
  33379. * @hidden
  33380. * Defines the actions happening during the active mesh stage.
  33381. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  33382. /**
  33383. * @hidden
  33384. * Defines the actions happening during the per camera render target step.
  33385. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33386. /**
  33387. * @hidden
  33388. * Defines the actions happening just before the active camera is drawing.
  33389. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  33390. /**
  33391. * @hidden
  33392. * Defines the actions happening just before a render target is drawing.
  33393. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33394. /**
  33395. * @hidden
  33396. * Defines the actions happening just before a rendering group is drawing.
  33397. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33398. /**
  33399. * @hidden
  33400. * Defines the actions happening just before a mesh is drawing.
  33401. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33402. /**
  33403. * @hidden
  33404. * Defines the actions happening just after a mesh has been drawn.
  33405. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33406. /**
  33407. * @hidden
  33408. * Defines the actions happening just after a rendering group has been drawn.
  33409. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33410. /**
  33411. * @hidden
  33412. * Defines the actions happening just after the active camera has been drawn.
  33413. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  33414. /**
  33415. * @hidden
  33416. * Defines the actions happening just after a render target has been drawn.
  33417. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33418. /**
  33419. * @hidden
  33420. * Defines the actions happening just after rendering all cameras and computing intersections.
  33421. */ private _afterRenderStage: Stage<SimpleStageAction>;
  33422. /**
  33423. * @hidden
  33424. * Defines the actions happening when a pointer move event happens.
  33425. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  33426. /**
  33427. * @hidden
  33428. * Defines the actions happening when a pointer down event happens.
  33429. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  33430. /**
  33431. * @hidden
  33432. * Defines the actions happening when a pointer up event happens.
  33433. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  33434. /**
  33435. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33436. */
  33437. private geometriesByUniqueId;
  33438. /**
  33439. * Creates a new Scene
  33440. * @param engine defines the engine to use to render this scene
  33441. * @param options defines the scene options
  33442. */
  33443. constructor(engine: Engine, options?: SceneOptions);
  33444. /**
  33445. * Gets a string idenfifying the name of the class
  33446. * @returns "Scene" string
  33447. */
  33448. getClassName(): string;
  33449. private _defaultMeshCandidates;
  33450. /**
  33451. * @hidden
  33452. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33453. private _defaultSubMeshCandidates;
  33454. /**
  33455. * @hidden
  33456. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33457. /**
  33458. * Sets the default candidate providers for the scene.
  33459. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33460. * and getCollidingSubMeshCandidates to their default function
  33461. */
  33462. setDefaultCandidateProviders(): void;
  33463. /**
  33464. * Gets the mesh that is currently under the pointer
  33465. */
  33466. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33467. /**
  33468. * Gets or sets the current on-screen X position of the pointer
  33469. */
  33470. pointerX: number;
  33471. /**
  33472. * Gets or sets the current on-screen Y position of the pointer
  33473. */
  33474. pointerY: number;
  33475. /**
  33476. * Gets the cached material (ie. the latest rendered one)
  33477. * @returns the cached material
  33478. */
  33479. getCachedMaterial(): Nullable<Material>;
  33480. /**
  33481. * Gets the cached effect (ie. the latest rendered one)
  33482. * @returns the cached effect
  33483. */
  33484. getCachedEffect(): Nullable<Effect>;
  33485. /**
  33486. * Gets the cached visibility state (ie. the latest rendered one)
  33487. * @returns the cached visibility state
  33488. */
  33489. getCachedVisibility(): Nullable<number>;
  33490. /**
  33491. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33492. * @param material defines the current material
  33493. * @param effect defines the current effect
  33494. * @param visibility defines the current visibility state
  33495. * @returns true if one parameter is not cached
  33496. */
  33497. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33498. /**
  33499. * Gets the engine associated with the scene
  33500. * @returns an Engine
  33501. */
  33502. getEngine(): Engine;
  33503. /**
  33504. * Gets the total number of vertices rendered per frame
  33505. * @returns the total number of vertices rendered per frame
  33506. */
  33507. getTotalVertices(): number;
  33508. /**
  33509. * Gets the performance counter for total vertices
  33510. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33511. */
  33512. readonly totalVerticesPerfCounter: PerfCounter;
  33513. /**
  33514. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33515. * @returns the total number of active indices rendered per frame
  33516. */
  33517. getActiveIndices(): number;
  33518. /**
  33519. * Gets the performance counter for active indices
  33520. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33521. */
  33522. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33523. /**
  33524. * Gets the total number of active particles rendered per frame
  33525. * @returns the total number of active particles rendered per frame
  33526. */
  33527. getActiveParticles(): number;
  33528. /**
  33529. * Gets the performance counter for active particles
  33530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33531. */
  33532. readonly activeParticlesPerfCounter: PerfCounter;
  33533. /**
  33534. * Gets the total number of active bones rendered per frame
  33535. * @returns the total number of active bones rendered per frame
  33536. */
  33537. getActiveBones(): number;
  33538. /**
  33539. * Gets the performance counter for active bones
  33540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33541. */
  33542. readonly activeBonesPerfCounter: PerfCounter;
  33543. /**
  33544. * Gets the array of active meshes
  33545. * @returns an array of AbstractMesh
  33546. */
  33547. getActiveMeshes(): SmartArray<AbstractMesh>;
  33548. /**
  33549. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33550. * @returns a number
  33551. */
  33552. getAnimationRatio(): number;
  33553. /**
  33554. * Gets an unique Id for the current render phase
  33555. * @returns a number
  33556. */
  33557. getRenderId(): number;
  33558. /**
  33559. * Gets an unique Id for the current frame
  33560. * @returns a number
  33561. */
  33562. getFrameId(): number;
  33563. /** Call this function if you want to manually increment the render Id*/
  33564. incrementRenderId(): void;
  33565. private _createUbo;
  33566. /**
  33567. * Use this method to simulate a pointer move on a mesh
  33568. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33569. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33570. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33571. * @returns the current scene
  33572. */
  33573. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33574. /**
  33575. * Use this method to simulate a pointer down on a mesh
  33576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33579. * @returns the current scene
  33580. */
  33581. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33582. /**
  33583. * Use this method to simulate a pointer up on a mesh
  33584. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33585. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33586. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33587. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33588. * @returns the current scene
  33589. */
  33590. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33591. /**
  33592. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33593. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33594. * @returns true if the pointer was captured
  33595. */
  33596. isPointerCaptured(pointerId?: number): boolean;
  33597. /**
  33598. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33599. * @param attachUp defines if you want to attach events to pointerup
  33600. * @param attachDown defines if you want to attach events to pointerdown
  33601. * @param attachMove defines if you want to attach events to pointermove
  33602. */
  33603. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33604. /** Detaches all event handlers*/
  33605. detachControl(): void;
  33606. /**
  33607. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33608. * Delay loaded resources are not taking in account
  33609. * @return true if all required resources are ready
  33610. */
  33611. isReady(): boolean;
  33612. /** Resets all cached information relative to material (including effect and visibility) */
  33613. resetCachedMaterial(): void;
  33614. /**
  33615. * Registers a function to be called before every frame render
  33616. * @param func defines the function to register
  33617. */
  33618. registerBeforeRender(func: () => void): void;
  33619. /**
  33620. * Unregisters a function called before every frame render
  33621. * @param func defines the function to unregister
  33622. */
  33623. unregisterBeforeRender(func: () => void): void;
  33624. /**
  33625. * Registers a function to be called after every frame render
  33626. * @param func defines the function to register
  33627. */
  33628. registerAfterRender(func: () => void): void;
  33629. /**
  33630. * Unregisters a function called after every frame render
  33631. * @param func defines the function to unregister
  33632. */
  33633. unregisterAfterRender(func: () => void): void;
  33634. private _executeOnceBeforeRender;
  33635. /**
  33636. * The provided function will run before render once and will be disposed afterwards.
  33637. * A timeout delay can be provided so that the function will be executed in N ms.
  33638. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33639. * @param func The function to be executed.
  33640. * @param timeout optional delay in ms
  33641. */
  33642. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33643. /** @hidden */ private _addPendingData(data: any): void;
  33644. /** @hidden */ private _removePendingData(data: any): void;
  33645. /**
  33646. * Returns the number of items waiting to be loaded
  33647. * @returns the number of items waiting to be loaded
  33648. */
  33649. getWaitingItemsCount(): number;
  33650. /**
  33651. * Returns a boolean indicating if the scene is still loading data
  33652. */
  33653. readonly isLoading: boolean;
  33654. /**
  33655. * Registers a function to be executed when the scene is ready
  33656. * @param {Function} func - the function to be executed
  33657. */
  33658. executeWhenReady(func: () => void): void;
  33659. /**
  33660. * Returns a promise that resolves when the scene is ready
  33661. * @returns A promise that resolves when the scene is ready
  33662. */
  33663. whenReadyAsync(): Promise<void>;
  33664. /** @hidden */ private _checkIsReady(): void;
  33665. /**
  33666. * Gets all animatable attached to the scene
  33667. */
  33668. readonly animatables: Animatable[];
  33669. /**
  33670. * Resets the last animation time frame.
  33671. * Useful to override when animations start running when loading a scene for the first time.
  33672. */
  33673. resetLastAnimationTimeFrame(): void;
  33674. /**
  33675. * Gets the current view matrix
  33676. * @returns a Matrix
  33677. */
  33678. getViewMatrix(): Matrix;
  33679. /**
  33680. * Gets the current projection matrix
  33681. * @returns a Matrix
  33682. */
  33683. getProjectionMatrix(): Matrix;
  33684. /**
  33685. * Gets the current transform matrix
  33686. * @returns a Matrix made of View * Projection
  33687. */
  33688. getTransformMatrix(): Matrix;
  33689. /**
  33690. * Sets the current transform matrix
  33691. * @param viewL defines the View matrix to use
  33692. * @param projectionL defines the Projection matrix to use
  33693. * @param viewR defines the right View matrix to use (if provided)
  33694. * @param projectionR defines the right Projection matrix to use (if provided)
  33695. */
  33696. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33697. /**
  33698. * Gets the uniform buffer used to store scene data
  33699. * @returns a UniformBuffer
  33700. */
  33701. getSceneUniformBuffer(): UniformBuffer;
  33702. /**
  33703. * Gets an unique (relatively to the current scene) Id
  33704. * @returns an unique number for the scene
  33705. */
  33706. getUniqueId(): number;
  33707. /**
  33708. * Add a mesh to the list of scene's meshes
  33709. * @param newMesh defines the mesh to add
  33710. * @param recursive if all child meshes should also be added to the scene
  33711. */
  33712. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33713. /**
  33714. * Remove a mesh for the list of scene's meshes
  33715. * @param toRemove defines the mesh to remove
  33716. * @param recursive if all child meshes should also be removed from the scene
  33717. * @returns the index where the mesh was in the mesh list
  33718. */
  33719. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33720. /**
  33721. * Add a transform node to the list of scene's transform nodes
  33722. * @param newTransformNode defines the transform node to add
  33723. */
  33724. addTransformNode(newTransformNode: TransformNode): void;
  33725. /**
  33726. * Remove a transform node for the list of scene's transform nodes
  33727. * @param toRemove defines the transform node to remove
  33728. * @returns the index where the transform node was in the transform node list
  33729. */
  33730. removeTransformNode(toRemove: TransformNode): number;
  33731. /**
  33732. * Remove a skeleton for the list of scene's skeletons
  33733. * @param toRemove defines the skeleton to remove
  33734. * @returns the index where the skeleton was in the skeleton list
  33735. */
  33736. removeSkeleton(toRemove: Skeleton): number;
  33737. /**
  33738. * Remove a morph target for the list of scene's morph targets
  33739. * @param toRemove defines the morph target to remove
  33740. * @returns the index where the morph target was in the morph target list
  33741. */
  33742. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33743. /**
  33744. * Remove a light for the list of scene's lights
  33745. * @param toRemove defines the light to remove
  33746. * @returns the index where the light was in the light list
  33747. */
  33748. removeLight(toRemove: Light): number;
  33749. /**
  33750. * Remove a camera for the list of scene's cameras
  33751. * @param toRemove defines the camera to remove
  33752. * @returns the index where the camera was in the camera list
  33753. */
  33754. removeCamera(toRemove: Camera): number;
  33755. /**
  33756. * Remove a particle system for the list of scene's particle systems
  33757. * @param toRemove defines the particle system to remove
  33758. * @returns the index where the particle system was in the particle system list
  33759. */
  33760. removeParticleSystem(toRemove: IParticleSystem): number;
  33761. /**
  33762. * Remove a animation for the list of scene's animations
  33763. * @param toRemove defines the animation to remove
  33764. * @returns the index where the animation was in the animation list
  33765. */
  33766. removeAnimation(toRemove: Animation): number;
  33767. /**
  33768. * Will stop the animation of the given target
  33769. * @param target - the target
  33770. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33771. * @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)
  33772. */
  33773. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33774. /**
  33775. * Removes the given animation group from this scene.
  33776. * @param toRemove The animation group to remove
  33777. * @returns The index of the removed animation group
  33778. */
  33779. removeAnimationGroup(toRemove: AnimationGroup): number;
  33780. /**
  33781. * Removes the given multi-material from this scene.
  33782. * @param toRemove The multi-material to remove
  33783. * @returns The index of the removed multi-material
  33784. */
  33785. removeMultiMaterial(toRemove: MultiMaterial): number;
  33786. /**
  33787. * Removes the given material from this scene.
  33788. * @param toRemove The material to remove
  33789. * @returns The index of the removed material
  33790. */
  33791. removeMaterial(toRemove: Material): number;
  33792. /**
  33793. * Removes the given action manager from this scene.
  33794. * @param toRemove The action manager to remove
  33795. * @returns The index of the removed action manager
  33796. */
  33797. removeActionManager(toRemove: AbstractActionManager): number;
  33798. /**
  33799. * Removes the given texture from this scene.
  33800. * @param toRemove The texture to remove
  33801. * @returns The index of the removed texture
  33802. */
  33803. removeTexture(toRemove: BaseTexture): number;
  33804. /**
  33805. * Adds the given light to this scene
  33806. * @param newLight The light to add
  33807. */
  33808. addLight(newLight: Light): void;
  33809. /**
  33810. * Sorts the list list based on light priorities
  33811. */
  33812. sortLightsByPriority(): void;
  33813. /**
  33814. * Adds the given camera to this scene
  33815. * @param newCamera The camera to add
  33816. */
  33817. addCamera(newCamera: Camera): void;
  33818. /**
  33819. * Adds the given skeleton to this scene
  33820. * @param newSkeleton The skeleton to add
  33821. */
  33822. addSkeleton(newSkeleton: Skeleton): void;
  33823. /**
  33824. * Adds the given particle system to this scene
  33825. * @param newParticleSystem The particle system to add
  33826. */
  33827. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33828. /**
  33829. * Adds the given animation to this scene
  33830. * @param newAnimation The animation to add
  33831. */
  33832. addAnimation(newAnimation: Animation): void;
  33833. /**
  33834. * Adds the given animation group to this scene.
  33835. * @param newAnimationGroup The animation group to add
  33836. */
  33837. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33838. /**
  33839. * Adds the given multi-material to this scene
  33840. * @param newMultiMaterial The multi-material to add
  33841. */
  33842. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33843. /**
  33844. * Adds the given material to this scene
  33845. * @param newMaterial The material to add
  33846. */
  33847. addMaterial(newMaterial: Material): void;
  33848. /**
  33849. * Adds the given morph target to this scene
  33850. * @param newMorphTargetManager The morph target to add
  33851. */
  33852. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33853. /**
  33854. * Adds the given geometry to this scene
  33855. * @param newGeometry The geometry to add
  33856. */
  33857. addGeometry(newGeometry: Geometry): void;
  33858. /**
  33859. * Adds the given action manager to this scene
  33860. * @param newActionManager The action manager to add
  33861. */
  33862. addActionManager(newActionManager: AbstractActionManager): void;
  33863. /**
  33864. * Adds the given texture to this scene.
  33865. * @param newTexture The texture to add
  33866. */
  33867. addTexture(newTexture: BaseTexture): void;
  33868. /**
  33869. * Switch active camera
  33870. * @param newCamera defines the new active camera
  33871. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33872. */
  33873. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33874. /**
  33875. * sets the active camera of the scene using its ID
  33876. * @param id defines the camera's ID
  33877. * @return the new active camera or null if none found.
  33878. */
  33879. setActiveCameraByID(id: string): Nullable<Camera>;
  33880. /**
  33881. * sets the active camera of the scene using its name
  33882. * @param name defines the camera's name
  33883. * @returns the new active camera or null if none found.
  33884. */
  33885. setActiveCameraByName(name: string): Nullable<Camera>;
  33886. /**
  33887. * get an animation group using its name
  33888. * @param name defines the material's name
  33889. * @return the animation group or null if none found.
  33890. */
  33891. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33892. /**
  33893. * Get a material using its unique id
  33894. * @param uniqueId defines the material's unique id
  33895. * @return the material or null if none found.
  33896. */
  33897. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33898. /**
  33899. * get a material using its id
  33900. * @param id defines the material's ID
  33901. * @return the material or null if none found.
  33902. */
  33903. getMaterialByID(id: string): Nullable<Material>;
  33904. /**
  33905. * Gets a the last added material using a given id
  33906. * @param id defines the material's ID
  33907. * @return the last material with the given id or null if none found.
  33908. */
  33909. getLastMaterialByID(id: string): Nullable<Material>;
  33910. /**
  33911. * Gets a material using its name
  33912. * @param name defines the material's name
  33913. * @return the material or null if none found.
  33914. */
  33915. getMaterialByName(name: string): Nullable<Material>;
  33916. /**
  33917. * Get a texture using its unique id
  33918. * @param uniqueId defines the texture's unique id
  33919. * @return the texture or null if none found.
  33920. */
  33921. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33922. /**
  33923. * Gets a camera using its id
  33924. * @param id defines the id to look for
  33925. * @returns the camera or null if not found
  33926. */
  33927. getCameraByID(id: string): Nullable<Camera>;
  33928. /**
  33929. * Gets a camera using its unique id
  33930. * @param uniqueId defines the unique id to look for
  33931. * @returns the camera or null if not found
  33932. */
  33933. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33934. /**
  33935. * Gets a camera using its name
  33936. * @param name defines the camera's name
  33937. * @return the camera or null if none found.
  33938. */
  33939. getCameraByName(name: string): Nullable<Camera>;
  33940. /**
  33941. * Gets a bone using its id
  33942. * @param id defines the bone's id
  33943. * @return the bone or null if not found
  33944. */
  33945. getBoneByID(id: string): Nullable<Bone>;
  33946. /**
  33947. * Gets a bone using its id
  33948. * @param name defines the bone's name
  33949. * @return the bone or null if not found
  33950. */
  33951. getBoneByName(name: string): Nullable<Bone>;
  33952. /**
  33953. * Gets a light node using its name
  33954. * @param name defines the the light's name
  33955. * @return the light or null if none found.
  33956. */
  33957. getLightByName(name: string): Nullable<Light>;
  33958. /**
  33959. * Gets a light node using its id
  33960. * @param id defines the light's id
  33961. * @return the light or null if none found.
  33962. */
  33963. getLightByID(id: string): Nullable<Light>;
  33964. /**
  33965. * Gets a light node using its scene-generated unique ID
  33966. * @param uniqueId defines the light's unique id
  33967. * @return the light or null if none found.
  33968. */
  33969. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33970. /**
  33971. * Gets a particle system by id
  33972. * @param id defines the particle system id
  33973. * @return the corresponding system or null if none found
  33974. */
  33975. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33976. /**
  33977. * Gets a geometry using its ID
  33978. * @param id defines the geometry's id
  33979. * @return the geometry or null if none found.
  33980. */
  33981. getGeometryByID(id: string): Nullable<Geometry>;
  33982. private _getGeometryByUniqueID;
  33983. /**
  33984. * Add a new geometry to this scene
  33985. * @param geometry defines the geometry to be added to the scene.
  33986. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33987. * @return a boolean defining if the geometry was added or not
  33988. */
  33989. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33990. /**
  33991. * Removes an existing geometry
  33992. * @param geometry defines the geometry to be removed from the scene
  33993. * @return a boolean defining if the geometry was removed or not
  33994. */
  33995. removeGeometry(geometry: Geometry): boolean;
  33996. /**
  33997. * Gets the list of geometries attached to the scene
  33998. * @returns an array of Geometry
  33999. */
  34000. getGeometries(): Geometry[];
  34001. /**
  34002. * Gets the first added mesh found of a given ID
  34003. * @param id defines the id to search for
  34004. * @return the mesh found or null if not found at all
  34005. */
  34006. getMeshByID(id: string): Nullable<AbstractMesh>;
  34007. /**
  34008. * Gets a list of meshes using their id
  34009. * @param id defines the id to search for
  34010. * @returns a list of meshes
  34011. */
  34012. getMeshesByID(id: string): Array<AbstractMesh>;
  34013. /**
  34014. * Gets the first added transform node found of a given ID
  34015. * @param id defines the id to search for
  34016. * @return the found transform node or null if not found at all.
  34017. */
  34018. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34019. /**
  34020. * Gets a transform node with its auto-generated unique id
  34021. * @param uniqueId efines the unique id to search for
  34022. * @return the found transform node or null if not found at all.
  34023. */
  34024. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34025. /**
  34026. * Gets a list of transform nodes using their id
  34027. * @param id defines the id to search for
  34028. * @returns a list of transform nodes
  34029. */
  34030. getTransformNodesByID(id: string): Array<TransformNode>;
  34031. /**
  34032. * Gets a mesh with its auto-generated unique id
  34033. * @param uniqueId defines the unique id to search for
  34034. * @return the found mesh or null if not found at all.
  34035. */
  34036. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34037. /**
  34038. * Gets a the last added mesh using a given id
  34039. * @param id defines the id to search for
  34040. * @return the found mesh or null if not found at all.
  34041. */
  34042. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34043. /**
  34044. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34045. * @param id defines the id to search for
  34046. * @return the found node or null if not found at all
  34047. */
  34048. getLastEntryByID(id: string): Nullable<Node>;
  34049. /**
  34050. * Gets a node (Mesh, Camera, Light) using a given id
  34051. * @param id defines the id to search for
  34052. * @return the found node or null if not found at all
  34053. */
  34054. getNodeByID(id: string): Nullable<Node>;
  34055. /**
  34056. * Gets a node (Mesh, Camera, Light) using a given name
  34057. * @param name defines the name to search for
  34058. * @return the found node or null if not found at all.
  34059. */
  34060. getNodeByName(name: string): Nullable<Node>;
  34061. /**
  34062. * Gets a mesh using a given name
  34063. * @param name defines the name to search for
  34064. * @return the found mesh or null if not found at all.
  34065. */
  34066. getMeshByName(name: string): Nullable<AbstractMesh>;
  34067. /**
  34068. * Gets a transform node using a given name
  34069. * @param name defines the name to search for
  34070. * @return the found transform node or null if not found at all.
  34071. */
  34072. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34073. /**
  34074. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34075. * @param id defines the id to search for
  34076. * @return the found skeleton or null if not found at all.
  34077. */
  34078. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34079. /**
  34080. * Gets a skeleton using a given auto generated unique id
  34081. * @param uniqueId defines the unique id to search for
  34082. * @return the found skeleton or null if not found at all.
  34083. */
  34084. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34085. /**
  34086. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34087. * @param id defines the id to search for
  34088. * @return the found skeleton or null if not found at all.
  34089. */
  34090. getSkeletonById(id: string): Nullable<Skeleton>;
  34091. /**
  34092. * Gets a skeleton using a given name
  34093. * @param name defines the name to search for
  34094. * @return the found skeleton or null if not found at all.
  34095. */
  34096. getSkeletonByName(name: string): Nullable<Skeleton>;
  34097. /**
  34098. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34099. * @param id defines the id to search for
  34100. * @return the found morph target manager or null if not found at all.
  34101. */
  34102. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34103. /**
  34104. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34105. * @param id defines the id to search for
  34106. * @return the found morph target or null if not found at all.
  34107. */
  34108. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34109. /**
  34110. * Gets a boolean indicating if the given mesh is active
  34111. * @param mesh defines the mesh to look for
  34112. * @returns true if the mesh is in the active list
  34113. */
  34114. isActiveMesh(mesh: AbstractMesh): boolean;
  34115. /**
  34116. * Return a unique id as a string which can serve as an identifier for the scene
  34117. */
  34118. readonly uid: string;
  34119. /**
  34120. * Add an externaly attached data from its key.
  34121. * This method call will fail and return false, if such key already exists.
  34122. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34123. * @param key the unique key that identifies the data
  34124. * @param data the data object to associate to the key for this Engine instance
  34125. * @return true if no such key were already present and the data was added successfully, false otherwise
  34126. */
  34127. addExternalData<T>(key: string, data: T): boolean;
  34128. /**
  34129. * Get an externaly attached data from its key
  34130. * @param key the unique key that identifies the data
  34131. * @return the associated data, if present (can be null), or undefined if not present
  34132. */
  34133. getExternalData<T>(key: string): Nullable<T>;
  34134. /**
  34135. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34136. * @param key the unique key that identifies the data
  34137. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34138. * @return the associated data, can be null if the factory returned null.
  34139. */
  34140. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34141. /**
  34142. * Remove an externaly attached data from the Engine instance
  34143. * @param key the unique key that identifies the data
  34144. * @return true if the data was successfully removed, false if it doesn't exist
  34145. */
  34146. removeExternalData(key: string): boolean;
  34147. private _evaluateSubMesh;
  34148. /**
  34149. * Clear the processed materials smart array preventing retention point in material dispose.
  34150. */
  34151. freeProcessedMaterials(): void;
  34152. private _preventFreeActiveMeshesAndRenderingGroups;
  34153. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34154. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34155. * when disposing several meshes in a row or a hierarchy of meshes.
  34156. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34157. */
  34158. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34159. /**
  34160. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34161. */
  34162. freeActiveMeshes(): void;
  34163. /**
  34164. * Clear the info related to rendering groups preventing retention points during dispose.
  34165. */
  34166. freeRenderingGroups(): void;
  34167. /** @hidden */ private _isInIntermediateRendering(): boolean;
  34168. /**
  34169. * Lambda returning the list of potentially active meshes.
  34170. */
  34171. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34172. /**
  34173. * Lambda returning the list of potentially active sub meshes.
  34174. */
  34175. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34176. /**
  34177. * Lambda returning the list of potentially intersecting sub meshes.
  34178. */
  34179. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34180. /**
  34181. * Lambda returning the list of potentially colliding sub meshes.
  34182. */
  34183. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34184. private _activeMeshesFrozen;
  34185. private _skipEvaluateActiveMeshesCompletely;
  34186. /**
  34187. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34188. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  34189. * @returns the current scene
  34190. */
  34191. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  34192. /**
  34193. * Use this function to restart evaluating active meshes on every frame
  34194. * @returns the current scene
  34195. */
  34196. unfreezeActiveMeshes(): Scene;
  34197. private _evaluateActiveMeshes;
  34198. private _activeMesh;
  34199. /**
  34200. * Update the transform matrix to update from the current active camera
  34201. * @param force defines a boolean used to force the update even if cache is up to date
  34202. */
  34203. updateTransformMatrix(force?: boolean): void;
  34204. private _bindFrameBuffer;
  34205. /** @hidden */ private _allowPostProcessClearColor: boolean;
  34206. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34207. private _processSubCameras;
  34208. private _checkIntersections;
  34209. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  34210. /**
  34211. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34212. */
  34213. getDeterministicFrameTime: () => number;
  34214. /** @hidden */ private _animate(): void;
  34215. /** Execute all animations (for a frame) */
  34216. animate(): void;
  34217. /**
  34218. * Render the scene
  34219. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34220. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34221. */
  34222. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34223. /**
  34224. * Freeze all materials
  34225. * A frozen material will not be updatable but should be faster to render
  34226. */
  34227. freezeMaterials(): void;
  34228. /**
  34229. * Unfreeze all materials
  34230. * A frozen material will not be updatable but should be faster to render
  34231. */
  34232. unfreezeMaterials(): void;
  34233. /**
  34234. * Releases all held ressources
  34235. */
  34236. dispose(): void;
  34237. /**
  34238. * Gets if the scene is already disposed
  34239. */
  34240. readonly isDisposed: boolean;
  34241. /**
  34242. * Call this function to reduce memory footprint of the scene.
  34243. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34244. */
  34245. clearCachedVertexData(): void;
  34246. /**
  34247. * This function will remove the local cached buffer data from texture.
  34248. * It will save memory but will prevent the texture from being rebuilt
  34249. */
  34250. cleanCachedTextureBuffer(): void;
  34251. /**
  34252. * Get the world extend vectors with an optional filter
  34253. *
  34254. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34255. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34256. */
  34257. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34258. min: Vector3;
  34259. max: Vector3;
  34260. };
  34261. /**
  34262. * Creates a ray that can be used to pick in the scene
  34263. * @param x defines the x coordinate of the origin (on-screen)
  34264. * @param y defines the y coordinate of the origin (on-screen)
  34265. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34266. * @param camera defines the camera to use for the picking
  34267. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34268. * @returns a Ray
  34269. */
  34270. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34271. /**
  34272. * Creates a ray that can be used to pick in the scene
  34273. * @param x defines the x coordinate of the origin (on-screen)
  34274. * @param y defines the y coordinate of the origin (on-screen)
  34275. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34276. * @param result defines the ray where to store the picking ray
  34277. * @param camera defines the camera to use for the picking
  34278. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34279. * @returns the current scene
  34280. */
  34281. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34282. /**
  34283. * Creates a ray that can be used to pick in the scene
  34284. * @param x defines the x coordinate of the origin (on-screen)
  34285. * @param y defines the y coordinate of the origin (on-screen)
  34286. * @param camera defines the camera to use for the picking
  34287. * @returns a Ray
  34288. */
  34289. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34290. /**
  34291. * Creates a ray that can be used to pick in the scene
  34292. * @param x defines the x coordinate of the origin (on-screen)
  34293. * @param y defines the y coordinate of the origin (on-screen)
  34294. * @param result defines the ray where to store the picking ray
  34295. * @param camera defines the camera to use for the picking
  34296. * @returns the current scene
  34297. */
  34298. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34299. /** Launch a ray to try to pick a mesh in the scene
  34300. * @param x position on screen
  34301. * @param y position on screen
  34302. * @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
  34303. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34304. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34305. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34306. * @returns a PickingInfo
  34307. */
  34308. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34309. /** Use the given ray to pick a mesh in the scene
  34310. * @param ray The ray to use to pick meshes
  34311. * @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
  34312. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34313. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34314. * @returns a PickingInfo
  34315. */
  34316. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34317. /**
  34318. * Launch a ray to try to pick a mesh in the scene
  34319. * @param x X position on screen
  34320. * @param y Y position on screen
  34321. * @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
  34322. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34323. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34324. * @returns an array of PickingInfo
  34325. */
  34326. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34327. /**
  34328. * Launch a ray to try to pick a mesh in the scene
  34329. * @param ray Ray to use
  34330. * @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
  34331. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34332. * @returns an array of PickingInfo
  34333. */
  34334. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34335. /**
  34336. * Force the value of meshUnderPointer
  34337. * @param mesh defines the mesh to use
  34338. */
  34339. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34340. /**
  34341. * Gets the mesh under the pointer
  34342. * @returns a Mesh or null if no mesh is under the pointer
  34343. */
  34344. getPointerOverMesh(): Nullable<AbstractMesh>;
  34345. /** @hidden */ private _rebuildGeometries(): void;
  34346. /** @hidden */ private _rebuildTextures(): void;
  34347. private _getByTags;
  34348. /**
  34349. * Get a list of meshes by tags
  34350. * @param tagsQuery defines the tags query to use
  34351. * @param forEach defines a predicate used to filter results
  34352. * @returns an array of Mesh
  34353. */
  34354. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34355. /**
  34356. * Get a list of cameras by tags
  34357. * @param tagsQuery defines the tags query to use
  34358. * @param forEach defines a predicate used to filter results
  34359. * @returns an array of Camera
  34360. */
  34361. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34362. /**
  34363. * Get a list of lights by tags
  34364. * @param tagsQuery defines the tags query to use
  34365. * @param forEach defines a predicate used to filter results
  34366. * @returns an array of Light
  34367. */
  34368. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34369. /**
  34370. * Get a list of materials by tags
  34371. * @param tagsQuery defines the tags query to use
  34372. * @param forEach defines a predicate used to filter results
  34373. * @returns an array of Material
  34374. */
  34375. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34376. /**
  34377. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34378. * This allowed control for front to back rendering or reversly depending of the special needs.
  34379. *
  34380. * @param renderingGroupId The rendering group id corresponding to its index
  34381. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34382. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34383. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34384. */
  34385. 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;
  34386. /**
  34387. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34388. *
  34389. * @param renderingGroupId The rendering group id corresponding to its index
  34390. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34391. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34392. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34393. */
  34394. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34395. /**
  34396. * Gets the current auto clear configuration for one rendering group of the rendering
  34397. * manager.
  34398. * @param index the rendering group index to get the information for
  34399. * @returns The auto clear setup for the requested rendering group
  34400. */
  34401. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34402. private _blockMaterialDirtyMechanism;
  34403. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34404. blockMaterialDirtyMechanism: boolean;
  34405. /**
  34406. * Will flag all materials as dirty to trigger new shader compilation
  34407. * @param flag defines the flag used to specify which material part must be marked as dirty
  34408. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34409. */
  34410. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34411. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  34412. /** @hidden */ private _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34413. /** @hidden */ private _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  34414. /** @hidden */ private _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  34415. /** @hidden */ private _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34416. /** @hidden */ private _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34417. }
  34418. }
  34419. declare module BABYLON {
  34420. /**
  34421. * Set of assets to keep when moving a scene into an asset container.
  34422. */
  34423. export class KeepAssets extends AbstractScene {
  34424. }
  34425. /**
  34426. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  34427. */
  34428. export class InstantiatedEntries {
  34429. /**
  34430. * List of new root nodes (eg. nodes with no parent)
  34431. */
  34432. rootNodes: TransformNode[];
  34433. /**
  34434. * List of new skeletons
  34435. */
  34436. skeletons: Skeleton[];
  34437. /**
  34438. * List of new animation groups
  34439. */
  34440. animationGroups: AnimationGroup[];
  34441. }
  34442. /**
  34443. * Container with a set of assets that can be added or removed from a scene.
  34444. */
  34445. export class AssetContainer extends AbstractScene {
  34446. /**
  34447. * The scene the AssetContainer belongs to.
  34448. */
  34449. scene: Scene;
  34450. /**
  34451. * Instantiates an AssetContainer.
  34452. * @param scene The scene the AssetContainer belongs to.
  34453. */
  34454. constructor(scene: Scene);
  34455. /**
  34456. * Instantiate or clone all meshes and add the new ones to the scene.
  34457. * Skeletons and animation groups will all be cloned
  34458. * @param nameFunction defines an optional function used to get new names for clones
  34459. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  34460. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  34461. */
  34462. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  34463. /**
  34464. * Adds all the assets from the container to the scene.
  34465. */
  34466. addAllToScene(): void;
  34467. /**
  34468. * Removes all the assets in the container from the scene
  34469. */
  34470. removeAllFromScene(): void;
  34471. /**
  34472. * Disposes all the assets in the container
  34473. */
  34474. dispose(): void;
  34475. private _moveAssets;
  34476. /**
  34477. * Removes all the assets contained in the scene and adds them to the container.
  34478. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34479. */
  34480. moveAllFromScene(keepAssets?: KeepAssets): void;
  34481. /**
  34482. * 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.
  34483. * @returns the root mesh
  34484. */
  34485. createRootMesh(): Mesh;
  34486. }
  34487. }
  34488. declare module BABYLON {
  34489. /**
  34490. * Defines how the parser contract is defined.
  34491. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34492. */
  34493. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34494. /**
  34495. * Defines how the individual parser contract is defined.
  34496. * These parser can parse an individual asset
  34497. */
  34498. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34499. /**
  34500. * Base class of the scene acting as a container for the different elements composing a scene.
  34501. * This class is dynamically extended by the different components of the scene increasing
  34502. * flexibility and reducing coupling
  34503. */
  34504. export abstract class AbstractScene {
  34505. /**
  34506. * Stores the list of available parsers in the application.
  34507. */
  34508. private static _BabylonFileParsers;
  34509. /**
  34510. * Stores the list of available individual parsers in the application.
  34511. */
  34512. private static _IndividualBabylonFileParsers;
  34513. /**
  34514. * Adds a parser in the list of available ones
  34515. * @param name Defines the name of the parser
  34516. * @param parser Defines the parser to add
  34517. */
  34518. static AddParser(name: string, parser: BabylonFileParser): void;
  34519. /**
  34520. * Gets a general parser from the list of avaialble ones
  34521. * @param name Defines the name of the parser
  34522. * @returns the requested parser or null
  34523. */
  34524. static GetParser(name: string): Nullable<BabylonFileParser>;
  34525. /**
  34526. * Adds n individual parser in the list of available ones
  34527. * @param name Defines the name of the parser
  34528. * @param parser Defines the parser to add
  34529. */
  34530. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34531. /**
  34532. * Gets an individual parser from the list of avaialble ones
  34533. * @param name Defines the name of the parser
  34534. * @returns the requested parser or null
  34535. */
  34536. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34537. /**
  34538. * Parser json data and populate both a scene and its associated container object
  34539. * @param jsonData Defines the data to parse
  34540. * @param scene Defines the scene to parse the data for
  34541. * @param container Defines the container attached to the parsing sequence
  34542. * @param rootUrl Defines the root url of the data
  34543. */
  34544. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34545. /**
  34546. * Gets the list of root nodes (ie. nodes with no parent)
  34547. */
  34548. rootNodes: Node[];
  34549. /** All of the cameras added to this scene
  34550. * @see http://doc.babylonjs.com/babylon101/cameras
  34551. */
  34552. cameras: Camera[];
  34553. /**
  34554. * All of the lights added to this scene
  34555. * @see http://doc.babylonjs.com/babylon101/lights
  34556. */
  34557. lights: Light[];
  34558. /**
  34559. * All of the (abstract) meshes added to this scene
  34560. */
  34561. meshes: AbstractMesh[];
  34562. /**
  34563. * The list of skeletons added to the scene
  34564. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34565. */
  34566. skeletons: Skeleton[];
  34567. /**
  34568. * All of the particle systems added to this scene
  34569. * @see http://doc.babylonjs.com/babylon101/particles
  34570. */
  34571. particleSystems: IParticleSystem[];
  34572. /**
  34573. * Gets a list of Animations associated with the scene
  34574. */
  34575. animations: Animation[];
  34576. /**
  34577. * All of the animation groups added to this scene
  34578. * @see http://doc.babylonjs.com/how_to/group
  34579. */
  34580. animationGroups: AnimationGroup[];
  34581. /**
  34582. * All of the multi-materials added to this scene
  34583. * @see http://doc.babylonjs.com/how_to/multi_materials
  34584. */
  34585. multiMaterials: MultiMaterial[];
  34586. /**
  34587. * All of the materials added to this scene
  34588. * In the context of a Scene, it is not supposed to be modified manually.
  34589. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  34590. * Note also that the order of the Material within the array is not significant and might change.
  34591. * @see http://doc.babylonjs.com/babylon101/materials
  34592. */
  34593. materials: Material[];
  34594. /**
  34595. * The list of morph target managers added to the scene
  34596. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34597. */
  34598. morphTargetManagers: MorphTargetManager[];
  34599. /**
  34600. * The list of geometries used in the scene.
  34601. */
  34602. geometries: Geometry[];
  34603. /**
  34604. * All of the tranform nodes added to this scene
  34605. * In the context of a Scene, it is not supposed to be modified manually.
  34606. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34607. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34608. * @see http://doc.babylonjs.com/how_to/transformnode
  34609. */
  34610. transformNodes: TransformNode[];
  34611. /**
  34612. * ActionManagers available on the scene.
  34613. */
  34614. actionManagers: AbstractActionManager[];
  34615. /**
  34616. * Textures to keep.
  34617. */
  34618. textures: BaseTexture[];
  34619. /**
  34620. * Environment texture for the scene
  34621. */
  34622. environmentTexture: Nullable<BaseTexture>;
  34623. }
  34624. }
  34625. declare module BABYLON {
  34626. /**
  34627. * Interface used to define options for Sound class
  34628. */
  34629. export interface ISoundOptions {
  34630. /**
  34631. * Does the sound autoplay once loaded.
  34632. */
  34633. autoplay?: boolean;
  34634. /**
  34635. * Does the sound loop after it finishes playing once.
  34636. */
  34637. loop?: boolean;
  34638. /**
  34639. * Sound's volume
  34640. */
  34641. volume?: number;
  34642. /**
  34643. * Is it a spatial sound?
  34644. */
  34645. spatialSound?: boolean;
  34646. /**
  34647. * Maximum distance to hear that sound
  34648. */
  34649. maxDistance?: number;
  34650. /**
  34651. * Uses user defined attenuation function
  34652. */
  34653. useCustomAttenuation?: boolean;
  34654. /**
  34655. * Define the roll off factor of spatial sounds.
  34656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34657. */
  34658. rolloffFactor?: number;
  34659. /**
  34660. * Define the reference distance the sound should be heard perfectly.
  34661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34662. */
  34663. refDistance?: number;
  34664. /**
  34665. * Define the distance attenuation model the sound will follow.
  34666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34667. */
  34668. distanceModel?: string;
  34669. /**
  34670. * Defines the playback speed (1 by default)
  34671. */
  34672. playbackRate?: number;
  34673. /**
  34674. * Defines if the sound is from a streaming source
  34675. */
  34676. streaming?: boolean;
  34677. /**
  34678. * Defines an optional length (in seconds) inside the sound file
  34679. */
  34680. length?: number;
  34681. /**
  34682. * Defines an optional offset (in seconds) inside the sound file
  34683. */
  34684. offset?: number;
  34685. /**
  34686. * If true, URLs will not be required to state the audio file codec to use.
  34687. */
  34688. skipCodecCheck?: boolean;
  34689. }
  34690. /**
  34691. * Defines a sound that can be played in the application.
  34692. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34694. */
  34695. export class Sound {
  34696. /**
  34697. * The name of the sound in the scene.
  34698. */
  34699. name: string;
  34700. /**
  34701. * Does the sound autoplay once loaded.
  34702. */
  34703. autoplay: boolean;
  34704. /**
  34705. * Does the sound loop after it finishes playing once.
  34706. */
  34707. loop: boolean;
  34708. /**
  34709. * Does the sound use a custom attenuation curve to simulate the falloff
  34710. * happening when the source gets further away from the camera.
  34711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34712. */
  34713. useCustomAttenuation: boolean;
  34714. /**
  34715. * The sound track id this sound belongs to.
  34716. */
  34717. soundTrackId: number;
  34718. /**
  34719. * Is this sound currently played.
  34720. */
  34721. isPlaying: boolean;
  34722. /**
  34723. * Is this sound currently paused.
  34724. */
  34725. isPaused: boolean;
  34726. /**
  34727. * Does this sound enables spatial sound.
  34728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34729. */
  34730. spatialSound: boolean;
  34731. /**
  34732. * Define the reference distance the sound should be heard perfectly.
  34733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34734. */
  34735. refDistance: number;
  34736. /**
  34737. * Define the roll off factor of spatial sounds.
  34738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34739. */
  34740. rolloffFactor: number;
  34741. /**
  34742. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34744. */
  34745. maxDistance: number;
  34746. /**
  34747. * Define the distance attenuation model the sound will follow.
  34748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34749. */
  34750. distanceModel: string;
  34751. /**
  34752. * @hidden
  34753. * Back Compat
  34754. **/
  34755. onended: () => any;
  34756. /**
  34757. * Observable event when the current playing sound finishes.
  34758. */
  34759. onEndedObservable: Observable<Sound>;
  34760. private _panningModel;
  34761. private _playbackRate;
  34762. private _streaming;
  34763. private _startTime;
  34764. private _startOffset;
  34765. private _position;
  34766. /** @hidden */ private _positionInEmitterSpace: boolean;
  34767. private _localDirection;
  34768. private _volume;
  34769. private _isReadyToPlay;
  34770. private _isDirectional;
  34771. private _readyToPlayCallback;
  34772. private _audioBuffer;
  34773. private _soundSource;
  34774. private _streamingSource;
  34775. private _soundPanner;
  34776. private _soundGain;
  34777. private _inputAudioNode;
  34778. private _outputAudioNode;
  34779. private _coneInnerAngle;
  34780. private _coneOuterAngle;
  34781. private _coneOuterGain;
  34782. private _scene;
  34783. private _connectedTransformNode;
  34784. private _customAttenuationFunction;
  34785. private _registerFunc;
  34786. private _isOutputConnected;
  34787. private _htmlAudioElement;
  34788. private _urlType;
  34789. private _length?;
  34790. private _offset?;
  34791. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34792. /**
  34793. * Create a sound and attach it to a scene
  34794. * @param name Name of your sound
  34795. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34796. * @param scene defines the scene the sound belongs to
  34797. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34798. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34799. */
  34800. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34801. /**
  34802. * Release the sound and its associated resources
  34803. */
  34804. dispose(): void;
  34805. /**
  34806. * Gets if the sounds is ready to be played or not.
  34807. * @returns true if ready, otherwise false
  34808. */
  34809. isReady(): boolean;
  34810. private _soundLoaded;
  34811. /**
  34812. * Sets the data of the sound from an audiobuffer
  34813. * @param audioBuffer The audioBuffer containing the data
  34814. */
  34815. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34816. /**
  34817. * Updates the current sounds options such as maxdistance, loop...
  34818. * @param options A JSON object containing values named as the object properties
  34819. */
  34820. updateOptions(options: ISoundOptions): void;
  34821. private _createSpatialParameters;
  34822. private _updateSpatialParameters;
  34823. /**
  34824. * Switch the panning model to HRTF:
  34825. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34827. */
  34828. switchPanningModelToHRTF(): void;
  34829. /**
  34830. * Switch the panning model to Equal Power:
  34831. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34833. */
  34834. switchPanningModelToEqualPower(): void;
  34835. private _switchPanningModel;
  34836. /**
  34837. * Connect this sound to a sound track audio node like gain...
  34838. * @param soundTrackAudioNode the sound track audio node to connect to
  34839. */
  34840. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34841. /**
  34842. * Transform this sound into a directional source
  34843. * @param coneInnerAngle Size of the inner cone in degree
  34844. * @param coneOuterAngle Size of the outer cone in degree
  34845. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34846. */
  34847. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34848. /**
  34849. * Gets or sets the inner angle for the directional cone.
  34850. */
  34851. /**
  34852. * Gets or sets the inner angle for the directional cone.
  34853. */
  34854. directionalConeInnerAngle: number;
  34855. /**
  34856. * Gets or sets the outer angle for the directional cone.
  34857. */
  34858. /**
  34859. * Gets or sets the outer angle for the directional cone.
  34860. */
  34861. directionalConeOuterAngle: number;
  34862. /**
  34863. * Sets the position of the emitter if spatial sound is enabled
  34864. * @param newPosition Defines the new posisiton
  34865. */
  34866. setPosition(newPosition: Vector3): void;
  34867. /**
  34868. * Sets the local direction of the emitter if spatial sound is enabled
  34869. * @param newLocalDirection Defines the new local direction
  34870. */
  34871. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34872. private _updateDirection;
  34873. /** @hidden */
  34874. updateDistanceFromListener(): void;
  34875. /**
  34876. * Sets a new custom attenuation function for the sound.
  34877. * @param callback Defines the function used for the attenuation
  34878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34879. */
  34880. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34881. /**
  34882. * Play the sound
  34883. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34884. * @param offset (optional) Start the sound at a specific time in seconds
  34885. * @param length (optional) Sound duration (in seconds)
  34886. */
  34887. play(time?: number, offset?: number, length?: number): void;
  34888. private _onended;
  34889. /**
  34890. * Stop the sound
  34891. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34892. */
  34893. stop(time?: number): void;
  34894. /**
  34895. * Put the sound in pause
  34896. */
  34897. pause(): void;
  34898. /**
  34899. * Sets a dedicated volume for this sounds
  34900. * @param newVolume Define the new volume of the sound
  34901. * @param time Define time for gradual change to new volume
  34902. */
  34903. setVolume(newVolume: number, time?: number): void;
  34904. /**
  34905. * Set the sound play back rate
  34906. * @param newPlaybackRate Define the playback rate the sound should be played at
  34907. */
  34908. setPlaybackRate(newPlaybackRate: number): void;
  34909. /**
  34910. * Gets the volume of the sound.
  34911. * @returns the volume of the sound
  34912. */
  34913. getVolume(): number;
  34914. /**
  34915. * Attach the sound to a dedicated mesh
  34916. * @param transformNode The transform node to connect the sound with
  34917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34918. */
  34919. attachToMesh(transformNode: TransformNode): void;
  34920. /**
  34921. * Detach the sound from the previously attached mesh
  34922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34923. */
  34924. detachFromMesh(): void;
  34925. private _onRegisterAfterWorldMatrixUpdate;
  34926. /**
  34927. * Clone the current sound in the scene.
  34928. * @returns the new sound clone
  34929. */
  34930. clone(): Nullable<Sound>;
  34931. /**
  34932. * Gets the current underlying audio buffer containing the data
  34933. * @returns the audio buffer
  34934. */
  34935. getAudioBuffer(): Nullable<AudioBuffer>;
  34936. /**
  34937. * Serializes the Sound in a JSON representation
  34938. * @returns the JSON representation of the sound
  34939. */
  34940. serialize(): any;
  34941. /**
  34942. * Parse a JSON representation of a sound to innstantiate in a given scene
  34943. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34944. * @param scene Define the scene the new parsed sound should be created in
  34945. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34946. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34947. * @returns the newly parsed sound
  34948. */
  34949. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34950. }
  34951. }
  34952. declare module BABYLON {
  34953. /**
  34954. * This defines an action helpful to play a defined sound on a triggered action.
  34955. */
  34956. export class PlaySoundAction extends Action {
  34957. private _sound;
  34958. /**
  34959. * Instantiate the action
  34960. * @param triggerOptions defines the trigger options
  34961. * @param sound defines the sound to play
  34962. * @param condition defines the trigger related conditions
  34963. */
  34964. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34965. /** @hidden */ private _prepare(): void;
  34966. /**
  34967. * Execute the action and play the sound.
  34968. */
  34969. execute(): void;
  34970. /**
  34971. * Serializes the actions and its related information.
  34972. * @param parent defines the object to serialize in
  34973. * @returns the serialized object
  34974. */
  34975. serialize(parent: any): any;
  34976. }
  34977. /**
  34978. * This defines an action helpful to stop a defined sound on a triggered action.
  34979. */
  34980. export class StopSoundAction extends Action {
  34981. private _sound;
  34982. /**
  34983. * Instantiate the action
  34984. * @param triggerOptions defines the trigger options
  34985. * @param sound defines the sound to stop
  34986. * @param condition defines the trigger related conditions
  34987. */
  34988. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34989. /** @hidden */ private _prepare(): void;
  34990. /**
  34991. * Execute the action and stop the sound.
  34992. */
  34993. execute(): void;
  34994. /**
  34995. * Serializes the actions and its related information.
  34996. * @param parent defines the object to serialize in
  34997. * @returns the serialized object
  34998. */
  34999. serialize(parent: any): any;
  35000. }
  35001. }
  35002. declare module BABYLON {
  35003. /**
  35004. * This defines an action responsible to change the value of a property
  35005. * by interpolating between its current value and the newly set one once triggered.
  35006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35007. */
  35008. export class InterpolateValueAction extends Action {
  35009. /**
  35010. * Defines the path of the property where the value should be interpolated
  35011. */
  35012. propertyPath: string;
  35013. /**
  35014. * Defines the target value at the end of the interpolation.
  35015. */
  35016. value: any;
  35017. /**
  35018. * Defines the time it will take for the property to interpolate to the value.
  35019. */
  35020. duration: number;
  35021. /**
  35022. * Defines if the other scene animations should be stopped when the action has been triggered
  35023. */
  35024. stopOtherAnimations?: boolean;
  35025. /**
  35026. * Defines a callback raised once the interpolation animation has been done.
  35027. */
  35028. onInterpolationDone?: () => void;
  35029. /**
  35030. * Observable triggered once the interpolation animation has been done.
  35031. */
  35032. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35033. private _target;
  35034. private _effectiveTarget;
  35035. private _property;
  35036. /**
  35037. * Instantiate the action
  35038. * @param triggerOptions defines the trigger options
  35039. * @param target defines the object containing the value to interpolate
  35040. * @param propertyPath defines the path to the property in the target object
  35041. * @param value defines the target value at the end of the interpolation
  35042. * @param duration deines the time it will take for the property to interpolate to the value.
  35043. * @param condition defines the trigger related conditions
  35044. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35045. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35046. */
  35047. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35048. /** @hidden */ private _prepare(): void;
  35049. /**
  35050. * Execute the action starts the value interpolation.
  35051. */
  35052. execute(): void;
  35053. /**
  35054. * Serializes the actions and its related information.
  35055. * @param parent defines the object to serialize in
  35056. * @returns the serialized object
  35057. */
  35058. serialize(parent: any): any;
  35059. }
  35060. }
  35061. declare module BABYLON {
  35062. /**
  35063. * Options allowed during the creation of a sound track.
  35064. */
  35065. export interface ISoundTrackOptions {
  35066. /**
  35067. * The volume the sound track should take during creation
  35068. */
  35069. volume?: number;
  35070. /**
  35071. * Define if the sound track is the main sound track of the scene
  35072. */
  35073. mainTrack?: boolean;
  35074. }
  35075. /**
  35076. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35077. * It will be also used in a future release to apply effects on a specific track.
  35078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35079. */
  35080. export class SoundTrack {
  35081. /**
  35082. * The unique identifier of the sound track in the scene.
  35083. */
  35084. id: number;
  35085. /**
  35086. * The list of sounds included in the sound track.
  35087. */
  35088. soundCollection: Array<Sound>;
  35089. private _outputAudioNode;
  35090. private _scene;
  35091. private _connectedAnalyser;
  35092. private _options;
  35093. private _isInitialized;
  35094. /**
  35095. * Creates a new sound track.
  35096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35097. * @param scene Define the scene the sound track belongs to
  35098. * @param options
  35099. */
  35100. constructor(scene: Scene, options?: ISoundTrackOptions);
  35101. private _initializeSoundTrackAudioGraph;
  35102. /**
  35103. * Release the sound track and its associated resources
  35104. */
  35105. dispose(): void;
  35106. /**
  35107. * Adds a sound to this sound track
  35108. * @param sound define the cound to add
  35109. * @ignoreNaming
  35110. */
  35111. AddSound(sound: Sound): void;
  35112. /**
  35113. * Removes a sound to this sound track
  35114. * @param sound define the cound to remove
  35115. * @ignoreNaming
  35116. */
  35117. RemoveSound(sound: Sound): void;
  35118. /**
  35119. * Set a global volume for the full sound track.
  35120. * @param newVolume Define the new volume of the sound track
  35121. */
  35122. setVolume(newVolume: number): void;
  35123. /**
  35124. * Switch the panning model to HRTF:
  35125. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35127. */
  35128. switchPanningModelToHRTF(): void;
  35129. /**
  35130. * Switch the panning model to Equal Power:
  35131. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35133. */
  35134. switchPanningModelToEqualPower(): void;
  35135. /**
  35136. * Connect the sound track to an audio analyser allowing some amazing
  35137. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35139. * @param analyser The analyser to connect to the engine
  35140. */
  35141. connectToAnalyser(analyser: Analyser): void;
  35142. }
  35143. }
  35144. declare module BABYLON {
  35145. interface AbstractScene {
  35146. /**
  35147. * The list of sounds used in the scene.
  35148. */
  35149. sounds: Nullable<Array<Sound>>;
  35150. }
  35151. interface Scene {
  35152. /**
  35153. * @hidden
  35154. * Backing field
  35155. */ private _mainSoundTrack: SoundTrack;
  35156. /**
  35157. * The main sound track played by the scene.
  35158. * It cotains your primary collection of sounds.
  35159. */
  35160. mainSoundTrack: SoundTrack;
  35161. /**
  35162. * The list of sound tracks added to the scene
  35163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35164. */
  35165. soundTracks: Nullable<Array<SoundTrack>>;
  35166. /**
  35167. * Gets a sound using a given name
  35168. * @param name defines the name to search for
  35169. * @return the found sound or null if not found at all.
  35170. */
  35171. getSoundByName(name: string): Nullable<Sound>;
  35172. /**
  35173. * Gets or sets if audio support is enabled
  35174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35175. */
  35176. audioEnabled: boolean;
  35177. /**
  35178. * Gets or sets if audio will be output to headphones
  35179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35180. */
  35181. headphone: boolean;
  35182. /**
  35183. * Gets or sets custom audio listener position provider
  35184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35185. */
  35186. audioListenerPositionProvider: Nullable<() => Vector3>;
  35187. /**
  35188. * Gets or sets a refresh rate when using 3D audio positioning
  35189. */
  35190. audioPositioningRefreshRate: number;
  35191. }
  35192. /**
  35193. * Defines the sound scene component responsible to manage any sounds
  35194. * in a given scene.
  35195. */
  35196. export class AudioSceneComponent implements ISceneSerializableComponent {
  35197. /**
  35198. * The component name helpfull to identify the component in the list of scene components.
  35199. */
  35200. readonly name: string;
  35201. /**
  35202. * The scene the component belongs to.
  35203. */
  35204. scene: Scene;
  35205. private _audioEnabled;
  35206. /**
  35207. * Gets whether audio is enabled or not.
  35208. * Please use related enable/disable method to switch state.
  35209. */
  35210. readonly audioEnabled: boolean;
  35211. private _headphone;
  35212. /**
  35213. * Gets whether audio is outputing to headphone or not.
  35214. * Please use the according Switch methods to change output.
  35215. */
  35216. readonly headphone: boolean;
  35217. /**
  35218. * Gets or sets a refresh rate when using 3D audio positioning
  35219. */
  35220. audioPositioningRefreshRate: number;
  35221. private _audioListenerPositionProvider;
  35222. /**
  35223. * Gets the current audio listener position provider
  35224. */
  35225. /**
  35226. * Sets a custom listener position for all sounds in the scene
  35227. * By default, this is the position of the first active camera
  35228. */
  35229. audioListenerPositionProvider: Nullable<() => Vector3>;
  35230. /**
  35231. * Creates a new instance of the component for the given scene
  35232. * @param scene Defines the scene to register the component in
  35233. */
  35234. constructor(scene: Scene);
  35235. /**
  35236. * Registers the component in a given scene
  35237. */
  35238. register(): void;
  35239. /**
  35240. * Rebuilds the elements related to this component in case of
  35241. * context lost for instance.
  35242. */
  35243. rebuild(): void;
  35244. /**
  35245. * Serializes the component data to the specified json object
  35246. * @param serializationObject The object to serialize to
  35247. */
  35248. serialize(serializationObject: any): void;
  35249. /**
  35250. * Adds all the elements from the container to the scene
  35251. * @param container the container holding the elements
  35252. */
  35253. addFromContainer(container: AbstractScene): void;
  35254. /**
  35255. * Removes all the elements in the container from the scene
  35256. * @param container contains the elements to remove
  35257. * @param dispose if the removed element should be disposed (default: false)
  35258. */
  35259. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35260. /**
  35261. * Disposes the component and the associated ressources.
  35262. */
  35263. dispose(): void;
  35264. /**
  35265. * Disables audio in the associated scene.
  35266. */
  35267. disableAudio(): void;
  35268. /**
  35269. * Enables audio in the associated scene.
  35270. */
  35271. enableAudio(): void;
  35272. /**
  35273. * Switch audio to headphone output.
  35274. */
  35275. switchAudioModeForHeadphones(): void;
  35276. /**
  35277. * Switch audio to normal speakers.
  35278. */
  35279. switchAudioModeForNormalSpeakers(): void;
  35280. private _cachedCameraDirection;
  35281. private _cachedCameraPosition;
  35282. private _lastCheck;
  35283. private _afterRender;
  35284. }
  35285. }
  35286. declare module BABYLON {
  35287. /**
  35288. * Wraps one or more Sound objects and selects one with random weight for playback.
  35289. */
  35290. export class WeightedSound {
  35291. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35292. loop: boolean;
  35293. private _coneInnerAngle;
  35294. private _coneOuterAngle;
  35295. private _volume;
  35296. /** A Sound is currently playing. */
  35297. isPlaying: boolean;
  35298. /** A Sound is currently paused. */
  35299. isPaused: boolean;
  35300. private _sounds;
  35301. private _weights;
  35302. private _currentIndex?;
  35303. /**
  35304. * Creates a new WeightedSound from the list of sounds given.
  35305. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35306. * @param sounds Array of Sounds that will be selected from.
  35307. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35308. */
  35309. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35310. /**
  35311. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35312. */
  35313. /**
  35314. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35315. */
  35316. directionalConeInnerAngle: number;
  35317. /**
  35318. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35319. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35320. */
  35321. /**
  35322. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35323. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35324. */
  35325. directionalConeOuterAngle: number;
  35326. /**
  35327. * Playback volume.
  35328. */
  35329. /**
  35330. * Playback volume.
  35331. */
  35332. volume: number;
  35333. private _onended;
  35334. /**
  35335. * Suspend playback
  35336. */
  35337. pause(): void;
  35338. /**
  35339. * Stop playback
  35340. */
  35341. stop(): void;
  35342. /**
  35343. * Start playback.
  35344. * @param startOffset Position the clip head at a specific time in seconds.
  35345. */
  35346. play(startOffset?: number): void;
  35347. }
  35348. }
  35349. declare module BABYLON {
  35350. /**
  35351. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35352. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35353. */
  35354. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35355. /**
  35356. * Gets the name of the behavior.
  35357. */
  35358. readonly name: string;
  35359. /**
  35360. * The easing function used by animations
  35361. */
  35362. static EasingFunction: BackEase;
  35363. /**
  35364. * The easing mode used by animations
  35365. */
  35366. static EasingMode: number;
  35367. /**
  35368. * The duration of the animation, in milliseconds
  35369. */
  35370. transitionDuration: number;
  35371. /**
  35372. * Length of the distance animated by the transition when lower radius is reached
  35373. */
  35374. lowerRadiusTransitionRange: number;
  35375. /**
  35376. * Length of the distance animated by the transition when upper radius is reached
  35377. */
  35378. upperRadiusTransitionRange: number;
  35379. private _autoTransitionRange;
  35380. /**
  35381. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35382. */
  35383. /**
  35384. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35385. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35386. */
  35387. autoTransitionRange: boolean;
  35388. private _attachedCamera;
  35389. private _onAfterCheckInputsObserver;
  35390. private _onMeshTargetChangedObserver;
  35391. /**
  35392. * Initializes the behavior.
  35393. */
  35394. init(): void;
  35395. /**
  35396. * Attaches the behavior to its arc rotate camera.
  35397. * @param camera Defines the camera to attach the behavior to
  35398. */
  35399. attach(camera: ArcRotateCamera): void;
  35400. /**
  35401. * Detaches the behavior from its current arc rotate camera.
  35402. */
  35403. detach(): void;
  35404. private _radiusIsAnimating;
  35405. private _radiusBounceTransition;
  35406. private _animatables;
  35407. private _cachedWheelPrecision;
  35408. /**
  35409. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35410. * @param radiusLimit The limit to check against.
  35411. * @return Bool to indicate if at limit.
  35412. */
  35413. private _isRadiusAtLimit;
  35414. /**
  35415. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35416. * @param radiusDelta The delta by which to animate to. Can be negative.
  35417. */
  35418. private _applyBoundRadiusAnimation;
  35419. /**
  35420. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35421. */
  35422. protected _clearAnimationLocks(): void;
  35423. /**
  35424. * Stops and removes all animations that have been applied to the camera
  35425. */
  35426. stopAllAnimations(): void;
  35427. }
  35428. }
  35429. declare module BABYLON {
  35430. /**
  35431. * 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.
  35432. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35433. */
  35434. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35435. /**
  35436. * Gets the name of the behavior.
  35437. */
  35438. readonly name: string;
  35439. private _mode;
  35440. private _radiusScale;
  35441. private _positionScale;
  35442. private _defaultElevation;
  35443. private _elevationReturnTime;
  35444. private _elevationReturnWaitTime;
  35445. private _zoomStopsAnimation;
  35446. private _framingTime;
  35447. /**
  35448. * The easing function used by animations
  35449. */
  35450. static EasingFunction: ExponentialEase;
  35451. /**
  35452. * The easing mode used by animations
  35453. */
  35454. static EasingMode: number;
  35455. /**
  35456. * Sets the current mode used by the behavior
  35457. */
  35458. /**
  35459. * Gets current mode used by the behavior.
  35460. */
  35461. mode: number;
  35462. /**
  35463. * Sets the scale applied to the radius (1 by default)
  35464. */
  35465. /**
  35466. * Gets the scale applied to the radius
  35467. */
  35468. radiusScale: number;
  35469. /**
  35470. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35471. */
  35472. /**
  35473. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35474. */
  35475. positionScale: number;
  35476. /**
  35477. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35478. * behaviour is triggered, in radians.
  35479. */
  35480. /**
  35481. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35482. * behaviour is triggered, in radians.
  35483. */
  35484. defaultElevation: number;
  35485. /**
  35486. * Sets the time (in milliseconds) taken to return to the default beta position.
  35487. * Negative value indicates camera should not return to default.
  35488. */
  35489. /**
  35490. * Gets the time (in milliseconds) taken to return to the default beta position.
  35491. * Negative value indicates camera should not return to default.
  35492. */
  35493. elevationReturnTime: number;
  35494. /**
  35495. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35496. */
  35497. /**
  35498. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35499. */
  35500. elevationReturnWaitTime: number;
  35501. /**
  35502. * Sets the flag that indicates if user zooming should stop animation.
  35503. */
  35504. /**
  35505. * Gets the flag that indicates if user zooming should stop animation.
  35506. */
  35507. zoomStopsAnimation: boolean;
  35508. /**
  35509. * Sets the transition time when framing the mesh, in milliseconds
  35510. */
  35511. /**
  35512. * Gets the transition time when framing the mesh, in milliseconds
  35513. */
  35514. framingTime: number;
  35515. /**
  35516. * Define if the behavior should automatically change the configured
  35517. * camera limits and sensibilities.
  35518. */
  35519. autoCorrectCameraLimitsAndSensibility: boolean;
  35520. private _onPrePointerObservableObserver;
  35521. private _onAfterCheckInputsObserver;
  35522. private _onMeshTargetChangedObserver;
  35523. private _attachedCamera;
  35524. private _isPointerDown;
  35525. private _lastInteractionTime;
  35526. /**
  35527. * Initializes the behavior.
  35528. */
  35529. init(): void;
  35530. /**
  35531. * Attaches the behavior to its arc rotate camera.
  35532. * @param camera Defines the camera to attach the behavior to
  35533. */
  35534. attach(camera: ArcRotateCamera): void;
  35535. /**
  35536. * Detaches the behavior from its current arc rotate camera.
  35537. */
  35538. detach(): void;
  35539. private _animatables;
  35540. private _betaIsAnimating;
  35541. private _betaTransition;
  35542. private _radiusTransition;
  35543. private _vectorTransition;
  35544. /**
  35545. * Targets the given mesh and updates zoom level accordingly.
  35546. * @param mesh The mesh to target.
  35547. * @param radius Optional. If a cached radius position already exists, overrides default.
  35548. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35549. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35550. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35551. */
  35552. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35553. /**
  35554. * Targets the given mesh with its children and updates zoom level accordingly.
  35555. * @param mesh The mesh to target.
  35556. * @param radius Optional. If a cached radius position already exists, overrides default.
  35557. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35558. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35559. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35560. */
  35561. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35562. /**
  35563. * Targets the given meshes with their children and updates zoom level accordingly.
  35564. * @param meshes The mesh to target.
  35565. * @param radius Optional. If a cached radius position already exists, overrides default.
  35566. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35567. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35568. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35569. */
  35570. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35571. /**
  35572. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35573. * @param minimumWorld Determines the smaller position of the bounding box extend
  35574. * @param maximumWorld Determines the bigger position of the bounding box extend
  35575. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35576. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35577. */
  35578. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35579. /**
  35580. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35581. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35582. * frustum width.
  35583. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35584. * to fully enclose the mesh in the viewing frustum.
  35585. */
  35586. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35587. /**
  35588. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35589. * is automatically returned to its default position (expected to be above ground plane).
  35590. */
  35591. private _maintainCameraAboveGround;
  35592. /**
  35593. * Returns the frustum slope based on the canvas ratio and camera FOV
  35594. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35595. */
  35596. private _getFrustumSlope;
  35597. /**
  35598. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35599. */
  35600. private _clearAnimationLocks;
  35601. /**
  35602. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35603. */
  35604. private _applyUserInteraction;
  35605. /**
  35606. * Stops and removes all animations that have been applied to the camera
  35607. */
  35608. stopAllAnimations(): void;
  35609. /**
  35610. * Gets a value indicating if the user is moving the camera
  35611. */
  35612. readonly isUserIsMoving: boolean;
  35613. /**
  35614. * The camera can move all the way towards the mesh.
  35615. */
  35616. static IgnoreBoundsSizeMode: number;
  35617. /**
  35618. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35619. */
  35620. static FitFrustumSidesMode: number;
  35621. }
  35622. }
  35623. declare module BABYLON {
  35624. /**
  35625. * Base class for Camera Pointer Inputs.
  35626. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35627. * for example usage.
  35628. */
  35629. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35630. /**
  35631. * Defines the camera the input is attached to.
  35632. */
  35633. abstract camera: Camera;
  35634. /**
  35635. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35636. */
  35637. protected _altKey: boolean;
  35638. protected _ctrlKey: boolean;
  35639. protected _metaKey: boolean;
  35640. protected _shiftKey: boolean;
  35641. /**
  35642. * Which mouse buttons were pressed at time of last mouse event.
  35643. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35644. */
  35645. protected _buttonsPressed: number;
  35646. /**
  35647. * Defines the buttons associated with the input to handle camera move.
  35648. */
  35649. buttons: number[];
  35650. /**
  35651. * Attach the input controls to a specific dom element to get the input from.
  35652. * @param element Defines the element the controls should be listened from
  35653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35654. */
  35655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35656. /**
  35657. * Detach the current controls from the specified dom element.
  35658. * @param element Defines the element to stop listening the inputs from
  35659. */
  35660. detachControl(element: Nullable<HTMLElement>): void;
  35661. /**
  35662. * Gets the class name of the current input.
  35663. * @returns the class name
  35664. */
  35665. getClassName(): string;
  35666. /**
  35667. * Get the friendly name associated with the input class.
  35668. * @returns the input friendly name
  35669. */
  35670. getSimpleName(): string;
  35671. /**
  35672. * Called on pointer POINTERDOUBLETAP event.
  35673. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35674. */
  35675. protected onDoubleTap(type: string): void;
  35676. /**
  35677. * Called on pointer POINTERMOVE event if only a single touch is active.
  35678. * Override this method to provide functionality.
  35679. */
  35680. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35681. /**
  35682. * Called on pointer POINTERMOVE event if multiple touches are active.
  35683. * Override this method to provide functionality.
  35684. */
  35685. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35686. /**
  35687. * Called on JS contextmenu event.
  35688. * Override this method to provide functionality.
  35689. */
  35690. protected onContextMenu(evt: PointerEvent): void;
  35691. /**
  35692. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35693. * press.
  35694. * Override this method to provide functionality.
  35695. */
  35696. protected onButtonDown(evt: PointerEvent): void;
  35697. /**
  35698. * Called each time a new POINTERUP event occurs. Ie, for each button
  35699. * release.
  35700. * Override this method to provide functionality.
  35701. */
  35702. protected onButtonUp(evt: PointerEvent): void;
  35703. /**
  35704. * Called when window becomes inactive.
  35705. * Override this method to provide functionality.
  35706. */
  35707. protected onLostFocus(): void;
  35708. private _pointerInput;
  35709. private _observer;
  35710. private _onLostFocus;
  35711. private pointA;
  35712. private pointB;
  35713. }
  35714. }
  35715. declare module BABYLON {
  35716. /**
  35717. * Manage the pointers inputs to control an arc rotate camera.
  35718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35719. */
  35720. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35721. /**
  35722. * Defines the camera the input is attached to.
  35723. */
  35724. camera: ArcRotateCamera;
  35725. /**
  35726. * Gets the class name of the current input.
  35727. * @returns the class name
  35728. */
  35729. getClassName(): string;
  35730. /**
  35731. * Defines the buttons associated with the input to handle camera move.
  35732. */
  35733. buttons: number[];
  35734. /**
  35735. * Defines the pointer angular sensibility along the X axis or how fast is
  35736. * the camera rotating.
  35737. */
  35738. angularSensibilityX: number;
  35739. /**
  35740. * Defines the pointer angular sensibility along the Y axis or how fast is
  35741. * the camera rotating.
  35742. */
  35743. angularSensibilityY: number;
  35744. /**
  35745. * Defines the pointer pinch precision or how fast is the camera zooming.
  35746. */
  35747. pinchPrecision: number;
  35748. /**
  35749. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35750. * from 0.
  35751. * It defines the percentage of current camera.radius to use as delta when
  35752. * pinch zoom is used.
  35753. */
  35754. pinchDeltaPercentage: number;
  35755. /**
  35756. * Defines the pointer panning sensibility or how fast is the camera moving.
  35757. */
  35758. panningSensibility: number;
  35759. /**
  35760. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35761. */
  35762. multiTouchPanning: boolean;
  35763. /**
  35764. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35765. * zoom (pinch) through multitouch.
  35766. */
  35767. multiTouchPanAndZoom: boolean;
  35768. /**
  35769. * Revers pinch action direction.
  35770. */
  35771. pinchInwards: boolean;
  35772. private _isPanClick;
  35773. private _twoFingerActivityCount;
  35774. private _isPinching;
  35775. /**
  35776. * Called on pointer POINTERMOVE event if only a single touch is active.
  35777. */
  35778. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35779. /**
  35780. * Called on pointer POINTERDOUBLETAP event.
  35781. */
  35782. protected onDoubleTap(type: string): void;
  35783. /**
  35784. * Called on pointer POINTERMOVE event if multiple touches are active.
  35785. */
  35786. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35787. /**
  35788. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35789. * press.
  35790. */
  35791. protected onButtonDown(evt: PointerEvent): void;
  35792. /**
  35793. * Called each time a new POINTERUP event occurs. Ie, for each button
  35794. * release.
  35795. */
  35796. protected onButtonUp(evt: PointerEvent): void;
  35797. /**
  35798. * Called when window becomes inactive.
  35799. */
  35800. protected onLostFocus(): void;
  35801. }
  35802. }
  35803. declare module BABYLON {
  35804. /**
  35805. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35807. */
  35808. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35809. /**
  35810. * Defines the camera the input is attached to.
  35811. */
  35812. camera: ArcRotateCamera;
  35813. /**
  35814. * Defines the list of key codes associated with the up action (increase alpha)
  35815. */
  35816. keysUp: number[];
  35817. /**
  35818. * Defines the list of key codes associated with the down action (decrease alpha)
  35819. */
  35820. keysDown: number[];
  35821. /**
  35822. * Defines the list of key codes associated with the left action (increase beta)
  35823. */
  35824. keysLeft: number[];
  35825. /**
  35826. * Defines the list of key codes associated with the right action (decrease beta)
  35827. */
  35828. keysRight: number[];
  35829. /**
  35830. * Defines the list of key codes associated with the reset action.
  35831. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35832. */
  35833. keysReset: number[];
  35834. /**
  35835. * Defines the panning sensibility of the inputs.
  35836. * (How fast is the camera paning)
  35837. */
  35838. panningSensibility: number;
  35839. /**
  35840. * Defines the zooming sensibility of the inputs.
  35841. * (How fast is the camera zooming)
  35842. */
  35843. zoomingSensibility: number;
  35844. /**
  35845. * Defines wether maintaining the alt key down switch the movement mode from
  35846. * orientation to zoom.
  35847. */
  35848. useAltToZoom: boolean;
  35849. /**
  35850. * Rotation speed of the camera
  35851. */
  35852. angularSpeed: number;
  35853. private _keys;
  35854. private _ctrlPressed;
  35855. private _altPressed;
  35856. private _onCanvasBlurObserver;
  35857. private _onKeyboardObserver;
  35858. private _engine;
  35859. private _scene;
  35860. /**
  35861. * Attach the input controls to a specific dom element to get the input from.
  35862. * @param element Defines the element the controls should be listened from
  35863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35864. */
  35865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35866. /**
  35867. * Detach the current controls from the specified dom element.
  35868. * @param element Defines the element to stop listening the inputs from
  35869. */
  35870. detachControl(element: Nullable<HTMLElement>): void;
  35871. /**
  35872. * Update the current camera state depending on the inputs that have been used this frame.
  35873. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35874. */
  35875. checkInputs(): void;
  35876. /**
  35877. * Gets the class name of the current intput.
  35878. * @returns the class name
  35879. */
  35880. getClassName(): string;
  35881. /**
  35882. * Get the friendly name associated with the input class.
  35883. * @returns the input friendly name
  35884. */
  35885. getSimpleName(): string;
  35886. }
  35887. }
  35888. declare module BABYLON {
  35889. /**
  35890. * Manage the mouse wheel inputs to control an arc rotate camera.
  35891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35892. */
  35893. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35894. /**
  35895. * Defines the camera the input is attached to.
  35896. */
  35897. camera: ArcRotateCamera;
  35898. /**
  35899. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35900. */
  35901. wheelPrecision: number;
  35902. /**
  35903. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35904. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35905. */
  35906. wheelDeltaPercentage: number;
  35907. private _wheel;
  35908. private _observer;
  35909. private computeDeltaFromMouseWheelLegacyEvent;
  35910. /**
  35911. * Attach the input controls to a specific dom element to get the input from.
  35912. * @param element Defines the element the controls should be listened from
  35913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35914. */
  35915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35916. /**
  35917. * Detach the current controls from the specified dom element.
  35918. * @param element Defines the element to stop listening the inputs from
  35919. */
  35920. detachControl(element: Nullable<HTMLElement>): void;
  35921. /**
  35922. * Gets the class name of the current intput.
  35923. * @returns the class name
  35924. */
  35925. getClassName(): string;
  35926. /**
  35927. * Get the friendly name associated with the input class.
  35928. * @returns the input friendly name
  35929. */
  35930. getSimpleName(): string;
  35931. }
  35932. }
  35933. declare module BABYLON {
  35934. /**
  35935. * Default Inputs manager for the ArcRotateCamera.
  35936. * It groups all the default supported inputs for ease of use.
  35937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35938. */
  35939. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35940. /**
  35941. * Instantiates a new ArcRotateCameraInputsManager.
  35942. * @param camera Defines the camera the inputs belong to
  35943. */
  35944. constructor(camera: ArcRotateCamera);
  35945. /**
  35946. * Add mouse wheel input support to the input manager.
  35947. * @returns the current input manager
  35948. */
  35949. addMouseWheel(): ArcRotateCameraInputsManager;
  35950. /**
  35951. * Add pointers input support to the input manager.
  35952. * @returns the current input manager
  35953. */
  35954. addPointers(): ArcRotateCameraInputsManager;
  35955. /**
  35956. * Add keyboard input support to the input manager.
  35957. * @returns the current input manager
  35958. */
  35959. addKeyboard(): ArcRotateCameraInputsManager;
  35960. }
  35961. }
  35962. declare module BABYLON {
  35963. /**
  35964. * This represents an orbital type of camera.
  35965. *
  35966. * 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.
  35967. * 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.
  35968. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35969. */
  35970. export class ArcRotateCamera extends TargetCamera {
  35971. /**
  35972. * Defines the rotation angle of the camera along the longitudinal axis.
  35973. */
  35974. alpha: number;
  35975. /**
  35976. * Defines the rotation angle of the camera along the latitudinal axis.
  35977. */
  35978. beta: number;
  35979. /**
  35980. * Defines the radius of the camera from it s target point.
  35981. */
  35982. radius: number;
  35983. protected _target: Vector3;
  35984. protected _targetHost: Nullable<AbstractMesh>;
  35985. /**
  35986. * Defines the target point of the camera.
  35987. * The camera looks towards it form the radius distance.
  35988. */
  35989. target: Vector3;
  35990. /**
  35991. * Define the current local position of the camera in the scene
  35992. */
  35993. position: Vector3;
  35994. protected _upVector: Vector3;
  35995. protected _upToYMatrix: Matrix;
  35996. protected _YToUpMatrix: Matrix;
  35997. /**
  35998. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35999. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36000. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36001. */
  36002. upVector: Vector3;
  36003. /**
  36004. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36005. */
  36006. setMatUp(): void;
  36007. /**
  36008. * Current inertia value on the longitudinal axis.
  36009. * The bigger this number the longer it will take for the camera to stop.
  36010. */
  36011. inertialAlphaOffset: number;
  36012. /**
  36013. * Current inertia value on the latitudinal axis.
  36014. * The bigger this number the longer it will take for the camera to stop.
  36015. */
  36016. inertialBetaOffset: number;
  36017. /**
  36018. * Current inertia value on the radius axis.
  36019. * The bigger this number the longer it will take for the camera to stop.
  36020. */
  36021. inertialRadiusOffset: number;
  36022. /**
  36023. * Minimum allowed angle on the longitudinal axis.
  36024. * This can help limiting how the Camera is able to move in the scene.
  36025. */
  36026. lowerAlphaLimit: Nullable<number>;
  36027. /**
  36028. * Maximum allowed angle on the longitudinal axis.
  36029. * This can help limiting how the Camera is able to move in the scene.
  36030. */
  36031. upperAlphaLimit: Nullable<number>;
  36032. /**
  36033. * Minimum allowed angle on the latitudinal axis.
  36034. * This can help limiting how the Camera is able to move in the scene.
  36035. */
  36036. lowerBetaLimit: number;
  36037. /**
  36038. * Maximum allowed angle on the latitudinal axis.
  36039. * This can help limiting how the Camera is able to move in the scene.
  36040. */
  36041. upperBetaLimit: number;
  36042. /**
  36043. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36044. * This can help limiting how the Camera is able to move in the scene.
  36045. */
  36046. lowerRadiusLimit: Nullable<number>;
  36047. /**
  36048. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36049. * This can help limiting how the Camera is able to move in the scene.
  36050. */
  36051. upperRadiusLimit: Nullable<number>;
  36052. /**
  36053. * Defines the current inertia value used during panning of the camera along the X axis.
  36054. */
  36055. inertialPanningX: number;
  36056. /**
  36057. * Defines the current inertia value used during panning of the camera along the Y axis.
  36058. */
  36059. inertialPanningY: number;
  36060. /**
  36061. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36062. * Basically if your fingers moves away from more than this distance you will be considered
  36063. * in pinch mode.
  36064. */
  36065. pinchToPanMaxDistance: number;
  36066. /**
  36067. * Defines the maximum distance the camera can pan.
  36068. * This could help keeping the cammera always in your scene.
  36069. */
  36070. panningDistanceLimit: Nullable<number>;
  36071. /**
  36072. * Defines the target of the camera before paning.
  36073. */
  36074. panningOriginTarget: Vector3;
  36075. /**
  36076. * Defines the value of the inertia used during panning.
  36077. * 0 would mean stop inertia and one would mean no decelleration at all.
  36078. */
  36079. panningInertia: number;
  36080. /**
  36081. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36082. */
  36083. angularSensibilityX: number;
  36084. /**
  36085. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36086. */
  36087. angularSensibilityY: number;
  36088. /**
  36089. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36090. */
  36091. pinchPrecision: number;
  36092. /**
  36093. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36094. * It will be used instead of pinchDeltaPrecision if different from 0.
  36095. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36096. */
  36097. pinchDeltaPercentage: number;
  36098. /**
  36099. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36100. */
  36101. panningSensibility: number;
  36102. /**
  36103. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36104. */
  36105. keysUp: number[];
  36106. /**
  36107. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36108. */
  36109. keysDown: number[];
  36110. /**
  36111. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36112. */
  36113. keysLeft: number[];
  36114. /**
  36115. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36116. */
  36117. keysRight: number[];
  36118. /**
  36119. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36120. */
  36121. wheelPrecision: number;
  36122. /**
  36123. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36124. * It will be used instead of pinchDeltaPrecision if different from 0.
  36125. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36126. */
  36127. wheelDeltaPercentage: number;
  36128. /**
  36129. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36130. */
  36131. zoomOnFactor: number;
  36132. /**
  36133. * Defines a screen offset for the camera position.
  36134. */
  36135. targetScreenOffset: Vector2;
  36136. /**
  36137. * Allows the camera to be completely reversed.
  36138. * If false the camera can not arrive upside down.
  36139. */
  36140. allowUpsideDown: boolean;
  36141. /**
  36142. * Define if double tap/click is used to restore the previously saved state of the camera.
  36143. */
  36144. useInputToRestoreState: boolean;
  36145. /** @hidden */ private _viewMatrix: Matrix;
  36146. /** @hidden */ private _useCtrlForPanning: boolean;
  36147. /** @hidden */ private _panningMouseButton: number;
  36148. /**
  36149. * Defines the input associated to the camera.
  36150. */
  36151. inputs: ArcRotateCameraInputsManager;
  36152. /** @hidden */ private _reset: () => void;
  36153. /**
  36154. * Defines the allowed panning axis.
  36155. */
  36156. panningAxis: Vector3;
  36157. protected _localDirection: Vector3;
  36158. protected _transformedDirection: Vector3;
  36159. private _bouncingBehavior;
  36160. /**
  36161. * Gets the bouncing behavior of the camera if it has been enabled.
  36162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36163. */
  36164. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36165. /**
  36166. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36167. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36168. */
  36169. useBouncingBehavior: boolean;
  36170. private _framingBehavior;
  36171. /**
  36172. * Gets the framing behavior of the camera if it has been enabled.
  36173. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36174. */
  36175. readonly framingBehavior: Nullable<FramingBehavior>;
  36176. /**
  36177. * Defines if the framing behavior of the camera is enabled on the camera.
  36178. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36179. */
  36180. useFramingBehavior: boolean;
  36181. private _autoRotationBehavior;
  36182. /**
  36183. * Gets the auto rotation behavior of the camera if it has been enabled.
  36184. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36185. */
  36186. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36187. /**
  36188. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36189. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36190. */
  36191. useAutoRotationBehavior: boolean;
  36192. /**
  36193. * Observable triggered when the mesh target has been changed on the camera.
  36194. */
  36195. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36196. /**
  36197. * Event raised when the camera is colliding with a mesh.
  36198. */
  36199. onCollide: (collidedMesh: AbstractMesh) => void;
  36200. /**
  36201. * Defines whether the camera should check collision with the objects oh the scene.
  36202. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36203. */
  36204. checkCollisions: boolean;
  36205. /**
  36206. * Defines the collision radius of the camera.
  36207. * This simulates a sphere around the camera.
  36208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36209. */
  36210. collisionRadius: Vector3;
  36211. protected _collider: Collider;
  36212. protected _previousPosition: Vector3;
  36213. protected _collisionVelocity: Vector3;
  36214. protected _newPosition: Vector3;
  36215. protected _previousAlpha: number;
  36216. protected _previousBeta: number;
  36217. protected _previousRadius: number;
  36218. protected _collisionTriggered: boolean;
  36219. protected _targetBoundingCenter: Nullable<Vector3>;
  36220. private _computationVector;
  36221. /**
  36222. * Instantiates a new ArcRotateCamera in a given scene
  36223. * @param name Defines the name of the camera
  36224. * @param alpha Defines the camera rotation along the logitudinal axis
  36225. * @param beta Defines the camera rotation along the latitudinal axis
  36226. * @param radius Defines the camera distance from its target
  36227. * @param target Defines the camera target
  36228. * @param scene Defines the scene the camera belongs to
  36229. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36230. */
  36231. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36232. /** @hidden */ private _initCache(): void;
  36233. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  36234. protected _getTargetPosition(): Vector3;
  36235. private _storedAlpha;
  36236. private _storedBeta;
  36237. private _storedRadius;
  36238. private _storedTarget;
  36239. private _storedTargetScreenOffset;
  36240. /**
  36241. * Stores the current state of the camera (alpha, beta, radius and target)
  36242. * @returns the camera itself
  36243. */
  36244. storeState(): Camera;
  36245. /**
  36246. * @hidden
  36247. * Restored camera state. You must call storeState() first
  36248. */ private _restoreStateValues(): boolean;
  36249. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  36250. /**
  36251. * Attached controls to the current camera.
  36252. * @param element Defines the element the controls should be listened from
  36253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36254. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36255. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36256. */
  36257. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36258. /**
  36259. * Detach the current controls from the camera.
  36260. * The camera will stop reacting to inputs.
  36261. * @param element Defines the element to stop listening the inputs from
  36262. */
  36263. detachControl(element: HTMLElement): void;
  36264. /** @hidden */ private _checkInputs(): void;
  36265. protected _checkLimits(): void;
  36266. /**
  36267. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36268. */
  36269. rebuildAnglesAndRadius(): void;
  36270. /**
  36271. * Use a position to define the current camera related information like alpha, beta and radius
  36272. * @param position Defines the position to set the camera at
  36273. */
  36274. setPosition(position: Vector3): void;
  36275. /**
  36276. * Defines the target the camera should look at.
  36277. * This will automatically adapt alpha beta and radius to fit within the new target.
  36278. * @param target Defines the new target as a Vector or a mesh
  36279. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36280. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36281. */
  36282. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36283. /** @hidden */ private _getViewMatrix(): Matrix;
  36284. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36285. /**
  36286. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36287. * @param meshes Defines the mesh to zoom on
  36288. * @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)
  36289. */
  36290. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36291. /**
  36292. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36293. * The target will be changed but the radius
  36294. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36295. * @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)
  36296. */
  36297. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36298. min: Vector3;
  36299. max: Vector3;
  36300. distance: number;
  36301. }, doNotUpdateMaxZ?: boolean): void;
  36302. /**
  36303. * @override
  36304. * Override Camera.createRigCamera
  36305. */
  36306. createRigCamera(name: string, cameraIndex: number): Camera;
  36307. /**
  36308. * @hidden
  36309. * @override
  36310. * Override Camera._updateRigCameras
  36311. */ private _updateRigCameras(): void;
  36312. /**
  36313. * Destroy the camera and release the current resources hold by it.
  36314. */
  36315. dispose(): void;
  36316. /**
  36317. * Gets the current object class name.
  36318. * @return the class name
  36319. */
  36320. getClassName(): string;
  36321. }
  36322. }
  36323. declare module BABYLON {
  36324. /**
  36325. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36326. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36327. */
  36328. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36329. /**
  36330. * Gets the name of the behavior.
  36331. */
  36332. readonly name: string;
  36333. private _zoomStopsAnimation;
  36334. private _idleRotationSpeed;
  36335. private _idleRotationWaitTime;
  36336. private _idleRotationSpinupTime;
  36337. /**
  36338. * Sets the flag that indicates if user zooming should stop animation.
  36339. */
  36340. /**
  36341. * Gets the flag that indicates if user zooming should stop animation.
  36342. */
  36343. zoomStopsAnimation: boolean;
  36344. /**
  36345. * Sets the default speed at which the camera rotates around the model.
  36346. */
  36347. /**
  36348. * Gets the default speed at which the camera rotates around the model.
  36349. */
  36350. idleRotationSpeed: number;
  36351. /**
  36352. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36353. */
  36354. /**
  36355. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36356. */
  36357. idleRotationWaitTime: number;
  36358. /**
  36359. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36360. */
  36361. /**
  36362. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36363. */
  36364. idleRotationSpinupTime: number;
  36365. /**
  36366. * Gets a value indicating if the camera is currently rotating because of this behavior
  36367. */
  36368. readonly rotationInProgress: boolean;
  36369. private _onPrePointerObservableObserver;
  36370. private _onAfterCheckInputsObserver;
  36371. private _attachedCamera;
  36372. private _isPointerDown;
  36373. private _lastFrameTime;
  36374. private _lastInteractionTime;
  36375. private _cameraRotationSpeed;
  36376. /**
  36377. * Initializes the behavior.
  36378. */
  36379. init(): void;
  36380. /**
  36381. * Attaches the behavior to its arc rotate camera.
  36382. * @param camera Defines the camera to attach the behavior to
  36383. */
  36384. attach(camera: ArcRotateCamera): void;
  36385. /**
  36386. * Detaches the behavior from its current arc rotate camera.
  36387. */
  36388. detach(): void;
  36389. /**
  36390. * Returns true if user is scrolling.
  36391. * @return true if user is scrolling.
  36392. */
  36393. private _userIsZooming;
  36394. private _lastFrameRadius;
  36395. private _shouldAnimationStopForInteraction;
  36396. /**
  36397. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36398. */
  36399. private _applyUserInteraction;
  36400. private _userIsMoving;
  36401. }
  36402. }
  36403. declare module BABYLON {
  36404. /**
  36405. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36406. */
  36407. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36408. private ui;
  36409. /**
  36410. * The name of the behavior
  36411. */
  36412. name: string;
  36413. /**
  36414. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36415. */
  36416. distanceAwayFromFace: number;
  36417. /**
  36418. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36419. */
  36420. distanceAwayFromBottomOfFace: number;
  36421. private _faceVectors;
  36422. private _target;
  36423. private _scene;
  36424. private _onRenderObserver;
  36425. private _tmpMatrix;
  36426. private _tmpVector;
  36427. /**
  36428. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36429. * @param ui The transform node that should be attched to the mesh
  36430. */
  36431. constructor(ui: TransformNode);
  36432. /**
  36433. * Initializes the behavior
  36434. */
  36435. init(): void;
  36436. private _closestFace;
  36437. private _zeroVector;
  36438. private _lookAtTmpMatrix;
  36439. private _lookAtToRef;
  36440. /**
  36441. * Attaches the AttachToBoxBehavior to the passed in mesh
  36442. * @param target The mesh that the specified node will be attached to
  36443. */
  36444. attach(target: Mesh): void;
  36445. /**
  36446. * Detaches the behavior from the mesh
  36447. */
  36448. detach(): void;
  36449. }
  36450. }
  36451. declare module BABYLON {
  36452. /**
  36453. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36454. */
  36455. export class FadeInOutBehavior implements Behavior<Mesh> {
  36456. /**
  36457. * Time in milliseconds to delay before fading in (Default: 0)
  36458. */
  36459. delay: number;
  36460. /**
  36461. * Time in milliseconds for the mesh to fade in (Default: 300)
  36462. */
  36463. fadeInTime: number;
  36464. private _millisecondsPerFrame;
  36465. private _hovered;
  36466. private _hoverValue;
  36467. private _ownerNode;
  36468. /**
  36469. * Instatiates the FadeInOutBehavior
  36470. */
  36471. constructor();
  36472. /**
  36473. * The name of the behavior
  36474. */
  36475. readonly name: string;
  36476. /**
  36477. * Initializes the behavior
  36478. */
  36479. init(): void;
  36480. /**
  36481. * Attaches the fade behavior on the passed in mesh
  36482. * @param ownerNode The mesh that will be faded in/out once attached
  36483. */
  36484. attach(ownerNode: Mesh): void;
  36485. /**
  36486. * Detaches the behavior from the mesh
  36487. */
  36488. detach(): void;
  36489. /**
  36490. * Triggers the mesh to begin fading in or out
  36491. * @param value if the object should fade in or out (true to fade in)
  36492. */
  36493. fadeIn(value: boolean): void;
  36494. private _update;
  36495. private _setAllVisibility;
  36496. }
  36497. }
  36498. declare module BABYLON {
  36499. /**
  36500. * Class containing a set of static utilities functions for managing Pivots
  36501. * @hidden
  36502. */
  36503. export class PivotTools {
  36504. private static _PivotCached;
  36505. private static _OldPivotPoint;
  36506. private static _PivotTranslation;
  36507. private static _PivotTmpVector;
  36508. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36509. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  36510. }
  36511. }
  36512. declare module BABYLON {
  36513. /**
  36514. * Class containing static functions to help procedurally build meshes
  36515. */
  36516. export class PlaneBuilder {
  36517. /**
  36518. * Creates a plane mesh
  36519. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36520. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36521. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36523. * * 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
  36524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36525. * @param name defines the name of the mesh
  36526. * @param options defines the options used to create the mesh
  36527. * @param scene defines the hosting scene
  36528. * @returns the plane mesh
  36529. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36530. */
  36531. static CreatePlane(name: string, options: {
  36532. size?: number;
  36533. width?: number;
  36534. height?: number;
  36535. sideOrientation?: number;
  36536. frontUVs?: Vector4;
  36537. backUVs?: Vector4;
  36538. updatable?: boolean;
  36539. sourcePlane?: Plane;
  36540. }, scene?: Nullable<Scene>): Mesh;
  36541. }
  36542. }
  36543. declare module BABYLON {
  36544. /**
  36545. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36546. */
  36547. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36548. private static _AnyMouseID;
  36549. /**
  36550. * Abstract mesh the behavior is set on
  36551. */
  36552. attachedNode: AbstractMesh;
  36553. private _dragPlane;
  36554. private _scene;
  36555. private _pointerObserver;
  36556. private _beforeRenderObserver;
  36557. private static _planeScene;
  36558. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36559. /**
  36560. * 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)
  36561. */
  36562. maxDragAngle: number;
  36563. /**
  36564. * @hidden
  36565. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36566. /**
  36567. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36568. */
  36569. currentDraggingPointerID: number;
  36570. /**
  36571. * The last position where the pointer hit the drag plane in world space
  36572. */
  36573. lastDragPosition: Vector3;
  36574. /**
  36575. * If the behavior is currently in a dragging state
  36576. */
  36577. dragging: boolean;
  36578. /**
  36579. * 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)
  36580. */
  36581. dragDeltaRatio: number;
  36582. /**
  36583. * If the drag plane orientation should be updated during the dragging (Default: true)
  36584. */
  36585. updateDragPlane: boolean;
  36586. private _debugMode;
  36587. private _moving;
  36588. /**
  36589. * Fires each time the attached mesh is dragged with the pointer
  36590. * * delta between last drag position and current drag position in world space
  36591. * * dragDistance along the drag axis
  36592. * * dragPlaneNormal normal of the current drag plane used during the drag
  36593. * * dragPlanePoint in world space where the drag intersects the drag plane
  36594. */
  36595. onDragObservable: Observable<{
  36596. delta: Vector3;
  36597. dragPlanePoint: Vector3;
  36598. dragPlaneNormal: Vector3;
  36599. dragDistance: number;
  36600. pointerId: number;
  36601. }>;
  36602. /**
  36603. * Fires each time a drag begins (eg. mouse down on mesh)
  36604. */
  36605. onDragStartObservable: Observable<{
  36606. dragPlanePoint: Vector3;
  36607. pointerId: number;
  36608. }>;
  36609. /**
  36610. * Fires each time a drag ends (eg. mouse release after drag)
  36611. */
  36612. onDragEndObservable: Observable<{
  36613. dragPlanePoint: Vector3;
  36614. pointerId: number;
  36615. }>;
  36616. /**
  36617. * If the attached mesh should be moved when dragged
  36618. */
  36619. moveAttached: boolean;
  36620. /**
  36621. * If the drag behavior will react to drag events (Default: true)
  36622. */
  36623. enabled: boolean;
  36624. /**
  36625. * If pointer events should start and release the drag (Default: true)
  36626. */
  36627. startAndReleaseDragOnPointerEvents: boolean;
  36628. /**
  36629. * If camera controls should be detached during the drag
  36630. */
  36631. detachCameraControls: boolean;
  36632. /**
  36633. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36634. */
  36635. useObjectOrienationForDragging: boolean;
  36636. private _options;
  36637. /**
  36638. * Creates a pointer drag behavior that can be attached to a mesh
  36639. * @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)
  36640. */
  36641. constructor(options?: {
  36642. dragAxis?: Vector3;
  36643. dragPlaneNormal?: Vector3;
  36644. });
  36645. /**
  36646. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36647. */
  36648. validateDrag: (targetPosition: Vector3) => boolean;
  36649. /**
  36650. * The name of the behavior
  36651. */
  36652. readonly name: string;
  36653. /**
  36654. * Initializes the behavior
  36655. */
  36656. init(): void;
  36657. private _tmpVector;
  36658. private _alternatePickedPoint;
  36659. private _worldDragAxis;
  36660. private _targetPosition;
  36661. private _attachedElement;
  36662. /**
  36663. * Attaches the drag behavior the passed in mesh
  36664. * @param ownerNode The mesh that will be dragged around once attached
  36665. * @param predicate Predicate to use for pick filtering
  36666. */
  36667. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36668. /**
  36669. * Force relase the drag action by code.
  36670. */
  36671. releaseDrag(): void;
  36672. private _startDragRay;
  36673. private _lastPointerRay;
  36674. /**
  36675. * Simulates the start of a pointer drag event on the behavior
  36676. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36677. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36678. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36679. */
  36680. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36681. private _startDrag;
  36682. private _dragDelta;
  36683. private _moveDrag;
  36684. private _pickWithRayOnDragPlane;
  36685. private _pointA;
  36686. private _pointB;
  36687. private _pointC;
  36688. private _lineA;
  36689. private _lineB;
  36690. private _localAxis;
  36691. private _lookAt;
  36692. private _updateDragPlanePosition;
  36693. /**
  36694. * Detaches the behavior from the mesh
  36695. */
  36696. detach(): void;
  36697. }
  36698. }
  36699. declare module BABYLON {
  36700. /**
  36701. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36702. */
  36703. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36704. private _dragBehaviorA;
  36705. private _dragBehaviorB;
  36706. private _startDistance;
  36707. private _initialScale;
  36708. private _targetScale;
  36709. private _ownerNode;
  36710. private _sceneRenderObserver;
  36711. /**
  36712. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36713. */
  36714. constructor();
  36715. /**
  36716. * The name of the behavior
  36717. */
  36718. readonly name: string;
  36719. /**
  36720. * Initializes the behavior
  36721. */
  36722. init(): void;
  36723. private _getCurrentDistance;
  36724. /**
  36725. * Attaches the scale behavior the passed in mesh
  36726. * @param ownerNode The mesh that will be scaled around once attached
  36727. */
  36728. attach(ownerNode: Mesh): void;
  36729. /**
  36730. * Detaches the behavior from the mesh
  36731. */
  36732. detach(): void;
  36733. }
  36734. }
  36735. declare module BABYLON {
  36736. /**
  36737. * 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
  36738. */
  36739. export class SixDofDragBehavior implements Behavior<Mesh> {
  36740. private static _virtualScene;
  36741. private _ownerNode;
  36742. private _sceneRenderObserver;
  36743. private _scene;
  36744. private _targetPosition;
  36745. private _virtualOriginMesh;
  36746. private _virtualDragMesh;
  36747. private _pointerObserver;
  36748. private _moving;
  36749. private _startingOrientation;
  36750. /**
  36751. * 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)
  36752. */
  36753. private zDragFactor;
  36754. /**
  36755. * If the object should rotate to face the drag origin
  36756. */
  36757. rotateDraggedObject: boolean;
  36758. /**
  36759. * If the behavior is currently in a dragging state
  36760. */
  36761. dragging: boolean;
  36762. /**
  36763. * 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)
  36764. */
  36765. dragDeltaRatio: number;
  36766. /**
  36767. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36768. */
  36769. currentDraggingPointerID: number;
  36770. /**
  36771. * If camera controls should be detached during the drag
  36772. */
  36773. detachCameraControls: boolean;
  36774. /**
  36775. * Fires each time a drag starts
  36776. */
  36777. onDragStartObservable: Observable<{}>;
  36778. /**
  36779. * Fires each time a drag ends (eg. mouse release after drag)
  36780. */
  36781. onDragEndObservable: Observable<{}>;
  36782. /**
  36783. * 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
  36784. */
  36785. constructor();
  36786. /**
  36787. * The name of the behavior
  36788. */
  36789. readonly name: string;
  36790. /**
  36791. * Initializes the behavior
  36792. */
  36793. init(): void;
  36794. /**
  36795. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36796. */
  36797. private readonly _pointerCamera;
  36798. /**
  36799. * Attaches the scale behavior the passed in mesh
  36800. * @param ownerNode The mesh that will be scaled around once attached
  36801. */
  36802. attach(ownerNode: Mesh): void;
  36803. /**
  36804. * Detaches the behavior from the mesh
  36805. */
  36806. detach(): void;
  36807. }
  36808. }
  36809. declare module BABYLON {
  36810. /**
  36811. * Class used to apply inverse kinematics to bones
  36812. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36813. */
  36814. export class BoneIKController {
  36815. private static _tmpVecs;
  36816. private static _tmpQuat;
  36817. private static _tmpMats;
  36818. /**
  36819. * Gets or sets the target mesh
  36820. */
  36821. targetMesh: AbstractMesh;
  36822. /** Gets or sets the mesh used as pole */
  36823. poleTargetMesh: AbstractMesh;
  36824. /**
  36825. * Gets or sets the bone used as pole
  36826. */
  36827. poleTargetBone: Nullable<Bone>;
  36828. /**
  36829. * Gets or sets the target position
  36830. */
  36831. targetPosition: Vector3;
  36832. /**
  36833. * Gets or sets the pole target position
  36834. */
  36835. poleTargetPosition: Vector3;
  36836. /**
  36837. * Gets or sets the pole target local offset
  36838. */
  36839. poleTargetLocalOffset: Vector3;
  36840. /**
  36841. * Gets or sets the pole angle
  36842. */
  36843. poleAngle: number;
  36844. /**
  36845. * Gets or sets the mesh associated with the controller
  36846. */
  36847. mesh: AbstractMesh;
  36848. /**
  36849. * 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)
  36850. */
  36851. slerpAmount: number;
  36852. private _bone1Quat;
  36853. private _bone1Mat;
  36854. private _bone2Ang;
  36855. private _bone1;
  36856. private _bone2;
  36857. private _bone1Length;
  36858. private _bone2Length;
  36859. private _maxAngle;
  36860. private _maxReach;
  36861. private _rightHandedSystem;
  36862. private _bendAxis;
  36863. private _slerping;
  36864. private _adjustRoll;
  36865. /**
  36866. * Gets or sets maximum allowed angle
  36867. */
  36868. maxAngle: number;
  36869. /**
  36870. * Creates a new BoneIKController
  36871. * @param mesh defines the mesh to control
  36872. * @param bone defines the bone to control
  36873. * @param options defines options to set up the controller
  36874. */
  36875. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36876. targetMesh?: AbstractMesh;
  36877. poleTargetMesh?: AbstractMesh;
  36878. poleTargetBone?: Bone;
  36879. poleTargetLocalOffset?: Vector3;
  36880. poleAngle?: number;
  36881. bendAxis?: Vector3;
  36882. maxAngle?: number;
  36883. slerpAmount?: number;
  36884. });
  36885. private _setMaxAngle;
  36886. /**
  36887. * Force the controller to update the bones
  36888. */
  36889. update(): void;
  36890. }
  36891. }
  36892. declare module BABYLON {
  36893. /**
  36894. * Class used to make a bone look toward a point in space
  36895. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36896. */
  36897. export class BoneLookController {
  36898. private static _tmpVecs;
  36899. private static _tmpQuat;
  36900. private static _tmpMats;
  36901. /**
  36902. * The target Vector3 that the bone will look at
  36903. */
  36904. target: Vector3;
  36905. /**
  36906. * The mesh that the bone is attached to
  36907. */
  36908. mesh: AbstractMesh;
  36909. /**
  36910. * The bone that will be looking to the target
  36911. */
  36912. bone: Bone;
  36913. /**
  36914. * The up axis of the coordinate system that is used when the bone is rotated
  36915. */
  36916. upAxis: Vector3;
  36917. /**
  36918. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36919. */
  36920. upAxisSpace: Space;
  36921. /**
  36922. * Used to make an adjustment to the yaw of the bone
  36923. */
  36924. adjustYaw: number;
  36925. /**
  36926. * Used to make an adjustment to the pitch of the bone
  36927. */
  36928. adjustPitch: number;
  36929. /**
  36930. * Used to make an adjustment to the roll of the bone
  36931. */
  36932. adjustRoll: number;
  36933. /**
  36934. * 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)
  36935. */
  36936. slerpAmount: number;
  36937. private _minYaw;
  36938. private _maxYaw;
  36939. private _minPitch;
  36940. private _maxPitch;
  36941. private _minYawSin;
  36942. private _minYawCos;
  36943. private _maxYawSin;
  36944. private _maxYawCos;
  36945. private _midYawConstraint;
  36946. private _minPitchTan;
  36947. private _maxPitchTan;
  36948. private _boneQuat;
  36949. private _slerping;
  36950. private _transformYawPitch;
  36951. private _transformYawPitchInv;
  36952. private _firstFrameSkipped;
  36953. private _yawRange;
  36954. private _fowardAxis;
  36955. /**
  36956. * Gets or sets the minimum yaw angle that the bone can look to
  36957. */
  36958. minYaw: number;
  36959. /**
  36960. * Gets or sets the maximum yaw angle that the bone can look to
  36961. */
  36962. maxYaw: number;
  36963. /**
  36964. * Gets or sets the minimum pitch angle that the bone can look to
  36965. */
  36966. minPitch: number;
  36967. /**
  36968. * Gets or sets the maximum pitch angle that the bone can look to
  36969. */
  36970. maxPitch: number;
  36971. /**
  36972. * Create a BoneLookController
  36973. * @param mesh the mesh that the bone belongs to
  36974. * @param bone the bone that will be looking to the target
  36975. * @param target the target Vector3 to look at
  36976. * @param options optional settings:
  36977. * * maxYaw: the maximum angle the bone will yaw to
  36978. * * minYaw: the minimum angle the bone will yaw to
  36979. * * maxPitch: the maximum angle the bone will pitch to
  36980. * * minPitch: the minimum angle the bone will yaw to
  36981. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36982. * * upAxis: the up axis of the coordinate system
  36983. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36984. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36985. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36986. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36987. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36988. * * adjustRoll: used to make an adjustment to the roll of the bone
  36989. **/
  36990. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36991. maxYaw?: number;
  36992. minYaw?: number;
  36993. maxPitch?: number;
  36994. minPitch?: number;
  36995. slerpAmount?: number;
  36996. upAxis?: Vector3;
  36997. upAxisSpace?: Space;
  36998. yawAxis?: Vector3;
  36999. pitchAxis?: Vector3;
  37000. adjustYaw?: number;
  37001. adjustPitch?: number;
  37002. adjustRoll?: number;
  37003. });
  37004. /**
  37005. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37006. */
  37007. update(): void;
  37008. private _getAngleDiff;
  37009. private _getAngleBetween;
  37010. private _isAngleBetween;
  37011. }
  37012. }
  37013. declare module BABYLON {
  37014. /**
  37015. * Manage the gamepad inputs to control an arc rotate camera.
  37016. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37017. */
  37018. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37019. /**
  37020. * Defines the camera the input is attached to.
  37021. */
  37022. camera: ArcRotateCamera;
  37023. /**
  37024. * Defines the gamepad the input is gathering event from.
  37025. */
  37026. gamepad: Nullable<Gamepad>;
  37027. /**
  37028. * Defines the gamepad rotation sensiblity.
  37029. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37030. */
  37031. gamepadRotationSensibility: number;
  37032. /**
  37033. * Defines the gamepad move sensiblity.
  37034. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37035. */
  37036. gamepadMoveSensibility: number;
  37037. private _yAxisScale;
  37038. /**
  37039. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37040. */
  37041. invertYAxis: boolean;
  37042. private _onGamepadConnectedObserver;
  37043. private _onGamepadDisconnectedObserver;
  37044. /**
  37045. * Attach the input controls to a specific dom element to get the input from.
  37046. * @param element Defines the element the controls should be listened from
  37047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37048. */
  37049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37050. /**
  37051. * Detach the current controls from the specified dom element.
  37052. * @param element Defines the element to stop listening the inputs from
  37053. */
  37054. detachControl(element: Nullable<HTMLElement>): void;
  37055. /**
  37056. * Update the current camera state depending on the inputs that have been used this frame.
  37057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37058. */
  37059. checkInputs(): void;
  37060. /**
  37061. * Gets the class name of the current intput.
  37062. * @returns the class name
  37063. */
  37064. getClassName(): string;
  37065. /**
  37066. * Get the friendly name associated with the input class.
  37067. * @returns the input friendly name
  37068. */
  37069. getSimpleName(): string;
  37070. }
  37071. }
  37072. declare module BABYLON {
  37073. interface ArcRotateCameraInputsManager {
  37074. /**
  37075. * Add orientation input support to the input manager.
  37076. * @returns the current input manager
  37077. */
  37078. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37079. }
  37080. /**
  37081. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37083. */
  37084. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37085. /**
  37086. * Defines the camera the input is attached to.
  37087. */
  37088. camera: ArcRotateCamera;
  37089. /**
  37090. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37091. */
  37092. alphaCorrection: number;
  37093. /**
  37094. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37095. */
  37096. gammaCorrection: number;
  37097. private _alpha;
  37098. private _gamma;
  37099. private _dirty;
  37100. private _deviceOrientationHandler;
  37101. /**
  37102. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37103. */
  37104. constructor();
  37105. /**
  37106. * Attach the input controls to a specific dom element to get the input from.
  37107. * @param element Defines the element the controls should be listened from
  37108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37109. */
  37110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37111. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37112. /**
  37113. * Update the current camera state depending on the inputs that have been used this frame.
  37114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37115. */
  37116. checkInputs(): void;
  37117. /**
  37118. * Detach the current controls from the specified dom element.
  37119. * @param element Defines the element to stop listening the inputs from
  37120. */
  37121. detachControl(element: Nullable<HTMLElement>): void;
  37122. /**
  37123. * Gets the class name of the current intput.
  37124. * @returns the class name
  37125. */
  37126. getClassName(): string;
  37127. /**
  37128. * Get the friendly name associated with the input class.
  37129. * @returns the input friendly name
  37130. */
  37131. getSimpleName(): string;
  37132. }
  37133. }
  37134. declare module BABYLON {
  37135. /**
  37136. * Listen to mouse events to control the camera.
  37137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37138. */
  37139. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37140. /**
  37141. * Defines the camera the input is attached to.
  37142. */
  37143. camera: FlyCamera;
  37144. /**
  37145. * Defines if touch is enabled. (Default is true.)
  37146. */
  37147. touchEnabled: boolean;
  37148. /**
  37149. * Defines the buttons associated with the input to handle camera rotation.
  37150. */
  37151. buttons: number[];
  37152. /**
  37153. * Assign buttons for Yaw control.
  37154. */
  37155. buttonsYaw: number[];
  37156. /**
  37157. * Assign buttons for Pitch control.
  37158. */
  37159. buttonsPitch: number[];
  37160. /**
  37161. * Assign buttons for Roll control.
  37162. */
  37163. buttonsRoll: number[];
  37164. /**
  37165. * Detect if any button is being pressed while mouse is moved.
  37166. * -1 = Mouse locked.
  37167. * 0 = Left button.
  37168. * 1 = Middle Button.
  37169. * 2 = Right Button.
  37170. */
  37171. activeButton: number;
  37172. /**
  37173. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37174. * Higher values reduce its sensitivity.
  37175. */
  37176. angularSensibility: number;
  37177. private _mousemoveCallback;
  37178. private _observer;
  37179. private _rollObserver;
  37180. private previousPosition;
  37181. private noPreventDefault;
  37182. private element;
  37183. /**
  37184. * Listen to mouse events to control the camera.
  37185. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37187. */
  37188. constructor(touchEnabled?: boolean);
  37189. /**
  37190. * Attach the mouse control to the HTML DOM element.
  37191. * @param element Defines the element that listens to the input events.
  37192. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37193. */
  37194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37195. /**
  37196. * Detach the current controls from the specified dom element.
  37197. * @param element Defines the element to stop listening the inputs from
  37198. */
  37199. detachControl(element: Nullable<HTMLElement>): void;
  37200. /**
  37201. * Gets the class name of the current input.
  37202. * @returns the class name.
  37203. */
  37204. getClassName(): string;
  37205. /**
  37206. * Get the friendly name associated with the input class.
  37207. * @returns the input's friendly name.
  37208. */
  37209. getSimpleName(): string;
  37210. private _pointerInput;
  37211. private _onMouseMove;
  37212. /**
  37213. * Rotate camera by mouse offset.
  37214. */
  37215. private rotateCamera;
  37216. }
  37217. }
  37218. declare module BABYLON {
  37219. /**
  37220. * Default Inputs manager for the FlyCamera.
  37221. * It groups all the default supported inputs for ease of use.
  37222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37223. */
  37224. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37225. /**
  37226. * Instantiates a new FlyCameraInputsManager.
  37227. * @param camera Defines the camera the inputs belong to.
  37228. */
  37229. constructor(camera: FlyCamera);
  37230. /**
  37231. * Add keyboard input support to the input manager.
  37232. * @returns the new FlyCameraKeyboardMoveInput().
  37233. */
  37234. addKeyboard(): FlyCameraInputsManager;
  37235. /**
  37236. * Add mouse input support to the input manager.
  37237. * @param touchEnabled Enable touch screen support.
  37238. * @returns the new FlyCameraMouseInput().
  37239. */
  37240. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37241. }
  37242. }
  37243. declare module BABYLON {
  37244. /**
  37245. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37246. * such as in a 3D Space Shooter or a Flight Simulator.
  37247. */
  37248. export class FlyCamera extends TargetCamera {
  37249. /**
  37250. * Define the collision ellipsoid of the camera.
  37251. * This is helpful for simulating a camera body, like a player's body.
  37252. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37253. */
  37254. ellipsoid: Vector3;
  37255. /**
  37256. * Define an offset for the position of the ellipsoid around the camera.
  37257. * This can be helpful if the camera is attached away from the player's body center,
  37258. * such as at its head.
  37259. */
  37260. ellipsoidOffset: Vector3;
  37261. /**
  37262. * Enable or disable collisions of the camera with the rest of the scene objects.
  37263. */
  37264. checkCollisions: boolean;
  37265. /**
  37266. * Enable or disable gravity on the camera.
  37267. */
  37268. applyGravity: boolean;
  37269. /**
  37270. * Define the current direction the camera is moving to.
  37271. */
  37272. cameraDirection: Vector3;
  37273. /**
  37274. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37275. * This overrides and empties cameraRotation.
  37276. */
  37277. rotationQuaternion: Quaternion;
  37278. /**
  37279. * Track Roll to maintain the wanted Rolling when looking around.
  37280. */ private _trackRoll: number;
  37281. /**
  37282. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37283. */
  37284. rollCorrect: number;
  37285. /**
  37286. * Mimic a banked turn, Rolling the camera when Yawing.
  37287. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37288. */
  37289. bankedTurn: boolean;
  37290. /**
  37291. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37292. */
  37293. bankedTurnLimit: number;
  37294. /**
  37295. * Value of 0 disables the banked Roll.
  37296. * Value of 1 is equal to the Yaw angle in radians.
  37297. */
  37298. bankedTurnMultiplier: number;
  37299. /**
  37300. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37301. */
  37302. inputs: FlyCameraInputsManager;
  37303. /**
  37304. * Gets the input sensibility for mouse input.
  37305. * Higher values reduce sensitivity.
  37306. */
  37307. /**
  37308. * Sets the input sensibility for a mouse input.
  37309. * Higher values reduce sensitivity.
  37310. */
  37311. angularSensibility: number;
  37312. /**
  37313. * Get the keys for camera movement forward.
  37314. */
  37315. /**
  37316. * Set the keys for camera movement forward.
  37317. */
  37318. keysForward: number[];
  37319. /**
  37320. * Get the keys for camera movement backward.
  37321. */
  37322. keysBackward: number[];
  37323. /**
  37324. * Get the keys for camera movement up.
  37325. */
  37326. /**
  37327. * Set the keys for camera movement up.
  37328. */
  37329. keysUp: number[];
  37330. /**
  37331. * Get the keys for camera movement down.
  37332. */
  37333. /**
  37334. * Set the keys for camera movement down.
  37335. */
  37336. keysDown: number[];
  37337. /**
  37338. * Get the keys for camera movement left.
  37339. */
  37340. /**
  37341. * Set the keys for camera movement left.
  37342. */
  37343. keysLeft: number[];
  37344. /**
  37345. * Set the keys for camera movement right.
  37346. */
  37347. /**
  37348. * Set the keys for camera movement right.
  37349. */
  37350. keysRight: number[];
  37351. /**
  37352. * Event raised when the camera collides with a mesh in the scene.
  37353. */
  37354. onCollide: (collidedMesh: AbstractMesh) => void;
  37355. private _collider;
  37356. private _needMoveForGravity;
  37357. private _oldPosition;
  37358. private _diffPosition;
  37359. private _newPosition;
  37360. /** @hidden */ private _localDirection: Vector3;
  37361. /** @hidden */ private _transformedDirection: Vector3;
  37362. /**
  37363. * Instantiates a FlyCamera.
  37364. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37365. * such as in a 3D Space Shooter or a Flight Simulator.
  37366. * @param name Define the name of the camera in the scene.
  37367. * @param position Define the starting position of the camera in the scene.
  37368. * @param scene Define the scene the camera belongs to.
  37369. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37370. */
  37371. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37372. /**
  37373. * Attach a control to the HTML DOM element.
  37374. * @param element Defines the element that listens to the input events.
  37375. * @param noPreventDefault Defines whether events 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 a control from the HTML DOM element.
  37380. * The camera will stop reacting to that input.
  37381. * @param element Defines the element that listens to the input events.
  37382. */
  37383. detachControl(element: HTMLElement): void;
  37384. private _collisionMask;
  37385. /**
  37386. * Get the mask that the camera ignores in collision events.
  37387. */
  37388. /**
  37389. * Set the mask that the camera ignores in collision events.
  37390. */
  37391. collisionMask: number;
  37392. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  37393. /** @hidden */
  37394. private _onCollisionPositionChange;
  37395. /** @hidden */ private _checkInputs(): void;
  37396. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  37397. /** @hidden */ private _updatePosition(): void;
  37398. /**
  37399. * Restore the Roll to its target value at the rate specified.
  37400. * @param rate - Higher means slower restoring.
  37401. * @hidden
  37402. */
  37403. restoreRoll(rate: number): void;
  37404. /**
  37405. * Destroy the camera and release the current resources held by it.
  37406. */
  37407. dispose(): void;
  37408. /**
  37409. * Get the current object class name.
  37410. * @returns the class name.
  37411. */
  37412. getClassName(): string;
  37413. }
  37414. }
  37415. declare module BABYLON {
  37416. /**
  37417. * Listen to keyboard events to control the camera.
  37418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37419. */
  37420. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37421. /**
  37422. * Defines the camera the input is attached to.
  37423. */
  37424. camera: FlyCamera;
  37425. /**
  37426. * The list of keyboard keys used to control the forward move of the camera.
  37427. */
  37428. keysForward: number[];
  37429. /**
  37430. * The list of keyboard keys used to control the backward move of the camera.
  37431. */
  37432. keysBackward: number[];
  37433. /**
  37434. * The list of keyboard keys used to control the forward move of the camera.
  37435. */
  37436. keysUp: number[];
  37437. /**
  37438. * The list of keyboard keys used to control the backward move of the camera.
  37439. */
  37440. keysDown: number[];
  37441. /**
  37442. * The list of keyboard keys used to control the right strafe move of the camera.
  37443. */
  37444. keysRight: number[];
  37445. /**
  37446. * The list of keyboard keys used to control the left strafe move of the camera.
  37447. */
  37448. keysLeft: number[];
  37449. private _keys;
  37450. private _onCanvasBlurObserver;
  37451. private _onKeyboardObserver;
  37452. private _engine;
  37453. private _scene;
  37454. /**
  37455. * Attach the input controls to a specific dom element to get the input from.
  37456. * @param element Defines the element the controls should be listened from
  37457. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37458. */
  37459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37460. /**
  37461. * Detach the current controls from the specified dom element.
  37462. * @param element Defines the element to stop listening the inputs from
  37463. */
  37464. detachControl(element: Nullable<HTMLElement>): void;
  37465. /**
  37466. * Gets the class name of the current intput.
  37467. * @returns the class name
  37468. */
  37469. getClassName(): string;
  37470. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  37471. /**
  37472. * Get the friendly name associated with the input class.
  37473. * @returns the input friendly name
  37474. */
  37475. getSimpleName(): string;
  37476. /**
  37477. * Update the current camera state depending on the inputs that have been used this frame.
  37478. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37479. */
  37480. checkInputs(): void;
  37481. }
  37482. }
  37483. declare module BABYLON {
  37484. /**
  37485. * Manage the mouse wheel inputs to control a follow camera.
  37486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37487. */
  37488. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37489. /**
  37490. * Defines the camera the input is attached to.
  37491. */
  37492. camera: FollowCamera;
  37493. /**
  37494. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37495. */
  37496. axisControlRadius: boolean;
  37497. /**
  37498. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37499. */
  37500. axisControlHeight: boolean;
  37501. /**
  37502. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37503. */
  37504. axisControlRotation: boolean;
  37505. /**
  37506. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37507. * relation to mouseWheel events.
  37508. */
  37509. wheelPrecision: number;
  37510. /**
  37511. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37512. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37513. */
  37514. wheelDeltaPercentage: number;
  37515. private _wheel;
  37516. private _observer;
  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. * Gets the class name of the current intput.
  37530. * @returns the class name
  37531. */
  37532. getClassName(): string;
  37533. /**
  37534. * Get the friendly name associated with the input class.
  37535. * @returns the input friendly name
  37536. */
  37537. getSimpleName(): string;
  37538. }
  37539. }
  37540. declare module BABYLON {
  37541. /**
  37542. * Manage the pointers inputs to control an follow camera.
  37543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37544. */
  37545. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37546. /**
  37547. * Defines the camera the input is attached to.
  37548. */
  37549. camera: FollowCamera;
  37550. /**
  37551. * Gets the class name of the current input.
  37552. * @returns the class name
  37553. */
  37554. getClassName(): string;
  37555. /**
  37556. * Defines the pointer angular sensibility along the X axis or how fast is
  37557. * the camera rotating.
  37558. * A negative number will reverse the axis direction.
  37559. */
  37560. angularSensibilityX: number;
  37561. /**
  37562. * Defines the pointer angular sensibility along the Y axis or how fast is
  37563. * the camera rotating.
  37564. * A negative number will reverse the axis direction.
  37565. */
  37566. angularSensibilityY: number;
  37567. /**
  37568. * Defines the pointer pinch precision or how fast is the camera zooming.
  37569. * A negative number will reverse the axis direction.
  37570. */
  37571. pinchPrecision: number;
  37572. /**
  37573. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37574. * from 0.
  37575. * It defines the percentage of current camera.radius to use as delta when
  37576. * pinch zoom is used.
  37577. */
  37578. pinchDeltaPercentage: number;
  37579. /**
  37580. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37581. */
  37582. axisXControlRadius: boolean;
  37583. /**
  37584. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37585. */
  37586. axisXControlHeight: boolean;
  37587. /**
  37588. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37589. */
  37590. axisXControlRotation: boolean;
  37591. /**
  37592. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37593. */
  37594. axisYControlRadius: boolean;
  37595. /**
  37596. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37597. */
  37598. axisYControlHeight: boolean;
  37599. /**
  37600. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37601. */
  37602. axisYControlRotation: boolean;
  37603. /**
  37604. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37605. */
  37606. axisPinchControlRadius: boolean;
  37607. /**
  37608. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37609. */
  37610. axisPinchControlHeight: boolean;
  37611. /**
  37612. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37613. */
  37614. axisPinchControlRotation: boolean;
  37615. /**
  37616. * Log error messages if basic misconfiguration has occurred.
  37617. */
  37618. warningEnable: boolean;
  37619. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37620. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37621. private _warningCounter;
  37622. private _warning;
  37623. }
  37624. }
  37625. declare module BABYLON {
  37626. /**
  37627. * Default Inputs manager for the FollowCamera.
  37628. * It groups all the default supported inputs for ease of use.
  37629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37630. */
  37631. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37632. /**
  37633. * Instantiates a new FollowCameraInputsManager.
  37634. * @param camera Defines the camera the inputs belong to
  37635. */
  37636. constructor(camera: FollowCamera);
  37637. /**
  37638. * Add keyboard input support to the input manager.
  37639. * @returns the current input manager
  37640. */
  37641. addKeyboard(): FollowCameraInputsManager;
  37642. /**
  37643. * Add mouse wheel input support to the input manager.
  37644. * @returns the current input manager
  37645. */
  37646. addMouseWheel(): FollowCameraInputsManager;
  37647. /**
  37648. * Add pointers input support to the input manager.
  37649. * @returns the current input manager
  37650. */
  37651. addPointers(): FollowCameraInputsManager;
  37652. /**
  37653. * Add orientation input support to the input manager.
  37654. * @returns the current input manager
  37655. */
  37656. addVRDeviceOrientation(): FollowCameraInputsManager;
  37657. }
  37658. }
  37659. declare module BABYLON {
  37660. /**
  37661. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37662. * an arc rotate version arcFollowCamera are available.
  37663. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37664. */
  37665. export class FollowCamera extends TargetCamera {
  37666. /**
  37667. * Distance the follow camera should follow an object at
  37668. */
  37669. radius: number;
  37670. /**
  37671. * Minimum allowed distance of the camera to the axis of rotation
  37672. * (The camera can not get closer).
  37673. * This can help limiting how the Camera is able to move in the scene.
  37674. */
  37675. lowerRadiusLimit: Nullable<number>;
  37676. /**
  37677. * Maximum allowed distance of the camera to the axis of rotation
  37678. * (The camera can not get further).
  37679. * This can help limiting how the Camera is able to move in the scene.
  37680. */
  37681. upperRadiusLimit: Nullable<number>;
  37682. /**
  37683. * Define a rotation offset between the camera and the object it follows
  37684. */
  37685. rotationOffset: number;
  37686. /**
  37687. * Minimum allowed angle to camera position relative to target object.
  37688. * This can help limiting how the Camera is able to move in the scene.
  37689. */
  37690. lowerRotationOffsetLimit: Nullable<number>;
  37691. /**
  37692. * Maximum allowed angle to camera position relative to target object.
  37693. * This can help limiting how the Camera is able to move in the scene.
  37694. */
  37695. upperRotationOffsetLimit: Nullable<number>;
  37696. /**
  37697. * Define a height offset between the camera and the object it follows.
  37698. * It can help following an object from the top (like a car chaing a plane)
  37699. */
  37700. heightOffset: number;
  37701. /**
  37702. * Minimum allowed height of camera position relative to target object.
  37703. * This can help limiting how the Camera is able to move in the scene.
  37704. */
  37705. lowerHeightOffsetLimit: Nullable<number>;
  37706. /**
  37707. * Maximum allowed height of camera position relative to target object.
  37708. * This can help limiting how the Camera is able to move in the scene.
  37709. */
  37710. upperHeightOffsetLimit: Nullable<number>;
  37711. /**
  37712. * Define how fast the camera can accelerate to follow it s target.
  37713. */
  37714. cameraAcceleration: number;
  37715. /**
  37716. * Define the speed limit of the camera following an object.
  37717. */
  37718. maxCameraSpeed: number;
  37719. /**
  37720. * Define the target of the camera.
  37721. */
  37722. lockedTarget: Nullable<AbstractMesh>;
  37723. /**
  37724. * Defines the input associated with the camera.
  37725. */
  37726. inputs: FollowCameraInputsManager;
  37727. /**
  37728. * Instantiates the follow camera.
  37729. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37730. * @param name Define the name of the camera in the scene
  37731. * @param position Define the position of the camera
  37732. * @param scene Define the scene the camera belong to
  37733. * @param lockedTarget Define the target of the camera
  37734. */
  37735. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37736. private _follow;
  37737. /**
  37738. * Attached controls to the current camera.
  37739. * @param element Defines the element the controls should be listened from
  37740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37741. */
  37742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37743. /**
  37744. * Detach the current controls from the camera.
  37745. * The camera will stop reacting to inputs.
  37746. * @param element Defines the element to stop listening the inputs from
  37747. */
  37748. detachControl(element: HTMLElement): void;
  37749. /** @hidden */ private _checkInputs(): void;
  37750. private _checkLimits;
  37751. /**
  37752. * Gets the camera class name.
  37753. * @returns the class name
  37754. */
  37755. getClassName(): string;
  37756. }
  37757. /**
  37758. * Arc Rotate version of the follow camera.
  37759. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37760. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37761. */
  37762. export class ArcFollowCamera extends TargetCamera {
  37763. /** The longitudinal angle of the camera */
  37764. alpha: number;
  37765. /** The latitudinal angle of the camera */
  37766. beta: number;
  37767. /** The radius of the camera from its target */
  37768. radius: number;
  37769. /** Define the camera target (the messh it should follow) */
  37770. target: Nullable<AbstractMesh>;
  37771. private _cartesianCoordinates;
  37772. /**
  37773. * Instantiates a new ArcFollowCamera
  37774. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37775. * @param name Define the name of the camera
  37776. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37777. * @param beta Define the rotation angle of the camera around the elevation axis
  37778. * @param radius Define the radius of the camera from its target point
  37779. * @param target Define the target of the camera
  37780. * @param scene Define the scene the camera belongs to
  37781. */
  37782. constructor(name: string,
  37783. /** The longitudinal angle of the camera */
  37784. alpha: number,
  37785. /** The latitudinal angle of the camera */
  37786. beta: number,
  37787. /** The radius of the camera from its target */
  37788. radius: number,
  37789. /** Define the camera target (the messh it should follow) */
  37790. target: Nullable<AbstractMesh>, scene: Scene);
  37791. private _follow;
  37792. /** @hidden */ private _checkInputs(): void;
  37793. /**
  37794. * Returns the class name of the object.
  37795. * It is mostly used internally for serialization purposes.
  37796. */
  37797. getClassName(): string;
  37798. }
  37799. }
  37800. declare module BABYLON {
  37801. /**
  37802. * Manage the keyboard inputs to control the movement of a follow camera.
  37803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37804. */
  37805. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37806. /**
  37807. * Defines the camera the input is attached to.
  37808. */
  37809. camera: FollowCamera;
  37810. /**
  37811. * Defines the list of key codes associated with the up action (increase heightOffset)
  37812. */
  37813. keysHeightOffsetIncr: number[];
  37814. /**
  37815. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37816. */
  37817. keysHeightOffsetDecr: number[];
  37818. /**
  37819. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37820. */
  37821. keysHeightOffsetModifierAlt: boolean;
  37822. /**
  37823. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37824. */
  37825. keysHeightOffsetModifierCtrl: boolean;
  37826. /**
  37827. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37828. */
  37829. keysHeightOffsetModifierShift: boolean;
  37830. /**
  37831. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37832. */
  37833. keysRotationOffsetIncr: number[];
  37834. /**
  37835. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37836. */
  37837. keysRotationOffsetDecr: number[];
  37838. /**
  37839. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37840. */
  37841. keysRotationOffsetModifierAlt: boolean;
  37842. /**
  37843. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37844. */
  37845. keysRotationOffsetModifierCtrl: boolean;
  37846. /**
  37847. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37848. */
  37849. keysRotationOffsetModifierShift: boolean;
  37850. /**
  37851. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37852. */
  37853. keysRadiusIncr: number[];
  37854. /**
  37855. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37856. */
  37857. keysRadiusDecr: number[];
  37858. /**
  37859. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37860. */
  37861. keysRadiusModifierAlt: boolean;
  37862. /**
  37863. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37864. */
  37865. keysRadiusModifierCtrl: boolean;
  37866. /**
  37867. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37868. */
  37869. keysRadiusModifierShift: boolean;
  37870. /**
  37871. * Defines the rate of change of heightOffset.
  37872. */
  37873. heightSensibility: number;
  37874. /**
  37875. * Defines the rate of change of rotationOffset.
  37876. */
  37877. rotationSensibility: number;
  37878. /**
  37879. * Defines the rate of change of radius.
  37880. */
  37881. radiusSensibility: number;
  37882. private _keys;
  37883. private _ctrlPressed;
  37884. private _altPressed;
  37885. private _shiftPressed;
  37886. private _onCanvasBlurObserver;
  37887. private _onKeyboardObserver;
  37888. private _engine;
  37889. private _scene;
  37890. /**
  37891. * Attach the input controls to a specific dom element to get the input from.
  37892. * @param element Defines the element the controls should be listened from
  37893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37894. */
  37895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37896. /**
  37897. * Detach the current controls from the specified dom element.
  37898. * @param element Defines the element to stop listening the inputs from
  37899. */
  37900. detachControl(element: Nullable<HTMLElement>): void;
  37901. /**
  37902. * Update the current camera state depending on the inputs that have been used this frame.
  37903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37904. */
  37905. checkInputs(): void;
  37906. /**
  37907. * Gets the class name of the current input.
  37908. * @returns the class name
  37909. */
  37910. getClassName(): string;
  37911. /**
  37912. * Get the friendly name associated with the input class.
  37913. * @returns the input friendly name
  37914. */
  37915. getSimpleName(): string;
  37916. /**
  37917. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37918. * allow modification of the heightOffset value.
  37919. */
  37920. private _modifierHeightOffset;
  37921. /**
  37922. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37923. * allow modification of the rotationOffset value.
  37924. */
  37925. private _modifierRotationOffset;
  37926. /**
  37927. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37928. * allow modification of the radius value.
  37929. */
  37930. private _modifierRadius;
  37931. }
  37932. }
  37933. declare module BABYLON {
  37934. interface FreeCameraInputsManager {
  37935. /**
  37936. * @hidden
  37937. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37938. /**
  37939. * Add orientation input support to the input manager.
  37940. * @returns the current input manager
  37941. */
  37942. addDeviceOrientation(): FreeCameraInputsManager;
  37943. }
  37944. /**
  37945. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37946. * Screen rotation is taken into account.
  37947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37948. */
  37949. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37950. private _camera;
  37951. private _screenOrientationAngle;
  37952. private _constantTranform;
  37953. private _screenQuaternion;
  37954. private _alpha;
  37955. private _beta;
  37956. private _gamma;
  37957. /**
  37958. * Can be used to detect if a device orientation sensor is availible on a device
  37959. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37960. * @returns a promise that will resolve on orientation change
  37961. */
  37962. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37963. /**
  37964. * @hidden
  37965. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37966. /**
  37967. * Instantiates a new input
  37968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37969. */
  37970. constructor();
  37971. /**
  37972. * Define the camera controlled by the input.
  37973. */
  37974. camera: FreeCamera;
  37975. /**
  37976. * Attach the input controls to a specific dom element to get the input from.
  37977. * @param element Defines the element the controls should be listened from
  37978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37979. */
  37980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37981. private _orientationChanged;
  37982. private _deviceOrientation;
  37983. /**
  37984. * Detach the current controls from the specified dom element.
  37985. * @param element Defines the element to stop listening the inputs from
  37986. */
  37987. detachControl(element: Nullable<HTMLElement>): void;
  37988. /**
  37989. * Update the current camera state depending on the inputs that have been used this frame.
  37990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37991. */
  37992. checkInputs(): void;
  37993. /**
  37994. * Gets the class name of the current intput.
  37995. * @returns the class name
  37996. */
  37997. getClassName(): string;
  37998. /**
  37999. * Get the friendly name associated with the input class.
  38000. * @returns the input friendly name
  38001. */
  38002. getSimpleName(): string;
  38003. }
  38004. }
  38005. declare module BABYLON {
  38006. /**
  38007. * Manage the gamepad inputs to control a free camera.
  38008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38009. */
  38010. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38011. /**
  38012. * Define the camera the input is attached to.
  38013. */
  38014. camera: FreeCamera;
  38015. /**
  38016. * Define the Gamepad controlling the input
  38017. */
  38018. gamepad: Nullable<Gamepad>;
  38019. /**
  38020. * Defines the gamepad rotation sensiblity.
  38021. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38022. */
  38023. gamepadAngularSensibility: number;
  38024. /**
  38025. * Defines the gamepad move sensiblity.
  38026. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38027. */
  38028. gamepadMoveSensibility: number;
  38029. private _yAxisScale;
  38030. /**
  38031. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38032. */
  38033. invertYAxis: boolean;
  38034. private _onGamepadConnectedObserver;
  38035. private _onGamepadDisconnectedObserver;
  38036. private _cameraTransform;
  38037. private _deltaTransform;
  38038. private _vector3;
  38039. private _vector2;
  38040. /**
  38041. * Attach the input controls to a specific dom element to get the input from.
  38042. * @param element Defines the element the controls should be listened from
  38043. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38044. */
  38045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38046. /**
  38047. * Detach the current controls from the specified dom element.
  38048. * @param element Defines the element to stop listening the inputs from
  38049. */
  38050. detachControl(element: Nullable<HTMLElement>): void;
  38051. /**
  38052. * Update the current camera state depending on the inputs that have been used this frame.
  38053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38054. */
  38055. checkInputs(): void;
  38056. /**
  38057. * Gets the class name of the current intput.
  38058. * @returns the class name
  38059. */
  38060. getClassName(): string;
  38061. /**
  38062. * Get the friendly name associated with the input class.
  38063. * @returns the input friendly name
  38064. */
  38065. getSimpleName(): string;
  38066. }
  38067. }
  38068. declare module BABYLON {
  38069. /**
  38070. * Defines the potential axis of a Joystick
  38071. */
  38072. export enum JoystickAxis {
  38073. /** X axis */
  38074. X = 0,
  38075. /** Y axis */
  38076. Y = 1,
  38077. /** Z axis */
  38078. Z = 2
  38079. }
  38080. /**
  38081. * Class used to define virtual joystick (used in touch mode)
  38082. */
  38083. export class VirtualJoystick {
  38084. /**
  38085. * Gets or sets a boolean indicating that left and right values must be inverted
  38086. */
  38087. reverseLeftRight: boolean;
  38088. /**
  38089. * Gets or sets a boolean indicating that up and down values must be inverted
  38090. */
  38091. reverseUpDown: boolean;
  38092. /**
  38093. * Gets the offset value for the position (ie. the change of the position value)
  38094. */
  38095. deltaPosition: Vector3;
  38096. /**
  38097. * Gets a boolean indicating if the virtual joystick was pressed
  38098. */
  38099. pressed: boolean;
  38100. /**
  38101. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38102. */
  38103. static Canvas: Nullable<HTMLCanvasElement>;
  38104. private static _globalJoystickIndex;
  38105. private static vjCanvasContext;
  38106. private static vjCanvasWidth;
  38107. private static vjCanvasHeight;
  38108. private static halfWidth;
  38109. private _action;
  38110. private _axisTargetedByLeftAndRight;
  38111. private _axisTargetedByUpAndDown;
  38112. private _joystickSensibility;
  38113. private _inversedSensibility;
  38114. private _joystickPointerID;
  38115. private _joystickColor;
  38116. private _joystickPointerPos;
  38117. private _joystickPreviousPointerPos;
  38118. private _joystickPointerStartPos;
  38119. private _deltaJoystickVector;
  38120. private _leftJoystick;
  38121. private _touches;
  38122. private _onPointerDownHandlerRef;
  38123. private _onPointerMoveHandlerRef;
  38124. private _onPointerUpHandlerRef;
  38125. private _onResize;
  38126. /**
  38127. * Creates a new virtual joystick
  38128. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38129. */
  38130. constructor(leftJoystick?: boolean);
  38131. /**
  38132. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38133. * @param newJoystickSensibility defines the new sensibility
  38134. */
  38135. setJoystickSensibility(newJoystickSensibility: number): void;
  38136. private _onPointerDown;
  38137. private _onPointerMove;
  38138. private _onPointerUp;
  38139. /**
  38140. * Change the color of the virtual joystick
  38141. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38142. */
  38143. setJoystickColor(newColor: string): void;
  38144. /**
  38145. * Defines a callback to call when the joystick is touched
  38146. * @param action defines the callback
  38147. */
  38148. setActionOnTouch(action: () => any): void;
  38149. /**
  38150. * Defines which axis you'd like to control for left & right
  38151. * @param axis defines the axis to use
  38152. */
  38153. setAxisForLeftRight(axis: JoystickAxis): void;
  38154. /**
  38155. * Defines which axis you'd like to control for up & down
  38156. * @param axis defines the axis to use
  38157. */
  38158. setAxisForUpDown(axis: JoystickAxis): void;
  38159. private _drawVirtualJoystick;
  38160. /**
  38161. * Release internal HTML canvas
  38162. */
  38163. releaseCanvas(): void;
  38164. }
  38165. }
  38166. declare module BABYLON {
  38167. interface FreeCameraInputsManager {
  38168. /**
  38169. * Add virtual joystick input support to the input manager.
  38170. * @returns the current input manager
  38171. */
  38172. addVirtualJoystick(): FreeCameraInputsManager;
  38173. }
  38174. /**
  38175. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38177. */
  38178. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38179. /**
  38180. * Defines the camera the input is attached to.
  38181. */
  38182. camera: FreeCamera;
  38183. private _leftjoystick;
  38184. private _rightjoystick;
  38185. /**
  38186. * Gets the left stick of the virtual joystick.
  38187. * @returns The virtual Joystick
  38188. */
  38189. getLeftJoystick(): VirtualJoystick;
  38190. /**
  38191. * Gets the right stick of the virtual joystick.
  38192. * @returns The virtual Joystick
  38193. */
  38194. getRightJoystick(): VirtualJoystick;
  38195. /**
  38196. * Update the current camera state depending on the inputs that have been used this frame.
  38197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38198. */
  38199. checkInputs(): void;
  38200. /**
  38201. * Attach the input controls to a specific dom element to get the input from.
  38202. * @param element Defines the element the controls should be listened from
  38203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38204. */
  38205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38206. /**
  38207. * Detach the current controls from the specified dom element.
  38208. * @param element Defines the element to stop listening the inputs from
  38209. */
  38210. detachControl(element: Nullable<HTMLElement>): void;
  38211. /**
  38212. * Gets the class name of the current intput.
  38213. * @returns the class name
  38214. */
  38215. getClassName(): string;
  38216. /**
  38217. * Get the friendly name associated with the input class.
  38218. * @returns the input friendly name
  38219. */
  38220. getSimpleName(): string;
  38221. }
  38222. }
  38223. declare module BABYLON {
  38224. /**
  38225. * This represents a FPS type of camera controlled by touch.
  38226. * This is like a universal camera minus the Gamepad controls.
  38227. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38228. */
  38229. export class TouchCamera extends FreeCamera {
  38230. /**
  38231. * Defines the touch sensibility for rotation.
  38232. * The higher the faster.
  38233. */
  38234. touchAngularSensibility: number;
  38235. /**
  38236. * Defines the touch sensibility for move.
  38237. * The higher the faster.
  38238. */
  38239. touchMoveSensibility: number;
  38240. /**
  38241. * Instantiates a new touch camera.
  38242. * This represents a FPS type of camera controlled by touch.
  38243. * This is like a universal camera minus the Gamepad controls.
  38244. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38245. * @param name Define the name of the camera in the scene
  38246. * @param position Define the start position of the camera in the scene
  38247. * @param scene Define the scene the camera belongs to
  38248. */
  38249. constructor(name: string, position: Vector3, scene: Scene);
  38250. /**
  38251. * Gets the current object class name.
  38252. * @return the class name
  38253. */
  38254. getClassName(): string;
  38255. /** @hidden */ private _setupInputs(): void;
  38256. }
  38257. }
  38258. declare module BABYLON {
  38259. /**
  38260. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38261. * being tilted forward or back and left or right.
  38262. */
  38263. export class DeviceOrientationCamera extends FreeCamera {
  38264. private _initialQuaternion;
  38265. private _quaternionCache;
  38266. private _tmpDragQuaternion;
  38267. private _disablePointerInputWhenUsingDeviceOrientation;
  38268. /**
  38269. * Creates a new device orientation camera
  38270. * @param name The name of the camera
  38271. * @param position The start position camera
  38272. * @param scene The scene the camera belongs to
  38273. */
  38274. constructor(name: string, position: Vector3, scene: Scene);
  38275. /**
  38276. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38277. */
  38278. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38279. private _dragFactor;
  38280. /**
  38281. * Enabled turning on the y axis when the orientation sensor is active
  38282. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38283. */
  38284. enableHorizontalDragging(dragFactor?: number): void;
  38285. /**
  38286. * Gets the current instance class name ("DeviceOrientationCamera").
  38287. * This helps avoiding instanceof at run time.
  38288. * @returns the class name
  38289. */
  38290. getClassName(): string;
  38291. /**
  38292. * @hidden
  38293. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38294. */ private _checkInputs(): void;
  38295. /**
  38296. * Reset the camera to its default orientation on the specified axis only.
  38297. * @param axis The axis to reset
  38298. */
  38299. resetToCurrentRotation(axis?: Axis): void;
  38300. }
  38301. }
  38302. declare module BABYLON {
  38303. /**
  38304. * Defines supported buttons for XBox360 compatible gamepads
  38305. */
  38306. export enum Xbox360Button {
  38307. /** A */
  38308. A = 0,
  38309. /** B */
  38310. B = 1,
  38311. /** X */
  38312. X = 2,
  38313. /** Y */
  38314. Y = 3,
  38315. /** Start */
  38316. Start = 4,
  38317. /** Back */
  38318. Back = 5,
  38319. /** Left button */
  38320. LB = 6,
  38321. /** Right button */
  38322. RB = 7,
  38323. /** Left stick */
  38324. LeftStick = 8,
  38325. /** Right stick */
  38326. RightStick = 9
  38327. }
  38328. /** Defines values for XBox360 DPad */
  38329. export enum Xbox360Dpad {
  38330. /** Up */
  38331. Up = 0,
  38332. /** Down */
  38333. Down = 1,
  38334. /** Left */
  38335. Left = 2,
  38336. /** Right */
  38337. Right = 3
  38338. }
  38339. /**
  38340. * Defines a XBox360 gamepad
  38341. */
  38342. export class Xbox360Pad extends Gamepad {
  38343. private _leftTrigger;
  38344. private _rightTrigger;
  38345. private _onlefttriggerchanged;
  38346. private _onrighttriggerchanged;
  38347. private _onbuttondown;
  38348. private _onbuttonup;
  38349. private _ondpaddown;
  38350. private _ondpadup;
  38351. /** Observable raised when a button is pressed */
  38352. onButtonDownObservable: Observable<Xbox360Button>;
  38353. /** Observable raised when a button is released */
  38354. onButtonUpObservable: Observable<Xbox360Button>;
  38355. /** Observable raised when a pad is pressed */
  38356. onPadDownObservable: Observable<Xbox360Dpad>;
  38357. /** Observable raised when a pad is released */
  38358. onPadUpObservable: Observable<Xbox360Dpad>;
  38359. private _buttonA;
  38360. private _buttonB;
  38361. private _buttonX;
  38362. private _buttonY;
  38363. private _buttonBack;
  38364. private _buttonStart;
  38365. private _buttonLB;
  38366. private _buttonRB;
  38367. private _buttonLeftStick;
  38368. private _buttonRightStick;
  38369. private _dPadUp;
  38370. private _dPadDown;
  38371. private _dPadLeft;
  38372. private _dPadRight;
  38373. private _isXboxOnePad;
  38374. /**
  38375. * Creates a new XBox360 gamepad object
  38376. * @param id defines the id of this gamepad
  38377. * @param index defines its index
  38378. * @param gamepad defines the internal HTML gamepad object
  38379. * @param xboxOne defines if it is a XBox One gamepad
  38380. */
  38381. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38382. /**
  38383. * Defines the callback to call when left trigger is pressed
  38384. * @param callback defines the callback to use
  38385. */
  38386. onlefttriggerchanged(callback: (value: number) => void): void;
  38387. /**
  38388. * Defines the callback to call when right trigger is pressed
  38389. * @param callback defines the callback to use
  38390. */
  38391. onrighttriggerchanged(callback: (value: number) => void): void;
  38392. /**
  38393. * Gets the left trigger value
  38394. */
  38395. /**
  38396. * Sets the left trigger value
  38397. */
  38398. leftTrigger: number;
  38399. /**
  38400. * Gets the right trigger value
  38401. */
  38402. /**
  38403. * Sets the right trigger value
  38404. */
  38405. rightTrigger: number;
  38406. /**
  38407. * Defines the callback to call when a button is pressed
  38408. * @param callback defines the callback to use
  38409. */
  38410. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38411. /**
  38412. * Defines the callback to call when a button is released
  38413. * @param callback defines the callback to use
  38414. */
  38415. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38416. /**
  38417. * Defines the callback to call when a pad is pressed
  38418. * @param callback defines the callback to use
  38419. */
  38420. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38421. /**
  38422. * Defines the callback to call when a pad is released
  38423. * @param callback defines the callback to use
  38424. */
  38425. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38426. private _setButtonValue;
  38427. private _setDPadValue;
  38428. /**
  38429. * Gets the value of the `A` button
  38430. */
  38431. /**
  38432. * Sets the value of the `A` button
  38433. */
  38434. buttonA: number;
  38435. /**
  38436. * Gets the value of the `B` button
  38437. */
  38438. /**
  38439. * Sets the value of the `B` button
  38440. */
  38441. buttonB: number;
  38442. /**
  38443. * Gets the value of the `X` button
  38444. */
  38445. /**
  38446. * Sets the value of the `X` button
  38447. */
  38448. buttonX: number;
  38449. /**
  38450. * Gets the value of the `Y` button
  38451. */
  38452. /**
  38453. * Sets the value of the `Y` button
  38454. */
  38455. buttonY: number;
  38456. /**
  38457. * Gets the value of the `Start` button
  38458. */
  38459. /**
  38460. * Sets the value of the `Start` button
  38461. */
  38462. buttonStart: number;
  38463. /**
  38464. * Gets the value of the `Back` button
  38465. */
  38466. /**
  38467. * Sets the value of the `Back` button
  38468. */
  38469. buttonBack: number;
  38470. /**
  38471. * Gets the value of the `Left` button
  38472. */
  38473. /**
  38474. * Sets the value of the `Left` button
  38475. */
  38476. buttonLB: number;
  38477. /**
  38478. * Gets the value of the `Right` button
  38479. */
  38480. /**
  38481. * Sets the value of the `Right` button
  38482. */
  38483. buttonRB: number;
  38484. /**
  38485. * Gets the value of the Left joystick
  38486. */
  38487. /**
  38488. * Sets the value of the Left joystick
  38489. */
  38490. buttonLeftStick: number;
  38491. /**
  38492. * Gets the value of the Right joystick
  38493. */
  38494. /**
  38495. * Sets the value of the Right joystick
  38496. */
  38497. buttonRightStick: number;
  38498. /**
  38499. * Gets the value of D-pad up
  38500. */
  38501. /**
  38502. * Sets the value of D-pad up
  38503. */
  38504. dPadUp: number;
  38505. /**
  38506. * Gets the value of D-pad down
  38507. */
  38508. /**
  38509. * Sets the value of D-pad down
  38510. */
  38511. dPadDown: number;
  38512. /**
  38513. * Gets the value of D-pad left
  38514. */
  38515. /**
  38516. * Sets the value of D-pad left
  38517. */
  38518. dPadLeft: number;
  38519. /**
  38520. * Gets the value of D-pad right
  38521. */
  38522. /**
  38523. * Sets the value of D-pad right
  38524. */
  38525. dPadRight: number;
  38526. /**
  38527. * Force the gamepad to synchronize with device values
  38528. */
  38529. update(): void;
  38530. /**
  38531. * Disposes the gamepad
  38532. */
  38533. dispose(): void;
  38534. }
  38535. }
  38536. declare module BABYLON {
  38537. /**
  38538. * Defines supported buttons for DualShock compatible gamepads
  38539. */
  38540. export enum DualShockButton {
  38541. /** Cross */
  38542. Cross = 0,
  38543. /** Circle */
  38544. Circle = 1,
  38545. /** Square */
  38546. Square = 2,
  38547. /** Triangle */
  38548. Triangle = 3,
  38549. /** Options */
  38550. Options = 4,
  38551. /** Share */
  38552. Share = 5,
  38553. /** L1 */
  38554. L1 = 6,
  38555. /** R1 */
  38556. R1 = 7,
  38557. /** Left stick */
  38558. LeftStick = 8,
  38559. /** Right stick */
  38560. RightStick = 9
  38561. }
  38562. /** Defines values for DualShock DPad */
  38563. export enum DualShockDpad {
  38564. /** Up */
  38565. Up = 0,
  38566. /** Down */
  38567. Down = 1,
  38568. /** Left */
  38569. Left = 2,
  38570. /** Right */
  38571. Right = 3
  38572. }
  38573. /**
  38574. * Defines a DualShock gamepad
  38575. */
  38576. export class DualShockPad extends Gamepad {
  38577. private _leftTrigger;
  38578. private _rightTrigger;
  38579. private _onlefttriggerchanged;
  38580. private _onrighttriggerchanged;
  38581. private _onbuttondown;
  38582. private _onbuttonup;
  38583. private _ondpaddown;
  38584. private _ondpadup;
  38585. /** Observable raised when a button is pressed */
  38586. onButtonDownObservable: Observable<DualShockButton>;
  38587. /** Observable raised when a button is released */
  38588. onButtonUpObservable: Observable<DualShockButton>;
  38589. /** Observable raised when a pad is pressed */
  38590. onPadDownObservable: Observable<DualShockDpad>;
  38591. /** Observable raised when a pad is released */
  38592. onPadUpObservable: Observable<DualShockDpad>;
  38593. private _buttonCross;
  38594. private _buttonCircle;
  38595. private _buttonSquare;
  38596. private _buttonTriangle;
  38597. private _buttonShare;
  38598. private _buttonOptions;
  38599. private _buttonL1;
  38600. private _buttonR1;
  38601. private _buttonLeftStick;
  38602. private _buttonRightStick;
  38603. private _dPadUp;
  38604. private _dPadDown;
  38605. private _dPadLeft;
  38606. private _dPadRight;
  38607. /**
  38608. * Creates a new DualShock gamepad object
  38609. * @param id defines the id of this gamepad
  38610. * @param index defines its index
  38611. * @param gamepad defines the internal HTML gamepad object
  38612. */
  38613. constructor(id: string, index: number, gamepad: any);
  38614. /**
  38615. * Defines the callback to call when left trigger is pressed
  38616. * @param callback defines the callback to use
  38617. */
  38618. onlefttriggerchanged(callback: (value: number) => void): void;
  38619. /**
  38620. * Defines the callback to call when right trigger is pressed
  38621. * @param callback defines the callback to use
  38622. */
  38623. onrighttriggerchanged(callback: (value: number) => void): void;
  38624. /**
  38625. * Gets the left trigger value
  38626. */
  38627. /**
  38628. * Sets the left trigger value
  38629. */
  38630. leftTrigger: number;
  38631. /**
  38632. * Gets the right trigger value
  38633. */
  38634. /**
  38635. * Sets the right trigger value
  38636. */
  38637. rightTrigger: number;
  38638. /**
  38639. * Defines the callback to call when a button is pressed
  38640. * @param callback defines the callback to use
  38641. */
  38642. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38643. /**
  38644. * Defines the callback to call when a button is released
  38645. * @param callback defines the callback to use
  38646. */
  38647. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38648. /**
  38649. * Defines the callback to call when a pad is pressed
  38650. * @param callback defines the callback to use
  38651. */
  38652. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38653. /**
  38654. * Defines the callback to call when a pad is released
  38655. * @param callback defines the callback to use
  38656. */
  38657. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38658. private _setButtonValue;
  38659. private _setDPadValue;
  38660. /**
  38661. * Gets the value of the `Cross` button
  38662. */
  38663. /**
  38664. * Sets the value of the `Cross` button
  38665. */
  38666. buttonCross: number;
  38667. /**
  38668. * Gets the value of the `Circle` button
  38669. */
  38670. /**
  38671. * Sets the value of the `Circle` button
  38672. */
  38673. buttonCircle: number;
  38674. /**
  38675. * Gets the value of the `Square` button
  38676. */
  38677. /**
  38678. * Sets the value of the `Square` button
  38679. */
  38680. buttonSquare: number;
  38681. /**
  38682. * Gets the value of the `Triangle` button
  38683. */
  38684. /**
  38685. * Sets the value of the `Triangle` button
  38686. */
  38687. buttonTriangle: number;
  38688. /**
  38689. * Gets the value of the `Options` button
  38690. */
  38691. /**
  38692. * Sets the value of the `Options` button
  38693. */
  38694. buttonOptions: number;
  38695. /**
  38696. * Gets the value of the `Share` button
  38697. */
  38698. /**
  38699. * Sets the value of the `Share` button
  38700. */
  38701. buttonShare: number;
  38702. /**
  38703. * Gets the value of the `L1` button
  38704. */
  38705. /**
  38706. * Sets the value of the `L1` button
  38707. */
  38708. buttonL1: number;
  38709. /**
  38710. * Gets the value of the `R1` button
  38711. */
  38712. /**
  38713. * Sets the value of the `R1` button
  38714. */
  38715. buttonR1: number;
  38716. /**
  38717. * Gets the value of the Left joystick
  38718. */
  38719. /**
  38720. * Sets the value of the Left joystick
  38721. */
  38722. buttonLeftStick: number;
  38723. /**
  38724. * Gets the value of the Right joystick
  38725. */
  38726. /**
  38727. * Sets the value of the Right joystick
  38728. */
  38729. buttonRightStick: number;
  38730. /**
  38731. * Gets the value of D-pad up
  38732. */
  38733. /**
  38734. * Sets the value of D-pad up
  38735. */
  38736. dPadUp: number;
  38737. /**
  38738. * Gets the value of D-pad down
  38739. */
  38740. /**
  38741. * Sets the value of D-pad down
  38742. */
  38743. dPadDown: number;
  38744. /**
  38745. * Gets the value of D-pad left
  38746. */
  38747. /**
  38748. * Sets the value of D-pad left
  38749. */
  38750. dPadLeft: number;
  38751. /**
  38752. * Gets the value of D-pad right
  38753. */
  38754. /**
  38755. * Sets the value of D-pad right
  38756. */
  38757. dPadRight: number;
  38758. /**
  38759. * Force the gamepad to synchronize with device values
  38760. */
  38761. update(): void;
  38762. /**
  38763. * Disposes the gamepad
  38764. */
  38765. dispose(): void;
  38766. }
  38767. }
  38768. declare module BABYLON {
  38769. /**
  38770. * Manager for handling gamepads
  38771. */
  38772. export class GamepadManager {
  38773. private _scene?;
  38774. private _babylonGamepads;
  38775. private _oneGamepadConnected;
  38776. /** @hidden */ private _isMonitoring: boolean;
  38777. private _gamepadEventSupported;
  38778. private _gamepadSupport;
  38779. /**
  38780. * observable to be triggered when the gamepad controller has been connected
  38781. */
  38782. onGamepadConnectedObservable: Observable<Gamepad>;
  38783. /**
  38784. * observable to be triggered when the gamepad controller has been disconnected
  38785. */
  38786. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38787. private _onGamepadConnectedEvent;
  38788. private _onGamepadDisconnectedEvent;
  38789. /**
  38790. * Initializes the gamepad manager
  38791. * @param _scene BabylonJS scene
  38792. */
  38793. constructor(_scene?: Scene | undefined);
  38794. /**
  38795. * The gamepads in the game pad manager
  38796. */
  38797. readonly gamepads: Gamepad[];
  38798. /**
  38799. * Get the gamepad controllers based on type
  38800. * @param type The type of gamepad controller
  38801. * @returns Nullable gamepad
  38802. */
  38803. getGamepadByType(type?: number): Nullable<Gamepad>;
  38804. /**
  38805. * Disposes the gamepad manager
  38806. */
  38807. dispose(): void;
  38808. private _addNewGamepad;
  38809. private _startMonitoringGamepads;
  38810. private _stopMonitoringGamepads;
  38811. /** @hidden */ private _checkGamepadsStatus(): void;
  38812. private _updateGamepadObjects;
  38813. }
  38814. }
  38815. declare module BABYLON {
  38816. interface Scene {
  38817. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38818. /**
  38819. * Gets the gamepad manager associated with the scene
  38820. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38821. */
  38822. gamepadManager: GamepadManager;
  38823. }
  38824. /**
  38825. * Interface representing a free camera inputs manager
  38826. */
  38827. interface FreeCameraInputsManager {
  38828. /**
  38829. * Adds gamepad input support to the FreeCameraInputsManager.
  38830. * @returns the FreeCameraInputsManager
  38831. */
  38832. addGamepad(): FreeCameraInputsManager;
  38833. }
  38834. /**
  38835. * Interface representing an arc rotate camera inputs manager
  38836. */
  38837. interface ArcRotateCameraInputsManager {
  38838. /**
  38839. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38840. * @returns the camera inputs manager
  38841. */
  38842. addGamepad(): ArcRotateCameraInputsManager;
  38843. }
  38844. /**
  38845. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38846. */
  38847. export class GamepadSystemSceneComponent implements ISceneComponent {
  38848. /**
  38849. * The component name helpfull to identify the component in the list of scene components.
  38850. */
  38851. readonly name: string;
  38852. /**
  38853. * The scene the component belongs to.
  38854. */
  38855. scene: Scene;
  38856. /**
  38857. * Creates a new instance of the component for the given scene
  38858. * @param scene Defines the scene to register the component in
  38859. */
  38860. constructor(scene: Scene);
  38861. /**
  38862. * Registers the component in a given scene
  38863. */
  38864. register(): void;
  38865. /**
  38866. * Rebuilds the elements related to this component in case of
  38867. * context lost for instance.
  38868. */
  38869. rebuild(): void;
  38870. /**
  38871. * Disposes the component and the associated ressources
  38872. */
  38873. dispose(): void;
  38874. private _beforeCameraUpdate;
  38875. }
  38876. }
  38877. declare module BABYLON {
  38878. /**
  38879. * 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,
  38880. * which still works and will still be found in many Playgrounds.
  38881. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38882. */
  38883. export class UniversalCamera extends TouchCamera {
  38884. /**
  38885. * Defines the gamepad rotation sensiblity.
  38886. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38887. */
  38888. gamepadAngularSensibility: number;
  38889. /**
  38890. * Defines the gamepad move sensiblity.
  38891. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38892. */
  38893. gamepadMoveSensibility: number;
  38894. /**
  38895. * 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,
  38896. * which still works and will still be found in many Playgrounds.
  38897. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38898. * @param name Define the name of the camera in the scene
  38899. * @param position Define the start position of the camera in the scene
  38900. * @param scene Define the scene the camera belongs to
  38901. */
  38902. constructor(name: string, position: Vector3, scene: Scene);
  38903. /**
  38904. * Gets the current object class name.
  38905. * @return the class name
  38906. */
  38907. getClassName(): string;
  38908. }
  38909. }
  38910. declare module BABYLON {
  38911. /**
  38912. * This represents a FPS type of camera. This is only here for back compat purpose.
  38913. * Please use the UniversalCamera instead as both are identical.
  38914. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38915. */
  38916. export class GamepadCamera extends UniversalCamera {
  38917. /**
  38918. * Instantiates a new Gamepad Camera
  38919. * This represents a FPS type of camera. This is only here for back compat purpose.
  38920. * Please use the UniversalCamera instead as both are identical.
  38921. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38922. * @param name Define the name of the camera in the scene
  38923. * @param position Define the start position of the camera in the scene
  38924. * @param scene Define the scene the camera belongs to
  38925. */
  38926. constructor(name: string, position: Vector3, scene: Scene);
  38927. /**
  38928. * Gets the current object class name.
  38929. * @return the class name
  38930. */
  38931. getClassName(): string;
  38932. }
  38933. }
  38934. declare module BABYLON {
  38935. /** @hidden */
  38936. export var passPixelShader: {
  38937. name: string;
  38938. shader: string;
  38939. };
  38940. }
  38941. declare module BABYLON {
  38942. /** @hidden */
  38943. export var passCubePixelShader: {
  38944. name: string;
  38945. shader: string;
  38946. };
  38947. }
  38948. declare module BABYLON {
  38949. /**
  38950. * PassPostProcess which produces an output the same as it's input
  38951. */
  38952. export class PassPostProcess extends PostProcess {
  38953. /**
  38954. * Creates the PassPostProcess
  38955. * @param name The name of the effect.
  38956. * @param options The required width/height ratio to downsize to before computing the render pass.
  38957. * @param camera The camera to apply the render pass to.
  38958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38959. * @param engine The engine which the post process will be applied. (default: current engine)
  38960. * @param reusable If the post process can be reused on the same frame. (default: false)
  38961. * @param textureType The type of texture to be used when performing the post processing.
  38962. * @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)
  38963. */
  38964. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38965. }
  38966. /**
  38967. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38968. */
  38969. export class PassCubePostProcess extends PostProcess {
  38970. private _face;
  38971. /**
  38972. * Gets or sets the cube face to display.
  38973. * * 0 is +X
  38974. * * 1 is -X
  38975. * * 2 is +Y
  38976. * * 3 is -Y
  38977. * * 4 is +Z
  38978. * * 5 is -Z
  38979. */
  38980. face: number;
  38981. /**
  38982. * Creates the PassCubePostProcess
  38983. * @param name The name of the effect.
  38984. * @param options The required width/height ratio to downsize to before computing the render pass.
  38985. * @param camera The camera to apply the render pass to.
  38986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38987. * @param engine The engine which the post process will be applied. (default: current engine)
  38988. * @param reusable If the post process can be reused on the same frame. (default: false)
  38989. * @param textureType The type of texture to be used when performing the post processing.
  38990. * @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)
  38991. */
  38992. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38993. }
  38994. }
  38995. declare module BABYLON {
  38996. /** @hidden */
  38997. export var anaglyphPixelShader: {
  38998. name: string;
  38999. shader: string;
  39000. };
  39001. }
  39002. declare module BABYLON {
  39003. /**
  39004. * Postprocess used to generate anaglyphic rendering
  39005. */
  39006. export class AnaglyphPostProcess extends PostProcess {
  39007. private _passedProcess;
  39008. /**
  39009. * Creates a new AnaglyphPostProcess
  39010. * @param name defines postprocess name
  39011. * @param options defines creation options or target ratio scale
  39012. * @param rigCameras defines cameras using this postprocess
  39013. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39014. * @param engine defines hosting engine
  39015. * @param reusable defines if the postprocess will be reused multiple times per frame
  39016. */
  39017. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39018. }
  39019. }
  39020. declare module BABYLON {
  39021. /**
  39022. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39023. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39024. */
  39025. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39026. /**
  39027. * Creates a new AnaglyphArcRotateCamera
  39028. * @param name defines camera name
  39029. * @param alpha defines alpha angle (in radians)
  39030. * @param beta defines beta angle (in radians)
  39031. * @param radius defines radius
  39032. * @param target defines camera target
  39033. * @param interaxialDistance defines distance between each color axis
  39034. * @param scene defines the hosting scene
  39035. */
  39036. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39037. /**
  39038. * Gets camera class name
  39039. * @returns AnaglyphArcRotateCamera
  39040. */
  39041. getClassName(): string;
  39042. }
  39043. }
  39044. declare module BABYLON {
  39045. /**
  39046. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39047. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39048. */
  39049. export class AnaglyphFreeCamera extends FreeCamera {
  39050. /**
  39051. * Creates a new AnaglyphFreeCamera
  39052. * @param name defines camera name
  39053. * @param position defines initial position
  39054. * @param interaxialDistance defines distance between each color axis
  39055. * @param scene defines the hosting scene
  39056. */
  39057. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39058. /**
  39059. * Gets camera class name
  39060. * @returns AnaglyphFreeCamera
  39061. */
  39062. getClassName(): string;
  39063. }
  39064. }
  39065. declare module BABYLON {
  39066. /**
  39067. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39068. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39069. */
  39070. export class AnaglyphGamepadCamera extends GamepadCamera {
  39071. /**
  39072. * Creates a new AnaglyphGamepadCamera
  39073. * @param name defines camera name
  39074. * @param position defines initial position
  39075. * @param interaxialDistance defines distance between each color axis
  39076. * @param scene defines the hosting scene
  39077. */
  39078. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39079. /**
  39080. * Gets camera class name
  39081. * @returns AnaglyphGamepadCamera
  39082. */
  39083. getClassName(): string;
  39084. }
  39085. }
  39086. declare module BABYLON {
  39087. /**
  39088. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39089. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39090. */
  39091. export class AnaglyphUniversalCamera extends UniversalCamera {
  39092. /**
  39093. * Creates a new AnaglyphUniversalCamera
  39094. * @param name defines camera name
  39095. * @param position defines initial position
  39096. * @param interaxialDistance defines distance between each color axis
  39097. * @param scene defines the hosting scene
  39098. */
  39099. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39100. /**
  39101. * Gets camera class name
  39102. * @returns AnaglyphUniversalCamera
  39103. */
  39104. getClassName(): string;
  39105. }
  39106. }
  39107. declare module BABYLON {
  39108. /** @hidden */
  39109. export var stereoscopicInterlacePixelShader: {
  39110. name: string;
  39111. shader: string;
  39112. };
  39113. }
  39114. declare module BABYLON {
  39115. /**
  39116. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39117. */
  39118. export class StereoscopicInterlacePostProcess extends PostProcess {
  39119. private _stepSize;
  39120. private _passedProcess;
  39121. /**
  39122. * Initializes a StereoscopicInterlacePostProcess
  39123. * @param name The name of the effect.
  39124. * @param rigCameras The rig cameras to be appled to the post process
  39125. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39127. * @param engine The engine which the post process will be applied. (default: current engine)
  39128. * @param reusable If the post process can be reused on the same frame. (default: false)
  39129. */
  39130. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39131. }
  39132. }
  39133. declare module BABYLON {
  39134. /**
  39135. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39136. * @see http://doc.babylonjs.com/features/cameras
  39137. */
  39138. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39139. /**
  39140. * Creates a new StereoscopicArcRotateCamera
  39141. * @param name defines camera name
  39142. * @param alpha defines alpha angle (in radians)
  39143. * @param beta defines beta angle (in radians)
  39144. * @param radius defines radius
  39145. * @param target defines camera target
  39146. * @param interaxialDistance defines distance between each color axis
  39147. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39148. * @param scene defines the hosting scene
  39149. */
  39150. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39151. /**
  39152. * Gets camera class name
  39153. * @returns StereoscopicArcRotateCamera
  39154. */
  39155. getClassName(): string;
  39156. }
  39157. }
  39158. declare module BABYLON {
  39159. /**
  39160. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39161. * @see http://doc.babylonjs.com/features/cameras
  39162. */
  39163. export class StereoscopicFreeCamera extends FreeCamera {
  39164. /**
  39165. * Creates a new StereoscopicFreeCamera
  39166. * @param name defines camera name
  39167. * @param position defines initial position
  39168. * @param interaxialDistance defines distance between each color axis
  39169. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39170. * @param scene defines the hosting scene
  39171. */
  39172. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39173. /**
  39174. * Gets camera class name
  39175. * @returns StereoscopicFreeCamera
  39176. */
  39177. getClassName(): string;
  39178. }
  39179. }
  39180. declare module BABYLON {
  39181. /**
  39182. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39183. * @see http://doc.babylonjs.com/features/cameras
  39184. */
  39185. export class StereoscopicGamepadCamera extends GamepadCamera {
  39186. /**
  39187. * Creates a new StereoscopicGamepadCamera
  39188. * @param name defines camera name
  39189. * @param position defines initial position
  39190. * @param interaxialDistance defines distance between each color axis
  39191. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39192. * @param scene defines the hosting scene
  39193. */
  39194. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39195. /**
  39196. * Gets camera class name
  39197. * @returns StereoscopicGamepadCamera
  39198. */
  39199. getClassName(): string;
  39200. }
  39201. }
  39202. declare module BABYLON {
  39203. /**
  39204. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39205. * @see http://doc.babylonjs.com/features/cameras
  39206. */
  39207. export class StereoscopicUniversalCamera extends UniversalCamera {
  39208. /**
  39209. * Creates a new StereoscopicUniversalCamera
  39210. * @param name defines camera name
  39211. * @param position defines initial position
  39212. * @param interaxialDistance defines distance between each color axis
  39213. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39214. * @param scene defines the hosting scene
  39215. */
  39216. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39217. /**
  39218. * Gets camera class name
  39219. * @returns StereoscopicUniversalCamera
  39220. */
  39221. getClassName(): string;
  39222. }
  39223. }
  39224. declare module BABYLON {
  39225. /**
  39226. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39227. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39228. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39229. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39230. */
  39231. export class VirtualJoysticksCamera extends FreeCamera {
  39232. /**
  39233. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39234. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39235. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39236. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39237. * @param name Define the name of the camera in the scene
  39238. * @param position Define the start position of the camera in the scene
  39239. * @param scene Define the scene the camera belongs to
  39240. */
  39241. constructor(name: string, position: Vector3, scene: Scene);
  39242. /**
  39243. * Gets the current object class name.
  39244. * @return the class name
  39245. */
  39246. getClassName(): string;
  39247. }
  39248. }
  39249. declare module BABYLON {
  39250. /**
  39251. * This represents all the required metrics to create a VR camera.
  39252. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39253. */
  39254. export class VRCameraMetrics {
  39255. /**
  39256. * Define the horizontal resolution off the screen.
  39257. */
  39258. hResolution: number;
  39259. /**
  39260. * Define the vertical resolution off the screen.
  39261. */
  39262. vResolution: number;
  39263. /**
  39264. * Define the horizontal screen size.
  39265. */
  39266. hScreenSize: number;
  39267. /**
  39268. * Define the vertical screen size.
  39269. */
  39270. vScreenSize: number;
  39271. /**
  39272. * Define the vertical screen center position.
  39273. */
  39274. vScreenCenter: number;
  39275. /**
  39276. * Define the distance of the eyes to the screen.
  39277. */
  39278. eyeToScreenDistance: number;
  39279. /**
  39280. * Define the distance between both lenses
  39281. */
  39282. lensSeparationDistance: number;
  39283. /**
  39284. * Define the distance between both viewer's eyes.
  39285. */
  39286. interpupillaryDistance: number;
  39287. /**
  39288. * Define the distortion factor of the VR postprocess.
  39289. * Please, touch with care.
  39290. */
  39291. distortionK: number[];
  39292. /**
  39293. * Define the chromatic aberration correction factors for the VR post process.
  39294. */
  39295. chromaAbCorrection: number[];
  39296. /**
  39297. * Define the scale factor of the post process.
  39298. * The smaller the better but the slower.
  39299. */
  39300. postProcessScaleFactor: number;
  39301. /**
  39302. * Define an offset for the lens center.
  39303. */
  39304. lensCenterOffset: number;
  39305. /**
  39306. * Define if the current vr camera should compensate the distortion of the lense or not.
  39307. */
  39308. compensateDistortion: boolean;
  39309. /**
  39310. * Defines if multiview should be enabled when rendering (Default: false)
  39311. */
  39312. multiviewEnabled: boolean;
  39313. /**
  39314. * Gets the rendering aspect ratio based on the provided resolutions.
  39315. */
  39316. readonly aspectRatio: number;
  39317. /**
  39318. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39319. */
  39320. readonly aspectRatioFov: number;
  39321. /**
  39322. * @hidden
  39323. */
  39324. readonly leftHMatrix: Matrix;
  39325. /**
  39326. * @hidden
  39327. */
  39328. readonly rightHMatrix: Matrix;
  39329. /**
  39330. * @hidden
  39331. */
  39332. readonly leftPreViewMatrix: Matrix;
  39333. /**
  39334. * @hidden
  39335. */
  39336. readonly rightPreViewMatrix: Matrix;
  39337. /**
  39338. * Get the default VRMetrics based on the most generic setup.
  39339. * @returns the default vr metrics
  39340. */
  39341. static GetDefault(): VRCameraMetrics;
  39342. }
  39343. }
  39344. declare module BABYLON {
  39345. /** @hidden */
  39346. export var vrDistortionCorrectionPixelShader: {
  39347. name: string;
  39348. shader: string;
  39349. };
  39350. }
  39351. declare module BABYLON {
  39352. /**
  39353. * VRDistortionCorrectionPostProcess used for mobile VR
  39354. */
  39355. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39356. private _isRightEye;
  39357. private _distortionFactors;
  39358. private _postProcessScaleFactor;
  39359. private _lensCenterOffset;
  39360. private _scaleIn;
  39361. private _scaleFactor;
  39362. private _lensCenter;
  39363. /**
  39364. * Initializes the VRDistortionCorrectionPostProcess
  39365. * @param name The name of the effect.
  39366. * @param camera The camera to apply the render pass to.
  39367. * @param isRightEye If this is for the right eye distortion
  39368. * @param vrMetrics All the required metrics for the VR camera
  39369. */
  39370. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39371. }
  39372. }
  39373. declare module BABYLON {
  39374. /**
  39375. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39376. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39377. */
  39378. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39379. /**
  39380. * Creates a new VRDeviceOrientationArcRotateCamera
  39381. * @param name defines camera name
  39382. * @param alpha defines the camera rotation along the logitudinal axis
  39383. * @param beta defines the camera rotation along the latitudinal axis
  39384. * @param radius defines the camera distance from its target
  39385. * @param target defines the camera target
  39386. * @param scene defines the scene the camera belongs to
  39387. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39388. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39389. */
  39390. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39391. /**
  39392. * Gets camera class name
  39393. * @returns VRDeviceOrientationArcRotateCamera
  39394. */
  39395. getClassName(): string;
  39396. }
  39397. }
  39398. declare module BABYLON {
  39399. /**
  39400. * Camera used to simulate VR rendering (based on FreeCamera)
  39401. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39402. */
  39403. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39404. /**
  39405. * Creates a new VRDeviceOrientationFreeCamera
  39406. * @param name defines camera name
  39407. * @param position defines the start position of the camera
  39408. * @param scene defines the scene the camera belongs to
  39409. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39410. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39411. */
  39412. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39413. /**
  39414. * Gets camera class name
  39415. * @returns VRDeviceOrientationFreeCamera
  39416. */
  39417. getClassName(): string;
  39418. }
  39419. }
  39420. declare module BABYLON {
  39421. /**
  39422. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39423. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39424. */
  39425. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39426. /**
  39427. * Creates a new VRDeviceOrientationGamepadCamera
  39428. * @param name defines camera name
  39429. * @param position defines the start position of the camera
  39430. * @param scene defines the scene the camera belongs to
  39431. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39432. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39433. */
  39434. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39435. /**
  39436. * Gets camera class name
  39437. * @returns VRDeviceOrientationGamepadCamera
  39438. */
  39439. getClassName(): string;
  39440. }
  39441. }
  39442. declare module BABYLON {
  39443. /**
  39444. * Base class of materials working in push mode in babylon JS
  39445. * @hidden
  39446. */
  39447. export class PushMaterial extends Material {
  39448. protected _activeEffect: Effect;
  39449. protected _normalMatrix: Matrix;
  39450. /**
  39451. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39452. * This means that the material can keep using a previous shader while a new one is being compiled.
  39453. * This is mostly used when shader parallel compilation is supported (true by default)
  39454. */
  39455. allowShaderHotSwapping: boolean;
  39456. constructor(name: string, scene: Scene);
  39457. getEffect(): Effect;
  39458. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39459. /**
  39460. * Binds the given world matrix to the active effect
  39461. *
  39462. * @param world the matrix to bind
  39463. */
  39464. bindOnlyWorldMatrix(world: Matrix): void;
  39465. /**
  39466. * Binds the given normal matrix to the active effect
  39467. *
  39468. * @param normalMatrix the matrix to bind
  39469. */
  39470. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39471. bind(world: Matrix, mesh?: Mesh): void;
  39472. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39473. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39474. }
  39475. }
  39476. declare module BABYLON {
  39477. /**
  39478. * This groups all the flags used to control the materials channel.
  39479. */
  39480. export class MaterialFlags {
  39481. private static _DiffuseTextureEnabled;
  39482. /**
  39483. * Are diffuse textures enabled in the application.
  39484. */
  39485. static DiffuseTextureEnabled: boolean;
  39486. private static _AmbientTextureEnabled;
  39487. /**
  39488. * Are ambient textures enabled in the application.
  39489. */
  39490. static AmbientTextureEnabled: boolean;
  39491. private static _OpacityTextureEnabled;
  39492. /**
  39493. * Are opacity textures enabled in the application.
  39494. */
  39495. static OpacityTextureEnabled: boolean;
  39496. private static _ReflectionTextureEnabled;
  39497. /**
  39498. * Are reflection textures enabled in the application.
  39499. */
  39500. static ReflectionTextureEnabled: boolean;
  39501. private static _EmissiveTextureEnabled;
  39502. /**
  39503. * Are emissive textures enabled in the application.
  39504. */
  39505. static EmissiveTextureEnabled: boolean;
  39506. private static _SpecularTextureEnabled;
  39507. /**
  39508. * Are specular textures enabled in the application.
  39509. */
  39510. static SpecularTextureEnabled: boolean;
  39511. private static _BumpTextureEnabled;
  39512. /**
  39513. * Are bump textures enabled in the application.
  39514. */
  39515. static BumpTextureEnabled: boolean;
  39516. private static _LightmapTextureEnabled;
  39517. /**
  39518. * Are lightmap textures enabled in the application.
  39519. */
  39520. static LightmapTextureEnabled: boolean;
  39521. private static _RefractionTextureEnabled;
  39522. /**
  39523. * Are refraction textures enabled in the application.
  39524. */
  39525. static RefractionTextureEnabled: boolean;
  39526. private static _ColorGradingTextureEnabled;
  39527. /**
  39528. * Are color grading textures enabled in the application.
  39529. */
  39530. static ColorGradingTextureEnabled: boolean;
  39531. private static _FresnelEnabled;
  39532. /**
  39533. * Are fresnels enabled in the application.
  39534. */
  39535. static FresnelEnabled: boolean;
  39536. private static _ClearCoatTextureEnabled;
  39537. /**
  39538. * Are clear coat textures enabled in the application.
  39539. */
  39540. static ClearCoatTextureEnabled: boolean;
  39541. private static _ClearCoatBumpTextureEnabled;
  39542. /**
  39543. * Are clear coat bump textures enabled in the application.
  39544. */
  39545. static ClearCoatBumpTextureEnabled: boolean;
  39546. private static _ClearCoatTintTextureEnabled;
  39547. /**
  39548. * Are clear coat tint textures enabled in the application.
  39549. */
  39550. static ClearCoatTintTextureEnabled: boolean;
  39551. private static _SheenTextureEnabled;
  39552. /**
  39553. * Are sheen textures enabled in the application.
  39554. */
  39555. static SheenTextureEnabled: boolean;
  39556. private static _AnisotropicTextureEnabled;
  39557. /**
  39558. * Are anisotropic textures enabled in the application.
  39559. */
  39560. static AnisotropicTextureEnabled: boolean;
  39561. private static _ThicknessTextureEnabled;
  39562. /**
  39563. * Are thickness textures enabled in the application.
  39564. */
  39565. static ThicknessTextureEnabled: boolean;
  39566. }
  39567. }
  39568. declare module BABYLON {
  39569. /** @hidden */
  39570. export var defaultFragmentDeclaration: {
  39571. name: string;
  39572. shader: string;
  39573. };
  39574. }
  39575. declare module BABYLON {
  39576. /** @hidden */
  39577. export var defaultUboDeclaration: {
  39578. name: string;
  39579. shader: string;
  39580. };
  39581. }
  39582. declare module BABYLON {
  39583. /** @hidden */
  39584. export var lightFragmentDeclaration: {
  39585. name: string;
  39586. shader: string;
  39587. };
  39588. }
  39589. declare module BABYLON {
  39590. /** @hidden */
  39591. export var lightUboDeclaration: {
  39592. name: string;
  39593. shader: string;
  39594. };
  39595. }
  39596. declare module BABYLON {
  39597. /** @hidden */
  39598. export var lightsFragmentFunctions: {
  39599. name: string;
  39600. shader: string;
  39601. };
  39602. }
  39603. declare module BABYLON {
  39604. /** @hidden */
  39605. export var shadowsFragmentFunctions: {
  39606. name: string;
  39607. shader: string;
  39608. };
  39609. }
  39610. declare module BABYLON {
  39611. /** @hidden */
  39612. export var fresnelFunction: {
  39613. name: string;
  39614. shader: string;
  39615. };
  39616. }
  39617. declare module BABYLON {
  39618. /** @hidden */
  39619. export var reflectionFunction: {
  39620. name: string;
  39621. shader: string;
  39622. };
  39623. }
  39624. declare module BABYLON {
  39625. /** @hidden */
  39626. export var bumpFragmentFunctions: {
  39627. name: string;
  39628. shader: string;
  39629. };
  39630. }
  39631. declare module BABYLON {
  39632. /** @hidden */
  39633. export var logDepthDeclaration: {
  39634. name: string;
  39635. shader: string;
  39636. };
  39637. }
  39638. declare module BABYLON {
  39639. /** @hidden */
  39640. export var bumpFragment: {
  39641. name: string;
  39642. shader: string;
  39643. };
  39644. }
  39645. declare module BABYLON {
  39646. /** @hidden */
  39647. export var depthPrePass: {
  39648. name: string;
  39649. shader: string;
  39650. };
  39651. }
  39652. declare module BABYLON {
  39653. /** @hidden */
  39654. export var lightFragment: {
  39655. name: string;
  39656. shader: string;
  39657. };
  39658. }
  39659. declare module BABYLON {
  39660. /** @hidden */
  39661. export var logDepthFragment: {
  39662. name: string;
  39663. shader: string;
  39664. };
  39665. }
  39666. declare module BABYLON {
  39667. /** @hidden */
  39668. export var defaultPixelShader: {
  39669. name: string;
  39670. shader: string;
  39671. };
  39672. }
  39673. declare module BABYLON {
  39674. /** @hidden */
  39675. export var defaultVertexDeclaration: {
  39676. name: string;
  39677. shader: string;
  39678. };
  39679. }
  39680. declare module BABYLON {
  39681. /** @hidden */
  39682. export var bumpVertexDeclaration: {
  39683. name: string;
  39684. shader: string;
  39685. };
  39686. }
  39687. declare module BABYLON {
  39688. /** @hidden */
  39689. export var bumpVertex: {
  39690. name: string;
  39691. shader: string;
  39692. };
  39693. }
  39694. declare module BABYLON {
  39695. /** @hidden */
  39696. export var fogVertex: {
  39697. name: string;
  39698. shader: string;
  39699. };
  39700. }
  39701. declare module BABYLON {
  39702. /** @hidden */
  39703. export var shadowsVertex: {
  39704. name: string;
  39705. shader: string;
  39706. };
  39707. }
  39708. declare module BABYLON {
  39709. /** @hidden */
  39710. export var pointCloudVertex: {
  39711. name: string;
  39712. shader: string;
  39713. };
  39714. }
  39715. declare module BABYLON {
  39716. /** @hidden */
  39717. export var logDepthVertex: {
  39718. name: string;
  39719. shader: string;
  39720. };
  39721. }
  39722. declare module BABYLON {
  39723. /** @hidden */
  39724. export var defaultVertexShader: {
  39725. name: string;
  39726. shader: string;
  39727. };
  39728. }
  39729. declare module BABYLON {
  39730. /** @hidden */
  39731. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39732. MAINUV1: boolean;
  39733. MAINUV2: boolean;
  39734. DIFFUSE: boolean;
  39735. DIFFUSEDIRECTUV: number;
  39736. AMBIENT: boolean;
  39737. AMBIENTDIRECTUV: number;
  39738. OPACITY: boolean;
  39739. OPACITYDIRECTUV: number;
  39740. OPACITYRGB: boolean;
  39741. REFLECTION: boolean;
  39742. EMISSIVE: boolean;
  39743. EMISSIVEDIRECTUV: number;
  39744. SPECULAR: boolean;
  39745. SPECULARDIRECTUV: number;
  39746. BUMP: boolean;
  39747. BUMPDIRECTUV: number;
  39748. PARALLAX: boolean;
  39749. PARALLAXOCCLUSION: boolean;
  39750. SPECULAROVERALPHA: boolean;
  39751. CLIPPLANE: boolean;
  39752. CLIPPLANE2: boolean;
  39753. CLIPPLANE3: boolean;
  39754. CLIPPLANE4: boolean;
  39755. ALPHATEST: boolean;
  39756. DEPTHPREPASS: boolean;
  39757. ALPHAFROMDIFFUSE: boolean;
  39758. POINTSIZE: boolean;
  39759. FOG: boolean;
  39760. SPECULARTERM: boolean;
  39761. DIFFUSEFRESNEL: boolean;
  39762. OPACITYFRESNEL: boolean;
  39763. REFLECTIONFRESNEL: boolean;
  39764. REFRACTIONFRESNEL: boolean;
  39765. EMISSIVEFRESNEL: boolean;
  39766. FRESNEL: boolean;
  39767. NORMAL: boolean;
  39768. UV1: boolean;
  39769. UV2: boolean;
  39770. VERTEXCOLOR: boolean;
  39771. VERTEXALPHA: boolean;
  39772. NUM_BONE_INFLUENCERS: number;
  39773. BonesPerMesh: number;
  39774. BONETEXTURE: boolean;
  39775. INSTANCES: boolean;
  39776. GLOSSINESS: boolean;
  39777. ROUGHNESS: boolean;
  39778. EMISSIVEASILLUMINATION: boolean;
  39779. LINKEMISSIVEWITHDIFFUSE: boolean;
  39780. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39781. LIGHTMAP: boolean;
  39782. LIGHTMAPDIRECTUV: number;
  39783. OBJECTSPACE_NORMALMAP: boolean;
  39784. USELIGHTMAPASSHADOWMAP: boolean;
  39785. REFLECTIONMAP_3D: boolean;
  39786. REFLECTIONMAP_SPHERICAL: boolean;
  39787. REFLECTIONMAP_PLANAR: boolean;
  39788. REFLECTIONMAP_CUBIC: boolean;
  39789. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39790. REFLECTIONMAP_PROJECTION: boolean;
  39791. REFLECTIONMAP_SKYBOX: boolean;
  39792. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39793. REFLECTIONMAP_EXPLICIT: boolean;
  39794. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39795. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39796. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39797. INVERTCUBICMAP: boolean;
  39798. LOGARITHMICDEPTH: boolean;
  39799. REFRACTION: boolean;
  39800. REFRACTIONMAP_3D: boolean;
  39801. REFLECTIONOVERALPHA: boolean;
  39802. TWOSIDEDLIGHTING: boolean;
  39803. SHADOWFLOAT: boolean;
  39804. MORPHTARGETS: boolean;
  39805. MORPHTARGETS_NORMAL: boolean;
  39806. MORPHTARGETS_TANGENT: boolean;
  39807. MORPHTARGETS_UV: boolean;
  39808. NUM_MORPH_INFLUENCERS: number;
  39809. NONUNIFORMSCALING: boolean;
  39810. PREMULTIPLYALPHA: boolean;
  39811. IMAGEPROCESSING: boolean;
  39812. VIGNETTE: boolean;
  39813. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39814. VIGNETTEBLENDMODEOPAQUE: boolean;
  39815. TONEMAPPING: boolean;
  39816. TONEMAPPING_ACES: boolean;
  39817. CONTRAST: boolean;
  39818. COLORCURVES: boolean;
  39819. COLORGRADING: boolean;
  39820. COLORGRADING3D: boolean;
  39821. SAMPLER3DGREENDEPTH: boolean;
  39822. SAMPLER3DBGRMAP: boolean;
  39823. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39824. MULTIVIEW: boolean;
  39825. /**
  39826. * If the reflection texture on this material is in linear color space
  39827. * @hidden
  39828. */
  39829. IS_REFLECTION_LINEAR: boolean;
  39830. /**
  39831. * If the refraction texture on this material is in linear color space
  39832. * @hidden
  39833. */
  39834. IS_REFRACTION_LINEAR: boolean;
  39835. EXPOSURE: boolean;
  39836. constructor();
  39837. setReflectionMode(modeToEnable: string): void;
  39838. }
  39839. /**
  39840. * This is the default material used in Babylon. It is the best trade off between quality
  39841. * and performances.
  39842. * @see http://doc.babylonjs.com/babylon101/materials
  39843. */
  39844. export class StandardMaterial extends PushMaterial {
  39845. private _diffuseTexture;
  39846. /**
  39847. * The basic texture of the material as viewed under a light.
  39848. */
  39849. diffuseTexture: Nullable<BaseTexture>;
  39850. private _ambientTexture;
  39851. /**
  39852. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39853. */
  39854. ambientTexture: Nullable<BaseTexture>;
  39855. private _opacityTexture;
  39856. /**
  39857. * Define the transparency of the material from a texture.
  39858. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39859. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39860. */
  39861. opacityTexture: Nullable<BaseTexture>;
  39862. private _reflectionTexture;
  39863. /**
  39864. * Define the texture used to display the reflection.
  39865. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39866. */
  39867. reflectionTexture: Nullable<BaseTexture>;
  39868. private _emissiveTexture;
  39869. /**
  39870. * Define texture of the material as if self lit.
  39871. * This will be mixed in the final result even in the absence of light.
  39872. */
  39873. emissiveTexture: Nullable<BaseTexture>;
  39874. private _specularTexture;
  39875. /**
  39876. * Define how the color and intensity of the highlight given by the light in the material.
  39877. */
  39878. specularTexture: Nullable<BaseTexture>;
  39879. private _bumpTexture;
  39880. /**
  39881. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39882. * 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.
  39883. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39884. */
  39885. bumpTexture: Nullable<BaseTexture>;
  39886. private _lightmapTexture;
  39887. /**
  39888. * Complex lighting can be computationally expensive to compute at runtime.
  39889. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39890. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39891. */
  39892. lightmapTexture: Nullable<BaseTexture>;
  39893. private _refractionTexture;
  39894. /**
  39895. * Define the texture used to display the refraction.
  39896. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39897. */
  39898. refractionTexture: Nullable<BaseTexture>;
  39899. /**
  39900. * The color of the material lit by the environmental background lighting.
  39901. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39902. */
  39903. ambientColor: Color3;
  39904. /**
  39905. * The basic color of the material as viewed under a light.
  39906. */
  39907. diffuseColor: Color3;
  39908. /**
  39909. * Define how the color and intensity of the highlight given by the light in the material.
  39910. */
  39911. specularColor: Color3;
  39912. /**
  39913. * Define the color of the material as if self lit.
  39914. * This will be mixed in the final result even in the absence of light.
  39915. */
  39916. emissiveColor: Color3;
  39917. /**
  39918. * Defines how sharp are the highlights in the material.
  39919. * The bigger the value the sharper giving a more glossy feeling to the result.
  39920. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39921. */
  39922. specularPower: number;
  39923. private _useAlphaFromDiffuseTexture;
  39924. /**
  39925. * Does the transparency come from the diffuse texture alpha channel.
  39926. */
  39927. useAlphaFromDiffuseTexture: boolean;
  39928. private _useEmissiveAsIllumination;
  39929. /**
  39930. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39931. */
  39932. useEmissiveAsIllumination: boolean;
  39933. private _linkEmissiveWithDiffuse;
  39934. /**
  39935. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39936. * the emissive level when the final color is close to one.
  39937. */
  39938. linkEmissiveWithDiffuse: boolean;
  39939. private _useSpecularOverAlpha;
  39940. /**
  39941. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39942. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39943. */
  39944. useSpecularOverAlpha: boolean;
  39945. private _useReflectionOverAlpha;
  39946. /**
  39947. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39948. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39949. */
  39950. useReflectionOverAlpha: boolean;
  39951. private _disableLighting;
  39952. /**
  39953. * Does lights from the scene impacts this material.
  39954. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39955. */
  39956. disableLighting: boolean;
  39957. private _useObjectSpaceNormalMap;
  39958. /**
  39959. * Allows using an object space normal map (instead of tangent space).
  39960. */
  39961. useObjectSpaceNormalMap: boolean;
  39962. private _useParallax;
  39963. /**
  39964. * Is parallax enabled or not.
  39965. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39966. */
  39967. useParallax: boolean;
  39968. private _useParallaxOcclusion;
  39969. /**
  39970. * Is parallax occlusion enabled or not.
  39971. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39972. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39973. */
  39974. useParallaxOcclusion: boolean;
  39975. /**
  39976. * 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.
  39977. */
  39978. parallaxScaleBias: number;
  39979. private _roughness;
  39980. /**
  39981. * Helps to define how blurry the reflections should appears in the material.
  39982. */
  39983. roughness: number;
  39984. /**
  39985. * In case of refraction, define the value of the index of refraction.
  39986. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39987. */
  39988. indexOfRefraction: number;
  39989. /**
  39990. * Invert the refraction texture alongside the y axis.
  39991. * It can be useful with procedural textures or probe for instance.
  39992. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39993. */
  39994. invertRefractionY: boolean;
  39995. /**
  39996. * Defines the alpha limits in alpha test mode.
  39997. */
  39998. alphaCutOff: number;
  39999. private _useLightmapAsShadowmap;
  40000. /**
  40001. * In case of light mapping, define whether the map contains light or shadow informations.
  40002. */
  40003. useLightmapAsShadowmap: boolean;
  40004. private _diffuseFresnelParameters;
  40005. /**
  40006. * Define the diffuse fresnel parameters of the material.
  40007. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40008. */
  40009. diffuseFresnelParameters: FresnelParameters;
  40010. private _opacityFresnelParameters;
  40011. /**
  40012. * Define the opacity fresnel parameters of the material.
  40013. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40014. */
  40015. opacityFresnelParameters: FresnelParameters;
  40016. private _reflectionFresnelParameters;
  40017. /**
  40018. * Define the reflection fresnel parameters of the material.
  40019. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40020. */
  40021. reflectionFresnelParameters: FresnelParameters;
  40022. private _refractionFresnelParameters;
  40023. /**
  40024. * Define the refraction fresnel parameters of the material.
  40025. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40026. */
  40027. refractionFresnelParameters: FresnelParameters;
  40028. private _emissiveFresnelParameters;
  40029. /**
  40030. * Define the emissive fresnel parameters of the material.
  40031. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40032. */
  40033. emissiveFresnelParameters: FresnelParameters;
  40034. private _useReflectionFresnelFromSpecular;
  40035. /**
  40036. * If true automatically deducts the fresnels values from the material specularity.
  40037. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40038. */
  40039. useReflectionFresnelFromSpecular: boolean;
  40040. private _useGlossinessFromSpecularMapAlpha;
  40041. /**
  40042. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40043. */
  40044. useGlossinessFromSpecularMapAlpha: boolean;
  40045. private _maxSimultaneousLights;
  40046. /**
  40047. * Defines the maximum number of lights that can be used in the material
  40048. */
  40049. maxSimultaneousLights: number;
  40050. private _invertNormalMapX;
  40051. /**
  40052. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40053. */
  40054. invertNormalMapX: boolean;
  40055. private _invertNormalMapY;
  40056. /**
  40057. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40058. */
  40059. invertNormalMapY: boolean;
  40060. private _twoSidedLighting;
  40061. /**
  40062. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40063. */
  40064. twoSidedLighting: boolean;
  40065. /**
  40066. * Default configuration related to image processing available in the standard Material.
  40067. */
  40068. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40069. /**
  40070. * Gets the image processing configuration used either in this material.
  40071. */
  40072. /**
  40073. * Sets the Default image processing configuration used either in the this material.
  40074. *
  40075. * If sets to null, the scene one is in use.
  40076. */
  40077. imageProcessingConfiguration: ImageProcessingConfiguration;
  40078. /**
  40079. * Keep track of the image processing observer to allow dispose and replace.
  40080. */
  40081. private _imageProcessingObserver;
  40082. /**
  40083. * Attaches a new image processing configuration to the Standard Material.
  40084. * @param configuration
  40085. */
  40086. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40087. /**
  40088. * Gets wether the color curves effect is enabled.
  40089. */
  40090. /**
  40091. * Sets wether the color curves effect is enabled.
  40092. */
  40093. cameraColorCurvesEnabled: boolean;
  40094. /**
  40095. * Gets wether the color grading effect is enabled.
  40096. */
  40097. /**
  40098. * Gets wether the color grading effect is enabled.
  40099. */
  40100. cameraColorGradingEnabled: boolean;
  40101. /**
  40102. * Gets wether tonemapping is enabled or not.
  40103. */
  40104. /**
  40105. * Sets wether tonemapping is enabled or not
  40106. */
  40107. cameraToneMappingEnabled: boolean;
  40108. /**
  40109. * The camera exposure used on this material.
  40110. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40111. * This corresponds to a photographic exposure.
  40112. */
  40113. /**
  40114. * The camera exposure used on this material.
  40115. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40116. * This corresponds to a photographic exposure.
  40117. */
  40118. cameraExposure: number;
  40119. /**
  40120. * Gets The camera contrast used on this material.
  40121. */
  40122. /**
  40123. * Sets The camera contrast used on this material.
  40124. */
  40125. cameraContrast: number;
  40126. /**
  40127. * Gets the Color Grading 2D Lookup Texture.
  40128. */
  40129. /**
  40130. * Sets the Color Grading 2D Lookup Texture.
  40131. */
  40132. cameraColorGradingTexture: Nullable<BaseTexture>;
  40133. /**
  40134. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40135. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40136. * 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;
  40137. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40138. */
  40139. /**
  40140. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40141. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40142. * 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;
  40143. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40144. */
  40145. cameraColorCurves: Nullable<ColorCurves>;
  40146. /**
  40147. * Custom callback helping to override the default shader used in the material.
  40148. */
  40149. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40150. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40151. protected _worldViewProjectionMatrix: Matrix;
  40152. protected _globalAmbientColor: Color3;
  40153. protected _useLogarithmicDepth: boolean;
  40154. protected _rebuildInParallel: boolean;
  40155. /**
  40156. * Instantiates a new standard material.
  40157. * This is the default material used in Babylon. It is the best trade off between quality
  40158. * and performances.
  40159. * @see http://doc.babylonjs.com/babylon101/materials
  40160. * @param name Define the name of the material in the scene
  40161. * @param scene Define the scene the material belong to
  40162. */
  40163. constructor(name: string, scene: Scene);
  40164. /**
  40165. * Gets a boolean indicating that current material needs to register RTT
  40166. */
  40167. readonly hasRenderTargetTextures: boolean;
  40168. /**
  40169. * Gets the current class name of the material e.g. "StandardMaterial"
  40170. * Mainly use in serialization.
  40171. * @returns the class name
  40172. */
  40173. getClassName(): string;
  40174. /**
  40175. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40176. * You can try switching to logarithmic depth.
  40177. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40178. */
  40179. useLogarithmicDepth: boolean;
  40180. /**
  40181. * Specifies if the material will require alpha blending
  40182. * @returns a boolean specifying if alpha blending is needed
  40183. */
  40184. needAlphaBlending(): boolean;
  40185. /**
  40186. * Specifies if this material should be rendered in alpha test mode
  40187. * @returns a boolean specifying if an alpha test is needed.
  40188. */
  40189. needAlphaTesting(): boolean;
  40190. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40191. /**
  40192. * Get the texture used for alpha test purpose.
  40193. * @returns the diffuse texture in case of the standard material.
  40194. */
  40195. getAlphaTestTexture(): Nullable<BaseTexture>;
  40196. /**
  40197. * Get if the submesh is ready to be used and all its information available.
  40198. * Child classes can use it to update shaders
  40199. * @param mesh defines the mesh to check
  40200. * @param subMesh defines which submesh to check
  40201. * @param useInstances specifies that instances should be used
  40202. * @returns a boolean indicating that the submesh is ready or not
  40203. */
  40204. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40205. /**
  40206. * Builds the material UBO layouts.
  40207. * Used internally during the effect preparation.
  40208. */
  40209. buildUniformLayout(): void;
  40210. /**
  40211. * Unbinds the material from the mesh
  40212. */
  40213. unbind(): void;
  40214. /**
  40215. * Binds the submesh to this material by preparing the effect and shader to draw
  40216. * @param world defines the world transformation matrix
  40217. * @param mesh defines the mesh containing the submesh
  40218. * @param subMesh defines the submesh to bind the material to
  40219. */
  40220. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40221. /**
  40222. * Get the list of animatables in the material.
  40223. * @returns the list of animatables object used in the material
  40224. */
  40225. getAnimatables(): IAnimatable[];
  40226. /**
  40227. * Gets the active textures from the material
  40228. * @returns an array of textures
  40229. */
  40230. getActiveTextures(): BaseTexture[];
  40231. /**
  40232. * Specifies if the material uses a texture
  40233. * @param texture defines the texture to check against the material
  40234. * @returns a boolean specifying if the material uses the texture
  40235. */
  40236. hasTexture(texture: BaseTexture): boolean;
  40237. /**
  40238. * Disposes the material
  40239. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40240. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40241. */
  40242. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40243. /**
  40244. * Makes a duplicate of the material, and gives it a new name
  40245. * @param name defines the new name for the duplicated material
  40246. * @returns the cloned material
  40247. */
  40248. clone(name: string): StandardMaterial;
  40249. /**
  40250. * Serializes this material in a JSON representation
  40251. * @returns the serialized material object
  40252. */
  40253. serialize(): any;
  40254. /**
  40255. * Creates a standard material from parsed material data
  40256. * @param source defines the JSON representation of the material
  40257. * @param scene defines the hosting scene
  40258. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40259. * @returns a new standard material
  40260. */
  40261. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40262. /**
  40263. * Are diffuse textures enabled in the application.
  40264. */
  40265. static DiffuseTextureEnabled: boolean;
  40266. /**
  40267. * Are ambient textures enabled in the application.
  40268. */
  40269. static AmbientTextureEnabled: boolean;
  40270. /**
  40271. * Are opacity textures enabled in the application.
  40272. */
  40273. static OpacityTextureEnabled: boolean;
  40274. /**
  40275. * Are reflection textures enabled in the application.
  40276. */
  40277. static ReflectionTextureEnabled: boolean;
  40278. /**
  40279. * Are emissive textures enabled in the application.
  40280. */
  40281. static EmissiveTextureEnabled: boolean;
  40282. /**
  40283. * Are specular textures enabled in the application.
  40284. */
  40285. static SpecularTextureEnabled: boolean;
  40286. /**
  40287. * Are bump textures enabled in the application.
  40288. */
  40289. static BumpTextureEnabled: boolean;
  40290. /**
  40291. * Are lightmap textures enabled in the application.
  40292. */
  40293. static LightmapTextureEnabled: boolean;
  40294. /**
  40295. * Are refraction textures enabled in the application.
  40296. */
  40297. static RefractionTextureEnabled: boolean;
  40298. /**
  40299. * Are color grading textures enabled in the application.
  40300. */
  40301. static ColorGradingTextureEnabled: boolean;
  40302. /**
  40303. * Are fresnels enabled in the application.
  40304. */
  40305. static FresnelEnabled: boolean;
  40306. }
  40307. }
  40308. declare module BABYLON {
  40309. /** @hidden */
  40310. export var imageProcessingPixelShader: {
  40311. name: string;
  40312. shader: string;
  40313. };
  40314. }
  40315. declare module BABYLON {
  40316. /**
  40317. * ImageProcessingPostProcess
  40318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40319. */
  40320. export class ImageProcessingPostProcess extends PostProcess {
  40321. /**
  40322. * Default configuration related to image processing available in the PBR Material.
  40323. */
  40324. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40325. /**
  40326. * Gets the image processing configuration used either in this material.
  40327. */
  40328. /**
  40329. * Sets the Default image processing configuration used either in the this material.
  40330. *
  40331. * If sets to null, the scene one is in use.
  40332. */
  40333. imageProcessingConfiguration: ImageProcessingConfiguration;
  40334. /**
  40335. * Keep track of the image processing observer to allow dispose and replace.
  40336. */
  40337. private _imageProcessingObserver;
  40338. /**
  40339. * Attaches a new image processing configuration to the PBR Material.
  40340. * @param configuration
  40341. */
  40342. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40343. /**
  40344. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40345. */
  40346. /**
  40347. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40348. */
  40349. colorCurves: Nullable<ColorCurves>;
  40350. /**
  40351. * Gets wether the color curves effect is enabled.
  40352. */
  40353. /**
  40354. * Sets wether the color curves effect is enabled.
  40355. */
  40356. colorCurvesEnabled: boolean;
  40357. /**
  40358. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40359. */
  40360. /**
  40361. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40362. */
  40363. colorGradingTexture: Nullable<BaseTexture>;
  40364. /**
  40365. * Gets wether the color grading effect is enabled.
  40366. */
  40367. /**
  40368. * Gets wether the color grading effect is enabled.
  40369. */
  40370. colorGradingEnabled: boolean;
  40371. /**
  40372. * Gets exposure used in the effect.
  40373. */
  40374. /**
  40375. * Sets exposure used in the effect.
  40376. */
  40377. exposure: number;
  40378. /**
  40379. * Gets wether tonemapping is enabled or not.
  40380. */
  40381. /**
  40382. * Sets wether tonemapping is enabled or not
  40383. */
  40384. toneMappingEnabled: boolean;
  40385. /**
  40386. * Gets the type of tone mapping effect.
  40387. */
  40388. /**
  40389. * Sets the type of tone mapping effect.
  40390. */
  40391. toneMappingType: number;
  40392. /**
  40393. * Gets contrast used in the effect.
  40394. */
  40395. /**
  40396. * Sets contrast used in the effect.
  40397. */
  40398. contrast: number;
  40399. /**
  40400. * Gets Vignette stretch size.
  40401. */
  40402. /**
  40403. * Sets Vignette stretch size.
  40404. */
  40405. vignetteStretch: number;
  40406. /**
  40407. * Gets Vignette centre X Offset.
  40408. */
  40409. /**
  40410. * Sets Vignette centre X Offset.
  40411. */
  40412. vignetteCentreX: number;
  40413. /**
  40414. * Gets Vignette centre Y Offset.
  40415. */
  40416. /**
  40417. * Sets Vignette centre Y Offset.
  40418. */
  40419. vignetteCentreY: number;
  40420. /**
  40421. * Gets Vignette weight or intensity of the vignette effect.
  40422. */
  40423. /**
  40424. * Sets Vignette weight or intensity of the vignette effect.
  40425. */
  40426. vignetteWeight: number;
  40427. /**
  40428. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40429. * if vignetteEnabled is set to true.
  40430. */
  40431. /**
  40432. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40433. * if vignetteEnabled is set to true.
  40434. */
  40435. vignetteColor: Color4;
  40436. /**
  40437. * Gets Camera field of view used by the Vignette effect.
  40438. */
  40439. /**
  40440. * Sets Camera field of view used by the Vignette effect.
  40441. */
  40442. vignetteCameraFov: number;
  40443. /**
  40444. * Gets the vignette blend mode allowing different kind of effect.
  40445. */
  40446. /**
  40447. * Sets the vignette blend mode allowing different kind of effect.
  40448. */
  40449. vignetteBlendMode: number;
  40450. /**
  40451. * Gets wether the vignette effect is enabled.
  40452. */
  40453. /**
  40454. * Sets wether the vignette effect is enabled.
  40455. */
  40456. vignetteEnabled: boolean;
  40457. private _fromLinearSpace;
  40458. /**
  40459. * Gets wether the input of the processing is in Gamma or Linear Space.
  40460. */
  40461. /**
  40462. * Sets wether the input of the processing is in Gamma or Linear Space.
  40463. */
  40464. fromLinearSpace: boolean;
  40465. /**
  40466. * Defines cache preventing GC.
  40467. */
  40468. private _defines;
  40469. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40470. /**
  40471. * "ImageProcessingPostProcess"
  40472. * @returns "ImageProcessingPostProcess"
  40473. */
  40474. getClassName(): string;
  40475. protected _updateParameters(): void;
  40476. dispose(camera?: Camera): void;
  40477. }
  40478. }
  40479. declare module BABYLON {
  40480. /**
  40481. * Class containing static functions to help procedurally build meshes
  40482. */
  40483. export class GroundBuilder {
  40484. /**
  40485. * Creates a ground mesh
  40486. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40487. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40489. * @param name defines the name of the mesh
  40490. * @param options defines the options used to create the mesh
  40491. * @param scene defines the hosting scene
  40492. * @returns the ground mesh
  40493. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40494. */
  40495. static CreateGround(name: string, options: {
  40496. width?: number;
  40497. height?: number;
  40498. subdivisions?: number;
  40499. subdivisionsX?: number;
  40500. subdivisionsY?: number;
  40501. updatable?: boolean;
  40502. }, scene: any): Mesh;
  40503. /**
  40504. * Creates a tiled ground mesh
  40505. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40506. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40507. * * 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
  40508. * * 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
  40509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40510. * @param name defines the name of the mesh
  40511. * @param options defines the options used to create the mesh
  40512. * @param scene defines the hosting scene
  40513. * @returns the tiled ground mesh
  40514. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40515. */
  40516. static CreateTiledGround(name: string, options: {
  40517. xmin: number;
  40518. zmin: number;
  40519. xmax: number;
  40520. zmax: number;
  40521. subdivisions?: {
  40522. w: number;
  40523. h: number;
  40524. };
  40525. precision?: {
  40526. w: number;
  40527. h: number;
  40528. };
  40529. updatable?: boolean;
  40530. }, scene?: Nullable<Scene>): Mesh;
  40531. /**
  40532. * Creates a ground mesh from a height map
  40533. * * The parameter `url` sets the URL of the height map image resource.
  40534. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40535. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40536. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40537. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40538. * * 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.
  40539. * * 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).
  40540. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40542. * @param name defines the name of the mesh
  40543. * @param url defines the url to the height map
  40544. * @param options defines the options used to create the mesh
  40545. * @param scene defines the hosting scene
  40546. * @returns the ground mesh
  40547. * @see https://doc.babylonjs.com/babylon101/height_map
  40548. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40549. */
  40550. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40551. width?: number;
  40552. height?: number;
  40553. subdivisions?: number;
  40554. minHeight?: number;
  40555. maxHeight?: number;
  40556. colorFilter?: Color3;
  40557. alphaFilter?: number;
  40558. updatable?: boolean;
  40559. onReady?: (mesh: GroundMesh) => void;
  40560. }, scene?: Nullable<Scene>): GroundMesh;
  40561. }
  40562. }
  40563. declare module BABYLON {
  40564. /**
  40565. * Class containing static functions to help procedurally build meshes
  40566. */
  40567. export class TorusBuilder {
  40568. /**
  40569. * Creates a torus mesh
  40570. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40571. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40572. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40574. * * 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
  40575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40576. * @param name defines the name of the mesh
  40577. * @param options defines the options used to create the mesh
  40578. * @param scene defines the hosting scene
  40579. * @returns the torus mesh
  40580. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40581. */
  40582. static CreateTorus(name: string, options: {
  40583. diameter?: number;
  40584. thickness?: number;
  40585. tessellation?: number;
  40586. updatable?: boolean;
  40587. sideOrientation?: number;
  40588. frontUVs?: Vector4;
  40589. backUVs?: Vector4;
  40590. }, scene: any): Mesh;
  40591. }
  40592. }
  40593. declare module BABYLON {
  40594. /**
  40595. * Class containing static functions to help procedurally build meshes
  40596. */
  40597. export class CylinderBuilder {
  40598. /**
  40599. * Creates a cylinder or a cone mesh
  40600. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40601. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40602. * * 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.
  40603. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40604. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40605. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40606. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40607. * * 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).
  40608. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40609. * * 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).
  40610. * * 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
  40611. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40612. * * 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
  40613. * * 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.
  40614. * * If `enclose` is false, a ring surface is one element.
  40615. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40616. * * 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
  40617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40618. * * 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
  40619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40620. * @param name defines the name of the mesh
  40621. * @param options defines the options used to create the mesh
  40622. * @param scene defines the hosting scene
  40623. * @returns the cylinder mesh
  40624. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40625. */
  40626. static CreateCylinder(name: string, options: {
  40627. height?: number;
  40628. diameterTop?: number;
  40629. diameterBottom?: number;
  40630. diameter?: number;
  40631. tessellation?: number;
  40632. subdivisions?: number;
  40633. arc?: number;
  40634. faceColors?: Color4[];
  40635. faceUV?: Vector4[];
  40636. updatable?: boolean;
  40637. hasRings?: boolean;
  40638. enclose?: boolean;
  40639. cap?: number;
  40640. sideOrientation?: number;
  40641. frontUVs?: Vector4;
  40642. backUVs?: Vector4;
  40643. }, scene: any): Mesh;
  40644. }
  40645. }
  40646. declare module BABYLON {
  40647. /**
  40648. * Options to modify the vr teleportation behavior.
  40649. */
  40650. export interface VRTeleportationOptions {
  40651. /**
  40652. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40653. */
  40654. floorMeshName?: string;
  40655. /**
  40656. * A list of meshes to be used as the teleportation floor. (default: empty)
  40657. */
  40658. floorMeshes?: Mesh[];
  40659. }
  40660. /**
  40661. * Options to modify the vr experience helper's behavior.
  40662. */
  40663. export interface VRExperienceHelperOptions extends WebVROptions {
  40664. /**
  40665. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40666. */
  40667. createDeviceOrientationCamera?: boolean;
  40668. /**
  40669. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40670. */
  40671. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40672. /**
  40673. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40674. */
  40675. laserToggle?: boolean;
  40676. /**
  40677. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40678. */
  40679. floorMeshes?: Mesh[];
  40680. /**
  40681. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40682. */
  40683. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40684. }
  40685. /**
  40686. * Event containing information after VR has been entered
  40687. */
  40688. export class OnAfterEnteringVRObservableEvent {
  40689. /**
  40690. * If entering vr was successful
  40691. */
  40692. success: boolean;
  40693. }
  40694. /**
  40695. * Helps to quickly add VR support to an existing scene.
  40696. * See http://doc.babylonjs.com/how_to/webvr_helper
  40697. */
  40698. export class VRExperienceHelper {
  40699. /** Options to modify the vr experience helper's behavior. */
  40700. webVROptions: VRExperienceHelperOptions;
  40701. private _scene;
  40702. private _position;
  40703. private _btnVR;
  40704. private _btnVRDisplayed;
  40705. private _webVRsupported;
  40706. private _webVRready;
  40707. private _webVRrequesting;
  40708. private _webVRpresenting;
  40709. private _hasEnteredVR;
  40710. private _fullscreenVRpresenting;
  40711. private _inputElement;
  40712. private _webVRCamera;
  40713. private _vrDeviceOrientationCamera;
  40714. private _deviceOrientationCamera;
  40715. private _existingCamera;
  40716. private _onKeyDown;
  40717. private _onVrDisplayPresentChange;
  40718. private _onVRDisplayChanged;
  40719. private _onVRRequestPresentStart;
  40720. private _onVRRequestPresentComplete;
  40721. /**
  40722. * 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)
  40723. */
  40724. enableGazeEvenWhenNoPointerLock: boolean;
  40725. /**
  40726. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40727. */
  40728. exitVROnDoubleTap: boolean;
  40729. /**
  40730. * Observable raised right before entering VR.
  40731. */
  40732. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40733. /**
  40734. * Observable raised when entering VR has completed.
  40735. */
  40736. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40737. /**
  40738. * Observable raised when exiting VR.
  40739. */
  40740. onExitingVRObservable: Observable<VRExperienceHelper>;
  40741. /**
  40742. * Observable raised when controller mesh is loaded.
  40743. */
  40744. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40745. /** Return this.onEnteringVRObservable
  40746. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40747. */
  40748. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40749. /** Return this.onExitingVRObservable
  40750. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40751. */
  40752. readonly onExitingVR: Observable<VRExperienceHelper>;
  40753. /** Return this.onControllerMeshLoadedObservable
  40754. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40755. */
  40756. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40757. private _rayLength;
  40758. private _useCustomVRButton;
  40759. private _teleportationRequested;
  40760. private _teleportActive;
  40761. private _floorMeshName;
  40762. private _floorMeshesCollection;
  40763. private _rotationAllowed;
  40764. private _teleportBackwardsVector;
  40765. private _teleportationTarget;
  40766. private _isDefaultTeleportationTarget;
  40767. private _postProcessMove;
  40768. private _teleportationFillColor;
  40769. private _teleportationBorderColor;
  40770. private _rotationAngle;
  40771. private _haloCenter;
  40772. private _cameraGazer;
  40773. private _padSensibilityUp;
  40774. private _padSensibilityDown;
  40775. private _leftController;
  40776. private _rightController;
  40777. /**
  40778. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40779. */
  40780. onNewMeshSelected: Observable<AbstractMesh>;
  40781. /**
  40782. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40783. * This observable will provide the mesh and the controller used to select the mesh
  40784. */
  40785. onMeshSelectedWithController: Observable<{
  40786. mesh: AbstractMesh;
  40787. controller: WebVRController;
  40788. }>;
  40789. /**
  40790. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40791. */
  40792. onNewMeshPicked: Observable<PickingInfo>;
  40793. private _circleEase;
  40794. /**
  40795. * Observable raised before camera teleportation
  40796. */
  40797. onBeforeCameraTeleport: Observable<Vector3>;
  40798. /**
  40799. * Observable raised after camera teleportation
  40800. */
  40801. onAfterCameraTeleport: Observable<Vector3>;
  40802. /**
  40803. * Observable raised when current selected mesh gets unselected
  40804. */
  40805. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40806. private _raySelectionPredicate;
  40807. /**
  40808. * To be optionaly changed by user to define custom ray selection
  40809. */
  40810. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40811. /**
  40812. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40813. */
  40814. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40815. /**
  40816. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40817. */
  40818. teleportationEnabled: boolean;
  40819. private _defaultHeight;
  40820. private _teleportationInitialized;
  40821. private _interactionsEnabled;
  40822. private _interactionsRequested;
  40823. private _displayGaze;
  40824. private _displayLaserPointer;
  40825. /**
  40826. * The mesh used to display where the user is going to teleport.
  40827. */
  40828. /**
  40829. * Sets the mesh to be used to display where the user is going to teleport.
  40830. */
  40831. teleportationTarget: Mesh;
  40832. /**
  40833. * 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
  40834. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40835. * See http://doc.babylonjs.com/resources/baking_transformations
  40836. */
  40837. gazeTrackerMesh: Mesh;
  40838. /**
  40839. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40840. */
  40841. updateGazeTrackerScale: boolean;
  40842. /**
  40843. * If the gaze trackers color should be updated when selecting meshes
  40844. */
  40845. updateGazeTrackerColor: boolean;
  40846. /**
  40847. * If the controller laser color should be updated when selecting meshes
  40848. */
  40849. updateControllerLaserColor: boolean;
  40850. /**
  40851. * The gaze tracking mesh corresponding to the left controller
  40852. */
  40853. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40854. /**
  40855. * The gaze tracking mesh corresponding to the right controller
  40856. */
  40857. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40858. /**
  40859. * If the ray of the gaze should be displayed.
  40860. */
  40861. /**
  40862. * Sets if the ray of the gaze should be displayed.
  40863. */
  40864. displayGaze: boolean;
  40865. /**
  40866. * If the ray of the LaserPointer should be displayed.
  40867. */
  40868. /**
  40869. * Sets if the ray of the LaserPointer should be displayed.
  40870. */
  40871. displayLaserPointer: boolean;
  40872. /**
  40873. * The deviceOrientationCamera used as the camera when not in VR.
  40874. */
  40875. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40876. /**
  40877. * Based on the current WebVR support, returns the current VR camera used.
  40878. */
  40879. readonly currentVRCamera: Nullable<Camera>;
  40880. /**
  40881. * The webVRCamera which is used when in VR.
  40882. */
  40883. readonly webVRCamera: WebVRFreeCamera;
  40884. /**
  40885. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40886. */
  40887. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40888. /**
  40889. * The html button that is used to trigger entering into VR.
  40890. */
  40891. readonly vrButton: Nullable<HTMLButtonElement>;
  40892. private readonly _teleportationRequestInitiated;
  40893. /**
  40894. * Defines wether or not Pointer lock should be requested when switching to
  40895. * full screen.
  40896. */
  40897. requestPointerLockOnFullScreen: boolean;
  40898. /**
  40899. * Instantiates a VRExperienceHelper.
  40900. * Helps to quickly add VR support to an existing scene.
  40901. * @param scene The scene the VRExperienceHelper belongs to.
  40902. * @param webVROptions Options to modify the vr experience helper's behavior.
  40903. */
  40904. constructor(scene: Scene,
  40905. /** Options to modify the vr experience helper's behavior. */
  40906. webVROptions?: VRExperienceHelperOptions);
  40907. private _onDefaultMeshLoaded;
  40908. private _onResize;
  40909. private _onFullscreenChange;
  40910. /**
  40911. * Gets a value indicating if we are currently in VR mode.
  40912. */
  40913. readonly isInVRMode: boolean;
  40914. private onVrDisplayPresentChange;
  40915. private onVRDisplayChanged;
  40916. private moveButtonToBottomRight;
  40917. private displayVRButton;
  40918. private updateButtonVisibility;
  40919. private _cachedAngularSensibility;
  40920. /**
  40921. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40922. * Otherwise, will use the fullscreen API.
  40923. */
  40924. enterVR(): void;
  40925. /**
  40926. * Attempt to exit VR, or fullscreen.
  40927. */
  40928. exitVR(): void;
  40929. /**
  40930. * The position of the vr experience helper.
  40931. */
  40932. /**
  40933. * Sets the position of the vr experience helper.
  40934. */
  40935. position: Vector3;
  40936. /**
  40937. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40938. */
  40939. enableInteractions(): void;
  40940. private readonly _noControllerIsActive;
  40941. private beforeRender;
  40942. private _isTeleportationFloor;
  40943. /**
  40944. * Adds a floor mesh to be used for teleportation.
  40945. * @param floorMesh the mesh to be used for teleportation.
  40946. */
  40947. addFloorMesh(floorMesh: Mesh): void;
  40948. /**
  40949. * Removes a floor mesh from being used for teleportation.
  40950. * @param floorMesh the mesh to be removed.
  40951. */
  40952. removeFloorMesh(floorMesh: Mesh): void;
  40953. /**
  40954. * Enables interactions and teleportation using the VR controllers and gaze.
  40955. * @param vrTeleportationOptions options to modify teleportation behavior.
  40956. */
  40957. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40958. private _onNewGamepadConnected;
  40959. private _tryEnableInteractionOnController;
  40960. private _onNewGamepadDisconnected;
  40961. private _enableInteractionOnController;
  40962. private _checkTeleportWithRay;
  40963. private _checkRotate;
  40964. private _checkTeleportBackwards;
  40965. private _enableTeleportationOnController;
  40966. private _createTeleportationCircles;
  40967. private _displayTeleportationTarget;
  40968. private _hideTeleportationTarget;
  40969. private _rotateCamera;
  40970. private _moveTeleportationSelectorTo;
  40971. private _workingVector;
  40972. private _workingQuaternion;
  40973. private _workingMatrix;
  40974. /**
  40975. * Teleports the users feet to the desired location
  40976. * @param location The location where the user's feet should be placed
  40977. */
  40978. teleportCamera(location: Vector3): void;
  40979. private _convertNormalToDirectionOfRay;
  40980. private _castRayAndSelectObject;
  40981. private _notifySelectedMeshUnselected;
  40982. /**
  40983. * Sets the color of the laser ray from the vr controllers.
  40984. * @param color new color for the ray.
  40985. */
  40986. changeLaserColor(color: Color3): void;
  40987. /**
  40988. * Sets the color of the ray from the vr headsets gaze.
  40989. * @param color new color for the ray.
  40990. */
  40991. changeGazeColor(color: Color3): void;
  40992. /**
  40993. * Exits VR and disposes of the vr experience helper
  40994. */
  40995. dispose(): void;
  40996. /**
  40997. * Gets the name of the VRExperienceHelper class
  40998. * @returns "VRExperienceHelper"
  40999. */
  41000. getClassName(): string;
  41001. }
  41002. }
  41003. declare module BABYLON {
  41004. /**
  41005. * States of the webXR experience
  41006. */
  41007. export enum WebXRState {
  41008. /**
  41009. * Transitioning to being in XR mode
  41010. */
  41011. ENTERING_XR = 0,
  41012. /**
  41013. * Transitioning to non XR mode
  41014. */
  41015. EXITING_XR = 1,
  41016. /**
  41017. * In XR mode and presenting
  41018. */
  41019. IN_XR = 2,
  41020. /**
  41021. * Not entered XR mode
  41022. */
  41023. NOT_IN_XR = 3
  41024. }
  41025. /**
  41026. * Abstraction of the XR render target
  41027. */
  41028. export interface WebXRRenderTarget extends IDisposable {
  41029. /**
  41030. * xrpresent context of the canvas which can be used to display/mirror xr content
  41031. */
  41032. canvasContext: WebGLRenderingContext;
  41033. /**
  41034. * xr layer for the canvas
  41035. */
  41036. xrLayer: Nullable<XRWebGLLayer>;
  41037. /**
  41038. * Initializes the xr layer for the session
  41039. * @param xrSession xr session
  41040. * @returns a promise that will resolve once the XR Layer has been created
  41041. */
  41042. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41043. }
  41044. }
  41045. declare module BABYLON {
  41046. /**
  41047. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41048. */
  41049. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41050. private _engine;
  41051. private _canvas;
  41052. /**
  41053. * xrpresent context of the canvas which can be used to display/mirror xr content
  41054. */
  41055. canvasContext: WebGLRenderingContext;
  41056. /**
  41057. * xr layer for the canvas
  41058. */
  41059. xrLayer: Nullable<XRWebGLLayer>;
  41060. /**
  41061. * Initializes the xr layer for the session
  41062. * @param xrSession xr session
  41063. * @returns a promise that will resolve once the XR Layer has been created
  41064. */
  41065. initializeXRLayerAsync(xrSession: any): any;
  41066. /**
  41067. * Initializes the canvas to be added/removed upon entering/exiting xr
  41068. * @param engine the Babylon engine
  41069. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41070. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41071. */
  41072. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  41073. /**
  41074. * Disposes of the object
  41075. */
  41076. dispose(): void;
  41077. private _setManagedOutputCanvas;
  41078. private _addCanvas;
  41079. private _removeCanvas;
  41080. }
  41081. }
  41082. declare module BABYLON {
  41083. /**
  41084. * Manages an XRSession to work with Babylon's engine
  41085. * @see https://doc.babylonjs.com/how_to/webxr
  41086. */
  41087. export class WebXRSessionManager implements IDisposable {
  41088. private scene;
  41089. /**
  41090. * Fires every time a new xrFrame arrives which can be used to update the camera
  41091. */
  41092. onXRFrameObservable: Observable<any>;
  41093. /**
  41094. * Fires when the xr session is ended either by the device or manually done
  41095. */
  41096. onXRSessionEnded: Observable<any>;
  41097. /**
  41098. * Underlying xr session
  41099. */
  41100. session: XRSession;
  41101. /**
  41102. * Type of reference space used when creating the session
  41103. */
  41104. referenceSpace: XRReferenceSpace;
  41105. /**
  41106. * Current XR frame
  41107. */
  41108. currentFrame: Nullable<XRFrame>;
  41109. private _xrNavigator;
  41110. private baseLayer;
  41111. private _rttProvider;
  41112. private _sessionEnded;
  41113. /**
  41114. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41115. * @param scene The scene which the session should be created for
  41116. */
  41117. constructor(scene: Scene);
  41118. /**
  41119. * Initializes the manager
  41120. * After initialization enterXR can be called to start an XR session
  41121. * @returns Promise which resolves after it is initialized
  41122. */
  41123. initializeAsync(): Promise<void>;
  41124. /**
  41125. * Initializes an xr session
  41126. * @param xrSessionMode mode to initialize
  41127. * @param optionalFeatures defines optional values to pass to the session builder
  41128. * @returns a promise which will resolve once the session has been initialized
  41129. */
  41130. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  41131. /**
  41132. * Sets the reference space on the xr session
  41133. * @param referenceSpace space to set
  41134. * @returns a promise that will resolve once the reference space has been set
  41135. */
  41136. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41137. /**
  41138. * Updates the render state of the session
  41139. * @param state state to set
  41140. * @returns a promise that resolves once the render state has been updated
  41141. */
  41142. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41143. /**
  41144. * Starts rendering to the xr layer
  41145. * @returns a promise that will resolve once rendering has started
  41146. */
  41147. startRenderingToXRAsync(): Promise<void>;
  41148. /**
  41149. * Gets the correct render target texture to be rendered this frame for this eye
  41150. * @param eye the eye for which to get the render target
  41151. * @returns the render target for the specified eye
  41152. */
  41153. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41154. /**
  41155. * Stops the xrSession and restores the renderloop
  41156. * @returns Promise which resolves after it exits XR
  41157. */
  41158. exitXRAsync(): Promise<void>;
  41159. /**
  41160. * Checks if a session would be supported for the creation options specified
  41161. * @param sessionMode session mode to check if supported eg. immersive-vr
  41162. * @returns true if supported
  41163. */
  41164. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41165. /**
  41166. * Creates a WebXRRenderTarget object for the XR session
  41167. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41168. * @returns a WebXR render target to which the session can render
  41169. */
  41170. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  41171. /**
  41172. * @hidden
  41173. * Converts the render layer of xrSession to a render target
  41174. * @param session session to create render target for
  41175. * @param scene scene the new render target should be created for
  41176. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41177. /**
  41178. * Disposes of the session manager
  41179. */
  41180. dispose(): void;
  41181. }
  41182. }
  41183. declare module BABYLON {
  41184. /**
  41185. * WebXR Camera which holds the views for the xrSession
  41186. * @see https://doc.babylonjs.com/how_to/webxr
  41187. */
  41188. export class WebXRCamera extends FreeCamera {
  41189. private static _TmpMatrix;
  41190. /**
  41191. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41192. * @param name the name of the camera
  41193. * @param scene the scene to add the camera to
  41194. */
  41195. constructor(name: string, scene: Scene);
  41196. private _updateNumberOfRigCameras;
  41197. /** @hidden */ private _updateForDualEyeDebugging(): void;
  41198. /**
  41199. * Updates the cameras position from the current pose information of the XR session
  41200. * @param xrSessionManager the session containing pose information
  41201. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41202. */
  41203. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41204. }
  41205. }
  41206. declare module BABYLON {
  41207. /**
  41208. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41209. * @see https://doc.babylonjs.com/how_to/webxr
  41210. */
  41211. export class WebXRExperienceHelper implements IDisposable {
  41212. private scene;
  41213. /**
  41214. * 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
  41215. */
  41216. container: AbstractMesh;
  41217. /**
  41218. * Camera used to render xr content
  41219. */
  41220. camera: WebXRCamera;
  41221. /**
  41222. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41223. */
  41224. state: WebXRState;
  41225. private _setState;
  41226. private static _TmpVector;
  41227. /**
  41228. * Fires when the state of the experience helper has changed
  41229. */
  41230. onStateChangedObservable: Observable<WebXRState>;
  41231. /** Session manager used to keep track of xr session */
  41232. sessionManager: WebXRSessionManager;
  41233. private _nonVRCamera;
  41234. private _originalSceneAutoClear;
  41235. private _supported;
  41236. /**
  41237. * Creates the experience helper
  41238. * @param scene the scene to attach the experience helper to
  41239. * @returns a promise for the experience helper
  41240. */
  41241. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41242. /**
  41243. * Creates a WebXRExperienceHelper
  41244. * @param scene The scene the helper should be created in
  41245. */
  41246. private constructor();
  41247. /**
  41248. * Exits XR mode and returns the scene to its original state
  41249. * @returns promise that resolves after xr mode has exited
  41250. */
  41251. exitXRAsync(): Promise<void>;
  41252. /**
  41253. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41254. * @param sessionMode options for the XR session
  41255. * @param referenceSpaceType frame of reference of the XR session
  41256. * @param renderTarget the output canvas that will be used to enter XR mode
  41257. * @returns promise that resolves after xr mode has entered
  41258. */
  41259. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  41260. /**
  41261. * Updates the global position of the camera by moving the camera's container
  41262. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41263. * @param position The desired global position of the camera
  41264. */
  41265. setPositionOfCameraUsingContainer(position: Vector3): void;
  41266. /**
  41267. * Rotates the xr camera by rotating the camera's container around the camera's position
  41268. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41269. * @param rotation the desired quaternion rotation to apply to the camera
  41270. */
  41271. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41272. /**
  41273. * Disposes of the experience helper
  41274. */
  41275. dispose(): void;
  41276. }
  41277. }
  41278. declare module BABYLON {
  41279. /**
  41280. * Button which can be used to enter a different mode of XR
  41281. */
  41282. export class WebXREnterExitUIButton {
  41283. /** button element */
  41284. element: HTMLElement;
  41285. /** XR initialization options for the button */
  41286. sessionMode: XRSessionMode;
  41287. /** Reference space type */
  41288. referenceSpaceType: XRReferenceSpaceType;
  41289. /**
  41290. * Creates a WebXREnterExitUIButton
  41291. * @param element button element
  41292. * @param sessionMode XR initialization session mode
  41293. * @param referenceSpaceType the type of reference space to be used
  41294. */
  41295. constructor(
  41296. /** button element */
  41297. element: HTMLElement,
  41298. /** XR initialization options for the button */
  41299. sessionMode: XRSessionMode,
  41300. /** Reference space type */
  41301. referenceSpaceType: XRReferenceSpaceType);
  41302. /**
  41303. * Overwritable function which can be used to update the button's visuals when the state changes
  41304. * @param activeButton the current active button in the UI
  41305. */
  41306. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41307. }
  41308. /**
  41309. * Options to create the webXR UI
  41310. */
  41311. export class WebXREnterExitUIOptions {
  41312. /**
  41313. * Context to enter xr with
  41314. */
  41315. renderTarget?: Nullable<WebXRRenderTarget>;
  41316. /**
  41317. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41318. */
  41319. customButtons?: Array<WebXREnterExitUIButton>;
  41320. }
  41321. /**
  41322. * UI to allow the user to enter/exit XR mode
  41323. */
  41324. export class WebXREnterExitUI implements IDisposable {
  41325. private scene;
  41326. private _overlay;
  41327. private _buttons;
  41328. private _activeButton;
  41329. /**
  41330. * Fired every time the active button is changed.
  41331. *
  41332. * When xr is entered via a button that launches xr that button will be the callback parameter
  41333. *
  41334. * When exiting xr the callback parameter will be null)
  41335. */
  41336. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41337. /**
  41338. * Creates UI to allow the user to enter/exit XR mode
  41339. * @param scene the scene to add the ui to
  41340. * @param helper the xr experience helper to enter/exit xr with
  41341. * @param options options to configure the UI
  41342. * @returns the created ui
  41343. */
  41344. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41345. private constructor();
  41346. private _updateButtons;
  41347. /**
  41348. * Disposes of the object
  41349. */
  41350. dispose(): void;
  41351. }
  41352. }
  41353. declare module BABYLON {
  41354. /**
  41355. * Represents an XR input
  41356. */
  41357. export class WebXRController {
  41358. private scene;
  41359. /** The underlying input source for the controller */
  41360. inputSource: XRInputSource;
  41361. private parentContainer;
  41362. /**
  41363. * 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
  41364. */
  41365. grip?: AbstractMesh;
  41366. /**
  41367. * Pointer which can be used to select objects or attach a visible laser to
  41368. */
  41369. pointer: AbstractMesh;
  41370. private _gamepadMode;
  41371. /**
  41372. * If available, this is the gamepad object related to this controller.
  41373. * Using this object it is possible to get click events and trackpad changes of the
  41374. * webxr controller that is currently being used.
  41375. */
  41376. gamepadController?: WebVRController;
  41377. /**
  41378. * Event that fires when the controller is removed/disposed
  41379. */
  41380. onDisposeObservable: Observable<{}>;
  41381. private _tmpMatrix;
  41382. private _tmpQuaternion;
  41383. private _tmpVector;
  41384. /**
  41385. * Creates the controller
  41386. * @see https://doc.babylonjs.com/how_to/webxr
  41387. * @param scene the scene which the controller should be associated to
  41388. * @param inputSource the underlying input source for the controller
  41389. * @param parentContainer parent that the controller meshes should be children of
  41390. */
  41391. constructor(scene: Scene,
  41392. /** The underlying input source for the controller */
  41393. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41394. /**
  41395. * Updates the controller pose based on the given XRFrame
  41396. * @param xrFrame xr frame to update the pose with
  41397. * @param referenceSpace reference space to use
  41398. */
  41399. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41400. /**
  41401. * Gets a world space ray coming from the controller
  41402. * @param result the resulting ray
  41403. */
  41404. getWorldPointerRayToRef(result: Ray): void;
  41405. /**
  41406. * Get the scene associated with this controller
  41407. * @returns the scene object
  41408. */
  41409. getScene(): Scene;
  41410. /**
  41411. * Disposes of the object
  41412. */
  41413. dispose(): void;
  41414. }
  41415. }
  41416. declare module BABYLON {
  41417. /**
  41418. * XR input used to track XR inputs such as controllers/rays
  41419. */
  41420. export class WebXRInput implements IDisposable {
  41421. /**
  41422. * Base experience the input listens to
  41423. */
  41424. baseExperience: WebXRExperienceHelper;
  41425. /**
  41426. * XR controllers being tracked
  41427. */
  41428. controllers: Array<WebXRController>;
  41429. private _frameObserver;
  41430. private _stateObserver;
  41431. /**
  41432. * Event when a controller has been connected/added
  41433. */
  41434. onControllerAddedObservable: Observable<WebXRController>;
  41435. /**
  41436. * Event when a controller has been removed/disconnected
  41437. */
  41438. onControllerRemovedObservable: Observable<WebXRController>;
  41439. /**
  41440. * Initializes the WebXRInput
  41441. * @param baseExperience experience helper which the input should be created for
  41442. */
  41443. constructor(
  41444. /**
  41445. * Base experience the input listens to
  41446. */
  41447. baseExperience: WebXRExperienceHelper);
  41448. private _onInputSourcesChange;
  41449. private _addAndRemoveControllers;
  41450. /**
  41451. * Disposes of the object
  41452. */
  41453. dispose(): void;
  41454. }
  41455. }
  41456. declare module BABYLON {
  41457. /**
  41458. * Enables teleportation
  41459. */
  41460. export class WebXRControllerTeleportation {
  41461. private _teleportationFillColor;
  41462. private _teleportationBorderColor;
  41463. private _tmpRay;
  41464. private _tmpVector;
  41465. /**
  41466. * Creates a WebXRControllerTeleportation
  41467. * @param input input manager to add teleportation to
  41468. * @param floorMeshes floormeshes which can be teleported to
  41469. */
  41470. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41471. }
  41472. }
  41473. declare module BABYLON {
  41474. /**
  41475. * Handles pointer input automatically for the pointer of XR controllers
  41476. */
  41477. export class WebXRControllerPointerSelection {
  41478. private static _idCounter;
  41479. private _tmpRay;
  41480. /**
  41481. * Creates a WebXRControllerPointerSelection
  41482. * @param input input manager to setup pointer selection
  41483. */
  41484. constructor(input: WebXRInput);
  41485. private _convertNormalToDirectionOfRay;
  41486. private _updatePointerDistance;
  41487. }
  41488. }
  41489. declare module BABYLON {
  41490. /**
  41491. * Class used to represent data loading progression
  41492. */
  41493. export class SceneLoaderProgressEvent {
  41494. /** defines if data length to load can be evaluated */
  41495. readonly lengthComputable: boolean;
  41496. /** defines the loaded data length */
  41497. readonly loaded: number;
  41498. /** defines the data length to load */
  41499. readonly total: number;
  41500. /**
  41501. * Create a new progress event
  41502. * @param lengthComputable defines if data length to load can be evaluated
  41503. * @param loaded defines the loaded data length
  41504. * @param total defines the data length to load
  41505. */
  41506. constructor(
  41507. /** defines if data length to load can be evaluated */
  41508. lengthComputable: boolean,
  41509. /** defines the loaded data length */
  41510. loaded: number,
  41511. /** defines the data length to load */
  41512. total: number);
  41513. /**
  41514. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41515. * @param event defines the source event
  41516. * @returns a new SceneLoaderProgressEvent
  41517. */
  41518. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41519. }
  41520. /**
  41521. * Interface used by SceneLoader plugins to define supported file extensions
  41522. */
  41523. export interface ISceneLoaderPluginExtensions {
  41524. /**
  41525. * Defines the list of supported extensions
  41526. */
  41527. [extension: string]: {
  41528. isBinary: boolean;
  41529. };
  41530. }
  41531. /**
  41532. * Interface used by SceneLoader plugin factory
  41533. */
  41534. export interface ISceneLoaderPluginFactory {
  41535. /**
  41536. * Defines the name of the factory
  41537. */
  41538. name: string;
  41539. /**
  41540. * Function called to create a new plugin
  41541. * @return the new plugin
  41542. */
  41543. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41544. /**
  41545. * The callback that returns true if the data can be directly loaded.
  41546. * @param data string containing the file data
  41547. * @returns if the data can be loaded directly
  41548. */
  41549. canDirectLoad?(data: string): boolean;
  41550. }
  41551. /**
  41552. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  41553. */
  41554. export interface ISceneLoaderPluginBase {
  41555. /**
  41556. * The friendly name of this plugin.
  41557. */
  41558. name: string;
  41559. /**
  41560. * The file extensions supported by this plugin.
  41561. */
  41562. extensions: string | ISceneLoaderPluginExtensions;
  41563. /**
  41564. * The callback called when loading from a url.
  41565. * @param scene scene loading this url
  41566. * @param url url to load
  41567. * @param onSuccess callback called when the file successfully loads
  41568. * @param onProgress callback called while file is loading (if the server supports this mode)
  41569. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41570. * @param onError callback called when the file fails to load
  41571. * @returns a file request object
  41572. */
  41573. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  41574. /**
  41575. * The callback called when loading from a file object.
  41576. * @param scene scene loading this file
  41577. * @param file defines the file to load
  41578. * @param onSuccess defines the callback to call when data is loaded
  41579. * @param onProgress defines the callback to call during loading process
  41580. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41581. * @param onError defines the callback to call when an error occurs
  41582. * @returns a file request object
  41583. */
  41584. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  41585. /**
  41586. * The callback that returns true if the data can be directly loaded.
  41587. * @param data string containing the file data
  41588. * @returns if the data can be loaded directly
  41589. */
  41590. canDirectLoad?(data: string): boolean;
  41591. /**
  41592. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  41593. * @param scene scene loading this data
  41594. * @param data string containing the data
  41595. * @returns data to pass to the plugin
  41596. */
  41597. directLoad?(scene: Scene, data: string): any;
  41598. /**
  41599. * The callback that allows custom handling of the root url based on the response url.
  41600. * @param rootUrl the original root url
  41601. * @param responseURL the response url if available
  41602. * @returns the new root url
  41603. */
  41604. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  41605. }
  41606. /**
  41607. * Interface used to define a SceneLoader plugin
  41608. */
  41609. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  41610. /**
  41611. * Import meshes into a scene.
  41612. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41613. * @param scene The scene to import into
  41614. * @param data The data to import
  41615. * @param rootUrl The root url for scene and resources
  41616. * @param meshes The meshes array to import into
  41617. * @param particleSystems The particle systems array to import into
  41618. * @param skeletons The skeletons array to import into
  41619. * @param onError The callback when import fails
  41620. * @returns True if successful or false otherwise
  41621. */
  41622. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41623. /**
  41624. * Load into a scene.
  41625. * @param scene The scene to load into
  41626. * @param data The data to import
  41627. * @param rootUrl The root url for scene and resources
  41628. * @param onError The callback when import fails
  41629. * @returns True if successful or false otherwise
  41630. */
  41631. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41632. /**
  41633. * Load into an asset container.
  41634. * @param scene The scene to load into
  41635. * @param data The data to import
  41636. * @param rootUrl The root url for scene and resources
  41637. * @param onError The callback when import fails
  41638. * @returns The loaded asset container
  41639. */
  41640. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41641. }
  41642. /**
  41643. * Interface used to define an async SceneLoader plugin
  41644. */
  41645. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  41646. /**
  41647. * Import meshes into a scene.
  41648. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41649. * @param scene The scene to import into
  41650. * @param data The data to import
  41651. * @param rootUrl The root url for scene and resources
  41652. * @param onProgress The callback when the load progresses
  41653. * @param fileName Defines the name of the file to load
  41654. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41655. */
  41656. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41657. meshes: AbstractMesh[];
  41658. particleSystems: IParticleSystem[];
  41659. skeletons: Skeleton[];
  41660. animationGroups: AnimationGroup[];
  41661. }>;
  41662. /**
  41663. * Load into a scene.
  41664. * @param scene The scene to load into
  41665. * @param data The data to import
  41666. * @param rootUrl The root url for scene and resources
  41667. * @param onProgress The callback when the load progresses
  41668. * @param fileName Defines the name of the file to load
  41669. * @returns Nothing
  41670. */
  41671. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41672. /**
  41673. * Load into an asset container.
  41674. * @param scene The scene to load into
  41675. * @param data The data to import
  41676. * @param rootUrl The root url for scene and resources
  41677. * @param onProgress The callback when the load progresses
  41678. * @param fileName Defines the name of the file to load
  41679. * @returns The loaded asset container
  41680. */
  41681. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41682. }
  41683. /**
  41684. * Class used to load scene from various file formats using registered plugins
  41685. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41686. */
  41687. export class SceneLoader {
  41688. /**
  41689. * No logging while loading
  41690. */
  41691. static readonly NO_LOGGING: number;
  41692. /**
  41693. * Minimal logging while loading
  41694. */
  41695. static readonly MINIMAL_LOGGING: number;
  41696. /**
  41697. * Summary logging while loading
  41698. */
  41699. static readonly SUMMARY_LOGGING: number;
  41700. /**
  41701. * Detailled logging while loading
  41702. */
  41703. static readonly DETAILED_LOGGING: number;
  41704. /**
  41705. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41706. */
  41707. static ForceFullSceneLoadingForIncremental: boolean;
  41708. /**
  41709. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41710. */
  41711. static ShowLoadingScreen: boolean;
  41712. /**
  41713. * Defines the current logging level (while loading the scene)
  41714. * @ignorenaming
  41715. */
  41716. static loggingLevel: number;
  41717. /**
  41718. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41719. */
  41720. static CleanBoneMatrixWeights: boolean;
  41721. /**
  41722. * Event raised when a plugin is used to load a scene
  41723. */
  41724. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41725. private static _registeredPlugins;
  41726. private static _getDefaultPlugin;
  41727. private static _getPluginForExtension;
  41728. private static _getPluginForDirectLoad;
  41729. private static _getPluginForFilename;
  41730. private static _getDirectLoad;
  41731. private static _loadData;
  41732. private static _getFileInfo;
  41733. /**
  41734. * Gets a plugin that can load the given extension
  41735. * @param extension defines the extension to load
  41736. * @returns a plugin or null if none works
  41737. */
  41738. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41739. /**
  41740. * Gets a boolean indicating that the given extension can be loaded
  41741. * @param extension defines the extension to load
  41742. * @returns true if the extension is supported
  41743. */
  41744. static IsPluginForExtensionAvailable(extension: string): boolean;
  41745. /**
  41746. * Adds a new plugin to the list of registered plugins
  41747. * @param plugin defines the plugin to add
  41748. */
  41749. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41750. /**
  41751. * Import meshes into a scene
  41752. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41753. * @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)
  41754. * @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)
  41755. * @param scene the instance of BABYLON.Scene to append to
  41756. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41757. * @param onProgress a callback with a progress event for each file being loaded
  41758. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41759. * @param pluginExtension the extension used to determine the plugin
  41760. * @returns The loaded plugin
  41761. */
  41762. 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>;
  41763. /**
  41764. * Import meshes into a scene
  41765. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41766. * @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)
  41767. * @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)
  41768. * @param scene the instance of BABYLON.Scene to append to
  41769. * @param onProgress a callback with a progress event for each file being loaded
  41770. * @param pluginExtension the extension used to determine the plugin
  41771. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41772. */
  41773. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41774. meshes: AbstractMesh[];
  41775. particleSystems: IParticleSystem[];
  41776. skeletons: Skeleton[];
  41777. animationGroups: AnimationGroup[];
  41778. }>;
  41779. /**
  41780. * Load a scene
  41781. * @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)
  41782. * @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)
  41783. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41784. * @param onSuccess a callback with the scene when import succeeds
  41785. * @param onProgress a callback with a progress event for each file being loaded
  41786. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41787. * @param pluginExtension the extension used to determine the plugin
  41788. * @returns The loaded plugin
  41789. */
  41790. 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>;
  41791. /**
  41792. * Load a scene
  41793. * @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)
  41794. * @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)
  41795. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41796. * @param onProgress a callback with a progress event for each file being loaded
  41797. * @param pluginExtension the extension used to determine the plugin
  41798. * @returns The loaded scene
  41799. */
  41800. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41801. /**
  41802. * Append a scene
  41803. * @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)
  41804. * @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)
  41805. * @param scene is the instance of BABYLON.Scene to append to
  41806. * @param onSuccess a callback with the scene when import succeeds
  41807. * @param onProgress a callback with a progress event for each file being loaded
  41808. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41809. * @param pluginExtension the extension used to determine the plugin
  41810. * @returns The loaded plugin
  41811. */
  41812. 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>;
  41813. /**
  41814. * Append a scene
  41815. * @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)
  41816. * @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)
  41817. * @param scene is the instance of BABYLON.Scene to append to
  41818. * @param onProgress a callback with a progress event for each file being loaded
  41819. * @param pluginExtension the extension used to determine the plugin
  41820. * @returns The given scene
  41821. */
  41822. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41823. /**
  41824. * Load a scene into an asset container
  41825. * @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)
  41826. * @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)
  41827. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41828. * @param onSuccess a callback with the scene when import succeeds
  41829. * @param onProgress a callback with a progress event for each file being loaded
  41830. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41831. * @param pluginExtension the extension used to determine the plugin
  41832. * @returns The loaded plugin
  41833. */
  41834. 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>;
  41835. /**
  41836. * Load a scene into an asset container
  41837. * @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)
  41838. * @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)
  41839. * @param scene is the instance of Scene to append to
  41840. * @param onProgress a callback with a progress event for each file being loaded
  41841. * @param pluginExtension the extension used to determine the plugin
  41842. * @returns The loaded asset container
  41843. */
  41844. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41845. }
  41846. }
  41847. declare module BABYLON {
  41848. /**
  41849. * Generic Controller
  41850. */
  41851. export class GenericController extends WebVRController {
  41852. /**
  41853. * Base Url for the controller model.
  41854. */
  41855. static readonly MODEL_BASE_URL: string;
  41856. /**
  41857. * File name for the controller model.
  41858. */
  41859. static readonly MODEL_FILENAME: string;
  41860. /**
  41861. * Creates a new GenericController from a gamepad
  41862. * @param vrGamepad the gamepad that the controller should be created from
  41863. */
  41864. constructor(vrGamepad: any);
  41865. /**
  41866. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41867. * @param scene scene in which to add meshes
  41868. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41869. */
  41870. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41871. /**
  41872. * Called once for each button that changed state since the last frame
  41873. * @param buttonIdx Which button index changed
  41874. * @param state New state of the button
  41875. * @param changes Which properties on the state changed since last frame
  41876. */
  41877. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41878. }
  41879. }
  41880. declare module BABYLON {
  41881. /**
  41882. * Defines the WindowsMotionController object that the state of the windows motion controller
  41883. */
  41884. export class WindowsMotionController extends WebVRController {
  41885. /**
  41886. * The base url used to load the left and right controller models
  41887. */
  41888. static MODEL_BASE_URL: string;
  41889. /**
  41890. * The name of the left controller model file
  41891. */
  41892. static MODEL_LEFT_FILENAME: string;
  41893. /**
  41894. * The name of the right controller model file
  41895. */
  41896. static MODEL_RIGHT_FILENAME: string;
  41897. /**
  41898. * The controller name prefix for this controller type
  41899. */
  41900. static readonly GAMEPAD_ID_PREFIX: string;
  41901. /**
  41902. * The controller id pattern for this controller type
  41903. */
  41904. private static readonly GAMEPAD_ID_PATTERN;
  41905. private _loadedMeshInfo;
  41906. private readonly _mapping;
  41907. /**
  41908. * Fired when the trackpad on this controller is clicked
  41909. */
  41910. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41911. /**
  41912. * Fired when the trackpad on this controller is modified
  41913. */
  41914. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41915. /**
  41916. * The current x and y values of this controller's trackpad
  41917. */
  41918. trackpad: StickValues;
  41919. /**
  41920. * Creates a new WindowsMotionController from a gamepad
  41921. * @param vrGamepad the gamepad that the controller should be created from
  41922. */
  41923. constructor(vrGamepad: any);
  41924. /**
  41925. * Fired when the trigger on this controller is modified
  41926. */
  41927. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41928. /**
  41929. * Fired when the menu button on this controller is modified
  41930. */
  41931. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41932. /**
  41933. * Fired when the grip button on this controller is modified
  41934. */
  41935. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41936. /**
  41937. * Fired when the thumbstick button on this controller is modified
  41938. */
  41939. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41940. /**
  41941. * Fired when the touchpad button on this controller is modified
  41942. */
  41943. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41944. /**
  41945. * Fired when the touchpad values on this controller are modified
  41946. */
  41947. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41948. private _updateTrackpad;
  41949. /**
  41950. * Called once per frame by the engine.
  41951. */
  41952. update(): void;
  41953. /**
  41954. * Called once for each button that changed state since the last frame
  41955. * @param buttonIdx Which button index changed
  41956. * @param state New state of the button
  41957. * @param changes Which properties on the state changed since last frame
  41958. */
  41959. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41960. /**
  41961. * Moves the buttons on the controller mesh based on their current state
  41962. * @param buttonName the name of the button to move
  41963. * @param buttonValue the value of the button which determines the buttons new position
  41964. */
  41965. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41966. /**
  41967. * Moves the axis on the controller mesh based on its current state
  41968. * @param axis the index of the axis
  41969. * @param axisValue the value of the axis which determines the meshes new position
  41970. * @hidden
  41971. */
  41972. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41973. /**
  41974. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41975. * @param scene scene in which to add meshes
  41976. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41977. */
  41978. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41979. /**
  41980. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41981. * can be transformed by button presses and axes values, based on this._mapping.
  41982. *
  41983. * @param scene scene in which the meshes exist
  41984. * @param meshes list of meshes that make up the controller model to process
  41985. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41986. */
  41987. private processModel;
  41988. private createMeshInfo;
  41989. /**
  41990. * Gets the ray of the controller in the direction the controller is pointing
  41991. * @param length the length the resulting ray should be
  41992. * @returns a ray in the direction the controller is pointing
  41993. */
  41994. getForwardRay(length?: number): Ray;
  41995. /**
  41996. * Disposes of the controller
  41997. */
  41998. dispose(): void;
  41999. }
  42000. }
  42001. declare module BABYLON {
  42002. /**
  42003. * Oculus Touch Controller
  42004. */
  42005. export class OculusTouchController extends WebVRController {
  42006. /**
  42007. * Base Url for the controller model.
  42008. */
  42009. static MODEL_BASE_URL: string;
  42010. /**
  42011. * File name for the left controller model.
  42012. */
  42013. static MODEL_LEFT_FILENAME: string;
  42014. /**
  42015. * File name for the right controller model.
  42016. */
  42017. static MODEL_RIGHT_FILENAME: string;
  42018. /**
  42019. * Base Url for the Quest controller model.
  42020. */
  42021. static QUEST_MODEL_BASE_URL: string;
  42022. /**
  42023. * @hidden
  42024. * If the controllers are running on a device that needs the updated Quest controller models
  42025. */ private static _IsQuest: boolean;
  42026. /**
  42027. * Fired when the secondary trigger on this controller is modified
  42028. */
  42029. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42030. /**
  42031. * Fired when the thumb rest on this controller is modified
  42032. */
  42033. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42034. /**
  42035. * Creates a new OculusTouchController from a gamepad
  42036. * @param vrGamepad the gamepad that the controller should be created from
  42037. */
  42038. constructor(vrGamepad: any);
  42039. /**
  42040. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42041. * @param scene scene in which to add meshes
  42042. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42043. */
  42044. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42045. /**
  42046. * Fired when the A button on this controller is modified
  42047. */
  42048. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42049. /**
  42050. * Fired when the B button on this controller is modified
  42051. */
  42052. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42053. /**
  42054. * Fired when the X button on this controller is modified
  42055. */
  42056. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42057. /**
  42058. * Fired when the Y button on this controller is modified
  42059. */
  42060. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42061. /**
  42062. * Called once for each button that changed state since the last frame
  42063. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42064. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42065. * 2) secondary trigger (same)
  42066. * 3) A (right) X (left), touch, pressed = value
  42067. * 4) B / Y
  42068. * 5) thumb rest
  42069. * @param buttonIdx Which button index changed
  42070. * @param state New state of the button
  42071. * @param changes Which properties on the state changed since last frame
  42072. */
  42073. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42074. }
  42075. }
  42076. declare module BABYLON {
  42077. /**
  42078. * Vive Controller
  42079. */
  42080. export class ViveController extends WebVRController {
  42081. /**
  42082. * Base Url for the controller model.
  42083. */
  42084. static MODEL_BASE_URL: string;
  42085. /**
  42086. * File name for the controller model.
  42087. */
  42088. static MODEL_FILENAME: string;
  42089. /**
  42090. * Creates a new ViveController from a gamepad
  42091. * @param vrGamepad the gamepad that the controller should be created from
  42092. */
  42093. constructor(vrGamepad: any);
  42094. /**
  42095. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42096. * @param scene scene in which to add meshes
  42097. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42098. */
  42099. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42100. /**
  42101. * Fired when the left button on this controller is modified
  42102. */
  42103. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42104. /**
  42105. * Fired when the right button on this controller is modified
  42106. */
  42107. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42108. /**
  42109. * Fired when the menu button on this controller is modified
  42110. */
  42111. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42112. /**
  42113. * Called once for each button that changed state since the last frame
  42114. * Vive mapping:
  42115. * 0: touchpad
  42116. * 1: trigger
  42117. * 2: left AND right buttons
  42118. * 3: menu button
  42119. * @param buttonIdx Which button index changed
  42120. * @param state New state of the button
  42121. * @param changes Which properties on the state changed since last frame
  42122. */
  42123. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42124. }
  42125. }
  42126. declare module BABYLON {
  42127. /**
  42128. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42129. */
  42130. export class WebXRControllerModelLoader {
  42131. /**
  42132. * Creates the WebXRControllerModelLoader
  42133. * @param input xr input that creates the controllers
  42134. */
  42135. constructor(input: WebXRInput);
  42136. }
  42137. }
  42138. declare module BABYLON {
  42139. /**
  42140. * Contains an array of blocks representing the octree
  42141. */
  42142. export interface IOctreeContainer<T> {
  42143. /**
  42144. * Blocks within the octree
  42145. */
  42146. blocks: Array<OctreeBlock<T>>;
  42147. }
  42148. /**
  42149. * Class used to store a cell in an octree
  42150. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42151. */
  42152. export class OctreeBlock<T> {
  42153. /**
  42154. * Gets the content of the current block
  42155. */
  42156. entries: T[];
  42157. /**
  42158. * Gets the list of block children
  42159. */
  42160. blocks: Array<OctreeBlock<T>>;
  42161. private _depth;
  42162. private _maxDepth;
  42163. private _capacity;
  42164. private _minPoint;
  42165. private _maxPoint;
  42166. private _boundingVectors;
  42167. private _creationFunc;
  42168. /**
  42169. * Creates a new block
  42170. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42171. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42172. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42173. * @param depth defines the current depth of this block in the octree
  42174. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42175. * @param creationFunc defines a callback to call when an element is added to the block
  42176. */
  42177. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42178. /**
  42179. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42180. */
  42181. readonly capacity: number;
  42182. /**
  42183. * Gets the minimum vector (in world space) of the block's bounding box
  42184. */
  42185. readonly minPoint: Vector3;
  42186. /**
  42187. * Gets the maximum vector (in world space) of the block's bounding box
  42188. */
  42189. readonly maxPoint: Vector3;
  42190. /**
  42191. * Add a new element to this block
  42192. * @param entry defines the element to add
  42193. */
  42194. addEntry(entry: T): void;
  42195. /**
  42196. * Remove an element from this block
  42197. * @param entry defines the element to remove
  42198. */
  42199. removeEntry(entry: T): void;
  42200. /**
  42201. * Add an array of elements to this block
  42202. * @param entries defines the array of elements to add
  42203. */
  42204. addEntries(entries: T[]): void;
  42205. /**
  42206. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42207. * @param frustumPlanes defines the frustum planes to test
  42208. * @param selection defines the array to store current content if selection is positive
  42209. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42210. */
  42211. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42212. /**
  42213. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42214. * @param sphereCenter defines the bounding sphere center
  42215. * @param sphereRadius defines the bounding sphere radius
  42216. * @param selection defines the array to store current content if selection is positive
  42217. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42218. */
  42219. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42220. /**
  42221. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42222. * @param ray defines the ray to test with
  42223. * @param selection defines the array to store current content if selection is positive
  42224. */
  42225. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42226. /**
  42227. * Subdivide the content into child blocks (this block will then be empty)
  42228. */
  42229. createInnerBlocks(): void;
  42230. /**
  42231. * @hidden
  42232. */ 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;
  42233. }
  42234. }
  42235. declare module BABYLON {
  42236. /**
  42237. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42238. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42239. */
  42240. export class Octree<T> {
  42241. /** 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.) */
  42242. maxDepth: number;
  42243. /**
  42244. * Blocks within the octree containing objects
  42245. */
  42246. blocks: Array<OctreeBlock<T>>;
  42247. /**
  42248. * Content stored in the octree
  42249. */
  42250. dynamicContent: T[];
  42251. private _maxBlockCapacity;
  42252. private _selectionContent;
  42253. private _creationFunc;
  42254. /**
  42255. * Creates a octree
  42256. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42257. * @param creationFunc function to be used to instatiate the octree
  42258. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42259. * @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.)
  42260. */
  42261. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42262. /** 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.) */
  42263. maxDepth?: number);
  42264. /**
  42265. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42266. * @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);
  42267. * @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);
  42268. * @param entries meshes to be added to the octree blocks
  42269. */
  42270. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42271. /**
  42272. * Adds a mesh to the octree
  42273. * @param entry Mesh to add to the octree
  42274. */
  42275. addMesh(entry: T): void;
  42276. /**
  42277. * Remove an element from the octree
  42278. * @param entry defines the element to remove
  42279. */
  42280. removeMesh(entry: T): void;
  42281. /**
  42282. * Selects an array of meshes within the frustum
  42283. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42284. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42285. * @returns array of meshes within the frustum
  42286. */
  42287. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42288. /**
  42289. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42290. * @param sphereCenter defines the bounding sphere center
  42291. * @param sphereRadius defines the bounding sphere radius
  42292. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42293. * @returns an array of objects that intersect the sphere
  42294. */
  42295. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42296. /**
  42297. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42298. * @param ray defines the ray to test with
  42299. * @returns array of intersected objects
  42300. */
  42301. intersectsRay(ray: Ray): SmartArray<T>;
  42302. /**
  42303. * Adds a mesh into the octree block if it intersects the block
  42304. */
  42305. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42306. /**
  42307. * Adds a submesh into the octree block if it intersects the block
  42308. */
  42309. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42310. }
  42311. }
  42312. declare module BABYLON {
  42313. interface Scene {
  42314. /**
  42315. * @hidden
  42316. * Backing Filed
  42317. */ private _selectionOctree: Octree<AbstractMesh>;
  42318. /**
  42319. * Gets the octree used to boost mesh selection (picking)
  42320. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42321. */
  42322. selectionOctree: Octree<AbstractMesh>;
  42323. /**
  42324. * Creates or updates the octree used to boost selection (picking)
  42325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42326. * @param maxCapacity defines the maximum capacity per leaf
  42327. * @param maxDepth defines the maximum depth of the octree
  42328. * @returns an octree of AbstractMesh
  42329. */
  42330. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42331. }
  42332. interface AbstractMesh {
  42333. /**
  42334. * @hidden
  42335. * Backing Field
  42336. */ private _submeshesOctree: Octree<SubMesh>;
  42337. /**
  42338. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42339. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42340. * @param maxCapacity defines the maximum size of each block (64 by default)
  42341. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42342. * @returns the new octree
  42343. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42345. */
  42346. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42347. }
  42348. /**
  42349. * Defines the octree scene component responsible to manage any octrees
  42350. * in a given scene.
  42351. */
  42352. export class OctreeSceneComponent {
  42353. /**
  42354. * The component name help to identify the component in the list of scene components.
  42355. */
  42356. readonly name: string;
  42357. /**
  42358. * The scene the component belongs to.
  42359. */
  42360. scene: Scene;
  42361. /**
  42362. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42363. */
  42364. readonly checksIsEnabled: boolean;
  42365. /**
  42366. * Creates a new instance of the component for the given scene
  42367. * @param scene Defines the scene to register the component in
  42368. */
  42369. constructor(scene: Scene);
  42370. /**
  42371. * Registers the component in a given scene
  42372. */
  42373. register(): void;
  42374. /**
  42375. * Return the list of active meshes
  42376. * @returns the list of active meshes
  42377. */
  42378. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42379. /**
  42380. * Return the list of active sub meshes
  42381. * @param mesh The mesh to get the candidates sub meshes from
  42382. * @returns the list of active sub meshes
  42383. */
  42384. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42385. private _tempRay;
  42386. /**
  42387. * Return the list of sub meshes intersecting with a given local ray
  42388. * @param mesh defines the mesh to find the submesh for
  42389. * @param localRay defines the ray in local space
  42390. * @returns the list of intersecting sub meshes
  42391. */
  42392. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42393. /**
  42394. * Return the list of sub meshes colliding with a collider
  42395. * @param mesh defines the mesh to find the submesh for
  42396. * @param collider defines the collider to evaluate the collision against
  42397. * @returns the list of colliding sub meshes
  42398. */
  42399. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42400. /**
  42401. * Rebuilds the elements related to this component in case of
  42402. * context lost for instance.
  42403. */
  42404. rebuild(): void;
  42405. /**
  42406. * Disposes the component and the associated ressources.
  42407. */
  42408. dispose(): void;
  42409. }
  42410. }
  42411. declare module BABYLON {
  42412. /**
  42413. * Renders a layer on top of an existing scene
  42414. */
  42415. export class UtilityLayerRenderer implements IDisposable {
  42416. /** the original scene that will be rendered on top of */
  42417. originalScene: Scene;
  42418. private _pointerCaptures;
  42419. private _lastPointerEvents;
  42420. private static _DefaultUtilityLayer;
  42421. private static _DefaultKeepDepthUtilityLayer;
  42422. private _sharedGizmoLight;
  42423. private _renderCamera;
  42424. /**
  42425. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42426. * @returns the camera that is used when rendering the utility layer
  42427. */
  42428. getRenderCamera(): Nullable<Camera>;
  42429. /**
  42430. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42431. * @param cam the camera that should be used when rendering the utility layer
  42432. */
  42433. setRenderCamera(cam: Nullable<Camera>): void;
  42434. /**
  42435. * @hidden
  42436. * Light which used by gizmos to get light shading
  42437. */ private _getSharedGizmoLight(): HemisphericLight;
  42438. /**
  42439. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42440. */
  42441. pickUtilitySceneFirst: boolean;
  42442. /**
  42443. * 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)
  42444. */
  42445. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42446. /**
  42447. * 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)
  42448. */
  42449. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42450. /**
  42451. * The scene that is rendered on top of the original scene
  42452. */
  42453. utilityLayerScene: Scene;
  42454. /**
  42455. * If the utility layer should automatically be rendered on top of existing scene
  42456. */
  42457. shouldRender: boolean;
  42458. /**
  42459. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42460. */
  42461. onlyCheckPointerDownEvents: boolean;
  42462. /**
  42463. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42464. */
  42465. processAllEvents: boolean;
  42466. /**
  42467. * Observable raised when the pointer move from the utility layer scene to the main scene
  42468. */
  42469. onPointerOutObservable: Observable<number>;
  42470. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42471. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42472. private _afterRenderObserver;
  42473. private _sceneDisposeObserver;
  42474. private _originalPointerObserver;
  42475. /**
  42476. * Instantiates a UtilityLayerRenderer
  42477. * @param originalScene the original scene that will be rendered on top of
  42478. * @param handleEvents boolean indicating if the utility layer should handle events
  42479. */
  42480. constructor(
  42481. /** the original scene that will be rendered on top of */
  42482. originalScene: Scene, handleEvents?: boolean);
  42483. private _notifyObservers;
  42484. /**
  42485. * Renders the utility layers scene on top of the original scene
  42486. */
  42487. render(): void;
  42488. /**
  42489. * Disposes of the renderer
  42490. */
  42491. dispose(): void;
  42492. private _updateCamera;
  42493. }
  42494. }
  42495. declare module BABYLON {
  42496. /**
  42497. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42498. */
  42499. export class Gizmo implements IDisposable {
  42500. /** The utility layer the gizmo will be added to */
  42501. gizmoLayer: UtilityLayerRenderer;
  42502. /**
  42503. * The root mesh of the gizmo
  42504. */ private _rootMesh: Mesh;
  42505. private _attachedMesh;
  42506. /**
  42507. * Ratio for the scale of the gizmo (Default: 1)
  42508. */
  42509. scaleRatio: number;
  42510. /**
  42511. * If a custom mesh has been set (Default: false)
  42512. */
  42513. protected _customMeshSet: boolean;
  42514. /**
  42515. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42516. * * When set, interactions will be enabled
  42517. */
  42518. attachedMesh: Nullable<AbstractMesh>;
  42519. /**
  42520. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42521. * @param mesh The mesh to replace the default mesh of the gizmo
  42522. */
  42523. setCustomMesh(mesh: Mesh): void;
  42524. /**
  42525. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42526. */
  42527. updateGizmoRotationToMatchAttachedMesh: boolean;
  42528. /**
  42529. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42530. */
  42531. updateGizmoPositionToMatchAttachedMesh: boolean;
  42532. /**
  42533. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42534. */
  42535. updateScale: boolean;
  42536. protected _interactionsEnabled: boolean;
  42537. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42538. private _beforeRenderObserver;
  42539. private _tempVector;
  42540. /**
  42541. * Creates a gizmo
  42542. * @param gizmoLayer The utility layer the gizmo will be added to
  42543. */
  42544. constructor(
  42545. /** The utility layer the gizmo will be added to */
  42546. gizmoLayer?: UtilityLayerRenderer);
  42547. /**
  42548. * Updates the gizmo to match the attached mesh's position/rotation
  42549. */
  42550. protected _update(): void;
  42551. /**
  42552. * Disposes of the gizmo
  42553. */
  42554. dispose(): void;
  42555. }
  42556. }
  42557. declare module BABYLON {
  42558. /**
  42559. * Single plane drag gizmo
  42560. */
  42561. export class PlaneDragGizmo extends Gizmo {
  42562. /**
  42563. * Drag behavior responsible for the gizmos dragging interactions
  42564. */
  42565. dragBehavior: PointerDragBehavior;
  42566. private _pointerObserver;
  42567. /**
  42568. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42569. */
  42570. snapDistance: number;
  42571. /**
  42572. * Event that fires each time the gizmo snaps to a new location.
  42573. * * snapDistance is the the change in distance
  42574. */
  42575. onSnapObservable: Observable<{
  42576. snapDistance: number;
  42577. }>;
  42578. private _plane;
  42579. private _coloredMaterial;
  42580. private _hoverMaterial;
  42581. private _isEnabled;
  42582. private _parent;
  42583. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42584. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42585. /**
  42586. * Creates a PlaneDragGizmo
  42587. * @param gizmoLayer The utility layer the gizmo will be added to
  42588. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42589. * @param color The color of the gizmo
  42590. */
  42591. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42592. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42593. /**
  42594. * If the gizmo is enabled
  42595. */
  42596. isEnabled: boolean;
  42597. /**
  42598. * Disposes of the gizmo
  42599. */
  42600. dispose(): void;
  42601. }
  42602. }
  42603. declare module BABYLON {
  42604. /**
  42605. * Gizmo that enables dragging a mesh along 3 axis
  42606. */
  42607. export class PositionGizmo extends Gizmo {
  42608. /**
  42609. * Internal gizmo used for interactions on the x axis
  42610. */
  42611. xGizmo: AxisDragGizmo;
  42612. /**
  42613. * Internal gizmo used for interactions on the y axis
  42614. */
  42615. yGizmo: AxisDragGizmo;
  42616. /**
  42617. * Internal gizmo used for interactions on the z axis
  42618. */
  42619. zGizmo: AxisDragGizmo;
  42620. /**
  42621. * Internal gizmo used for interactions on the yz plane
  42622. */
  42623. xPlaneGizmo: PlaneDragGizmo;
  42624. /**
  42625. * Internal gizmo used for interactions on the xz plane
  42626. */
  42627. yPlaneGizmo: PlaneDragGizmo;
  42628. /**
  42629. * Internal gizmo used for interactions on the xy plane
  42630. */
  42631. zPlaneGizmo: PlaneDragGizmo;
  42632. /**
  42633. * private variables
  42634. */
  42635. private _meshAttached;
  42636. private _updateGizmoRotationToMatchAttachedMesh;
  42637. private _snapDistance;
  42638. private _scaleRatio;
  42639. /** Fires an event when any of it's sub gizmos are dragged */
  42640. onDragStartObservable: Observable<unknown>;
  42641. /** Fires an event when any of it's sub gizmos are released from dragging */
  42642. onDragEndObservable: Observable<unknown>;
  42643. /**
  42644. * If set to true, planar drag is enabled
  42645. */
  42646. private _planarGizmoEnabled;
  42647. attachedMesh: Nullable<AbstractMesh>;
  42648. /**
  42649. * Creates a PositionGizmo
  42650. * @param gizmoLayer The utility layer the gizmo will be added to
  42651. */
  42652. constructor(gizmoLayer?: UtilityLayerRenderer);
  42653. /**
  42654. * If the planar drag gizmo is enabled
  42655. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42656. */
  42657. planarGizmoEnabled: boolean;
  42658. updateGizmoRotationToMatchAttachedMesh: boolean;
  42659. /**
  42660. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42661. */
  42662. snapDistance: number;
  42663. /**
  42664. * Ratio for the scale of the gizmo (Default: 1)
  42665. */
  42666. scaleRatio: number;
  42667. /**
  42668. * Disposes of the gizmo
  42669. */
  42670. dispose(): void;
  42671. /**
  42672. * CustomMeshes are not supported by this gizmo
  42673. * @param mesh The mesh to replace the default mesh of the gizmo
  42674. */
  42675. setCustomMesh(mesh: Mesh): void;
  42676. }
  42677. }
  42678. declare module BABYLON {
  42679. /**
  42680. * Single axis drag gizmo
  42681. */
  42682. export class AxisDragGizmo extends Gizmo {
  42683. /**
  42684. * Drag behavior responsible for the gizmos dragging interactions
  42685. */
  42686. dragBehavior: PointerDragBehavior;
  42687. private _pointerObserver;
  42688. /**
  42689. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42690. */
  42691. snapDistance: number;
  42692. /**
  42693. * Event that fires each time the gizmo snaps to a new location.
  42694. * * snapDistance is the the change in distance
  42695. */
  42696. onSnapObservable: Observable<{
  42697. snapDistance: number;
  42698. }>;
  42699. private _isEnabled;
  42700. private _parent;
  42701. private _arrow;
  42702. private _coloredMaterial;
  42703. private _hoverMaterial;
  42704. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42705. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42706. /**
  42707. * Creates an AxisDragGizmo
  42708. * @param gizmoLayer The utility layer the gizmo will be added to
  42709. * @param dragAxis The axis which the gizmo will be able to drag on
  42710. * @param color The color of the gizmo
  42711. */
  42712. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42713. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42714. /**
  42715. * If the gizmo is enabled
  42716. */
  42717. isEnabled: boolean;
  42718. /**
  42719. * Disposes of the gizmo
  42720. */
  42721. dispose(): void;
  42722. }
  42723. }
  42724. declare module BABYLON.Debug {
  42725. /**
  42726. * The Axes viewer will show 3 axes in a specific point in space
  42727. */
  42728. export class AxesViewer {
  42729. private _xAxis;
  42730. private _yAxis;
  42731. private _zAxis;
  42732. private _scaleLinesFactor;
  42733. private _instanced;
  42734. /**
  42735. * Gets the hosting scene
  42736. */
  42737. scene: Scene;
  42738. /**
  42739. * Gets or sets a number used to scale line length
  42740. */
  42741. scaleLines: number;
  42742. /** Gets the node hierarchy used to render x-axis */
  42743. readonly xAxis: TransformNode;
  42744. /** Gets the node hierarchy used to render y-axis */
  42745. readonly yAxis: TransformNode;
  42746. /** Gets the node hierarchy used to render z-axis */
  42747. readonly zAxis: TransformNode;
  42748. /**
  42749. * Creates a new AxesViewer
  42750. * @param scene defines the hosting scene
  42751. * @param scaleLines defines a number used to scale line length (1 by default)
  42752. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42753. * @param xAxis defines the node hierarchy used to render the x-axis
  42754. * @param yAxis defines the node hierarchy used to render the y-axis
  42755. * @param zAxis defines the node hierarchy used to render the z-axis
  42756. */
  42757. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42758. /**
  42759. * Force the viewer to update
  42760. * @param position defines the position of the viewer
  42761. * @param xaxis defines the x axis of the viewer
  42762. * @param yaxis defines the y axis of the viewer
  42763. * @param zaxis defines the z axis of the viewer
  42764. */
  42765. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42766. /**
  42767. * Creates an instance of this axes viewer.
  42768. * @returns a new axes viewer with instanced meshes
  42769. */
  42770. createInstance(): AxesViewer;
  42771. /** Releases resources */
  42772. dispose(): void;
  42773. private static _SetRenderingGroupId;
  42774. }
  42775. }
  42776. declare module BABYLON.Debug {
  42777. /**
  42778. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42779. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42780. */
  42781. export class BoneAxesViewer extends AxesViewer {
  42782. /**
  42783. * Gets or sets the target mesh where to display the axes viewer
  42784. */
  42785. mesh: Nullable<Mesh>;
  42786. /**
  42787. * Gets or sets the target bone where to display the axes viewer
  42788. */
  42789. bone: Nullable<Bone>;
  42790. /** Gets current position */
  42791. pos: Vector3;
  42792. /** Gets direction of X axis */
  42793. xaxis: Vector3;
  42794. /** Gets direction of Y axis */
  42795. yaxis: Vector3;
  42796. /** Gets direction of Z axis */
  42797. zaxis: Vector3;
  42798. /**
  42799. * Creates a new BoneAxesViewer
  42800. * @param scene defines the hosting scene
  42801. * @param bone defines the target bone
  42802. * @param mesh defines the target mesh
  42803. * @param scaleLines defines a scaling factor for line length (1 by default)
  42804. */
  42805. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42806. /**
  42807. * Force the viewer to update
  42808. */
  42809. update(): void;
  42810. /** Releases resources */
  42811. dispose(): void;
  42812. }
  42813. }
  42814. declare module BABYLON {
  42815. /**
  42816. * Interface used to define scene explorer extensibility option
  42817. */
  42818. export interface IExplorerExtensibilityOption {
  42819. /**
  42820. * Define the option label
  42821. */
  42822. label: string;
  42823. /**
  42824. * Defines the action to execute on click
  42825. */
  42826. action: (entity: any) => void;
  42827. }
  42828. /**
  42829. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42830. */
  42831. export interface IExplorerExtensibilityGroup {
  42832. /**
  42833. * Defines a predicate to test if a given type mut be extended
  42834. */
  42835. predicate: (entity: any) => boolean;
  42836. /**
  42837. * Gets the list of options added to a type
  42838. */
  42839. entries: IExplorerExtensibilityOption[];
  42840. }
  42841. /**
  42842. * Interface used to define the options to use to create the Inspector
  42843. */
  42844. export interface IInspectorOptions {
  42845. /**
  42846. * Display in overlay mode (default: false)
  42847. */
  42848. overlay?: boolean;
  42849. /**
  42850. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42851. */
  42852. globalRoot?: HTMLElement;
  42853. /**
  42854. * Display the Scene explorer
  42855. */
  42856. showExplorer?: boolean;
  42857. /**
  42858. * Display the property inspector
  42859. */
  42860. showInspector?: boolean;
  42861. /**
  42862. * Display in embed mode (both panes on the right)
  42863. */
  42864. embedMode?: boolean;
  42865. /**
  42866. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42867. */
  42868. handleResize?: boolean;
  42869. /**
  42870. * Allow the panes to popup (default: true)
  42871. */
  42872. enablePopup?: boolean;
  42873. /**
  42874. * Allow the panes to be closed by users (default: true)
  42875. */
  42876. enableClose?: boolean;
  42877. /**
  42878. * Optional list of extensibility entries
  42879. */
  42880. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42881. /**
  42882. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42883. */
  42884. inspectorURL?: string;
  42885. }
  42886. interface Scene {
  42887. /**
  42888. * @hidden
  42889. * Backing field
  42890. */ private _debugLayer: DebugLayer;
  42891. /**
  42892. * Gets the debug layer (aka Inspector) associated with the scene
  42893. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42894. */
  42895. debugLayer: DebugLayer;
  42896. }
  42897. /**
  42898. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42899. * what is happening in your scene
  42900. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42901. */
  42902. export class DebugLayer {
  42903. /**
  42904. * Define the url to get the inspector script from.
  42905. * By default it uses the babylonjs CDN.
  42906. * @ignoreNaming
  42907. */
  42908. static InspectorURL: string;
  42909. private _scene;
  42910. private BJSINSPECTOR;
  42911. private _onPropertyChangedObservable?;
  42912. /**
  42913. * Observable triggered when a property is changed through the inspector.
  42914. */
  42915. readonly onPropertyChangedObservable: any;
  42916. /**
  42917. * Instantiates a new debug layer.
  42918. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42919. * what is happening in your scene
  42920. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42921. * @param scene Defines the scene to inspect
  42922. */
  42923. constructor(scene: Scene);
  42924. /** Creates the inspector window. */
  42925. private _createInspector;
  42926. /**
  42927. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42928. * @param entity defines the entity to select
  42929. * @param lineContainerTitle defines the specific block to highlight
  42930. */
  42931. select(entity: any, lineContainerTitle?: string): void;
  42932. /** Get the inspector from bundle or global */
  42933. private _getGlobalInspector;
  42934. /**
  42935. * Get if the inspector is visible or not.
  42936. * @returns true if visible otherwise, false
  42937. */
  42938. isVisible(): boolean;
  42939. /**
  42940. * Hide the inspector and close its window.
  42941. */
  42942. hide(): void;
  42943. /**
  42944. * Launch the debugLayer.
  42945. * @param config Define the configuration of the inspector
  42946. * @return a promise fulfilled when the debug layer is visible
  42947. */
  42948. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42949. }
  42950. }
  42951. declare module BABYLON {
  42952. /**
  42953. * Class containing static functions to help procedurally build meshes
  42954. */
  42955. export class BoxBuilder {
  42956. /**
  42957. * Creates a box mesh
  42958. * * The parameter `size` sets the size (float) of each box side (default 1)
  42959. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42960. * * 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)
  42961. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42963. * * 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
  42964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42965. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42966. * @param name defines the name of the mesh
  42967. * @param options defines the options used to create the mesh
  42968. * @param scene defines the hosting scene
  42969. * @returns the box mesh
  42970. */
  42971. static CreateBox(name: string, options: {
  42972. size?: number;
  42973. width?: number;
  42974. height?: number;
  42975. depth?: number;
  42976. faceUV?: Vector4[];
  42977. faceColors?: Color4[];
  42978. sideOrientation?: number;
  42979. frontUVs?: Vector4;
  42980. backUVs?: Vector4;
  42981. wrap?: boolean;
  42982. topBaseAt?: number;
  42983. bottomBaseAt?: number;
  42984. updatable?: boolean;
  42985. }, scene?: Nullable<Scene>): Mesh;
  42986. }
  42987. }
  42988. declare module BABYLON {
  42989. /**
  42990. * Class containing static functions to help procedurally build meshes
  42991. */
  42992. export class SphereBuilder {
  42993. /**
  42994. * Creates a sphere mesh
  42995. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42996. * * 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`)
  42997. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42998. * * 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
  42999. * * 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)
  43000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43001. * * 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
  43002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43003. * @param name defines the name of the mesh
  43004. * @param options defines the options used to create the mesh
  43005. * @param scene defines the hosting scene
  43006. * @returns the sphere mesh
  43007. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43008. */
  43009. static CreateSphere(name: string, options: {
  43010. segments?: number;
  43011. diameter?: number;
  43012. diameterX?: number;
  43013. diameterY?: number;
  43014. diameterZ?: number;
  43015. arc?: number;
  43016. slice?: number;
  43017. sideOrientation?: number;
  43018. frontUVs?: Vector4;
  43019. backUVs?: Vector4;
  43020. updatable?: boolean;
  43021. }, scene?: Nullable<Scene>): Mesh;
  43022. }
  43023. }
  43024. declare module BABYLON.Debug {
  43025. /**
  43026. * Used to show the physics impostor around the specific mesh
  43027. */
  43028. export class PhysicsViewer {
  43029. /** @hidden */
  43030. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43031. /** @hidden */
  43032. protected _meshes: Array<Nullable<AbstractMesh>>;
  43033. /** @hidden */
  43034. protected _scene: Nullable<Scene>;
  43035. /** @hidden */
  43036. protected _numMeshes: number;
  43037. /** @hidden */
  43038. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43039. private _renderFunction;
  43040. private _utilityLayer;
  43041. private _debugBoxMesh;
  43042. private _debugSphereMesh;
  43043. private _debugCylinderMesh;
  43044. private _debugMaterial;
  43045. private _debugMeshMeshes;
  43046. /**
  43047. * Creates a new PhysicsViewer
  43048. * @param scene defines the hosting scene
  43049. */
  43050. constructor(scene: Scene);
  43051. /** @hidden */
  43052. protected _updateDebugMeshes(): void;
  43053. /**
  43054. * Renders a specified physic impostor
  43055. * @param impostor defines the impostor to render
  43056. * @param targetMesh defines the mesh represented by the impostor
  43057. * @returns the new debug mesh used to render the impostor
  43058. */
  43059. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43060. /**
  43061. * Hides a specified physic impostor
  43062. * @param impostor defines the impostor to hide
  43063. */
  43064. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43065. private _getDebugMaterial;
  43066. private _getDebugBoxMesh;
  43067. private _getDebugSphereMesh;
  43068. private _getDebugCylinderMesh;
  43069. private _getDebugMeshMesh;
  43070. private _getDebugMesh;
  43071. /** Releases all resources */
  43072. dispose(): void;
  43073. }
  43074. }
  43075. declare module BABYLON {
  43076. /**
  43077. * Class containing static functions to help procedurally build meshes
  43078. */
  43079. export class LinesBuilder {
  43080. /**
  43081. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43082. * * 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
  43083. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43084. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43085. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43086. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43087. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43088. * * 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
  43089. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43091. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43092. * @param name defines the name of the new line system
  43093. * @param options defines the options used to create the line system
  43094. * @param scene defines the hosting scene
  43095. * @returns a new line system mesh
  43096. */
  43097. static CreateLineSystem(name: string, options: {
  43098. lines: Vector3[][];
  43099. updatable?: boolean;
  43100. instance?: Nullable<LinesMesh>;
  43101. colors?: Nullable<Color4[][]>;
  43102. useVertexAlpha?: boolean;
  43103. }, scene: Nullable<Scene>): LinesMesh;
  43104. /**
  43105. * Creates a line mesh
  43106. * 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
  43107. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43108. * * The parameter `points` is an array successive Vector3
  43109. * * 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
  43110. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43111. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43112. * * When updating an instance, remember that only point positions can change, not the number of points
  43113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43114. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43115. * @param name defines the name of the new line system
  43116. * @param options defines the options used to create the line system
  43117. * @param scene defines the hosting scene
  43118. * @returns a new line mesh
  43119. */
  43120. static CreateLines(name: string, options: {
  43121. points: Vector3[];
  43122. updatable?: boolean;
  43123. instance?: Nullable<LinesMesh>;
  43124. colors?: Color4[];
  43125. useVertexAlpha?: boolean;
  43126. }, scene?: Nullable<Scene>): LinesMesh;
  43127. /**
  43128. * Creates a dashed line mesh
  43129. * * 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
  43130. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43131. * * The parameter `points` is an array successive Vector3
  43132. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43133. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43134. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43135. * * 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
  43136. * * When updating an instance, remember that only point positions can change, not the number of points
  43137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43138. * @param name defines the name of the mesh
  43139. * @param options defines the options used to create the mesh
  43140. * @param scene defines the hosting scene
  43141. * @returns the dashed line mesh
  43142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43143. */
  43144. static CreateDashedLines(name: string, options: {
  43145. points: Vector3[];
  43146. dashSize?: number;
  43147. gapSize?: number;
  43148. dashNb?: number;
  43149. updatable?: boolean;
  43150. instance?: LinesMesh;
  43151. }, scene?: Nullable<Scene>): LinesMesh;
  43152. }
  43153. }
  43154. declare module BABYLON {
  43155. /**
  43156. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43157. * in order to better appreciate the issue one might have.
  43158. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43159. */
  43160. export class RayHelper {
  43161. /**
  43162. * Defines the ray we are currently tryin to visualize.
  43163. */
  43164. ray: Nullable<Ray>;
  43165. private _renderPoints;
  43166. private _renderLine;
  43167. private _renderFunction;
  43168. private _scene;
  43169. private _updateToMeshFunction;
  43170. private _attachedToMesh;
  43171. private _meshSpaceDirection;
  43172. private _meshSpaceOrigin;
  43173. /**
  43174. * Helper function to create a colored helper in a scene in one line.
  43175. * @param ray Defines the ray we are currently tryin to visualize
  43176. * @param scene Defines the scene the ray is used in
  43177. * @param color Defines the color we want to see the ray in
  43178. * @returns The newly created ray helper.
  43179. */
  43180. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43181. /**
  43182. * Instantiate a new ray helper.
  43183. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43184. * in order to better appreciate the issue one might have.
  43185. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43186. * @param ray Defines the ray we are currently tryin to visualize
  43187. */
  43188. constructor(ray: Ray);
  43189. /**
  43190. * Shows the ray we are willing to debug.
  43191. * @param scene Defines the scene the ray needs to be rendered in
  43192. * @param color Defines the color the ray needs to be rendered in
  43193. */
  43194. show(scene: Scene, color?: Color3): void;
  43195. /**
  43196. * Hides the ray we are debugging.
  43197. */
  43198. hide(): void;
  43199. private _render;
  43200. /**
  43201. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43202. * @param mesh Defines the mesh we want the helper attached to
  43203. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43204. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43205. * @param length Defines the length of the ray
  43206. */
  43207. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43208. /**
  43209. * Detach the ray helper from the mesh it has previously been attached to.
  43210. */
  43211. detachFromMesh(): void;
  43212. private _updateToMesh;
  43213. /**
  43214. * Dispose the helper and release its associated resources.
  43215. */
  43216. dispose(): void;
  43217. }
  43218. }
  43219. declare module BABYLON.Debug {
  43220. /**
  43221. * Class used to render a debug view of a given skeleton
  43222. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43223. */
  43224. export class SkeletonViewer {
  43225. /** defines the skeleton to render */
  43226. skeleton: Skeleton;
  43227. /** defines the mesh attached to the skeleton */
  43228. mesh: AbstractMesh;
  43229. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43230. autoUpdateBonesMatrices: boolean;
  43231. /** defines the rendering group id to use with the viewer */
  43232. renderingGroupId: number;
  43233. /** Gets or sets the color used to render the skeleton */
  43234. color: Color3;
  43235. private _scene;
  43236. private _debugLines;
  43237. private _debugMesh;
  43238. private _isEnabled;
  43239. private _renderFunction;
  43240. private _utilityLayer;
  43241. /**
  43242. * Returns the mesh used to render the bones
  43243. */
  43244. readonly debugMesh: Nullable<LinesMesh>;
  43245. /**
  43246. * Creates a new SkeletonViewer
  43247. * @param skeleton defines the skeleton to render
  43248. * @param mesh defines the mesh attached to the skeleton
  43249. * @param scene defines the hosting scene
  43250. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43251. * @param renderingGroupId defines the rendering group id to use with the viewer
  43252. */
  43253. constructor(
  43254. /** defines the skeleton to render */
  43255. skeleton: Skeleton,
  43256. /** defines the mesh attached to the skeleton */
  43257. mesh: AbstractMesh, scene: Scene,
  43258. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43259. autoUpdateBonesMatrices?: boolean,
  43260. /** defines the rendering group id to use with the viewer */
  43261. renderingGroupId?: number);
  43262. /** Gets or sets a boolean indicating if the viewer is enabled */
  43263. isEnabled: boolean;
  43264. private _getBonePosition;
  43265. private _getLinesForBonesWithLength;
  43266. private _getLinesForBonesNoLength;
  43267. /** Update the viewer to sync with current skeleton state */
  43268. update(): void;
  43269. /** Release associated resources */
  43270. dispose(): void;
  43271. }
  43272. }
  43273. declare module BABYLON {
  43274. /**
  43275. * Options to create the null engine
  43276. */
  43277. export class NullEngineOptions {
  43278. /**
  43279. * Render width (Default: 512)
  43280. */
  43281. renderWidth: number;
  43282. /**
  43283. * Render height (Default: 256)
  43284. */
  43285. renderHeight: number;
  43286. /**
  43287. * Texture size (Default: 512)
  43288. */
  43289. textureSize: number;
  43290. /**
  43291. * If delta time between frames should be constant
  43292. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43293. */
  43294. deterministicLockstep: boolean;
  43295. /**
  43296. * Maximum about of steps between frames (Default: 4)
  43297. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43298. */
  43299. lockstepMaxSteps: number;
  43300. }
  43301. /**
  43302. * The null engine class provides support for headless version of babylon.js.
  43303. * This can be used in server side scenario or for testing purposes
  43304. */
  43305. export class NullEngine extends Engine {
  43306. private _options;
  43307. /**
  43308. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43309. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43310. * @returns true if engine is in deterministic lock step mode
  43311. */
  43312. isDeterministicLockStep(): boolean;
  43313. /**
  43314. * Gets the max steps when engine is running in deterministic lock step
  43315. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43316. * @returns the max steps
  43317. */
  43318. getLockstepMaxSteps(): number;
  43319. /**
  43320. * Gets the current hardware scaling level.
  43321. * By default the hardware scaling level is computed from the window device ratio.
  43322. * 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.
  43323. * @returns a number indicating the current hardware scaling level
  43324. */
  43325. getHardwareScalingLevel(): number;
  43326. constructor(options?: NullEngineOptions);
  43327. /**
  43328. * Creates a vertex buffer
  43329. * @param vertices the data for the vertex buffer
  43330. * @returns the new WebGL static buffer
  43331. */
  43332. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43333. /**
  43334. * Creates a new index buffer
  43335. * @param indices defines the content of the index buffer
  43336. * @param updatable defines if the index buffer must be updatable
  43337. * @returns a new webGL buffer
  43338. */
  43339. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43340. /**
  43341. * Clear the current render buffer or the current render target (if any is set up)
  43342. * @param color defines the color to use
  43343. * @param backBuffer defines if the back buffer must be cleared
  43344. * @param depth defines if the depth buffer must be cleared
  43345. * @param stencil defines if the stencil buffer must be cleared
  43346. */
  43347. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43348. /**
  43349. * Gets the current render width
  43350. * @param useScreen defines if screen size must be used (or the current render target if any)
  43351. * @returns a number defining the current render width
  43352. */
  43353. getRenderWidth(useScreen?: boolean): number;
  43354. /**
  43355. * Gets the current render height
  43356. * @param useScreen defines if screen size must be used (or the current render target if any)
  43357. * @returns a number defining the current render height
  43358. */
  43359. getRenderHeight(useScreen?: boolean): number;
  43360. /**
  43361. * Set the WebGL's viewport
  43362. * @param viewport defines the viewport element to be used
  43363. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43364. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43365. */
  43366. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43367. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43368. /**
  43369. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43370. * @param pipelineContext defines the pipeline context to use
  43371. * @param uniformsNames defines the list of uniform names
  43372. * @returns an array of webGL uniform locations
  43373. */
  43374. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43375. /**
  43376. * Gets the lsit of active attributes for a given webGL program
  43377. * @param pipelineContext defines the pipeline context to use
  43378. * @param attributesNames defines the list of attribute names to get
  43379. * @returns an array of indices indicating the offset of each attribute
  43380. */
  43381. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43382. /**
  43383. * Binds an effect to the webGL context
  43384. * @param effect defines the effect to bind
  43385. */
  43386. bindSamplers(effect: Effect): void;
  43387. /**
  43388. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43389. * @param effect defines the effect to activate
  43390. */
  43391. enableEffect(effect: Effect): void;
  43392. /**
  43393. * Set various states to the webGL context
  43394. * @param culling defines backface culling state
  43395. * @param zOffset defines the value to apply to zOffset (0 by default)
  43396. * @param force defines if states must be applied even if cache is up to date
  43397. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43398. */
  43399. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43400. /**
  43401. * Set the value of an uniform to an array of int32
  43402. * @param uniform defines the webGL uniform location where to store the value
  43403. * @param array defines the array of int32 to store
  43404. */
  43405. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43406. /**
  43407. * Set the value of an uniform to an array of int32 (stored as vec2)
  43408. * @param uniform defines the webGL uniform location where to store the value
  43409. * @param array defines the array of int32 to store
  43410. */
  43411. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43412. /**
  43413. * Set the value of an uniform to an array of int32 (stored as vec3)
  43414. * @param uniform defines the webGL uniform location where to store the value
  43415. * @param array defines the array of int32 to store
  43416. */
  43417. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43418. /**
  43419. * Set the value of an uniform to an array of int32 (stored as vec4)
  43420. * @param uniform defines the webGL uniform location where to store the value
  43421. * @param array defines the array of int32 to store
  43422. */
  43423. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43424. /**
  43425. * Set the value of an uniform to an array of float32
  43426. * @param uniform defines the webGL uniform location where to store the value
  43427. * @param array defines the array of float32 to store
  43428. */
  43429. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43430. /**
  43431. * Set the value of an uniform to an array of float32 (stored as vec2)
  43432. * @param uniform defines the webGL uniform location where to store the value
  43433. * @param array defines the array of float32 to store
  43434. */
  43435. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43436. /**
  43437. * Set the value of an uniform to an array of float32 (stored as vec3)
  43438. * @param uniform defines the webGL uniform location where to store the value
  43439. * @param array defines the array of float32 to store
  43440. */
  43441. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43442. /**
  43443. * Set the value of an uniform to an array of float32 (stored as vec4)
  43444. * @param uniform defines the webGL uniform location where to store the value
  43445. * @param array defines the array of float32 to store
  43446. */
  43447. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43448. /**
  43449. * Set the value of an uniform to an array of number
  43450. * @param uniform defines the webGL uniform location where to store the value
  43451. * @param array defines the array of number to store
  43452. */
  43453. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43454. /**
  43455. * Set the value of an uniform to an array of number (stored as vec2)
  43456. * @param uniform defines the webGL uniform location where to store the value
  43457. * @param array defines the array of number to store
  43458. */
  43459. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43460. /**
  43461. * Set the value of an uniform to an array of number (stored as vec3)
  43462. * @param uniform defines the webGL uniform location where to store the value
  43463. * @param array defines the array of number to store
  43464. */
  43465. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43466. /**
  43467. * Set the value of an uniform to an array of number (stored as vec4)
  43468. * @param uniform defines the webGL uniform location where to store the value
  43469. * @param array defines the array of number to store
  43470. */
  43471. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43472. /**
  43473. * Set the value of an uniform to an array of float32 (stored as matrices)
  43474. * @param uniform defines the webGL uniform location where to store the value
  43475. * @param matrices defines the array of float32 to store
  43476. */
  43477. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43478. /**
  43479. * Set the value of an uniform to a matrix (3x3)
  43480. * @param uniform defines the webGL uniform location where to store the value
  43481. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43482. */
  43483. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43484. /**
  43485. * Set the value of an uniform to a matrix (2x2)
  43486. * @param uniform defines the webGL uniform location where to store the value
  43487. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43488. */
  43489. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43490. /**
  43491. * Set the value of an uniform to a number (float)
  43492. * @param uniform defines the webGL uniform location where to store the value
  43493. * @param value defines the float number to store
  43494. */
  43495. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43496. /**
  43497. * Set the value of an uniform to a vec2
  43498. * @param uniform defines the webGL uniform location where to store the value
  43499. * @param x defines the 1st component of the value
  43500. * @param y defines the 2nd component of the value
  43501. */
  43502. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43503. /**
  43504. * Set the value of an uniform to a vec3
  43505. * @param uniform defines the webGL uniform location where to store the value
  43506. * @param x defines the 1st component of the value
  43507. * @param y defines the 2nd component of the value
  43508. * @param z defines the 3rd component of the value
  43509. */
  43510. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43511. /**
  43512. * Set the value of an uniform to a boolean
  43513. * @param uniform defines the webGL uniform location where to store the value
  43514. * @param bool defines the boolean to store
  43515. */
  43516. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43517. /**
  43518. * Set the value of an uniform to a vec4
  43519. * @param uniform defines the webGL uniform location where to store the value
  43520. * @param x defines the 1st component of the value
  43521. * @param y defines the 2nd component of the value
  43522. * @param z defines the 3rd component of the value
  43523. * @param w defines the 4th component of the value
  43524. */
  43525. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43526. /**
  43527. * Sets the current alpha mode
  43528. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43529. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43530. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43531. */
  43532. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43533. /**
  43534. * Bind webGl buffers directly to the webGL context
  43535. * @param vertexBuffers defines the vertex buffer to bind
  43536. * @param indexBuffer defines the index buffer to bind
  43537. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43538. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43539. * @param effect defines the effect associated with the vertex buffer
  43540. */
  43541. bindBuffers(vertexBuffers: {
  43542. [key: string]: VertexBuffer;
  43543. }, indexBuffer: DataBuffer, effect: Effect): void;
  43544. /**
  43545. * Force the entire cache to be cleared
  43546. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43547. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43548. */
  43549. wipeCaches(bruteForce?: boolean): void;
  43550. /**
  43551. * Send a draw order
  43552. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43553. * @param indexStart defines the starting index
  43554. * @param indexCount defines the number of index to draw
  43555. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43556. */
  43557. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43558. /**
  43559. * Draw a list of indexed primitives
  43560. * @param fillMode defines the primitive to use
  43561. * @param indexStart defines the starting index
  43562. * @param indexCount defines the number of index to draw
  43563. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43564. */
  43565. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43566. /**
  43567. * Draw a list of unindexed primitives
  43568. * @param fillMode defines the primitive to use
  43569. * @param verticesStart defines the index of first vertex to draw
  43570. * @param verticesCount defines the count of vertices to draw
  43571. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43572. */
  43573. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43574. /** @hidden */ private _createTexture(): WebGLTexture;
  43575. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  43576. /**
  43577. * Usually called from Texture.ts.
  43578. * Passed information to create a WebGLTexture
  43579. * @param urlArg defines a value which contains one of the following:
  43580. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43581. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43582. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43583. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43584. * @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)
  43585. * @param scene needed for loading to the correct scene
  43586. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43587. * @param onLoad optional callback to be called upon successful completion
  43588. * @param onError optional callback to be called upon failure
  43589. * @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
  43590. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43591. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43592. * @param forcedExtension defines the extension to use to pick the right loader
  43593. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43594. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43595. */
  43596. 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;
  43597. /**
  43598. * Creates a new render target texture
  43599. * @param size defines the size of the texture
  43600. * @param options defines the options used to create the texture
  43601. * @returns a new render target texture stored in an InternalTexture
  43602. */
  43603. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43604. /**
  43605. * Update the sampling mode of a given texture
  43606. * @param samplingMode defines the required sampling mode
  43607. * @param texture defines the texture to update
  43608. */
  43609. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43610. /**
  43611. * Binds the frame buffer to the specified texture.
  43612. * @param texture The texture to render to or null for the default canvas
  43613. * @param faceIndex The face of the texture to render to in case of cube texture
  43614. * @param requiredWidth The width of the target to render to
  43615. * @param requiredHeight The height of the target to render to
  43616. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43617. * @param depthStencilTexture The depth stencil texture to use to render
  43618. * @param lodLevel defines le lod level to bind to the frame buffer
  43619. */
  43620. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43621. /**
  43622. * Unbind the current render target texture from the webGL context
  43623. * @param texture defines the render target texture to unbind
  43624. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43625. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43626. */
  43627. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43628. /**
  43629. * Creates a dynamic vertex buffer
  43630. * @param vertices the data for the dynamic vertex buffer
  43631. * @returns the new WebGL dynamic buffer
  43632. */
  43633. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43634. /**
  43635. * Update the content of a dynamic texture
  43636. * @param texture defines the texture to update
  43637. * @param canvas defines the canvas containing the source
  43638. * @param invertY defines if data must be stored with Y axis inverted
  43639. * @param premulAlpha defines if alpha is stored as premultiplied
  43640. * @param format defines the format of the data
  43641. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43642. */
  43643. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43644. /**
  43645. * Gets a boolean indicating if all created effects are ready
  43646. * @returns true if all effects are ready
  43647. */
  43648. areAllEffectsReady(): boolean;
  43649. /**
  43650. * @hidden
  43651. * Get the current error code of the webGL context
  43652. * @returns the error code
  43653. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43654. */
  43655. getError(): number;
  43656. /** @hidden */ private _getUnpackAlignement(): number;
  43657. /** @hidden */ private _unpackFlipY(value: boolean): void;
  43658. /**
  43659. * Update a dynamic index buffer
  43660. * @param indexBuffer defines the target index buffer
  43661. * @param indices defines the data to update
  43662. * @param offset defines the offset in the target index buffer where update should start
  43663. */
  43664. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43665. /**
  43666. * Updates a dynamic vertex buffer.
  43667. * @param vertexBuffer the vertex buffer to update
  43668. * @param vertices the data used to update the vertex buffer
  43669. * @param byteOffset the byte offset of the data (optional)
  43670. * @param byteLength the byte length of the data (optional)
  43671. */
  43672. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43673. /** @hidden */ private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43674. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43675. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43676. /**
  43677. * 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
  43678. */
  43679. releaseEffects(): void;
  43680. displayLoadingUI(): void;
  43681. hideLoadingUI(): void;
  43682. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43683. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43684. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43685. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43686. }
  43687. }
  43688. declare module BABYLON {
  43689. /** @hidden */
  43690. export class _OcclusionDataStorage {
  43691. /** @hidden */
  43692. occlusionInternalRetryCounter: number;
  43693. /** @hidden */
  43694. isOcclusionQueryInProgress: boolean;
  43695. /** @hidden */
  43696. isOccluded: boolean;
  43697. /** @hidden */
  43698. occlusionRetryCount: number;
  43699. /** @hidden */
  43700. occlusionType: number;
  43701. /** @hidden */
  43702. occlusionQueryAlgorithmType: number;
  43703. }
  43704. interface Engine {
  43705. /**
  43706. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43707. * @return the new query
  43708. */
  43709. createQuery(): WebGLQuery;
  43710. /**
  43711. * Delete and release a webGL query
  43712. * @param query defines the query to delete
  43713. * @return the current engine
  43714. */
  43715. deleteQuery(query: WebGLQuery): Engine;
  43716. /**
  43717. * Check if a given query has resolved and got its value
  43718. * @param query defines the query to check
  43719. * @returns true if the query got its value
  43720. */
  43721. isQueryResultAvailable(query: WebGLQuery): boolean;
  43722. /**
  43723. * Gets the value of a given query
  43724. * @param query defines the query to check
  43725. * @returns the value of the query
  43726. */
  43727. getQueryResult(query: WebGLQuery): number;
  43728. /**
  43729. * Initiates an occlusion query
  43730. * @param algorithmType defines the algorithm to use
  43731. * @param query defines the query to use
  43732. * @returns the current engine
  43733. * @see http://doc.babylonjs.com/features/occlusionquery
  43734. */
  43735. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43736. /**
  43737. * Ends an occlusion query
  43738. * @see http://doc.babylonjs.com/features/occlusionquery
  43739. * @param algorithmType defines the algorithm to use
  43740. * @returns the current engine
  43741. */
  43742. endOcclusionQuery(algorithmType: number): Engine;
  43743. /**
  43744. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43745. * Please note that only one query can be issued at a time
  43746. * @returns a time token used to track the time span
  43747. */
  43748. startTimeQuery(): Nullable<_TimeToken>;
  43749. /**
  43750. * Ends a time query
  43751. * @param token defines the token used to measure the time span
  43752. * @returns the time spent (in ns)
  43753. */
  43754. endTimeQuery(token: _TimeToken): int;
  43755. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  43756. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  43757. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  43758. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  43759. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  43760. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  43761. }
  43762. interface AbstractMesh {
  43763. /**
  43764. * Backing filed
  43765. * @hidden
  43766. */ private __occlusionDataStorage: _OcclusionDataStorage;
  43767. /**
  43768. * Access property
  43769. * @hidden
  43770. */ private _occlusionDataStorage: _OcclusionDataStorage;
  43771. /**
  43772. * 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.
  43773. * The default value is -1 which means don't break the query and wait till the result
  43774. * @see http://doc.babylonjs.com/features/occlusionquery
  43775. */
  43776. occlusionRetryCount: number;
  43777. /**
  43778. * 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:
  43779. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43780. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43781. * * 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.
  43782. * @see http://doc.babylonjs.com/features/occlusionquery
  43783. */
  43784. occlusionType: number;
  43785. /**
  43786. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43787. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43788. * * 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.
  43789. * @see http://doc.babylonjs.com/features/occlusionquery
  43790. */
  43791. occlusionQueryAlgorithmType: number;
  43792. /**
  43793. * 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
  43794. * @see http://doc.babylonjs.com/features/occlusionquery
  43795. */
  43796. isOccluded: boolean;
  43797. /**
  43798. * Flag to check the progress status of the query
  43799. * @see http://doc.babylonjs.com/features/occlusionquery
  43800. */
  43801. isOcclusionQueryInProgress: boolean;
  43802. }
  43803. }
  43804. declare module BABYLON {
  43805. /** @hidden */
  43806. export var _forceTransformFeedbackToBundle: boolean;
  43807. interface Engine {
  43808. /**
  43809. * Creates a webGL transform feedback object
  43810. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43811. * @returns the webGL transform feedback object
  43812. */
  43813. createTransformFeedback(): WebGLTransformFeedback;
  43814. /**
  43815. * Delete a webGL transform feedback object
  43816. * @param value defines the webGL transform feedback object to delete
  43817. */
  43818. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43819. /**
  43820. * Bind a webGL transform feedback object to the webgl context
  43821. * @param value defines the webGL transform feedback object to bind
  43822. */
  43823. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43824. /**
  43825. * Begins a transform feedback operation
  43826. * @param usePoints defines if points or triangles must be used
  43827. */
  43828. beginTransformFeedback(usePoints: boolean): void;
  43829. /**
  43830. * Ends a transform feedback operation
  43831. */
  43832. endTransformFeedback(): void;
  43833. /**
  43834. * Specify the varyings to use with transform feedback
  43835. * @param program defines the associated webGL program
  43836. * @param value defines the list of strings representing the varying names
  43837. */
  43838. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43839. /**
  43840. * Bind a webGL buffer for a transform feedback operation
  43841. * @param value defines the webGL buffer to bind
  43842. */
  43843. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43844. }
  43845. }
  43846. declare module BABYLON {
  43847. /**
  43848. * Creation options of the multi render target texture.
  43849. */
  43850. export interface IMultiRenderTargetOptions {
  43851. /**
  43852. * Define if the texture needs to create mip maps after render.
  43853. */
  43854. generateMipMaps?: boolean;
  43855. /**
  43856. * Define the types of all the draw buffers we want to create
  43857. */
  43858. types?: number[];
  43859. /**
  43860. * Define the sampling modes of all the draw buffers we want to create
  43861. */
  43862. samplingModes?: number[];
  43863. /**
  43864. * Define if a depth buffer is required
  43865. */
  43866. generateDepthBuffer?: boolean;
  43867. /**
  43868. * Define if a stencil buffer is required
  43869. */
  43870. generateStencilBuffer?: boolean;
  43871. /**
  43872. * Define if a depth texture is required instead of a depth buffer
  43873. */
  43874. generateDepthTexture?: boolean;
  43875. /**
  43876. * Define the number of desired draw buffers
  43877. */
  43878. textureCount?: number;
  43879. /**
  43880. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43881. */
  43882. doNotChangeAspectRatio?: boolean;
  43883. /**
  43884. * Define the default type of the buffers we are creating
  43885. */
  43886. defaultType?: number;
  43887. }
  43888. /**
  43889. * A multi render target, like a render target provides the ability to render to a texture.
  43890. * Unlike the render target, it can render to several draw buffers in one draw.
  43891. * This is specially interesting in deferred rendering or for any effects requiring more than
  43892. * just one color from a single pass.
  43893. */
  43894. export class MultiRenderTarget extends RenderTargetTexture {
  43895. private _internalTextures;
  43896. private _textures;
  43897. private _multiRenderTargetOptions;
  43898. /**
  43899. * Get if draw buffers are currently supported by the used hardware and browser.
  43900. */
  43901. readonly isSupported: boolean;
  43902. /**
  43903. * Get the list of textures generated by the multi render target.
  43904. */
  43905. readonly textures: Texture[];
  43906. /**
  43907. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43908. */
  43909. readonly depthTexture: Texture;
  43910. /**
  43911. * Set the wrapping mode on U of all the textures we are rendering to.
  43912. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43913. */
  43914. wrapU: number;
  43915. /**
  43916. * Set the wrapping mode on V of all the textures we are rendering to.
  43917. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43918. */
  43919. wrapV: number;
  43920. /**
  43921. * Instantiate a new multi render target texture.
  43922. * A multi render target, like a render target provides the ability to render to a texture.
  43923. * Unlike the render target, it can render to several draw buffers in one draw.
  43924. * This is specially interesting in deferred rendering or for any effects requiring more than
  43925. * just one color from a single pass.
  43926. * @param name Define the name of the texture
  43927. * @param size Define the size of the buffers to render to
  43928. * @param count Define the number of target we are rendering into
  43929. * @param scene Define the scene the texture belongs to
  43930. * @param options Define the options used to create the multi render target
  43931. */
  43932. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43933. /** @hidden */ private _rebuild(): void;
  43934. private _createInternalTextures;
  43935. private _createTextures;
  43936. /**
  43937. * Define the number of samples used if MSAA is enabled.
  43938. */
  43939. samples: number;
  43940. /**
  43941. * Resize all the textures in the multi render target.
  43942. * Be carrefull as it will recreate all the data in the new texture.
  43943. * @param size Define the new size
  43944. */
  43945. resize(size: any): void;
  43946. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43947. /**
  43948. * Dispose the render targets and their associated resources
  43949. */
  43950. dispose(): void;
  43951. /**
  43952. * Release all the underlying texture used as draw buffers.
  43953. */
  43954. releaseInternalTextures(): void;
  43955. }
  43956. }
  43957. declare module BABYLON {
  43958. interface ThinEngine {
  43959. /**
  43960. * Unbind a list of render target textures from the webGL context
  43961. * This is used only when drawBuffer extension or webGL2 are active
  43962. * @param textures defines the render target textures to unbind
  43963. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43964. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43965. */
  43966. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43967. /**
  43968. * Create a multi render target texture
  43969. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43970. * @param size defines the size of the texture
  43971. * @param options defines the creation options
  43972. * @returns the cube texture as an InternalTexture
  43973. */
  43974. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43975. /**
  43976. * Update the sample count for a given multiple render target texture
  43977. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43978. * @param textures defines the textures to update
  43979. * @param samples defines the sample count to set
  43980. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43981. */
  43982. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43983. }
  43984. }
  43985. declare module BABYLON {
  43986. /**
  43987. * Class used to define an additional view for the engine
  43988. * @see https://doc.babylonjs.com/how_to/multi_canvases
  43989. */
  43990. export class EngineView {
  43991. /** Defines the canvas where to render the view */
  43992. target: HTMLCanvasElement;
  43993. /** Defines an optional camera used to render the view (will use active camera else) */
  43994. camera?: Camera;
  43995. }
  43996. interface Engine {
  43997. /**
  43998. * Gets or sets the HTML element to use for attaching events
  43999. */
  44000. inputElement: Nullable<HTMLElement>;
  44001. /**
  44002. * Gets the current engine view
  44003. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44004. */
  44005. activeView: Nullable<EngineView>;
  44006. /** Gets or sets the list of views */
  44007. views: EngineView[];
  44008. /**
  44009. * Register a new child canvas
  44010. * @param canvas defines the canvas to register
  44011. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  44012. * @returns the associated view
  44013. */
  44014. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  44015. /**
  44016. * Remove a registered child canvas
  44017. * @param canvas defines the canvas to remove
  44018. * @returns the current engine
  44019. */
  44020. unRegisterView(canvas: HTMLCanvasElement): Engine;
  44021. }
  44022. }
  44023. declare module BABYLON {
  44024. /**
  44025. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44026. */
  44027. export interface CubeMapInfo {
  44028. /**
  44029. * The pixel array for the front face.
  44030. * This is stored in format, left to right, up to down format.
  44031. */
  44032. front: Nullable<ArrayBufferView>;
  44033. /**
  44034. * The pixel array for the back face.
  44035. * This is stored in format, left to right, up to down format.
  44036. */
  44037. back: Nullable<ArrayBufferView>;
  44038. /**
  44039. * The pixel array for the left face.
  44040. * This is stored in format, left to right, up to down format.
  44041. */
  44042. left: Nullable<ArrayBufferView>;
  44043. /**
  44044. * The pixel array for the right face.
  44045. * This is stored in format, left to right, up to down format.
  44046. */
  44047. right: Nullable<ArrayBufferView>;
  44048. /**
  44049. * The pixel array for the up face.
  44050. * This is stored in format, left to right, up to down format.
  44051. */
  44052. up: Nullable<ArrayBufferView>;
  44053. /**
  44054. * The pixel array for the down face.
  44055. * This is stored in format, left to right, up to down format.
  44056. */
  44057. down: Nullable<ArrayBufferView>;
  44058. /**
  44059. * The size of the cubemap stored.
  44060. *
  44061. * Each faces will be size * size pixels.
  44062. */
  44063. size: number;
  44064. /**
  44065. * The format of the texture.
  44066. *
  44067. * RGBA, RGB.
  44068. */
  44069. format: number;
  44070. /**
  44071. * The type of the texture data.
  44072. *
  44073. * UNSIGNED_INT, FLOAT.
  44074. */
  44075. type: number;
  44076. /**
  44077. * Specifies whether the texture is in gamma space.
  44078. */
  44079. gammaSpace: boolean;
  44080. }
  44081. /**
  44082. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44083. */
  44084. export class PanoramaToCubeMapTools {
  44085. private static FACE_FRONT;
  44086. private static FACE_BACK;
  44087. private static FACE_RIGHT;
  44088. private static FACE_LEFT;
  44089. private static FACE_DOWN;
  44090. private static FACE_UP;
  44091. /**
  44092. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44093. *
  44094. * @param float32Array The source data.
  44095. * @param inputWidth The width of the input panorama.
  44096. * @param inputHeight The height of the input panorama.
  44097. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44098. * @return The cubemap data
  44099. */
  44100. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44101. private static CreateCubemapTexture;
  44102. private static CalcProjectionSpherical;
  44103. }
  44104. }
  44105. declare module BABYLON {
  44106. /**
  44107. * Helper class dealing with the extraction of spherical polynomial dataArray
  44108. * from a cube map.
  44109. */
  44110. export class CubeMapToSphericalPolynomialTools {
  44111. private static FileFaces;
  44112. /**
  44113. * Converts a texture to the according Spherical Polynomial data.
  44114. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44115. *
  44116. * @param texture The texture to extract the information from.
  44117. * @return The Spherical Polynomial data.
  44118. */
  44119. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44120. /**
  44121. * Converts a cubemap to the according Spherical Polynomial data.
  44122. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44123. *
  44124. * @param cubeInfo The Cube map to extract the information from.
  44125. * @return The Spherical Polynomial data.
  44126. */
  44127. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44128. }
  44129. }
  44130. declare module BABYLON {
  44131. interface BaseTexture {
  44132. /**
  44133. * Get the polynomial representation of the texture data.
  44134. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44135. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44136. */
  44137. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44138. }
  44139. }
  44140. declare module BABYLON {
  44141. /** @hidden */
  44142. export var rgbdEncodePixelShader: {
  44143. name: string;
  44144. shader: string;
  44145. };
  44146. }
  44147. declare module BABYLON {
  44148. /** @hidden */
  44149. export var rgbdDecodePixelShader: {
  44150. name: string;
  44151. shader: string;
  44152. };
  44153. }
  44154. declare module BABYLON {
  44155. /**
  44156. * Raw texture data and descriptor sufficient for WebGL texture upload
  44157. */
  44158. export interface EnvironmentTextureInfo {
  44159. /**
  44160. * Version of the environment map
  44161. */
  44162. version: number;
  44163. /**
  44164. * Width of image
  44165. */
  44166. width: number;
  44167. /**
  44168. * Irradiance information stored in the file.
  44169. */
  44170. irradiance: any;
  44171. /**
  44172. * Specular information stored in the file.
  44173. */
  44174. specular: any;
  44175. }
  44176. /**
  44177. * Defines One Image in the file. It requires only the position in the file
  44178. * as well as the length.
  44179. */
  44180. interface BufferImageData {
  44181. /**
  44182. * Length of the image data.
  44183. */
  44184. length: number;
  44185. /**
  44186. * Position of the data from the null terminator delimiting the end of the JSON.
  44187. */
  44188. position: number;
  44189. }
  44190. /**
  44191. * Defines the specular data enclosed in the file.
  44192. * This corresponds to the version 1 of the data.
  44193. */
  44194. export interface EnvironmentTextureSpecularInfoV1 {
  44195. /**
  44196. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44197. */
  44198. specularDataPosition?: number;
  44199. /**
  44200. * This contains all the images data needed to reconstruct the cubemap.
  44201. */
  44202. mipmaps: Array<BufferImageData>;
  44203. /**
  44204. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44205. */
  44206. lodGenerationScale: number;
  44207. }
  44208. /**
  44209. * Sets of helpers addressing the serialization and deserialization of environment texture
  44210. * stored in a BabylonJS env file.
  44211. * Those files are usually stored as .env files.
  44212. */
  44213. export class EnvironmentTextureTools {
  44214. /**
  44215. * Magic number identifying the env file.
  44216. */
  44217. private static _MagicBytes;
  44218. /**
  44219. * Gets the environment info from an env file.
  44220. * @param data The array buffer containing the .env bytes.
  44221. * @returns the environment file info (the json header) if successfully parsed.
  44222. */
  44223. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44224. /**
  44225. * Creates an environment texture from a loaded cube texture.
  44226. * @param texture defines the cube texture to convert in env file
  44227. * @return a promise containing the environment data if succesfull.
  44228. */
  44229. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44230. /**
  44231. * Creates a JSON representation of the spherical data.
  44232. * @param texture defines the texture containing the polynomials
  44233. * @return the JSON representation of the spherical info
  44234. */
  44235. private static _CreateEnvTextureIrradiance;
  44236. /**
  44237. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44238. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44239. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44240. * @return the views described by info providing access to the underlying buffer
  44241. */
  44242. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44243. /**
  44244. * Uploads the texture info contained in the env file to the GPU.
  44245. * @param texture defines the internal texture to upload to
  44246. * @param arrayBuffer defines the buffer cotaining the data to load
  44247. * @param info defines the texture info retrieved through the GetEnvInfo method
  44248. * @returns a promise
  44249. */
  44250. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44251. private static _OnImageReadyAsync;
  44252. /**
  44253. * Uploads the levels of image data to the GPU.
  44254. * @param texture defines the internal texture to upload to
  44255. * @param imageData defines the array buffer views of image data [mipmap][face]
  44256. * @returns a promise
  44257. */
  44258. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44259. /**
  44260. * Uploads spherical polynomials information to the texture.
  44261. * @param texture defines the texture we are trying to upload the information to
  44262. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44263. */
  44264. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44265. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44266. }
  44267. }
  44268. declare module BABYLON {
  44269. /**
  44270. * Contains position and normal vectors for a vertex
  44271. */
  44272. export class PositionNormalVertex {
  44273. /** the position of the vertex (defaut: 0,0,0) */
  44274. position: Vector3;
  44275. /** the normal of the vertex (defaut: 0,1,0) */
  44276. normal: Vector3;
  44277. /**
  44278. * Creates a PositionNormalVertex
  44279. * @param position the position of the vertex (defaut: 0,0,0)
  44280. * @param normal the normal of the vertex (defaut: 0,1,0)
  44281. */
  44282. constructor(
  44283. /** the position of the vertex (defaut: 0,0,0) */
  44284. position?: Vector3,
  44285. /** the normal of the vertex (defaut: 0,1,0) */
  44286. normal?: Vector3);
  44287. /**
  44288. * Clones the PositionNormalVertex
  44289. * @returns the cloned PositionNormalVertex
  44290. */
  44291. clone(): PositionNormalVertex;
  44292. }
  44293. /**
  44294. * Contains position, normal and uv vectors for a vertex
  44295. */
  44296. export class PositionNormalTextureVertex {
  44297. /** the position of the vertex (defaut: 0,0,0) */
  44298. position: Vector3;
  44299. /** the normal of the vertex (defaut: 0,1,0) */
  44300. normal: Vector3;
  44301. /** the uv of the vertex (default: 0,0) */
  44302. uv: Vector2;
  44303. /**
  44304. * Creates a PositionNormalTextureVertex
  44305. * @param position the position of the vertex (defaut: 0,0,0)
  44306. * @param normal the normal of the vertex (defaut: 0,1,0)
  44307. * @param uv the uv of the vertex (default: 0,0)
  44308. */
  44309. constructor(
  44310. /** the position of the vertex (defaut: 0,0,0) */
  44311. position?: Vector3,
  44312. /** the normal of the vertex (defaut: 0,1,0) */
  44313. normal?: Vector3,
  44314. /** the uv of the vertex (default: 0,0) */
  44315. uv?: Vector2);
  44316. /**
  44317. * Clones the PositionNormalTextureVertex
  44318. * @returns the cloned PositionNormalTextureVertex
  44319. */
  44320. clone(): PositionNormalTextureVertex;
  44321. }
  44322. }
  44323. declare module BABYLON {
  44324. /** @hidden */
  44325. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44326. private _genericAttributeLocation;
  44327. private _varyingLocationCount;
  44328. private _varyingLocationMap;
  44329. private _replacements;
  44330. private _textureCount;
  44331. private _uniforms;
  44332. lineProcessor(line: string): string;
  44333. attributeProcessor(attribute: string): string;
  44334. varyingProcessor(varying: string, isFragment: boolean): string;
  44335. uniformProcessor(uniform: string): string;
  44336. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44337. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44338. }
  44339. }
  44340. declare module BABYLON {
  44341. /**
  44342. * Container for accessors for natively-stored mesh data buffers.
  44343. */
  44344. class NativeDataBuffer extends DataBuffer {
  44345. /**
  44346. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44347. */
  44348. nativeIndexBuffer?: any;
  44349. /**
  44350. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44351. */
  44352. nativeVertexBuffer?: any;
  44353. }
  44354. /** @hidden */
  44355. class NativeTexture extends InternalTexture {
  44356. getInternalTexture(): InternalTexture;
  44357. getViewCount(): number;
  44358. }
  44359. /** @hidden */
  44360. export class NativeEngine extends Engine {
  44361. private readonly _native;
  44362. getHardwareScalingLevel(): number;
  44363. constructor();
  44364. /**
  44365. * Can be used to override the current requestAnimationFrame requester.
  44366. * @hidden
  44367. */
  44368. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  44369. /**
  44370. * Override default engine behavior.
  44371. * @param color
  44372. * @param backBuffer
  44373. * @param depth
  44374. * @param stencil
  44375. */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  44376. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44377. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44378. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44379. recordVertexArrayObject(vertexBuffers: {
  44380. [key: string]: VertexBuffer;
  44381. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44382. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44383. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44384. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44385. /**
  44386. * Draw a list of indexed primitives
  44387. * @param fillMode defines the primitive to use
  44388. * @param indexStart defines the starting index
  44389. * @param indexCount defines the number of index to draw
  44390. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44391. */
  44392. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44393. /**
  44394. * Draw a list of unindexed primitives
  44395. * @param fillMode defines the primitive to use
  44396. * @param verticesStart defines the index of first vertex to draw
  44397. * @param verticesCount defines the count of vertices to draw
  44398. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44399. */
  44400. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44401. createPipelineContext(): IPipelineContext; private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44402. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44403. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44404. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44405. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44406. protected _setProgram(program: WebGLProgram): void; private _releaseEffect(effect: Effect): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44407. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44408. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44409. bindSamplers(effect: Effect): void;
  44410. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44411. getRenderWidth(useScreen?: boolean): number;
  44412. getRenderHeight(useScreen?: boolean): number;
  44413. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44414. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44415. /**
  44416. * Set the z offset to apply to current rendering
  44417. * @param value defines the offset to apply
  44418. */
  44419. setZOffset(value: number): void;
  44420. /**
  44421. * Gets the current value of the zOffset
  44422. * @returns the current zOffset state
  44423. */
  44424. getZOffset(): number;
  44425. /**
  44426. * Enable or disable depth buffering
  44427. * @param enable defines the state to set
  44428. */
  44429. setDepthBuffer(enable: boolean): void;
  44430. /**
  44431. * Gets a boolean indicating if depth writing is enabled
  44432. * @returns the current depth writing state
  44433. */
  44434. getDepthWrite(): boolean;
  44435. /**
  44436. * Enable or disable depth writing
  44437. * @param enable defines the state to set
  44438. */
  44439. setDepthWrite(enable: boolean): void;
  44440. /**
  44441. * Enable or disable color writing
  44442. * @param enable defines the state to set
  44443. */
  44444. setColorWrite(enable: boolean): void;
  44445. /**
  44446. * Gets a boolean indicating if color writing is enabled
  44447. * @returns the current color writing state
  44448. */
  44449. getColorWrite(): boolean;
  44450. /**
  44451. * Sets alpha constants used by some alpha blending modes
  44452. * @param r defines the red component
  44453. * @param g defines the green component
  44454. * @param b defines the blue component
  44455. * @param a defines the alpha component
  44456. */
  44457. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44458. /**
  44459. * Sets the current alpha mode
  44460. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44461. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44462. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44463. */
  44464. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44465. /**
  44466. * Gets the current alpha mode
  44467. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44468. * @returns the current alpha mode
  44469. */
  44470. getAlphaMode(): number;
  44471. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44472. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44473. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44474. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44475. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44476. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44477. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44478. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44479. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44480. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44481. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44482. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44483. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44484. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44485. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44486. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44487. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44488. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44489. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44490. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44491. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44492. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44493. wipeCaches(bruteForce?: boolean): void; private _createTexture(): WebGLTexture;
  44494. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44495. /**
  44496. * Usually called from BABYLON.Texture.ts.
  44497. * Passed information to create a WebGLTexture
  44498. * @param urlArg defines a value which contains one of the following:
  44499. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44500. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44501. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44502. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44503. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44504. * @param scene needed for loading to the correct scene
  44505. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44506. * @param onLoad optional callback to be called upon successful completion
  44507. * @param onError optional callback to be called upon failure
  44508. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44509. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44510. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44511. * @param forcedExtension defines the extension to use to pick the right loader
  44512. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44513. */
  44514. 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;
  44515. /**
  44516. * Creates a cube texture
  44517. * @param rootUrl defines the url where the files to load is located
  44518. * @param scene defines the current scene
  44519. * @param files defines the list of files to load (1 per face)
  44520. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44521. * @param onLoad defines an optional callback raised when the texture is loaded
  44522. * @param onError defines an optional callback raised if there is an issue to load the texture
  44523. * @param format defines the format of the data
  44524. * @param forcedExtension defines the extension to use to pick the right loader
  44525. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44526. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44527. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44528. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44529. * @returns the cube texture as an InternalTexture
  44530. */
  44531. 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;
  44532. private _getSamplingFilter;
  44533. private static _GetNativeTextureFormat;
  44534. createRenderTargetTexture(size: number | {
  44535. width: number;
  44536. height: number;
  44537. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  44538. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44539. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44540. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44541. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44542. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44543. /**
  44544. * Updates a dynamic vertex buffer.
  44545. * @param vertexBuffer the vertex buffer to update
  44546. * @param data the data used to update the vertex buffer
  44547. * @param byteOffset the byte offset of the data (optional)
  44548. * @param byteLength the byte length of the data (optional)
  44549. */
  44550. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44551. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44552. private _updateAnisotropicLevel;
  44553. private _getAddressMode;
  44554. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  44555. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44556. releaseEffects(): void;
  44557. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44558. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44559. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44560. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44561. }
  44562. }
  44563. declare module BABYLON {
  44564. /**
  44565. * Gather the list of clipboard event types as constants.
  44566. */
  44567. export class ClipboardEventTypes {
  44568. /**
  44569. * The clipboard event is fired when a copy command is active (pressed).
  44570. */
  44571. static readonly COPY: number;
  44572. /**
  44573. * The clipboard event is fired when a cut command is active (pressed).
  44574. */
  44575. static readonly CUT: number;
  44576. /**
  44577. * The clipboard event is fired when a paste command is active (pressed).
  44578. */
  44579. static readonly PASTE: number;
  44580. }
  44581. /**
  44582. * This class is used to store clipboard related info for the onClipboardObservable event.
  44583. */
  44584. export class ClipboardInfo {
  44585. /**
  44586. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44587. */
  44588. type: number;
  44589. /**
  44590. * Defines the related dom event
  44591. */
  44592. event: ClipboardEvent;
  44593. /**
  44594. *Creates an instance of ClipboardInfo.
  44595. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44596. * @param event Defines the related dom event
  44597. */
  44598. constructor(
  44599. /**
  44600. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44601. */
  44602. type: number,
  44603. /**
  44604. * Defines the related dom event
  44605. */
  44606. event: ClipboardEvent);
  44607. /**
  44608. * Get the clipboard event's type from the keycode.
  44609. * @param keyCode Defines the keyCode for the current keyboard event.
  44610. * @return {number}
  44611. */
  44612. static GetTypeFromCharacter(keyCode: number): number;
  44613. }
  44614. }
  44615. declare module BABYLON {
  44616. /**
  44617. * Google Daydream controller
  44618. */
  44619. export class DaydreamController extends WebVRController {
  44620. /**
  44621. * Base Url for the controller model.
  44622. */
  44623. static MODEL_BASE_URL: string;
  44624. /**
  44625. * File name for the controller model.
  44626. */
  44627. static MODEL_FILENAME: string;
  44628. /**
  44629. * Gamepad Id prefix used to identify Daydream Controller.
  44630. */
  44631. static readonly GAMEPAD_ID_PREFIX: string;
  44632. /**
  44633. * Creates a new DaydreamController from a gamepad
  44634. * @param vrGamepad the gamepad that the controller should be created from
  44635. */
  44636. constructor(vrGamepad: any);
  44637. /**
  44638. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44639. * @param scene scene in which to add meshes
  44640. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44641. */
  44642. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44643. /**
  44644. * Called once for each button that changed state since the last frame
  44645. * @param buttonIdx Which button index changed
  44646. * @param state New state of the button
  44647. * @param changes Which properties on the state changed since last frame
  44648. */
  44649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44650. }
  44651. }
  44652. declare module BABYLON {
  44653. /**
  44654. * Gear VR Controller
  44655. */
  44656. export class GearVRController extends WebVRController {
  44657. /**
  44658. * Base Url for the controller model.
  44659. */
  44660. static MODEL_BASE_URL: string;
  44661. /**
  44662. * File name for the controller model.
  44663. */
  44664. static MODEL_FILENAME: string;
  44665. /**
  44666. * Gamepad Id prefix used to identify this controller.
  44667. */
  44668. static readonly GAMEPAD_ID_PREFIX: string;
  44669. private readonly _buttonIndexToObservableNameMap;
  44670. /**
  44671. * Creates a new GearVRController from a gamepad
  44672. * @param vrGamepad the gamepad that the controller should be created from
  44673. */
  44674. constructor(vrGamepad: any);
  44675. /**
  44676. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44677. * @param scene scene in which to add meshes
  44678. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44679. */
  44680. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44681. /**
  44682. * Called once for each button that changed state since the last frame
  44683. * @param buttonIdx Which button index changed
  44684. * @param state New state of the button
  44685. * @param changes Which properties on the state changed since last frame
  44686. */
  44687. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44688. }
  44689. }
  44690. declare module BABYLON {
  44691. /**
  44692. * Class containing static functions to help procedurally build meshes
  44693. */
  44694. export class PolyhedronBuilder {
  44695. /**
  44696. * Creates a polyhedron mesh
  44697. * * 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
  44698. * * The parameter `size` (positive float, default 1) sets the polygon size
  44699. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44700. * * 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`
  44701. * * 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
  44702. * * 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)`)
  44703. * * 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
  44704. * * 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
  44705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44706. * * 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
  44707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44708. * @param name defines the name of the mesh
  44709. * @param options defines the options used to create the mesh
  44710. * @param scene defines the hosting scene
  44711. * @returns the polyhedron mesh
  44712. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44713. */
  44714. static CreatePolyhedron(name: string, options: {
  44715. type?: number;
  44716. size?: number;
  44717. sizeX?: number;
  44718. sizeY?: number;
  44719. sizeZ?: number;
  44720. custom?: any;
  44721. faceUV?: Vector4[];
  44722. faceColors?: Color4[];
  44723. flat?: boolean;
  44724. updatable?: boolean;
  44725. sideOrientation?: number;
  44726. frontUVs?: Vector4;
  44727. backUVs?: Vector4;
  44728. }, scene?: Nullable<Scene>): Mesh;
  44729. }
  44730. }
  44731. declare module BABYLON {
  44732. /**
  44733. * Gizmo that enables scaling a mesh along 3 axis
  44734. */
  44735. export class ScaleGizmo extends Gizmo {
  44736. /**
  44737. * Internal gizmo used for interactions on the x axis
  44738. */
  44739. xGizmo: AxisScaleGizmo;
  44740. /**
  44741. * Internal gizmo used for interactions on the y axis
  44742. */
  44743. yGizmo: AxisScaleGizmo;
  44744. /**
  44745. * Internal gizmo used for interactions on the z axis
  44746. */
  44747. zGizmo: AxisScaleGizmo;
  44748. /**
  44749. * Internal gizmo used to scale all axis equally
  44750. */
  44751. uniformScaleGizmo: AxisScaleGizmo;
  44752. private _meshAttached;
  44753. private _updateGizmoRotationToMatchAttachedMesh;
  44754. private _snapDistance;
  44755. private _scaleRatio;
  44756. private _uniformScalingMesh;
  44757. private _octahedron;
  44758. /** Fires an event when any of it's sub gizmos are dragged */
  44759. onDragStartObservable: Observable<unknown>;
  44760. /** Fires an event when any of it's sub gizmos are released from dragging */
  44761. onDragEndObservable: Observable<unknown>;
  44762. attachedMesh: Nullable<AbstractMesh>;
  44763. /**
  44764. * Creates a ScaleGizmo
  44765. * @param gizmoLayer The utility layer the gizmo will be added to
  44766. */
  44767. constructor(gizmoLayer?: UtilityLayerRenderer);
  44768. updateGizmoRotationToMatchAttachedMesh: boolean;
  44769. /**
  44770. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44771. */
  44772. snapDistance: number;
  44773. /**
  44774. * Ratio for the scale of the gizmo (Default: 1)
  44775. */
  44776. scaleRatio: number;
  44777. /**
  44778. * Disposes of the gizmo
  44779. */
  44780. dispose(): void;
  44781. }
  44782. }
  44783. declare module BABYLON {
  44784. /**
  44785. * Single axis scale gizmo
  44786. */
  44787. export class AxisScaleGizmo extends Gizmo {
  44788. /**
  44789. * Drag behavior responsible for the gizmos dragging interactions
  44790. */
  44791. dragBehavior: PointerDragBehavior;
  44792. private _pointerObserver;
  44793. /**
  44794. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44795. */
  44796. snapDistance: number;
  44797. /**
  44798. * Event that fires each time the gizmo snaps to a new location.
  44799. * * snapDistance is the the change in distance
  44800. */
  44801. onSnapObservable: Observable<{
  44802. snapDistance: number;
  44803. }>;
  44804. /**
  44805. * If the scaling operation should be done on all axis (default: false)
  44806. */
  44807. uniformScaling: boolean;
  44808. private _isEnabled;
  44809. private _parent;
  44810. private _arrow;
  44811. private _coloredMaterial;
  44812. private _hoverMaterial;
  44813. /**
  44814. * Creates an AxisScaleGizmo
  44815. * @param gizmoLayer The utility layer the gizmo will be added to
  44816. * @param dragAxis The axis which the gizmo will be able to scale on
  44817. * @param color The color of the gizmo
  44818. */
  44819. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44820. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44821. /**
  44822. * If the gizmo is enabled
  44823. */
  44824. isEnabled: boolean;
  44825. /**
  44826. * Disposes of the gizmo
  44827. */
  44828. dispose(): void;
  44829. /**
  44830. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44831. * @param mesh The mesh to replace the default mesh of the gizmo
  44832. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44833. */
  44834. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44835. }
  44836. }
  44837. declare module BABYLON {
  44838. /**
  44839. * Bounding box gizmo
  44840. */
  44841. export class BoundingBoxGizmo extends Gizmo {
  44842. private _lineBoundingBox;
  44843. private _rotateSpheresParent;
  44844. private _scaleBoxesParent;
  44845. private _boundingDimensions;
  44846. private _renderObserver;
  44847. private _pointerObserver;
  44848. private _scaleDragSpeed;
  44849. private _tmpQuaternion;
  44850. private _tmpVector;
  44851. private _tmpRotationMatrix;
  44852. /**
  44853. * 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)
  44854. */
  44855. ignoreChildren: boolean;
  44856. /**
  44857. * 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)
  44858. */
  44859. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44860. /**
  44861. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44862. */
  44863. rotationSphereSize: number;
  44864. /**
  44865. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44866. */
  44867. scaleBoxSize: number;
  44868. /**
  44869. * 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)
  44870. */
  44871. fixedDragMeshScreenSize: boolean;
  44872. /**
  44873. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44874. */
  44875. fixedDragMeshScreenSizeDistanceFactor: number;
  44876. /**
  44877. * Fired when a rotation sphere or scale box is dragged
  44878. */
  44879. onDragStartObservable: Observable<{}>;
  44880. /**
  44881. * Fired when a scale box is dragged
  44882. */
  44883. onScaleBoxDragObservable: Observable<{}>;
  44884. /**
  44885. * Fired when a scale box drag is ended
  44886. */
  44887. onScaleBoxDragEndObservable: Observable<{}>;
  44888. /**
  44889. * Fired when a rotation sphere is dragged
  44890. */
  44891. onRotationSphereDragObservable: Observable<{}>;
  44892. /**
  44893. * Fired when a rotation sphere drag is ended
  44894. */
  44895. onRotationSphereDragEndObservable: Observable<{}>;
  44896. /**
  44897. * 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)
  44898. */
  44899. scalePivot: Nullable<Vector3>;
  44900. /**
  44901. * Mesh used as a pivot to rotate the attached mesh
  44902. */
  44903. private _anchorMesh;
  44904. private _existingMeshScale;
  44905. private _dragMesh;
  44906. private pointerDragBehavior;
  44907. private coloredMaterial;
  44908. private hoverColoredMaterial;
  44909. /**
  44910. * Sets the color of the bounding box gizmo
  44911. * @param color the color to set
  44912. */
  44913. setColor(color: Color3): void;
  44914. /**
  44915. * Creates an BoundingBoxGizmo
  44916. * @param gizmoLayer The utility layer the gizmo will be added to
  44917. * @param color The color of the gizmo
  44918. */
  44919. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44920. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44921. private _selectNode;
  44922. /**
  44923. * Updates the bounding box information for the Gizmo
  44924. */
  44925. updateBoundingBox(): void;
  44926. private _updateRotationSpheres;
  44927. private _updateScaleBoxes;
  44928. /**
  44929. * Enables rotation on the specified axis and disables rotation on the others
  44930. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44931. */
  44932. setEnabledRotationAxis(axis: string): void;
  44933. /**
  44934. * Enables/disables scaling
  44935. * @param enable if scaling should be enabled
  44936. */
  44937. setEnabledScaling(enable: boolean): void;
  44938. private _updateDummy;
  44939. /**
  44940. * Enables a pointer drag behavior on the bounding box of the gizmo
  44941. */
  44942. enableDragBehavior(): void;
  44943. /**
  44944. * Disposes of the gizmo
  44945. */
  44946. dispose(): void;
  44947. /**
  44948. * 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)
  44949. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44950. * @returns the bounding box mesh with the passed in mesh as a child
  44951. */
  44952. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44953. /**
  44954. * CustomMeshes are not supported by this gizmo
  44955. * @param mesh The mesh to replace the default mesh of the gizmo
  44956. */
  44957. setCustomMesh(mesh: Mesh): void;
  44958. }
  44959. }
  44960. declare module BABYLON {
  44961. /**
  44962. * Single plane rotation gizmo
  44963. */
  44964. export class PlaneRotationGizmo extends Gizmo {
  44965. /**
  44966. * Drag behavior responsible for the gizmos dragging interactions
  44967. */
  44968. dragBehavior: PointerDragBehavior;
  44969. private _pointerObserver;
  44970. /**
  44971. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44972. */
  44973. snapDistance: number;
  44974. /**
  44975. * Event that fires each time the gizmo snaps to a new location.
  44976. * * snapDistance is the the change in distance
  44977. */
  44978. onSnapObservable: Observable<{
  44979. snapDistance: number;
  44980. }>;
  44981. private _isEnabled;
  44982. private _parent;
  44983. /**
  44984. * Creates a PlaneRotationGizmo
  44985. * @param gizmoLayer The utility layer the gizmo will be added to
  44986. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44987. * @param color The color of the gizmo
  44988. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44989. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44990. */
  44991. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44992. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44993. /**
  44994. * If the gizmo is enabled
  44995. */
  44996. isEnabled: boolean;
  44997. /**
  44998. * Disposes of the gizmo
  44999. */
  45000. dispose(): void;
  45001. }
  45002. }
  45003. declare module BABYLON {
  45004. /**
  45005. * Gizmo that enables rotating a mesh along 3 axis
  45006. */
  45007. export class RotationGizmo extends Gizmo {
  45008. /**
  45009. * Internal gizmo used for interactions on the x axis
  45010. */
  45011. xGizmo: PlaneRotationGizmo;
  45012. /**
  45013. * Internal gizmo used for interactions on the y axis
  45014. */
  45015. yGizmo: PlaneRotationGizmo;
  45016. /**
  45017. * Internal gizmo used for interactions on the z axis
  45018. */
  45019. zGizmo: PlaneRotationGizmo;
  45020. /** Fires an event when any of it's sub gizmos are dragged */
  45021. onDragStartObservable: Observable<unknown>;
  45022. /** Fires an event when any of it's sub gizmos are released from dragging */
  45023. onDragEndObservable: Observable<unknown>;
  45024. private _meshAttached;
  45025. attachedMesh: Nullable<AbstractMesh>;
  45026. /**
  45027. * Creates a RotationGizmo
  45028. * @param gizmoLayer The utility layer the gizmo will be added to
  45029. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45030. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45031. */
  45032. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45033. updateGizmoRotationToMatchAttachedMesh: boolean;
  45034. /**
  45035. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45036. */
  45037. snapDistance: number;
  45038. /**
  45039. * Ratio for the scale of the gizmo (Default: 1)
  45040. */
  45041. scaleRatio: number;
  45042. /**
  45043. * Disposes of the gizmo
  45044. */
  45045. dispose(): void;
  45046. /**
  45047. * CustomMeshes are not supported by this gizmo
  45048. * @param mesh The mesh to replace the default mesh of the gizmo
  45049. */
  45050. setCustomMesh(mesh: Mesh): void;
  45051. }
  45052. }
  45053. declare module BABYLON {
  45054. /**
  45055. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45056. */
  45057. export class GizmoManager implements IDisposable {
  45058. private scene;
  45059. /**
  45060. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45061. */
  45062. gizmos: {
  45063. positionGizmo: Nullable<PositionGizmo>;
  45064. rotationGizmo: Nullable<RotationGizmo>;
  45065. scaleGizmo: Nullable<ScaleGizmo>;
  45066. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45067. };
  45068. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45069. clearGizmoOnEmptyPointerEvent: boolean;
  45070. /** Fires an event when the manager is attached to a mesh */
  45071. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45072. private _gizmosEnabled;
  45073. private _pointerObserver;
  45074. private _attachedMesh;
  45075. private _boundingBoxColor;
  45076. private _defaultUtilityLayer;
  45077. private _defaultKeepDepthUtilityLayer;
  45078. /**
  45079. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45080. */
  45081. boundingBoxDragBehavior: SixDofDragBehavior;
  45082. /**
  45083. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45084. */
  45085. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45086. /**
  45087. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45088. */
  45089. usePointerToAttachGizmos: boolean;
  45090. /**
  45091. * Utility layer that the bounding box gizmo belongs to
  45092. */
  45093. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45094. /**
  45095. * Utility layer that all gizmos besides bounding box belong to
  45096. */
  45097. readonly utilityLayer: UtilityLayerRenderer;
  45098. /**
  45099. * Instatiates a gizmo manager
  45100. * @param scene the scene to overlay the gizmos on top of
  45101. */
  45102. constructor(scene: Scene);
  45103. /**
  45104. * Attaches a set of gizmos to the specified mesh
  45105. * @param mesh The mesh the gizmo's should be attached to
  45106. */
  45107. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45108. /**
  45109. * If the position gizmo is enabled
  45110. */
  45111. positionGizmoEnabled: boolean;
  45112. /**
  45113. * If the rotation gizmo is enabled
  45114. */
  45115. rotationGizmoEnabled: boolean;
  45116. /**
  45117. * If the scale gizmo is enabled
  45118. */
  45119. scaleGizmoEnabled: boolean;
  45120. /**
  45121. * If the boundingBox gizmo is enabled
  45122. */
  45123. boundingBoxGizmoEnabled: boolean;
  45124. /**
  45125. * Disposes of the gizmo manager
  45126. */
  45127. dispose(): void;
  45128. }
  45129. }
  45130. declare module BABYLON {
  45131. /**
  45132. * A directional light is defined by a direction (what a surprise!).
  45133. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45134. * 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.
  45135. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45136. */
  45137. export class DirectionalLight extends ShadowLight {
  45138. private _shadowFrustumSize;
  45139. /**
  45140. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45141. */
  45142. /**
  45143. * Specifies a fix frustum size for the shadow generation.
  45144. */
  45145. shadowFrustumSize: number;
  45146. private _shadowOrthoScale;
  45147. /**
  45148. * Gets the shadow projection scale against the optimal computed one.
  45149. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45150. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45151. */
  45152. /**
  45153. * Sets the shadow projection scale against the optimal computed one.
  45154. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45155. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45156. */
  45157. shadowOrthoScale: number;
  45158. /**
  45159. * Automatically compute the projection matrix to best fit (including all the casters)
  45160. * on each frame.
  45161. */
  45162. autoUpdateExtends: boolean;
  45163. private _orthoLeft;
  45164. private _orthoRight;
  45165. private _orthoTop;
  45166. private _orthoBottom;
  45167. /**
  45168. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45169. * The directional light is emitted from everywhere in the given direction.
  45170. * It can cast shadows.
  45171. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45172. * @param name The friendly name of the light
  45173. * @param direction The direction of the light
  45174. * @param scene The scene the light belongs to
  45175. */
  45176. constructor(name: string, direction: Vector3, scene: Scene);
  45177. /**
  45178. * Returns the string "DirectionalLight".
  45179. * @return The class name
  45180. */
  45181. getClassName(): string;
  45182. /**
  45183. * Returns the integer 1.
  45184. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45185. */
  45186. getTypeID(): number;
  45187. /**
  45188. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45189. * Returns the DirectionalLight Shadow projection matrix.
  45190. */
  45191. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45192. /**
  45193. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45194. * Returns the DirectionalLight Shadow projection matrix.
  45195. */
  45196. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45197. /**
  45198. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45199. * Returns the DirectionalLight Shadow projection matrix.
  45200. */
  45201. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45202. protected _buildUniformLayout(): void;
  45203. /**
  45204. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45205. * @param effect The effect to update
  45206. * @param lightIndex The index of the light in the effect to update
  45207. * @returns The directional light
  45208. */
  45209. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45210. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45211. /**
  45212. * Gets the minZ used for shadow according to both the scene and the light.
  45213. *
  45214. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45215. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45216. * @param activeCamera The camera we are returning the min for
  45217. * @returns the depth min z
  45218. */
  45219. getDepthMinZ(activeCamera: Camera): number;
  45220. /**
  45221. * Gets the maxZ used for shadow according to both the scene and the light.
  45222. *
  45223. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45224. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45225. * @param activeCamera The camera we are returning the max for
  45226. * @returns the depth max z
  45227. */
  45228. getDepthMaxZ(activeCamera: Camera): number;
  45229. /**
  45230. * Prepares the list of defines specific to the light type.
  45231. * @param defines the list of defines
  45232. * @param lightIndex defines the index of the light for the effect
  45233. */
  45234. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45235. }
  45236. }
  45237. declare module BABYLON {
  45238. /**
  45239. * Class containing static functions to help procedurally build meshes
  45240. */
  45241. export class HemisphereBuilder {
  45242. /**
  45243. * Creates a hemisphere mesh
  45244. * @param name defines the name of the mesh
  45245. * @param options defines the options used to create the mesh
  45246. * @param scene defines the hosting scene
  45247. * @returns the hemisphere mesh
  45248. */
  45249. static CreateHemisphere(name: string, options: {
  45250. segments?: number;
  45251. diameter?: number;
  45252. sideOrientation?: number;
  45253. }, scene: any): Mesh;
  45254. }
  45255. }
  45256. declare module BABYLON {
  45257. /**
  45258. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45259. * These values define a cone of light starting from the position, emitting toward the direction.
  45260. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45261. * and the exponent defines the speed of the decay of the light with distance (reach).
  45262. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45263. */
  45264. export class SpotLight extends ShadowLight {
  45265. private _angle;
  45266. private _innerAngle;
  45267. private _cosHalfAngle;
  45268. private _lightAngleScale;
  45269. private _lightAngleOffset;
  45270. /**
  45271. * Gets the cone angle of the spot light in Radians.
  45272. */
  45273. /**
  45274. * Sets the cone angle of the spot light in Radians.
  45275. */
  45276. angle: number;
  45277. /**
  45278. * Only used in gltf falloff mode, this defines the angle where
  45279. * the directional falloff will start before cutting at angle which could be seen
  45280. * as outer angle.
  45281. */
  45282. /**
  45283. * Only used in gltf falloff mode, this defines the angle where
  45284. * the directional falloff will start before cutting at angle which could be seen
  45285. * as outer angle.
  45286. */
  45287. innerAngle: number;
  45288. private _shadowAngleScale;
  45289. /**
  45290. * Allows scaling the angle of the light for shadow generation only.
  45291. */
  45292. /**
  45293. * Allows scaling the angle of the light for shadow generation only.
  45294. */
  45295. shadowAngleScale: number;
  45296. /**
  45297. * The light decay speed with the distance from the emission spot.
  45298. */
  45299. exponent: number;
  45300. private _projectionTextureMatrix;
  45301. /**
  45302. * Allows reading the projecton texture
  45303. */
  45304. readonly projectionTextureMatrix: Matrix;
  45305. protected _projectionTextureLightNear: number;
  45306. /**
  45307. * Gets the near clip of the Spotlight for texture projection.
  45308. */
  45309. /**
  45310. * Sets the near clip of the Spotlight for texture projection.
  45311. */
  45312. projectionTextureLightNear: number;
  45313. protected _projectionTextureLightFar: number;
  45314. /**
  45315. * Gets the far clip of the Spotlight for texture projection.
  45316. */
  45317. /**
  45318. * Sets the far clip of the Spotlight for texture projection.
  45319. */
  45320. projectionTextureLightFar: number;
  45321. protected _projectionTextureUpDirection: Vector3;
  45322. /**
  45323. * Gets the Up vector of the Spotlight for texture projection.
  45324. */
  45325. /**
  45326. * Sets the Up vector of the Spotlight for texture projection.
  45327. */
  45328. projectionTextureUpDirection: Vector3;
  45329. private _projectionTexture;
  45330. /**
  45331. * Gets the projection texture of the light.
  45332. */
  45333. /**
  45334. * Sets the projection texture of the light.
  45335. */
  45336. projectionTexture: Nullable<BaseTexture>;
  45337. private _projectionTextureViewLightDirty;
  45338. private _projectionTextureProjectionLightDirty;
  45339. private _projectionTextureDirty;
  45340. private _projectionTextureViewTargetVector;
  45341. private _projectionTextureViewLightMatrix;
  45342. private _projectionTextureProjectionLightMatrix;
  45343. private _projectionTextureScalingMatrix;
  45344. /**
  45345. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45346. * It can cast shadows.
  45347. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45348. * @param name The light friendly name
  45349. * @param position The position of the spot light in the scene
  45350. * @param direction The direction of the light in the scene
  45351. * @param angle The cone angle of the light in Radians
  45352. * @param exponent The light decay speed with the distance from the emission spot
  45353. * @param scene The scene the lights belongs to
  45354. */
  45355. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45356. /**
  45357. * Returns the string "SpotLight".
  45358. * @returns the class name
  45359. */
  45360. getClassName(): string;
  45361. /**
  45362. * Returns the integer 2.
  45363. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45364. */
  45365. getTypeID(): number;
  45366. /**
  45367. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45368. */
  45369. protected _setDirection(value: Vector3): void;
  45370. /**
  45371. * Overrides the position setter to recompute the projection texture view light Matrix.
  45372. */
  45373. protected _setPosition(value: Vector3): void;
  45374. /**
  45375. * 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.
  45376. * Returns the SpotLight.
  45377. */
  45378. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45379. protected _computeProjectionTextureViewLightMatrix(): void;
  45380. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45381. /**
  45382. * Main function for light texture projection matrix computing.
  45383. */
  45384. protected _computeProjectionTextureMatrix(): void;
  45385. protected _buildUniformLayout(): void;
  45386. private _computeAngleValues;
  45387. /**
  45388. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45389. * @param effect The effect to update
  45390. * @param lightIndex The index of the light in the effect to update
  45391. * @returns The spot light
  45392. */
  45393. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45394. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45395. /**
  45396. * Disposes the light and the associated resources.
  45397. */
  45398. dispose(): void;
  45399. /**
  45400. * Prepares the list of defines specific to the light type.
  45401. * @param defines the list of defines
  45402. * @param lightIndex defines the index of the light for the effect
  45403. */
  45404. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45405. }
  45406. }
  45407. declare module BABYLON {
  45408. /**
  45409. * Gizmo that enables viewing a light
  45410. */
  45411. export class LightGizmo extends Gizmo {
  45412. private _lightMesh;
  45413. private _material;
  45414. private cachedPosition;
  45415. private cachedForward;
  45416. /**
  45417. * Creates a LightGizmo
  45418. * @param gizmoLayer The utility layer the gizmo will be added to
  45419. */
  45420. constructor(gizmoLayer?: UtilityLayerRenderer);
  45421. private _light;
  45422. /**
  45423. * The light that the gizmo is attached to
  45424. */
  45425. light: Nullable<Light>;
  45426. /**
  45427. * Gets the material used to render the light gizmo
  45428. */
  45429. readonly material: StandardMaterial;
  45430. /**
  45431. * @hidden
  45432. * Updates the gizmo to match the attached mesh's position/rotation
  45433. */
  45434. protected _update(): void;
  45435. private static _Scale;
  45436. /**
  45437. * Creates the lines for a light mesh
  45438. */
  45439. private static _createLightLines;
  45440. /**
  45441. * Disposes of the light gizmo
  45442. */
  45443. dispose(): void;
  45444. private static _CreateHemisphericLightMesh;
  45445. private static _CreatePointLightMesh;
  45446. private static _CreateSpotLightMesh;
  45447. private static _CreateDirectionalLightMesh;
  45448. }
  45449. }
  45450. declare module BABYLON {
  45451. /** @hidden */
  45452. export var backgroundFragmentDeclaration: {
  45453. name: string;
  45454. shader: string;
  45455. };
  45456. }
  45457. declare module BABYLON {
  45458. /** @hidden */
  45459. export var backgroundUboDeclaration: {
  45460. name: string;
  45461. shader: string;
  45462. };
  45463. }
  45464. declare module BABYLON {
  45465. /** @hidden */
  45466. export var backgroundPixelShader: {
  45467. name: string;
  45468. shader: string;
  45469. };
  45470. }
  45471. declare module BABYLON {
  45472. /** @hidden */
  45473. export var backgroundVertexDeclaration: {
  45474. name: string;
  45475. shader: string;
  45476. };
  45477. }
  45478. declare module BABYLON {
  45479. /** @hidden */
  45480. export var backgroundVertexShader: {
  45481. name: string;
  45482. shader: string;
  45483. };
  45484. }
  45485. declare module BABYLON {
  45486. /**
  45487. * Background material used to create an efficient environement around your scene.
  45488. */
  45489. export class BackgroundMaterial extends PushMaterial {
  45490. /**
  45491. * Standard reflectance value at parallel view angle.
  45492. */
  45493. static StandardReflectance0: number;
  45494. /**
  45495. * Standard reflectance value at grazing angle.
  45496. */
  45497. static StandardReflectance90: number;
  45498. protected _primaryColor: Color3;
  45499. /**
  45500. * Key light Color (multiply against the environement texture)
  45501. */
  45502. primaryColor: Color3;
  45503. protected __perceptualColor: Nullable<Color3>;
  45504. /**
  45505. * Experimental Internal Use Only.
  45506. *
  45507. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45508. * This acts as a helper to set the primary color to a more "human friendly" value.
  45509. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45510. * output color as close as possible from the chosen value.
  45511. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45512. * part of lighting setup.)
  45513. */ private _perceptualColor: Nullable<Color3>;
  45514. protected _primaryColorShadowLevel: float;
  45515. /**
  45516. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45517. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45518. */
  45519. primaryColorShadowLevel: float;
  45520. protected _primaryColorHighlightLevel: float;
  45521. /**
  45522. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45523. * The primary color is used at the level chosen to define what the white area would look.
  45524. */
  45525. primaryColorHighlightLevel: float;
  45526. protected _reflectionTexture: Nullable<BaseTexture>;
  45527. /**
  45528. * Reflection Texture used in the material.
  45529. * Should be author in a specific way for the best result (refer to the documentation).
  45530. */
  45531. reflectionTexture: Nullable<BaseTexture>;
  45532. protected _reflectionBlur: float;
  45533. /**
  45534. * Reflection Texture level of blur.
  45535. *
  45536. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45537. * texture twice.
  45538. */
  45539. reflectionBlur: float;
  45540. protected _diffuseTexture: Nullable<BaseTexture>;
  45541. /**
  45542. * Diffuse Texture used in the material.
  45543. * Should be author in a specific way for the best result (refer to the documentation).
  45544. */
  45545. diffuseTexture: Nullable<BaseTexture>;
  45546. protected _shadowLights: Nullable<IShadowLight[]>;
  45547. /**
  45548. * Specify the list of lights casting shadow on the material.
  45549. * All scene shadow lights will be included if null.
  45550. */
  45551. shadowLights: Nullable<IShadowLight[]>;
  45552. protected _shadowLevel: float;
  45553. /**
  45554. * Helps adjusting the shadow to a softer level if required.
  45555. * 0 means black shadows and 1 means no shadows.
  45556. */
  45557. shadowLevel: float;
  45558. protected _sceneCenter: Vector3;
  45559. /**
  45560. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45561. * It is usually zero but might be interesting to modify according to your setup.
  45562. */
  45563. sceneCenter: Vector3;
  45564. protected _opacityFresnel: boolean;
  45565. /**
  45566. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45567. * This helps ensuring a nice transition when the camera goes under the ground.
  45568. */
  45569. opacityFresnel: boolean;
  45570. protected _reflectionFresnel: boolean;
  45571. /**
  45572. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45573. * This helps adding a mirror texture on the ground.
  45574. */
  45575. reflectionFresnel: boolean;
  45576. protected _reflectionFalloffDistance: number;
  45577. /**
  45578. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45579. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45580. */
  45581. reflectionFalloffDistance: number;
  45582. protected _reflectionAmount: number;
  45583. /**
  45584. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45585. */
  45586. reflectionAmount: number;
  45587. protected _reflectionReflectance0: number;
  45588. /**
  45589. * This specifies the weight of the reflection at grazing angle.
  45590. */
  45591. reflectionReflectance0: number;
  45592. protected _reflectionReflectance90: number;
  45593. /**
  45594. * This specifies the weight of the reflection at a perpendicular point of view.
  45595. */
  45596. reflectionReflectance90: number;
  45597. /**
  45598. * Sets the reflection reflectance fresnel values according to the default standard
  45599. * empirically know to work well :-)
  45600. */
  45601. reflectionStandardFresnelWeight: number;
  45602. protected _useRGBColor: boolean;
  45603. /**
  45604. * Helps to directly use the maps channels instead of their level.
  45605. */
  45606. useRGBColor: boolean;
  45607. protected _enableNoise: boolean;
  45608. /**
  45609. * This helps reducing the banding effect that could occur on the background.
  45610. */
  45611. enableNoise: boolean;
  45612. /**
  45613. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45614. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45615. * Recommended to be keep at 1.0 except for special cases.
  45616. */
  45617. fovMultiplier: number;
  45618. private _fovMultiplier;
  45619. /**
  45620. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45621. */
  45622. useEquirectangularFOV: boolean;
  45623. private _maxSimultaneousLights;
  45624. /**
  45625. * Number of Simultaneous lights allowed on the material.
  45626. */
  45627. maxSimultaneousLights: int;
  45628. /**
  45629. * Default configuration related to image processing available in the Background Material.
  45630. */
  45631. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45632. /**
  45633. * Keep track of the image processing observer to allow dispose and replace.
  45634. */
  45635. private _imageProcessingObserver;
  45636. /**
  45637. * Attaches a new image processing configuration to the PBR Material.
  45638. * @param configuration (if null the scene configuration will be use)
  45639. */
  45640. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45641. /**
  45642. * Gets the image processing configuration used either in this material.
  45643. */
  45644. /**
  45645. * Sets the Default image processing configuration used either in the this material.
  45646. *
  45647. * If sets to null, the scene one is in use.
  45648. */
  45649. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45650. /**
  45651. * Gets wether the color curves effect is enabled.
  45652. */
  45653. /**
  45654. * Sets wether the color curves effect is enabled.
  45655. */
  45656. cameraColorCurvesEnabled: boolean;
  45657. /**
  45658. * Gets wether the color grading effect is enabled.
  45659. */
  45660. /**
  45661. * Gets wether the color grading effect is enabled.
  45662. */
  45663. cameraColorGradingEnabled: boolean;
  45664. /**
  45665. * Gets wether tonemapping is enabled or not.
  45666. */
  45667. /**
  45668. * Sets wether tonemapping is enabled or not
  45669. */
  45670. cameraToneMappingEnabled: boolean;
  45671. /**
  45672. * The camera exposure used on this material.
  45673. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45674. * This corresponds to a photographic exposure.
  45675. */
  45676. /**
  45677. * The camera exposure used on this material.
  45678. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45679. * This corresponds to a photographic exposure.
  45680. */
  45681. cameraExposure: float;
  45682. /**
  45683. * Gets The camera contrast used on this material.
  45684. */
  45685. /**
  45686. * Sets The camera contrast used on this material.
  45687. */
  45688. cameraContrast: float;
  45689. /**
  45690. * Gets the Color Grading 2D Lookup Texture.
  45691. */
  45692. /**
  45693. * Sets the Color Grading 2D Lookup Texture.
  45694. */
  45695. cameraColorGradingTexture: Nullable<BaseTexture>;
  45696. /**
  45697. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45698. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45699. * 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;
  45700. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45701. */
  45702. /**
  45703. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45704. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45705. * 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;
  45706. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45707. */
  45708. cameraColorCurves: Nullable<ColorCurves>;
  45709. /**
  45710. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45711. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45712. */
  45713. switchToBGR: boolean;
  45714. private _renderTargets;
  45715. private _reflectionControls;
  45716. private _white;
  45717. private _primaryShadowColor;
  45718. private _primaryHighlightColor;
  45719. /**
  45720. * Instantiates a Background Material in the given scene
  45721. * @param name The friendly name of the material
  45722. * @param scene The scene to add the material to
  45723. */
  45724. constructor(name: string, scene: Scene);
  45725. /**
  45726. * Gets a boolean indicating that current material needs to register RTT
  45727. */
  45728. readonly hasRenderTargetTextures: boolean;
  45729. /**
  45730. * The entire material has been created in order to prevent overdraw.
  45731. * @returns false
  45732. */
  45733. needAlphaTesting(): boolean;
  45734. /**
  45735. * The entire material has been created in order to prevent overdraw.
  45736. * @returns true if blending is enable
  45737. */
  45738. needAlphaBlending(): boolean;
  45739. /**
  45740. * Checks wether the material is ready to be rendered for a given mesh.
  45741. * @param mesh The mesh to render
  45742. * @param subMesh The submesh to check against
  45743. * @param useInstances Specify wether or not the material is used with instances
  45744. * @returns true if all the dependencies are ready (Textures, Effects...)
  45745. */
  45746. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45747. /**
  45748. * Compute the primary color according to the chosen perceptual color.
  45749. */
  45750. private _computePrimaryColorFromPerceptualColor;
  45751. /**
  45752. * Compute the highlights and shadow colors according to their chosen levels.
  45753. */
  45754. private _computePrimaryColors;
  45755. /**
  45756. * Build the uniform buffer used in the material.
  45757. */
  45758. buildUniformLayout(): void;
  45759. /**
  45760. * Unbind the material.
  45761. */
  45762. unbind(): void;
  45763. /**
  45764. * Bind only the world matrix to the material.
  45765. * @param world The world matrix to bind.
  45766. */
  45767. bindOnlyWorldMatrix(world: Matrix): void;
  45768. /**
  45769. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45770. * @param world The world matrix to bind.
  45771. * @param subMesh The submesh to bind for.
  45772. */
  45773. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45774. /**
  45775. * Checks to see if a texture is used in the material.
  45776. * @param texture - Base texture to use.
  45777. * @returns - Boolean specifying if a texture is used in the material.
  45778. */
  45779. hasTexture(texture: BaseTexture): boolean;
  45780. /**
  45781. * Dispose the material.
  45782. * @param forceDisposeEffect Force disposal of the associated effect.
  45783. * @param forceDisposeTextures Force disposal of the associated textures.
  45784. */
  45785. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45786. /**
  45787. * Clones the material.
  45788. * @param name The cloned name.
  45789. * @returns The cloned material.
  45790. */
  45791. clone(name: string): BackgroundMaterial;
  45792. /**
  45793. * Serializes the current material to its JSON representation.
  45794. * @returns The JSON representation.
  45795. */
  45796. serialize(): any;
  45797. /**
  45798. * Gets the class name of the material
  45799. * @returns "BackgroundMaterial"
  45800. */
  45801. getClassName(): string;
  45802. /**
  45803. * Parse a JSON input to create back a background material.
  45804. * @param source The JSON data to parse
  45805. * @param scene The scene to create the parsed material in
  45806. * @param rootUrl The root url of the assets the material depends upon
  45807. * @returns the instantiated BackgroundMaterial.
  45808. */
  45809. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45810. }
  45811. }
  45812. declare module BABYLON {
  45813. /**
  45814. * Represents the different options available during the creation of
  45815. * a Environment helper.
  45816. *
  45817. * This can control the default ground, skybox and image processing setup of your scene.
  45818. */
  45819. export interface IEnvironmentHelperOptions {
  45820. /**
  45821. * Specifies wether or not to create a ground.
  45822. * True by default.
  45823. */
  45824. createGround: boolean;
  45825. /**
  45826. * Specifies the ground size.
  45827. * 15 by default.
  45828. */
  45829. groundSize: number;
  45830. /**
  45831. * The texture used on the ground for the main color.
  45832. * Comes from the BabylonJS CDN by default.
  45833. *
  45834. * Remarks: Can be either a texture or a url.
  45835. */
  45836. groundTexture: string | BaseTexture;
  45837. /**
  45838. * The color mixed in the ground texture by default.
  45839. * BabylonJS clearColor by default.
  45840. */
  45841. groundColor: Color3;
  45842. /**
  45843. * Specifies the ground opacity.
  45844. * 1 by default.
  45845. */
  45846. groundOpacity: number;
  45847. /**
  45848. * Enables the ground to receive shadows.
  45849. * True by default.
  45850. */
  45851. enableGroundShadow: boolean;
  45852. /**
  45853. * Helps preventing the shadow to be fully black on the ground.
  45854. * 0.5 by default.
  45855. */
  45856. groundShadowLevel: number;
  45857. /**
  45858. * Creates a mirror texture attach to the ground.
  45859. * false by default.
  45860. */
  45861. enableGroundMirror: boolean;
  45862. /**
  45863. * Specifies the ground mirror size ratio.
  45864. * 0.3 by default as the default kernel is 64.
  45865. */
  45866. groundMirrorSizeRatio: number;
  45867. /**
  45868. * Specifies the ground mirror blur kernel size.
  45869. * 64 by default.
  45870. */
  45871. groundMirrorBlurKernel: number;
  45872. /**
  45873. * Specifies the ground mirror visibility amount.
  45874. * 1 by default
  45875. */
  45876. groundMirrorAmount: number;
  45877. /**
  45878. * Specifies the ground mirror reflectance weight.
  45879. * This uses the standard weight of the background material to setup the fresnel effect
  45880. * of the mirror.
  45881. * 1 by default.
  45882. */
  45883. groundMirrorFresnelWeight: number;
  45884. /**
  45885. * Specifies the ground mirror Falloff distance.
  45886. * This can helps reducing the size of the reflection.
  45887. * 0 by Default.
  45888. */
  45889. groundMirrorFallOffDistance: number;
  45890. /**
  45891. * Specifies the ground mirror texture type.
  45892. * Unsigned Int by Default.
  45893. */
  45894. groundMirrorTextureType: number;
  45895. /**
  45896. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45897. * the shown objects.
  45898. */
  45899. groundYBias: number;
  45900. /**
  45901. * Specifies wether or not to create a skybox.
  45902. * True by default.
  45903. */
  45904. createSkybox: boolean;
  45905. /**
  45906. * Specifies the skybox size.
  45907. * 20 by default.
  45908. */
  45909. skyboxSize: number;
  45910. /**
  45911. * The texture used on the skybox for the main color.
  45912. * Comes from the BabylonJS CDN by default.
  45913. *
  45914. * Remarks: Can be either a texture or a url.
  45915. */
  45916. skyboxTexture: string | BaseTexture;
  45917. /**
  45918. * The color mixed in the skybox texture by default.
  45919. * BabylonJS clearColor by default.
  45920. */
  45921. skyboxColor: Color3;
  45922. /**
  45923. * The background rotation around the Y axis of the scene.
  45924. * This helps aligning the key lights of your scene with the background.
  45925. * 0 by default.
  45926. */
  45927. backgroundYRotation: number;
  45928. /**
  45929. * Compute automatically the size of the elements to best fit with the scene.
  45930. */
  45931. sizeAuto: boolean;
  45932. /**
  45933. * Default position of the rootMesh if autoSize is not true.
  45934. */
  45935. rootPosition: Vector3;
  45936. /**
  45937. * Sets up the image processing in the scene.
  45938. * true by default.
  45939. */
  45940. setupImageProcessing: boolean;
  45941. /**
  45942. * The texture used as your environment texture in the scene.
  45943. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45944. *
  45945. * Remarks: Can be either a texture or a url.
  45946. */
  45947. environmentTexture: string | BaseTexture;
  45948. /**
  45949. * The value of the exposure to apply to the scene.
  45950. * 0.6 by default if setupImageProcessing is true.
  45951. */
  45952. cameraExposure: number;
  45953. /**
  45954. * The value of the contrast to apply to the scene.
  45955. * 1.6 by default if setupImageProcessing is true.
  45956. */
  45957. cameraContrast: number;
  45958. /**
  45959. * Specifies wether or not tonemapping should be enabled in the scene.
  45960. * true by default if setupImageProcessing is true.
  45961. */
  45962. toneMappingEnabled: boolean;
  45963. }
  45964. /**
  45965. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45966. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45967. * It also helps with the default setup of your imageProcessing configuration.
  45968. */
  45969. export class EnvironmentHelper {
  45970. /**
  45971. * Default ground texture URL.
  45972. */
  45973. private static _groundTextureCDNUrl;
  45974. /**
  45975. * Default skybox texture URL.
  45976. */
  45977. private static _skyboxTextureCDNUrl;
  45978. /**
  45979. * Default environment texture URL.
  45980. */
  45981. private static _environmentTextureCDNUrl;
  45982. /**
  45983. * Creates the default options for the helper.
  45984. */
  45985. private static _getDefaultOptions;
  45986. private _rootMesh;
  45987. /**
  45988. * Gets the root mesh created by the helper.
  45989. */
  45990. readonly rootMesh: Mesh;
  45991. private _skybox;
  45992. /**
  45993. * Gets the skybox created by the helper.
  45994. */
  45995. readonly skybox: Nullable<Mesh>;
  45996. private _skyboxTexture;
  45997. /**
  45998. * Gets the skybox texture created by the helper.
  45999. */
  46000. readonly skyboxTexture: Nullable<BaseTexture>;
  46001. private _skyboxMaterial;
  46002. /**
  46003. * Gets the skybox material created by the helper.
  46004. */
  46005. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46006. private _ground;
  46007. /**
  46008. * Gets the ground mesh created by the helper.
  46009. */
  46010. readonly ground: Nullable<Mesh>;
  46011. private _groundTexture;
  46012. /**
  46013. * Gets the ground texture created by the helper.
  46014. */
  46015. readonly groundTexture: Nullable<BaseTexture>;
  46016. private _groundMirror;
  46017. /**
  46018. * Gets the ground mirror created by the helper.
  46019. */
  46020. readonly groundMirror: Nullable<MirrorTexture>;
  46021. /**
  46022. * Gets the ground mirror render list to helps pushing the meshes
  46023. * you wish in the ground reflection.
  46024. */
  46025. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46026. private _groundMaterial;
  46027. /**
  46028. * Gets the ground material created by the helper.
  46029. */
  46030. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46031. /**
  46032. * Stores the creation options.
  46033. */
  46034. private readonly _scene;
  46035. private _options;
  46036. /**
  46037. * This observable will be notified with any error during the creation of the environment,
  46038. * mainly texture creation errors.
  46039. */
  46040. onErrorObservable: Observable<{
  46041. message?: string;
  46042. exception?: any;
  46043. }>;
  46044. /**
  46045. * constructor
  46046. * @param options Defines the options we want to customize the helper
  46047. * @param scene The scene to add the material to
  46048. */
  46049. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46050. /**
  46051. * Updates the background according to the new options
  46052. * @param options
  46053. */
  46054. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46055. /**
  46056. * Sets the primary color of all the available elements.
  46057. * @param color the main color to affect to the ground and the background
  46058. */
  46059. setMainColor(color: Color3): void;
  46060. /**
  46061. * Setup the image processing according to the specified options.
  46062. */
  46063. private _setupImageProcessing;
  46064. /**
  46065. * Setup the environment texture according to the specified options.
  46066. */
  46067. private _setupEnvironmentTexture;
  46068. /**
  46069. * Setup the background according to the specified options.
  46070. */
  46071. private _setupBackground;
  46072. /**
  46073. * Get the scene sizes according to the setup.
  46074. */
  46075. private _getSceneSize;
  46076. /**
  46077. * Setup the ground according to the specified options.
  46078. */
  46079. private _setupGround;
  46080. /**
  46081. * Setup the ground material according to the specified options.
  46082. */
  46083. private _setupGroundMaterial;
  46084. /**
  46085. * Setup the ground diffuse texture according to the specified options.
  46086. */
  46087. private _setupGroundDiffuseTexture;
  46088. /**
  46089. * Setup the ground mirror texture according to the specified options.
  46090. */
  46091. private _setupGroundMirrorTexture;
  46092. /**
  46093. * Setup the ground to receive the mirror texture.
  46094. */
  46095. private _setupMirrorInGroundMaterial;
  46096. /**
  46097. * Setup the skybox according to the specified options.
  46098. */
  46099. private _setupSkybox;
  46100. /**
  46101. * Setup the skybox material according to the specified options.
  46102. */
  46103. private _setupSkyboxMaterial;
  46104. /**
  46105. * Setup the skybox reflection texture according to the specified options.
  46106. */
  46107. private _setupSkyboxReflectionTexture;
  46108. private _errorHandler;
  46109. /**
  46110. * Dispose all the elements created by the Helper.
  46111. */
  46112. dispose(): void;
  46113. }
  46114. }
  46115. declare module BABYLON {
  46116. /**
  46117. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46118. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46119. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46120. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46121. */
  46122. export class PhotoDome extends TransformNode {
  46123. /**
  46124. * Define the image as a Monoscopic panoramic 360 image.
  46125. */
  46126. static readonly MODE_MONOSCOPIC: number;
  46127. /**
  46128. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46129. */
  46130. static readonly MODE_TOPBOTTOM: number;
  46131. /**
  46132. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46133. */
  46134. static readonly MODE_SIDEBYSIDE: number;
  46135. private _useDirectMapping;
  46136. /**
  46137. * The texture being displayed on the sphere
  46138. */
  46139. protected _photoTexture: Texture;
  46140. /**
  46141. * Gets or sets the texture being displayed on the sphere
  46142. */
  46143. photoTexture: Texture;
  46144. /**
  46145. * Observable raised when an error occured while loading the 360 image
  46146. */
  46147. onLoadErrorObservable: Observable<string>;
  46148. /**
  46149. * The skybox material
  46150. */
  46151. protected _material: BackgroundMaterial;
  46152. /**
  46153. * The surface used for the skybox
  46154. */
  46155. protected _mesh: Mesh;
  46156. /**
  46157. * Gets the mesh used for the skybox.
  46158. */
  46159. readonly mesh: Mesh;
  46160. /**
  46161. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46162. * Also see the options.resolution property.
  46163. */
  46164. fovMultiplier: number;
  46165. private _imageMode;
  46166. /**
  46167. * Gets or set the current video mode for the video. It can be:
  46168. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46169. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46170. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46171. */
  46172. imageMode: number;
  46173. /**
  46174. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46175. * @param name Element's name, child elements will append suffixes for their own names.
  46176. * @param urlsOfPhoto defines the url of the photo to display
  46177. * @param options defines an object containing optional or exposed sub element properties
  46178. * @param onError defines a callback called when an error occured while loading the texture
  46179. */
  46180. constructor(name: string, urlOfPhoto: string, options: {
  46181. resolution?: number;
  46182. size?: number;
  46183. useDirectMapping?: boolean;
  46184. faceForward?: boolean;
  46185. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46186. private _onBeforeCameraRenderObserver;
  46187. private _changeImageMode;
  46188. /**
  46189. * Releases resources associated with this node.
  46190. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46191. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46192. */
  46193. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46194. }
  46195. }
  46196. declare module BABYLON {
  46197. /**
  46198. * Class used to host RGBD texture specific utilities
  46199. */
  46200. export class RGBDTextureTools {
  46201. /**
  46202. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46203. * @param texture the texture to expand.
  46204. */
  46205. static ExpandRGBDTexture(texture: Texture): void;
  46206. }
  46207. }
  46208. declare module BABYLON {
  46209. /**
  46210. * Class used to host texture specific utilities
  46211. */
  46212. export class BRDFTextureTools {
  46213. /**
  46214. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46215. * @param scene defines the hosting scene
  46216. * @returns the environment BRDF texture
  46217. */
  46218. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46219. private static _environmentBRDFBase64Texture;
  46220. }
  46221. }
  46222. declare module BABYLON {
  46223. /**
  46224. * @hidden
  46225. */
  46226. export interface IMaterialClearCoatDefines {
  46227. CLEARCOAT: boolean;
  46228. CLEARCOAT_DEFAULTIOR: boolean;
  46229. CLEARCOAT_TEXTURE: boolean;
  46230. CLEARCOAT_TEXTUREDIRECTUV: number;
  46231. CLEARCOAT_BUMP: boolean;
  46232. CLEARCOAT_BUMPDIRECTUV: number;
  46233. CLEARCOAT_TINT: boolean;
  46234. CLEARCOAT_TINT_TEXTURE: boolean;
  46235. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46236. /** @hidden */ private _areTexturesDirty: boolean;
  46237. }
  46238. /**
  46239. * Define the code related to the clear coat parameters of the pbr material.
  46240. */
  46241. export class PBRClearCoatConfiguration {
  46242. /**
  46243. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46244. * The default fits with a polyurethane material.
  46245. */
  46246. private static readonly _DefaultIndexOfRefraction;
  46247. private _isEnabled;
  46248. /**
  46249. * Defines if the clear coat is enabled in the material.
  46250. */
  46251. isEnabled: boolean;
  46252. /**
  46253. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46254. */
  46255. intensity: number;
  46256. /**
  46257. * Defines the clear coat layer roughness.
  46258. */
  46259. roughness: number;
  46260. private _indexOfRefraction;
  46261. /**
  46262. * Defines the index of refraction of the clear coat.
  46263. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46264. * The default fits with a polyurethane material.
  46265. * Changing the default value is more performance intensive.
  46266. */
  46267. indexOfRefraction: number;
  46268. private _texture;
  46269. /**
  46270. * Stores the clear coat values in a texture.
  46271. */
  46272. texture: Nullable<BaseTexture>;
  46273. private _bumpTexture;
  46274. /**
  46275. * Define the clear coat specific bump texture.
  46276. */
  46277. bumpTexture: Nullable<BaseTexture>;
  46278. private _isTintEnabled;
  46279. /**
  46280. * Defines if the clear coat tint is enabled in the material.
  46281. */
  46282. isTintEnabled: boolean;
  46283. /**
  46284. * Defines the clear coat tint of the material.
  46285. * This is only use if tint is enabled
  46286. */
  46287. tintColor: Color3;
  46288. /**
  46289. * Defines the distance at which the tint color should be found in the
  46290. * clear coat media.
  46291. * This is only use if tint is enabled
  46292. */
  46293. tintColorAtDistance: number;
  46294. /**
  46295. * Defines the clear coat layer thickness.
  46296. * This is only use if tint is enabled
  46297. */
  46298. tintThickness: number;
  46299. private _tintTexture;
  46300. /**
  46301. * Stores the clear tint values in a texture.
  46302. * rgb is tint
  46303. * a is a thickness factor
  46304. */
  46305. tintTexture: Nullable<BaseTexture>;
  46306. /** @hidden */
  46307. private _internalMarkAllSubMeshesAsTexturesDirty;
  46308. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46309. /**
  46310. * Instantiate a new istance of clear coat configuration.
  46311. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46312. */
  46313. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46314. /**
  46315. * Gets wehter the submesh is ready to be used or not.
  46316. * @param defines the list of "defines" to update.
  46317. * @param scene defines the scene the material belongs to.
  46318. * @param engine defines the engine the material belongs to.
  46319. * @param disableBumpMap defines wether the material disables bump or not.
  46320. * @returns - boolean indicating that the submesh is ready or not.
  46321. */
  46322. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46323. /**
  46324. * Checks to see if a texture is used in the material.
  46325. * @param defines the list of "defines" to update.
  46326. * @param scene defines the scene to the material belongs to.
  46327. */
  46328. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46329. /**
  46330. * Binds the material data.
  46331. * @param uniformBuffer defines the Uniform buffer to fill in.
  46332. * @param scene defines the scene the material belongs to.
  46333. * @param engine defines the engine the material belongs to.
  46334. * @param disableBumpMap defines wether the material disables bump or not.
  46335. * @param isFrozen defines wether the material is frozen or not.
  46336. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46337. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46338. */
  46339. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46340. /**
  46341. * Checks to see if a texture is used in the material.
  46342. * @param texture - Base texture to use.
  46343. * @returns - Boolean specifying if a texture is used in the material.
  46344. */
  46345. hasTexture(texture: BaseTexture): boolean;
  46346. /**
  46347. * Returns an array of the actively used textures.
  46348. * @param activeTextures Array of BaseTextures
  46349. */
  46350. getActiveTextures(activeTextures: BaseTexture[]): void;
  46351. /**
  46352. * Returns the animatable textures.
  46353. * @param animatables Array of animatable textures.
  46354. */
  46355. getAnimatables(animatables: IAnimatable[]): void;
  46356. /**
  46357. * Disposes the resources of the material.
  46358. * @param forceDisposeTextures - Forces the disposal of all textures.
  46359. */
  46360. dispose(forceDisposeTextures?: boolean): void;
  46361. /**
  46362. * Get the current class name of the texture useful for serialization or dynamic coding.
  46363. * @returns "PBRClearCoatConfiguration"
  46364. */
  46365. getClassName(): string;
  46366. /**
  46367. * Add fallbacks to the effect fallbacks list.
  46368. * @param defines defines the Base texture to use.
  46369. * @param fallbacks defines the current fallback list.
  46370. * @param currentRank defines the current fallback rank.
  46371. * @returns the new fallback rank.
  46372. */
  46373. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46374. /**
  46375. * Add the required uniforms to the current list.
  46376. * @param uniforms defines the current uniform list.
  46377. */
  46378. static AddUniforms(uniforms: string[]): void;
  46379. /**
  46380. * Add the required samplers to the current list.
  46381. * @param samplers defines the current sampler list.
  46382. */
  46383. static AddSamplers(samplers: string[]): void;
  46384. /**
  46385. * Add the required uniforms to the current buffer.
  46386. * @param uniformBuffer defines the current uniform buffer.
  46387. */
  46388. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46389. /**
  46390. * Makes a duplicate of the current configuration into another one.
  46391. * @param clearCoatConfiguration define the config where to copy the info
  46392. */
  46393. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46394. /**
  46395. * Serializes this clear coat configuration.
  46396. * @returns - An object with the serialized config.
  46397. */
  46398. serialize(): any;
  46399. /**
  46400. * Parses a anisotropy Configuration from a serialized object.
  46401. * @param source - Serialized object.
  46402. * @param scene Defines the scene we are parsing for
  46403. * @param rootUrl Defines the rootUrl to load from
  46404. */
  46405. parse(source: any, scene: Scene, rootUrl: string): void;
  46406. }
  46407. }
  46408. declare module BABYLON {
  46409. /**
  46410. * @hidden
  46411. */
  46412. export interface IMaterialAnisotropicDefines {
  46413. ANISOTROPIC: boolean;
  46414. ANISOTROPIC_TEXTURE: boolean;
  46415. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46416. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  46417. }
  46418. /**
  46419. * Define the code related to the anisotropic parameters of the pbr material.
  46420. */
  46421. export class PBRAnisotropicConfiguration {
  46422. private _isEnabled;
  46423. /**
  46424. * Defines if the anisotropy is enabled in the material.
  46425. */
  46426. isEnabled: boolean;
  46427. /**
  46428. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46429. */
  46430. intensity: number;
  46431. /**
  46432. * Defines if the effect is along the tangents, bitangents or in between.
  46433. * By default, the effect is "strectching" the highlights along the tangents.
  46434. */
  46435. direction: Vector2;
  46436. private _texture;
  46437. /**
  46438. * Stores the anisotropy values in a texture.
  46439. * rg is direction (like normal from -1 to 1)
  46440. * b is a intensity
  46441. */
  46442. texture: Nullable<BaseTexture>;
  46443. /** @hidden */
  46444. private _internalMarkAllSubMeshesAsTexturesDirty;
  46445. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46446. /**
  46447. * Instantiate a new istance of anisotropy configuration.
  46448. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46449. */
  46450. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46451. /**
  46452. * Specifies that the submesh is ready to be used.
  46453. * @param defines the list of "defines" to update.
  46454. * @param scene defines the scene the material belongs to.
  46455. * @returns - boolean indicating that the submesh is ready or not.
  46456. */
  46457. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46458. /**
  46459. * Checks to see if a texture is used in the material.
  46460. * @param defines the list of "defines" to update.
  46461. * @param mesh the mesh we are preparing the defines for.
  46462. * @param scene defines the scene the material belongs to.
  46463. */
  46464. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46465. /**
  46466. * Binds the material data.
  46467. * @param uniformBuffer defines the Uniform buffer to fill in.
  46468. * @param scene defines the scene the material belongs to.
  46469. * @param isFrozen defines wether the material is frozen or not.
  46470. */
  46471. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46472. /**
  46473. * Checks to see if a texture is used in the material.
  46474. * @param texture - Base texture to use.
  46475. * @returns - Boolean specifying if a texture is used in the material.
  46476. */
  46477. hasTexture(texture: BaseTexture): boolean;
  46478. /**
  46479. * Returns an array of the actively used textures.
  46480. * @param activeTextures Array of BaseTextures
  46481. */
  46482. getActiveTextures(activeTextures: BaseTexture[]): void;
  46483. /**
  46484. * Returns the animatable textures.
  46485. * @param animatables Array of animatable textures.
  46486. */
  46487. getAnimatables(animatables: IAnimatable[]): void;
  46488. /**
  46489. * Disposes the resources of the material.
  46490. * @param forceDisposeTextures - Forces the disposal of all textures.
  46491. */
  46492. dispose(forceDisposeTextures?: boolean): void;
  46493. /**
  46494. * Get the current class name of the texture useful for serialization or dynamic coding.
  46495. * @returns "PBRAnisotropicConfiguration"
  46496. */
  46497. getClassName(): string;
  46498. /**
  46499. * Add fallbacks to the effect fallbacks list.
  46500. * @param defines defines the Base texture to use.
  46501. * @param fallbacks defines the current fallback list.
  46502. * @param currentRank defines the current fallback rank.
  46503. * @returns the new fallback rank.
  46504. */
  46505. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46506. /**
  46507. * Add the required uniforms to the current list.
  46508. * @param uniforms defines the current uniform list.
  46509. */
  46510. static AddUniforms(uniforms: string[]): void;
  46511. /**
  46512. * Add the required uniforms to the current buffer.
  46513. * @param uniformBuffer defines the current uniform buffer.
  46514. */
  46515. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46516. /**
  46517. * Add the required samplers to the current list.
  46518. * @param samplers defines the current sampler list.
  46519. */
  46520. static AddSamplers(samplers: string[]): void;
  46521. /**
  46522. * Makes a duplicate of the current configuration into another one.
  46523. * @param anisotropicConfiguration define the config where to copy the info
  46524. */
  46525. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46526. /**
  46527. * Serializes this anisotropy configuration.
  46528. * @returns - An object with the serialized config.
  46529. */
  46530. serialize(): any;
  46531. /**
  46532. * Parses a anisotropy Configuration from a serialized object.
  46533. * @param source - Serialized object.
  46534. * @param scene Defines the scene we are parsing for
  46535. * @param rootUrl Defines the rootUrl to load from
  46536. */
  46537. parse(source: any, scene: Scene, rootUrl: string): void;
  46538. }
  46539. }
  46540. declare module BABYLON {
  46541. /**
  46542. * @hidden
  46543. */
  46544. export interface IMaterialBRDFDefines {
  46545. BRDF_V_HEIGHT_CORRELATED: boolean;
  46546. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46547. SPHERICAL_HARMONICS: boolean;
  46548. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46549. /** @hidden */ private _areMiscDirty: boolean;
  46550. }
  46551. /**
  46552. * Define the code related to the BRDF parameters of the pbr material.
  46553. */
  46554. export class PBRBRDFConfiguration {
  46555. /**
  46556. * Default value used for the energy conservation.
  46557. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46558. */
  46559. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46560. /**
  46561. * Default value used for the Smith Visibility Height Correlated mode.
  46562. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46563. */
  46564. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46565. /**
  46566. * Default value used for the IBL diffuse part.
  46567. * This can help switching back to the polynomials mode globally which is a tiny bit
  46568. * less GPU intensive at the drawback of a lower quality.
  46569. */
  46570. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46571. /**
  46572. * Default value used for activating energy conservation for the specular workflow.
  46573. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46574. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46575. */
  46576. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46577. private _useEnergyConservation;
  46578. /**
  46579. * Defines if the material uses energy conservation.
  46580. */
  46581. useEnergyConservation: boolean;
  46582. private _useSmithVisibilityHeightCorrelated;
  46583. /**
  46584. * LEGACY Mode set to false
  46585. * Defines if the material uses height smith correlated visibility term.
  46586. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46587. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46588. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46589. * Not relying on height correlated will also disable energy conservation.
  46590. */
  46591. useSmithVisibilityHeightCorrelated: boolean;
  46592. private _useSphericalHarmonics;
  46593. /**
  46594. * LEGACY Mode set to false
  46595. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46596. * diffuse part of the IBL.
  46597. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46598. * to the ground truth.
  46599. */
  46600. useSphericalHarmonics: boolean;
  46601. private _useSpecularGlossinessInputEnergyConservation;
  46602. /**
  46603. * Defines if the material uses energy conservation, when the specular workflow is active.
  46604. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46605. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46606. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46607. */
  46608. useSpecularGlossinessInputEnergyConservation: boolean;
  46609. /** @hidden */
  46610. private _internalMarkAllSubMeshesAsMiscDirty;
  46611. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  46612. /**
  46613. * Instantiate a new istance of clear coat configuration.
  46614. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46615. */
  46616. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46617. /**
  46618. * Checks to see if a texture is used in the material.
  46619. * @param defines the list of "defines" to update.
  46620. */
  46621. prepareDefines(defines: IMaterialBRDFDefines): void;
  46622. /**
  46623. * Get the current class name of the texture useful for serialization or dynamic coding.
  46624. * @returns "PBRClearCoatConfiguration"
  46625. */
  46626. getClassName(): string;
  46627. /**
  46628. * Makes a duplicate of the current configuration into another one.
  46629. * @param brdfConfiguration define the config where to copy the info
  46630. */
  46631. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46632. /**
  46633. * Serializes this BRDF configuration.
  46634. * @returns - An object with the serialized config.
  46635. */
  46636. serialize(): any;
  46637. /**
  46638. * Parses a anisotropy Configuration from a serialized object.
  46639. * @param source - Serialized object.
  46640. * @param scene Defines the scene we are parsing for
  46641. * @param rootUrl Defines the rootUrl to load from
  46642. */
  46643. parse(source: any, scene: Scene, rootUrl: string): void;
  46644. }
  46645. }
  46646. declare module BABYLON {
  46647. /**
  46648. * @hidden
  46649. */
  46650. export interface IMaterialSheenDefines {
  46651. SHEEN: boolean;
  46652. SHEEN_TEXTURE: boolean;
  46653. SHEEN_TEXTUREDIRECTUV: number;
  46654. SHEEN_LINKWITHALBEDO: boolean;
  46655. /** @hidden */ private _areTexturesDirty: boolean;
  46656. }
  46657. /**
  46658. * Define the code related to the Sheen parameters of the pbr material.
  46659. */
  46660. export class PBRSheenConfiguration {
  46661. private _isEnabled;
  46662. /**
  46663. * Defines if the material uses sheen.
  46664. */
  46665. isEnabled: boolean;
  46666. private _linkSheenWithAlbedo;
  46667. /**
  46668. * Defines if the sheen is linked to the sheen color.
  46669. */
  46670. linkSheenWithAlbedo: boolean;
  46671. /**
  46672. * Defines the sheen intensity.
  46673. */
  46674. intensity: number;
  46675. /**
  46676. * Defines the sheen color.
  46677. */
  46678. color: Color3;
  46679. private _texture;
  46680. /**
  46681. * Stores the sheen tint values in a texture.
  46682. * rgb is tint
  46683. * a is a intensity
  46684. */
  46685. texture: Nullable<BaseTexture>;
  46686. /** @hidden */
  46687. private _internalMarkAllSubMeshesAsTexturesDirty;
  46688. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46689. /**
  46690. * Instantiate a new istance of clear coat configuration.
  46691. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46692. */
  46693. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46694. /**
  46695. * Specifies that the submesh is ready to be used.
  46696. * @param defines the list of "defines" to update.
  46697. * @param scene defines the scene the material belongs to.
  46698. * @returns - boolean indicating that the submesh is ready or not.
  46699. */
  46700. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46701. /**
  46702. * Checks to see if a texture is used in the material.
  46703. * @param defines the list of "defines" to update.
  46704. * @param scene defines the scene the material belongs to.
  46705. */
  46706. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46707. /**
  46708. * Binds the material data.
  46709. * @param uniformBuffer defines the Uniform buffer to fill in.
  46710. * @param scene defines the scene the material belongs to.
  46711. * @param isFrozen defines wether the material is frozen or not.
  46712. */
  46713. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46714. /**
  46715. * Checks to see if a texture is used in the material.
  46716. * @param texture - Base texture to use.
  46717. * @returns - Boolean specifying if a texture is used in the material.
  46718. */
  46719. hasTexture(texture: BaseTexture): boolean;
  46720. /**
  46721. * Returns an array of the actively used textures.
  46722. * @param activeTextures Array of BaseTextures
  46723. */
  46724. getActiveTextures(activeTextures: BaseTexture[]): void;
  46725. /**
  46726. * Returns the animatable textures.
  46727. * @param animatables Array of animatable textures.
  46728. */
  46729. getAnimatables(animatables: IAnimatable[]): void;
  46730. /**
  46731. * Disposes the resources of the material.
  46732. * @param forceDisposeTextures - Forces the disposal of all textures.
  46733. */
  46734. dispose(forceDisposeTextures?: boolean): void;
  46735. /**
  46736. * Get the current class name of the texture useful for serialization or dynamic coding.
  46737. * @returns "PBRSheenConfiguration"
  46738. */
  46739. getClassName(): string;
  46740. /**
  46741. * Add fallbacks to the effect fallbacks list.
  46742. * @param defines defines the Base texture to use.
  46743. * @param fallbacks defines the current fallback list.
  46744. * @param currentRank defines the current fallback rank.
  46745. * @returns the new fallback rank.
  46746. */
  46747. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46748. /**
  46749. * Add the required uniforms to the current list.
  46750. * @param uniforms defines the current uniform list.
  46751. */
  46752. static AddUniforms(uniforms: string[]): void;
  46753. /**
  46754. * Add the required uniforms to the current buffer.
  46755. * @param uniformBuffer defines the current uniform buffer.
  46756. */
  46757. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46758. /**
  46759. * Add the required samplers to the current list.
  46760. * @param samplers defines the current sampler list.
  46761. */
  46762. static AddSamplers(samplers: string[]): void;
  46763. /**
  46764. * Makes a duplicate of the current configuration into another one.
  46765. * @param sheenConfiguration define the config where to copy the info
  46766. */
  46767. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46768. /**
  46769. * Serializes this BRDF configuration.
  46770. * @returns - An object with the serialized config.
  46771. */
  46772. serialize(): any;
  46773. /**
  46774. * Parses a anisotropy Configuration from a serialized object.
  46775. * @param source - Serialized object.
  46776. * @param scene Defines the scene we are parsing for
  46777. * @param rootUrl Defines the rootUrl to load from
  46778. */
  46779. parse(source: any, scene: Scene, rootUrl: string): void;
  46780. }
  46781. }
  46782. declare module BABYLON {
  46783. /**
  46784. * @hidden
  46785. */
  46786. export interface IMaterialSubSurfaceDefines {
  46787. SUBSURFACE: boolean;
  46788. SS_REFRACTION: boolean;
  46789. SS_TRANSLUCENCY: boolean;
  46790. SS_SCATERRING: boolean;
  46791. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46792. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46793. SS_REFRACTIONMAP_3D: boolean;
  46794. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46795. SS_LODINREFRACTIONALPHA: boolean;
  46796. SS_GAMMAREFRACTION: boolean;
  46797. SS_RGBDREFRACTION: boolean;
  46798. SS_LINEARSPECULARREFRACTION: boolean;
  46799. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46800. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46801. /** @hidden */ private _areTexturesDirty: boolean;
  46802. }
  46803. /**
  46804. * Define the code related to the sub surface parameters of the pbr material.
  46805. */
  46806. export class PBRSubSurfaceConfiguration {
  46807. private _isRefractionEnabled;
  46808. /**
  46809. * Defines if the refraction is enabled in the material.
  46810. */
  46811. isRefractionEnabled: boolean;
  46812. private _isTranslucencyEnabled;
  46813. /**
  46814. * Defines if the translucency is enabled in the material.
  46815. */
  46816. isTranslucencyEnabled: boolean;
  46817. private _isScatteringEnabled;
  46818. /**
  46819. * Defines the refraction intensity of the material.
  46820. * The refraction when enabled replaces the Diffuse part of the material.
  46821. * The intensity helps transitionning between diffuse and refraction.
  46822. */
  46823. refractionIntensity: number;
  46824. /**
  46825. * Defines the translucency intensity of the material.
  46826. * When translucency has been enabled, this defines how much of the "translucency"
  46827. * is addded to the diffuse part of the material.
  46828. */
  46829. translucencyIntensity: number;
  46830. /**
  46831. * Defines the scattering intensity of the material.
  46832. * When scattering has been enabled, this defines how much of the "scattered light"
  46833. * is addded to the diffuse part of the material.
  46834. */
  46835. scatteringIntensity: number;
  46836. private _thicknessTexture;
  46837. /**
  46838. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46839. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46840. * 0 would mean minimumThickness
  46841. * 1 would mean maximumThickness
  46842. * The other channels might be use as a mask to vary the different effects intensity.
  46843. */
  46844. thicknessTexture: Nullable<BaseTexture>;
  46845. private _refractionTexture;
  46846. /**
  46847. * Defines the texture to use for refraction.
  46848. */
  46849. refractionTexture: Nullable<BaseTexture>;
  46850. private _indexOfRefraction;
  46851. /**
  46852. * Defines the index of refraction used in the material.
  46853. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46854. */
  46855. indexOfRefraction: number;
  46856. private _invertRefractionY;
  46857. /**
  46858. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46859. */
  46860. invertRefractionY: boolean;
  46861. private _linkRefractionWithTransparency;
  46862. /**
  46863. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46864. * Materials half opaque for instance using refraction could benefit from this control.
  46865. */
  46866. linkRefractionWithTransparency: boolean;
  46867. /**
  46868. * Defines the minimum thickness stored in the thickness map.
  46869. * If no thickness map is defined, this value will be used to simulate thickness.
  46870. */
  46871. minimumThickness: number;
  46872. /**
  46873. * Defines the maximum thickness stored in the thickness map.
  46874. */
  46875. maximumThickness: number;
  46876. /**
  46877. * Defines the volume tint of the material.
  46878. * This is used for both translucency and scattering.
  46879. */
  46880. tintColor: Color3;
  46881. /**
  46882. * Defines the distance at which the tint color should be found in the media.
  46883. * This is used for refraction only.
  46884. */
  46885. tintColorAtDistance: number;
  46886. /**
  46887. * Defines how far each channel transmit through the media.
  46888. * It is defined as a color to simplify it selection.
  46889. */
  46890. diffusionDistance: Color3;
  46891. private _useMaskFromThicknessTexture;
  46892. /**
  46893. * Stores the intensity of the different subsurface effects in the thickness texture.
  46894. * * the green channel is the translucency intensity.
  46895. * * the blue channel is the scattering intensity.
  46896. * * the alpha channel is the refraction intensity.
  46897. */
  46898. useMaskFromThicknessTexture: boolean;
  46899. /** @hidden */
  46900. private _internalMarkAllSubMeshesAsTexturesDirty;
  46901. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46902. /**
  46903. * Instantiate a new istance of sub surface configuration.
  46904. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46905. */
  46906. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46907. /**
  46908. * Gets wehter the submesh is ready to be used or not.
  46909. * @param defines the list of "defines" to update.
  46910. * @param scene defines the scene the material belongs to.
  46911. * @returns - boolean indicating that the submesh is ready or not.
  46912. */
  46913. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46914. /**
  46915. * Checks to see if a texture is used in the material.
  46916. * @param defines the list of "defines" to update.
  46917. * @param scene defines the scene to the material belongs to.
  46918. */
  46919. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46920. /**
  46921. * Binds the material data.
  46922. * @param uniformBuffer defines the Uniform buffer to fill in.
  46923. * @param scene defines the scene the material belongs to.
  46924. * @param engine defines the engine the material belongs to.
  46925. * @param isFrozen defines wether the material is frozen or not.
  46926. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46927. */
  46928. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46929. /**
  46930. * Unbinds the material from the mesh.
  46931. * @param activeEffect defines the effect that should be unbound from.
  46932. * @returns true if unbound, otherwise false
  46933. */
  46934. unbind(activeEffect: Effect): boolean;
  46935. /**
  46936. * Returns the texture used for refraction or null if none is used.
  46937. * @param scene defines the scene the material belongs to.
  46938. * @returns - Refraction texture if present. If no refraction texture and refraction
  46939. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46940. */
  46941. private _getRefractionTexture;
  46942. /**
  46943. * Returns true if alpha blending should be disabled.
  46944. */
  46945. readonly disableAlphaBlending: boolean;
  46946. /**
  46947. * Fills the list of render target textures.
  46948. * @param renderTargets the list of render targets to update
  46949. */
  46950. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46951. /**
  46952. * Checks to see if a texture is used in the material.
  46953. * @param texture - Base texture to use.
  46954. * @returns - Boolean specifying if a texture is used in the material.
  46955. */
  46956. hasTexture(texture: BaseTexture): boolean;
  46957. /**
  46958. * Gets a boolean indicating that current material needs to register RTT
  46959. * @returns true if this uses a render target otherwise false.
  46960. */
  46961. hasRenderTargetTextures(): boolean;
  46962. /**
  46963. * Returns an array of the actively used textures.
  46964. * @param activeTextures Array of BaseTextures
  46965. */
  46966. getActiveTextures(activeTextures: BaseTexture[]): void;
  46967. /**
  46968. * Returns the animatable textures.
  46969. * @param animatables Array of animatable textures.
  46970. */
  46971. getAnimatables(animatables: IAnimatable[]): void;
  46972. /**
  46973. * Disposes the resources of the material.
  46974. * @param forceDisposeTextures - Forces the disposal of all textures.
  46975. */
  46976. dispose(forceDisposeTextures?: boolean): void;
  46977. /**
  46978. * Get the current class name of the texture useful for serialization or dynamic coding.
  46979. * @returns "PBRSubSurfaceConfiguration"
  46980. */
  46981. getClassName(): string;
  46982. /**
  46983. * Add fallbacks to the effect fallbacks list.
  46984. * @param defines defines the Base texture to use.
  46985. * @param fallbacks defines the current fallback list.
  46986. * @param currentRank defines the current fallback rank.
  46987. * @returns the new fallback rank.
  46988. */
  46989. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46990. /**
  46991. * Add the required uniforms to the current list.
  46992. * @param uniforms defines the current uniform list.
  46993. */
  46994. static AddUniforms(uniforms: string[]): void;
  46995. /**
  46996. * Add the required samplers to the current list.
  46997. * @param samplers defines the current sampler list.
  46998. */
  46999. static AddSamplers(samplers: string[]): void;
  47000. /**
  47001. * Add the required uniforms to the current buffer.
  47002. * @param uniformBuffer defines the current uniform buffer.
  47003. */
  47004. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47005. /**
  47006. * Makes a duplicate of the current configuration into another one.
  47007. * @param configuration define the config where to copy the info
  47008. */
  47009. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47010. /**
  47011. * Serializes this Sub Surface configuration.
  47012. * @returns - An object with the serialized config.
  47013. */
  47014. serialize(): any;
  47015. /**
  47016. * Parses a anisotropy Configuration from a serialized object.
  47017. * @param source - Serialized object.
  47018. * @param scene Defines the scene we are parsing for
  47019. * @param rootUrl Defines the rootUrl to load from
  47020. */
  47021. parse(source: any, scene: Scene, rootUrl: string): void;
  47022. }
  47023. }
  47024. declare module BABYLON {
  47025. /** @hidden */
  47026. export var pbrFragmentDeclaration: {
  47027. name: string;
  47028. shader: string;
  47029. };
  47030. }
  47031. declare module BABYLON {
  47032. /** @hidden */
  47033. export var pbrUboDeclaration: {
  47034. name: string;
  47035. shader: string;
  47036. };
  47037. }
  47038. declare module BABYLON {
  47039. /** @hidden */
  47040. export var pbrFragmentExtraDeclaration: {
  47041. name: string;
  47042. shader: string;
  47043. };
  47044. }
  47045. declare module BABYLON {
  47046. /** @hidden */
  47047. export var pbrFragmentSamplersDeclaration: {
  47048. name: string;
  47049. shader: string;
  47050. };
  47051. }
  47052. declare module BABYLON {
  47053. /** @hidden */
  47054. export var pbrHelperFunctions: {
  47055. name: string;
  47056. shader: string;
  47057. };
  47058. }
  47059. declare module BABYLON {
  47060. /** @hidden */
  47061. export var harmonicsFunctions: {
  47062. name: string;
  47063. shader: string;
  47064. };
  47065. }
  47066. declare module BABYLON {
  47067. /** @hidden */
  47068. export var pbrDirectLightingSetupFunctions: {
  47069. name: string;
  47070. shader: string;
  47071. };
  47072. }
  47073. declare module BABYLON {
  47074. /** @hidden */
  47075. export var pbrDirectLightingFalloffFunctions: {
  47076. name: string;
  47077. shader: string;
  47078. };
  47079. }
  47080. declare module BABYLON {
  47081. /** @hidden */
  47082. export var pbrBRDFFunctions: {
  47083. name: string;
  47084. shader: string;
  47085. };
  47086. }
  47087. declare module BABYLON {
  47088. /** @hidden */
  47089. export var pbrDirectLightingFunctions: {
  47090. name: string;
  47091. shader: string;
  47092. };
  47093. }
  47094. declare module BABYLON {
  47095. /** @hidden */
  47096. export var pbrIBLFunctions: {
  47097. name: string;
  47098. shader: string;
  47099. };
  47100. }
  47101. declare module BABYLON {
  47102. /** @hidden */
  47103. export var pbrDebug: {
  47104. name: string;
  47105. shader: string;
  47106. };
  47107. }
  47108. declare module BABYLON {
  47109. /** @hidden */
  47110. export var pbrPixelShader: {
  47111. name: string;
  47112. shader: string;
  47113. };
  47114. }
  47115. declare module BABYLON {
  47116. /** @hidden */
  47117. export var pbrVertexDeclaration: {
  47118. name: string;
  47119. shader: string;
  47120. };
  47121. }
  47122. declare module BABYLON {
  47123. /** @hidden */
  47124. export var pbrVertexShader: {
  47125. name: string;
  47126. shader: string;
  47127. };
  47128. }
  47129. declare module BABYLON {
  47130. /**
  47131. * Manages the defines for the PBR Material.
  47132. * @hidden
  47133. */
  47134. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47135. PBR: boolean;
  47136. MAINUV1: boolean;
  47137. MAINUV2: boolean;
  47138. UV1: boolean;
  47139. UV2: boolean;
  47140. ALBEDO: boolean;
  47141. ALBEDODIRECTUV: number;
  47142. VERTEXCOLOR: boolean;
  47143. AMBIENT: boolean;
  47144. AMBIENTDIRECTUV: number;
  47145. AMBIENTINGRAYSCALE: boolean;
  47146. OPACITY: boolean;
  47147. VERTEXALPHA: boolean;
  47148. OPACITYDIRECTUV: number;
  47149. OPACITYRGB: boolean;
  47150. ALPHATEST: boolean;
  47151. DEPTHPREPASS: boolean;
  47152. ALPHABLEND: boolean;
  47153. ALPHAFROMALBEDO: boolean;
  47154. ALPHATESTVALUE: string;
  47155. SPECULAROVERALPHA: boolean;
  47156. RADIANCEOVERALPHA: boolean;
  47157. ALPHAFRESNEL: boolean;
  47158. LINEARALPHAFRESNEL: boolean;
  47159. PREMULTIPLYALPHA: boolean;
  47160. EMISSIVE: boolean;
  47161. EMISSIVEDIRECTUV: number;
  47162. REFLECTIVITY: boolean;
  47163. REFLECTIVITYDIRECTUV: number;
  47164. SPECULARTERM: boolean;
  47165. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47166. MICROSURFACEAUTOMATIC: boolean;
  47167. LODBASEDMICROSFURACE: boolean;
  47168. MICROSURFACEMAP: boolean;
  47169. MICROSURFACEMAPDIRECTUV: number;
  47170. METALLICWORKFLOW: boolean;
  47171. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47172. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47173. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47174. AOSTOREINMETALMAPRED: boolean;
  47175. METALLICF0FACTORFROMMETALLICMAP: boolean;
  47176. ENVIRONMENTBRDF: boolean;
  47177. ENVIRONMENTBRDF_RGBD: boolean;
  47178. NORMAL: boolean;
  47179. TANGENT: boolean;
  47180. BUMP: boolean;
  47181. BUMPDIRECTUV: number;
  47182. OBJECTSPACE_NORMALMAP: boolean;
  47183. PARALLAX: boolean;
  47184. PARALLAXOCCLUSION: boolean;
  47185. NORMALXYSCALE: boolean;
  47186. LIGHTMAP: boolean;
  47187. LIGHTMAPDIRECTUV: number;
  47188. USELIGHTMAPASSHADOWMAP: boolean;
  47189. GAMMALIGHTMAP: boolean;
  47190. RGBDLIGHTMAP: boolean;
  47191. REFLECTION: boolean;
  47192. REFLECTIONMAP_3D: boolean;
  47193. REFLECTIONMAP_SPHERICAL: boolean;
  47194. REFLECTIONMAP_PLANAR: boolean;
  47195. REFLECTIONMAP_CUBIC: boolean;
  47196. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47197. REFLECTIONMAP_PROJECTION: boolean;
  47198. REFLECTIONMAP_SKYBOX: boolean;
  47199. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47200. REFLECTIONMAP_EXPLICIT: boolean;
  47201. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47202. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47203. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47204. INVERTCUBICMAP: boolean;
  47205. USESPHERICALFROMREFLECTIONMAP: boolean;
  47206. USEIRRADIANCEMAP: boolean;
  47207. SPHERICAL_HARMONICS: boolean;
  47208. USESPHERICALINVERTEX: boolean;
  47209. REFLECTIONMAP_OPPOSITEZ: boolean;
  47210. LODINREFLECTIONALPHA: boolean;
  47211. GAMMAREFLECTION: boolean;
  47212. RGBDREFLECTION: boolean;
  47213. LINEARSPECULARREFLECTION: boolean;
  47214. RADIANCEOCCLUSION: boolean;
  47215. HORIZONOCCLUSION: boolean;
  47216. INSTANCES: boolean;
  47217. NUM_BONE_INFLUENCERS: number;
  47218. BonesPerMesh: number;
  47219. BONETEXTURE: boolean;
  47220. NONUNIFORMSCALING: boolean;
  47221. MORPHTARGETS: boolean;
  47222. MORPHTARGETS_NORMAL: boolean;
  47223. MORPHTARGETS_TANGENT: boolean;
  47224. MORPHTARGETS_UV: boolean;
  47225. NUM_MORPH_INFLUENCERS: number;
  47226. IMAGEPROCESSING: boolean;
  47227. VIGNETTE: boolean;
  47228. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47229. VIGNETTEBLENDMODEOPAQUE: boolean;
  47230. TONEMAPPING: boolean;
  47231. TONEMAPPING_ACES: boolean;
  47232. CONTRAST: boolean;
  47233. COLORCURVES: boolean;
  47234. COLORGRADING: boolean;
  47235. COLORGRADING3D: boolean;
  47236. SAMPLER3DGREENDEPTH: boolean;
  47237. SAMPLER3DBGRMAP: boolean;
  47238. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47239. EXPOSURE: boolean;
  47240. MULTIVIEW: boolean;
  47241. USEPHYSICALLIGHTFALLOFF: boolean;
  47242. USEGLTFLIGHTFALLOFF: boolean;
  47243. TWOSIDEDLIGHTING: boolean;
  47244. SHADOWFLOAT: boolean;
  47245. CLIPPLANE: boolean;
  47246. CLIPPLANE2: boolean;
  47247. CLIPPLANE3: boolean;
  47248. CLIPPLANE4: boolean;
  47249. POINTSIZE: boolean;
  47250. FOG: boolean;
  47251. LOGARITHMICDEPTH: boolean;
  47252. FORCENORMALFORWARD: boolean;
  47253. SPECULARAA: boolean;
  47254. CLEARCOAT: boolean;
  47255. CLEARCOAT_DEFAULTIOR: boolean;
  47256. CLEARCOAT_TEXTURE: boolean;
  47257. CLEARCOAT_TEXTUREDIRECTUV: number;
  47258. CLEARCOAT_BUMP: boolean;
  47259. CLEARCOAT_BUMPDIRECTUV: number;
  47260. CLEARCOAT_TINT: boolean;
  47261. CLEARCOAT_TINT_TEXTURE: boolean;
  47262. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47263. ANISOTROPIC: boolean;
  47264. ANISOTROPIC_TEXTURE: boolean;
  47265. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47266. BRDF_V_HEIGHT_CORRELATED: boolean;
  47267. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47268. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47269. SHEEN: boolean;
  47270. SHEEN_TEXTURE: boolean;
  47271. SHEEN_TEXTUREDIRECTUV: number;
  47272. SHEEN_LINKWITHALBEDO: boolean;
  47273. SUBSURFACE: boolean;
  47274. SS_REFRACTION: boolean;
  47275. SS_TRANSLUCENCY: boolean;
  47276. SS_SCATERRING: boolean;
  47277. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47278. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47279. SS_REFRACTIONMAP_3D: boolean;
  47280. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47281. SS_LODINREFRACTIONALPHA: boolean;
  47282. SS_GAMMAREFRACTION: boolean;
  47283. SS_RGBDREFRACTION: boolean;
  47284. SS_LINEARSPECULARREFRACTION: boolean;
  47285. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47286. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47287. UNLIT: boolean;
  47288. DEBUGMODE: number;
  47289. /**
  47290. * Initializes the PBR Material defines.
  47291. */
  47292. constructor();
  47293. /**
  47294. * Resets the PBR Material defines.
  47295. */
  47296. reset(): void;
  47297. }
  47298. /**
  47299. * The Physically based material base class of BJS.
  47300. *
  47301. * This offers the main features of a standard PBR material.
  47302. * For more information, please refer to the documentation :
  47303. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47304. */
  47305. export abstract class PBRBaseMaterial extends PushMaterial {
  47306. /**
  47307. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47308. */
  47309. static readonly PBRMATERIAL_OPAQUE: number;
  47310. /**
  47311. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47312. */
  47313. static readonly PBRMATERIAL_ALPHATEST: number;
  47314. /**
  47315. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47316. */
  47317. static readonly PBRMATERIAL_ALPHABLEND: number;
  47318. /**
  47319. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47320. * They are also discarded below the alpha cutoff threshold to improve performances.
  47321. */
  47322. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47323. /**
  47324. * Defines the default value of how much AO map is occluding the analytical lights
  47325. * (point spot...).
  47326. */
  47327. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47328. /**
  47329. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47330. */
  47331. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47332. /**
  47333. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47334. * to enhance interoperability with other engines.
  47335. */
  47336. static readonly LIGHTFALLOFF_GLTF: number;
  47337. /**
  47338. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47339. * to enhance interoperability with other materials.
  47340. */
  47341. static readonly LIGHTFALLOFF_STANDARD: number;
  47342. /**
  47343. * Intensity of the direct lights e.g. the four lights available in your scene.
  47344. * This impacts both the direct diffuse and specular highlights.
  47345. */
  47346. protected _directIntensity: number;
  47347. /**
  47348. * Intensity of the emissive part of the material.
  47349. * This helps controlling the emissive effect without modifying the emissive color.
  47350. */
  47351. protected _emissiveIntensity: number;
  47352. /**
  47353. * Intensity of the environment e.g. how much the environment will light the object
  47354. * either through harmonics for rough material or through the refelction for shiny ones.
  47355. */
  47356. protected _environmentIntensity: number;
  47357. /**
  47358. * This is a special control allowing the reduction of the specular highlights coming from the
  47359. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47360. */
  47361. protected _specularIntensity: number;
  47362. /**
  47363. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47364. */
  47365. private _lightingInfos;
  47366. /**
  47367. * Debug Control allowing disabling the bump map on this material.
  47368. */
  47369. protected _disableBumpMap: boolean;
  47370. /**
  47371. * AKA Diffuse Texture in standard nomenclature.
  47372. */
  47373. protected _albedoTexture: Nullable<BaseTexture>;
  47374. /**
  47375. * AKA Occlusion Texture in other nomenclature.
  47376. */
  47377. protected _ambientTexture: Nullable<BaseTexture>;
  47378. /**
  47379. * AKA Occlusion Texture Intensity in other nomenclature.
  47380. */
  47381. protected _ambientTextureStrength: number;
  47382. /**
  47383. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47384. * 1 means it completely occludes it
  47385. * 0 mean it has no impact
  47386. */
  47387. protected _ambientTextureImpactOnAnalyticalLights: number;
  47388. /**
  47389. * Stores the alpha values in a texture.
  47390. */
  47391. protected _opacityTexture: Nullable<BaseTexture>;
  47392. /**
  47393. * Stores the reflection values in a texture.
  47394. */
  47395. protected _reflectionTexture: Nullable<BaseTexture>;
  47396. /**
  47397. * Stores the emissive values in a texture.
  47398. */
  47399. protected _emissiveTexture: Nullable<BaseTexture>;
  47400. /**
  47401. * AKA Specular texture in other nomenclature.
  47402. */
  47403. protected _reflectivityTexture: Nullable<BaseTexture>;
  47404. /**
  47405. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47406. */
  47407. protected _metallicTexture: Nullable<BaseTexture>;
  47408. /**
  47409. * Specifies the metallic scalar of the metallic/roughness workflow.
  47410. * Can also be used to scale the metalness values of the metallic texture.
  47411. */
  47412. protected _metallic: Nullable<number>;
  47413. /**
  47414. * Specifies the roughness scalar of the metallic/roughness workflow.
  47415. * Can also be used to scale the roughness values of the metallic texture.
  47416. */
  47417. protected _roughness: Nullable<number>;
  47418. /**
  47419. * Specifies the an F0 factor to help configuring the material F0.
  47420. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  47421. * to 0.5 the previously hard coded value stays the same.
  47422. * Can also be used to scale the F0 values of the metallic texture.
  47423. */
  47424. protected _metallicF0Factor: number;
  47425. /**
  47426. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  47427. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  47428. * your expectation as it multiplies with the texture data.
  47429. */
  47430. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  47431. /**
  47432. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47433. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47434. */
  47435. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47436. /**
  47437. * Stores surface normal data used to displace a mesh in a texture.
  47438. */
  47439. protected _bumpTexture: Nullable<BaseTexture>;
  47440. /**
  47441. * Stores the pre-calculated light information of a mesh in a texture.
  47442. */
  47443. protected _lightmapTexture: Nullable<BaseTexture>;
  47444. /**
  47445. * The color of a material in ambient lighting.
  47446. */
  47447. protected _ambientColor: Color3;
  47448. /**
  47449. * AKA Diffuse Color in other nomenclature.
  47450. */
  47451. protected _albedoColor: Color3;
  47452. /**
  47453. * AKA Specular Color in other nomenclature.
  47454. */
  47455. protected _reflectivityColor: Color3;
  47456. /**
  47457. * The color applied when light is reflected from a material.
  47458. */
  47459. protected _reflectionColor: Color3;
  47460. /**
  47461. * The color applied when light is emitted from a material.
  47462. */
  47463. protected _emissiveColor: Color3;
  47464. /**
  47465. * AKA Glossiness in other nomenclature.
  47466. */
  47467. protected _microSurface: number;
  47468. /**
  47469. * Specifies that the material will use the light map as a show map.
  47470. */
  47471. protected _useLightmapAsShadowmap: boolean;
  47472. /**
  47473. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47474. * makes the reflect vector face the model (under horizon).
  47475. */
  47476. protected _useHorizonOcclusion: boolean;
  47477. /**
  47478. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47479. * too much the area relying on ambient texture to define their ambient occlusion.
  47480. */
  47481. protected _useRadianceOcclusion: boolean;
  47482. /**
  47483. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47484. */
  47485. protected _useAlphaFromAlbedoTexture: boolean;
  47486. /**
  47487. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47488. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47489. */
  47490. protected _useSpecularOverAlpha: boolean;
  47491. /**
  47492. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47493. */
  47494. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47495. /**
  47496. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47497. */
  47498. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47499. /**
  47500. * Specifies if the metallic texture contains the roughness information in its green channel.
  47501. */
  47502. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47503. /**
  47504. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47505. */
  47506. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47507. /**
  47508. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47509. */
  47510. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47511. /**
  47512. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47513. */
  47514. protected _useAmbientInGrayScale: boolean;
  47515. /**
  47516. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47517. * The material will try to infer what glossiness each pixel should be.
  47518. */
  47519. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47520. /**
  47521. * Defines the falloff type used in this material.
  47522. * It by default is Physical.
  47523. */
  47524. protected _lightFalloff: number;
  47525. /**
  47526. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47527. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47528. */
  47529. protected _useRadianceOverAlpha: boolean;
  47530. /**
  47531. * Allows using an object space normal map (instead of tangent space).
  47532. */
  47533. protected _useObjectSpaceNormalMap: boolean;
  47534. /**
  47535. * Allows using the bump map in parallax mode.
  47536. */
  47537. protected _useParallax: boolean;
  47538. /**
  47539. * Allows using the bump map in parallax occlusion mode.
  47540. */
  47541. protected _useParallaxOcclusion: boolean;
  47542. /**
  47543. * Controls the scale bias of the parallax mode.
  47544. */
  47545. protected _parallaxScaleBias: number;
  47546. /**
  47547. * If sets to true, disables all the lights affecting the material.
  47548. */
  47549. protected _disableLighting: boolean;
  47550. /**
  47551. * Number of Simultaneous lights allowed on the material.
  47552. */
  47553. protected _maxSimultaneousLights: number;
  47554. /**
  47555. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47556. */
  47557. protected _invertNormalMapX: boolean;
  47558. /**
  47559. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47560. */
  47561. protected _invertNormalMapY: boolean;
  47562. /**
  47563. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47564. */
  47565. protected _twoSidedLighting: boolean;
  47566. /**
  47567. * Defines the alpha limits in alpha test mode.
  47568. */
  47569. protected _alphaCutOff: number;
  47570. /**
  47571. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47572. */
  47573. protected _forceAlphaTest: boolean;
  47574. /**
  47575. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47576. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47577. */
  47578. protected _useAlphaFresnel: boolean;
  47579. /**
  47580. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47581. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47582. */
  47583. protected _useLinearAlphaFresnel: boolean;
  47584. /**
  47585. * The transparency mode of the material.
  47586. */
  47587. protected _transparencyMode: Nullable<number>;
  47588. /**
  47589. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47590. * from cos thetav and roughness:
  47591. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47592. */
  47593. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47594. /**
  47595. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47596. */
  47597. protected _forceIrradianceInFragment: boolean;
  47598. /**
  47599. * Force normal to face away from face.
  47600. */
  47601. protected _forceNormalForward: boolean;
  47602. /**
  47603. * Enables specular anti aliasing in the PBR shader.
  47604. * It will both interacts on the Geometry for analytical and IBL lighting.
  47605. * It also prefilter the roughness map based on the bump values.
  47606. */
  47607. protected _enableSpecularAntiAliasing: boolean;
  47608. /**
  47609. * Default configuration related to image processing available in the PBR Material.
  47610. */
  47611. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47612. /**
  47613. * Keep track of the image processing observer to allow dispose and replace.
  47614. */
  47615. private _imageProcessingObserver;
  47616. /**
  47617. * Attaches a new image processing configuration to the PBR Material.
  47618. * @param configuration
  47619. */
  47620. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47621. /**
  47622. * Stores the available render targets.
  47623. */
  47624. private _renderTargets;
  47625. /**
  47626. * Sets the global ambient color for the material used in lighting calculations.
  47627. */
  47628. private _globalAmbientColor;
  47629. /**
  47630. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47631. */
  47632. private _useLogarithmicDepth;
  47633. /**
  47634. * If set to true, no lighting calculations will be applied.
  47635. */
  47636. private _unlit;
  47637. private _debugMode;
  47638. /**
  47639. * @hidden
  47640. * This is reserved for the inspector.
  47641. * Defines the material debug mode.
  47642. * It helps seeing only some components of the material while troubleshooting.
  47643. */
  47644. debugMode: number;
  47645. /**
  47646. * @hidden
  47647. * This is reserved for the inspector.
  47648. * Specify from where on screen the debug mode should start.
  47649. * The value goes from -1 (full screen) to 1 (not visible)
  47650. * It helps with side by side comparison against the final render
  47651. * This defaults to -1
  47652. */
  47653. private debugLimit;
  47654. /**
  47655. * @hidden
  47656. * This is reserved for the inspector.
  47657. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47658. * You can use the factor to better multiply the final value.
  47659. */
  47660. private debugFactor;
  47661. /**
  47662. * Defines the clear coat layer parameters for the material.
  47663. */
  47664. readonly clearCoat: PBRClearCoatConfiguration;
  47665. /**
  47666. * Defines the anisotropic parameters for the material.
  47667. */
  47668. readonly anisotropy: PBRAnisotropicConfiguration;
  47669. /**
  47670. * Defines the BRDF parameters for the material.
  47671. */
  47672. readonly brdf: PBRBRDFConfiguration;
  47673. /**
  47674. * Defines the Sheen parameters for the material.
  47675. */
  47676. readonly sheen: PBRSheenConfiguration;
  47677. /**
  47678. * Defines the SubSurface parameters for the material.
  47679. */
  47680. readonly subSurface: PBRSubSurfaceConfiguration;
  47681. /**
  47682. * Custom callback helping to override the default shader used in the material.
  47683. */
  47684. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47685. protected _rebuildInParallel: boolean;
  47686. /**
  47687. * Instantiates a new PBRMaterial instance.
  47688. *
  47689. * @param name The material name
  47690. * @param scene The scene the material will be use in.
  47691. */
  47692. constructor(name: string, scene: Scene);
  47693. /**
  47694. * Gets a boolean indicating that current material needs to register RTT
  47695. */
  47696. readonly hasRenderTargetTextures: boolean;
  47697. /**
  47698. * Gets the name of the material class.
  47699. */
  47700. getClassName(): string;
  47701. /**
  47702. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47703. */
  47704. /**
  47705. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47706. */
  47707. useLogarithmicDepth: boolean;
  47708. /**
  47709. * Gets the current transparency mode.
  47710. */
  47711. /**
  47712. * Sets the transparency mode of the material.
  47713. *
  47714. * | Value | Type | Description |
  47715. * | ----- | ----------------------------------- | ----------- |
  47716. * | 0 | OPAQUE | |
  47717. * | 1 | ALPHATEST | |
  47718. * | 2 | ALPHABLEND | |
  47719. * | 3 | ALPHATESTANDBLEND | |
  47720. *
  47721. */
  47722. transparencyMode: Nullable<number>;
  47723. /**
  47724. * Returns true if alpha blending should be disabled.
  47725. */
  47726. private readonly _disableAlphaBlending;
  47727. /**
  47728. * Specifies whether or not this material should be rendered in alpha blend mode.
  47729. */
  47730. needAlphaBlending(): boolean;
  47731. /**
  47732. * Specifies if the mesh will require alpha blending.
  47733. * @param mesh - BJS mesh.
  47734. */
  47735. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47736. /**
  47737. * Specifies whether or not this material should be rendered in alpha test mode.
  47738. */
  47739. needAlphaTesting(): boolean;
  47740. /**
  47741. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47742. */
  47743. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47744. /**
  47745. * Gets the texture used for the alpha test.
  47746. */
  47747. getAlphaTestTexture(): Nullable<BaseTexture>;
  47748. /**
  47749. * Specifies that the submesh is ready to be used.
  47750. * @param mesh - BJS mesh.
  47751. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47752. * @param useInstances - Specifies that instances should be used.
  47753. * @returns - boolean indicating that the submesh is ready or not.
  47754. */
  47755. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47756. /**
  47757. * Specifies if the material uses metallic roughness workflow.
  47758. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47759. */
  47760. isMetallicWorkflow(): boolean;
  47761. private _prepareEffect;
  47762. private _prepareDefines;
  47763. /**
  47764. * Force shader compilation
  47765. */
  47766. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  47767. /**
  47768. * Initializes the uniform buffer layout for the shader.
  47769. */
  47770. buildUniformLayout(): void;
  47771. /**
  47772. * Unbinds the material from the mesh
  47773. */
  47774. unbind(): void;
  47775. /**
  47776. * Binds the submesh data.
  47777. * @param world - The world matrix.
  47778. * @param mesh - The BJS mesh.
  47779. * @param subMesh - A submesh of the BJS mesh.
  47780. */
  47781. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47782. /**
  47783. * Returns the animatable textures.
  47784. * @returns - Array of animatable textures.
  47785. */
  47786. getAnimatables(): IAnimatable[];
  47787. /**
  47788. * Returns the texture used for reflections.
  47789. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47790. */
  47791. private _getReflectionTexture;
  47792. /**
  47793. * Returns an array of the actively used textures.
  47794. * @returns - Array of BaseTextures
  47795. */
  47796. getActiveTextures(): BaseTexture[];
  47797. /**
  47798. * Checks to see if a texture is used in the material.
  47799. * @param texture - Base texture to use.
  47800. * @returns - Boolean specifying if a texture is used in the material.
  47801. */
  47802. hasTexture(texture: BaseTexture): boolean;
  47803. /**
  47804. * Disposes the resources of the material.
  47805. * @param forceDisposeEffect - Forces the disposal of effects.
  47806. * @param forceDisposeTextures - Forces the disposal of all textures.
  47807. */
  47808. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47809. }
  47810. }
  47811. declare module BABYLON {
  47812. /**
  47813. * The Physically based material of BJS.
  47814. *
  47815. * This offers the main features of a standard PBR material.
  47816. * For more information, please refer to the documentation :
  47817. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47818. */
  47819. export class PBRMaterial extends PBRBaseMaterial {
  47820. /**
  47821. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47822. */
  47823. static readonly PBRMATERIAL_OPAQUE: number;
  47824. /**
  47825. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47826. */
  47827. static readonly PBRMATERIAL_ALPHATEST: number;
  47828. /**
  47829. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47830. */
  47831. static readonly PBRMATERIAL_ALPHABLEND: number;
  47832. /**
  47833. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47834. * They are also discarded below the alpha cutoff threshold to improve performances.
  47835. */
  47836. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47837. /**
  47838. * Defines the default value of how much AO map is occluding the analytical lights
  47839. * (point spot...).
  47840. */
  47841. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47842. /**
  47843. * Intensity of the direct lights e.g. the four lights available in your scene.
  47844. * This impacts both the direct diffuse and specular highlights.
  47845. */
  47846. directIntensity: number;
  47847. /**
  47848. * Intensity of the emissive part of the material.
  47849. * This helps controlling the emissive effect without modifying the emissive color.
  47850. */
  47851. emissiveIntensity: number;
  47852. /**
  47853. * Intensity of the environment e.g. how much the environment will light the object
  47854. * either through harmonics for rough material or through the refelction for shiny ones.
  47855. */
  47856. environmentIntensity: number;
  47857. /**
  47858. * This is a special control allowing the reduction of the specular highlights coming from the
  47859. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47860. */
  47861. specularIntensity: number;
  47862. /**
  47863. * Debug Control allowing disabling the bump map on this material.
  47864. */
  47865. disableBumpMap: boolean;
  47866. /**
  47867. * AKA Diffuse Texture in standard nomenclature.
  47868. */
  47869. albedoTexture: BaseTexture;
  47870. /**
  47871. * AKA Occlusion Texture in other nomenclature.
  47872. */
  47873. ambientTexture: BaseTexture;
  47874. /**
  47875. * AKA Occlusion Texture Intensity in other nomenclature.
  47876. */
  47877. ambientTextureStrength: number;
  47878. /**
  47879. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47880. * 1 means it completely occludes it
  47881. * 0 mean it has no impact
  47882. */
  47883. ambientTextureImpactOnAnalyticalLights: number;
  47884. /**
  47885. * Stores the alpha values in a texture.
  47886. */
  47887. opacityTexture: BaseTexture;
  47888. /**
  47889. * Stores the reflection values in a texture.
  47890. */
  47891. reflectionTexture: Nullable<BaseTexture>;
  47892. /**
  47893. * Stores the emissive values in a texture.
  47894. */
  47895. emissiveTexture: BaseTexture;
  47896. /**
  47897. * AKA Specular texture in other nomenclature.
  47898. */
  47899. reflectivityTexture: BaseTexture;
  47900. /**
  47901. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47902. */
  47903. metallicTexture: BaseTexture;
  47904. /**
  47905. * Specifies the metallic scalar of the metallic/roughness workflow.
  47906. * Can also be used to scale the metalness values of the metallic texture.
  47907. */
  47908. metallic: Nullable<number>;
  47909. /**
  47910. * Specifies the roughness scalar of the metallic/roughness workflow.
  47911. * Can also be used to scale the roughness values of the metallic texture.
  47912. */
  47913. roughness: Nullable<number>;
  47914. /**
  47915. * Specifies the an F0 factor to help configuring the material F0.
  47916. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  47917. * to 0.5 the previously hard coded value stays the same.
  47918. * Can also be used to scale the F0 values of the metallic texture.
  47919. */
  47920. metallicF0Factor: number;
  47921. /**
  47922. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  47923. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  47924. * your expectation as it multiplies with the texture data.
  47925. */
  47926. useMetallicF0FactorFromMetallicTexture: boolean;
  47927. /**
  47928. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47929. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47930. */
  47931. microSurfaceTexture: BaseTexture;
  47932. /**
  47933. * Stores surface normal data used to displace a mesh in a texture.
  47934. */
  47935. bumpTexture: BaseTexture;
  47936. /**
  47937. * Stores the pre-calculated light information of a mesh in a texture.
  47938. */
  47939. lightmapTexture: BaseTexture;
  47940. /**
  47941. * Stores the refracted light information in a texture.
  47942. */
  47943. refractionTexture: Nullable<BaseTexture>;
  47944. /**
  47945. * The color of a material in ambient lighting.
  47946. */
  47947. ambientColor: Color3;
  47948. /**
  47949. * AKA Diffuse Color in other nomenclature.
  47950. */
  47951. albedoColor: Color3;
  47952. /**
  47953. * AKA Specular Color in other nomenclature.
  47954. */
  47955. reflectivityColor: Color3;
  47956. /**
  47957. * The color reflected from the material.
  47958. */
  47959. reflectionColor: Color3;
  47960. /**
  47961. * The color emitted from the material.
  47962. */
  47963. emissiveColor: Color3;
  47964. /**
  47965. * AKA Glossiness in other nomenclature.
  47966. */
  47967. microSurface: number;
  47968. /**
  47969. * source material index of refraction (IOR)' / 'destination material IOR.
  47970. */
  47971. indexOfRefraction: number;
  47972. /**
  47973. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47974. */
  47975. invertRefractionY: boolean;
  47976. /**
  47977. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47978. * Materials half opaque for instance using refraction could benefit from this control.
  47979. */
  47980. linkRefractionWithTransparency: boolean;
  47981. /**
  47982. * If true, the light map contains occlusion information instead of lighting info.
  47983. */
  47984. useLightmapAsShadowmap: boolean;
  47985. /**
  47986. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47987. */
  47988. useAlphaFromAlbedoTexture: boolean;
  47989. /**
  47990. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47991. */
  47992. forceAlphaTest: boolean;
  47993. /**
  47994. * Defines the alpha limits in alpha test mode.
  47995. */
  47996. alphaCutOff: number;
  47997. /**
  47998. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47999. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48000. */
  48001. useSpecularOverAlpha: boolean;
  48002. /**
  48003. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48004. */
  48005. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48006. /**
  48007. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48008. */
  48009. useRoughnessFromMetallicTextureAlpha: boolean;
  48010. /**
  48011. * Specifies if the metallic texture contains the roughness information in its green channel.
  48012. */
  48013. useRoughnessFromMetallicTextureGreen: boolean;
  48014. /**
  48015. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48016. */
  48017. useMetallnessFromMetallicTextureBlue: boolean;
  48018. /**
  48019. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48020. */
  48021. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48022. /**
  48023. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48024. */
  48025. useAmbientInGrayScale: boolean;
  48026. /**
  48027. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48028. * The material will try to infer what glossiness each pixel should be.
  48029. */
  48030. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48031. /**
  48032. * BJS is using an harcoded light falloff based on a manually sets up range.
  48033. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48034. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48035. */
  48036. /**
  48037. * BJS is using an harcoded light falloff based on a manually sets up range.
  48038. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48039. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48040. */
  48041. usePhysicalLightFalloff: boolean;
  48042. /**
  48043. * In order to support the falloff compatibility with gltf, a special mode has been added
  48044. * to reproduce the gltf light falloff.
  48045. */
  48046. /**
  48047. * In order to support the falloff compatibility with gltf, a special mode has been added
  48048. * to reproduce the gltf light falloff.
  48049. */
  48050. useGLTFLightFalloff: boolean;
  48051. /**
  48052. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48053. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48054. */
  48055. useRadianceOverAlpha: boolean;
  48056. /**
  48057. * Allows using an object space normal map (instead of tangent space).
  48058. */
  48059. useObjectSpaceNormalMap: boolean;
  48060. /**
  48061. * Allows using the bump map in parallax mode.
  48062. */
  48063. useParallax: boolean;
  48064. /**
  48065. * Allows using the bump map in parallax occlusion mode.
  48066. */
  48067. useParallaxOcclusion: boolean;
  48068. /**
  48069. * Controls the scale bias of the parallax mode.
  48070. */
  48071. parallaxScaleBias: number;
  48072. /**
  48073. * If sets to true, disables all the lights affecting the material.
  48074. */
  48075. disableLighting: boolean;
  48076. /**
  48077. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48078. */
  48079. forceIrradianceInFragment: boolean;
  48080. /**
  48081. * Number of Simultaneous lights allowed on the material.
  48082. */
  48083. maxSimultaneousLights: number;
  48084. /**
  48085. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48086. */
  48087. invertNormalMapX: boolean;
  48088. /**
  48089. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48090. */
  48091. invertNormalMapY: boolean;
  48092. /**
  48093. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48094. */
  48095. twoSidedLighting: boolean;
  48096. /**
  48097. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48098. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48099. */
  48100. useAlphaFresnel: boolean;
  48101. /**
  48102. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48103. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48104. */
  48105. useLinearAlphaFresnel: boolean;
  48106. /**
  48107. * Let user defines the brdf lookup texture used for IBL.
  48108. * A default 8bit version is embedded but you could point at :
  48109. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48110. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48111. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48112. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48113. */
  48114. environmentBRDFTexture: Nullable<BaseTexture>;
  48115. /**
  48116. * Force normal to face away from face.
  48117. */
  48118. forceNormalForward: boolean;
  48119. /**
  48120. * Enables specular anti aliasing in the PBR shader.
  48121. * It will both interacts on the Geometry for analytical and IBL lighting.
  48122. * It also prefilter the roughness map based on the bump values.
  48123. */
  48124. enableSpecularAntiAliasing: boolean;
  48125. /**
  48126. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48127. * makes the reflect vector face the model (under horizon).
  48128. */
  48129. useHorizonOcclusion: boolean;
  48130. /**
  48131. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48132. * too much the area relying on ambient texture to define their ambient occlusion.
  48133. */
  48134. useRadianceOcclusion: boolean;
  48135. /**
  48136. * If set to true, no lighting calculations will be applied.
  48137. */
  48138. unlit: boolean;
  48139. /**
  48140. * Gets the image processing configuration used either in this material.
  48141. */
  48142. /**
  48143. * Sets the Default image processing configuration used either in the this material.
  48144. *
  48145. * If sets to null, the scene one is in use.
  48146. */
  48147. imageProcessingConfiguration: ImageProcessingConfiguration;
  48148. /**
  48149. * Gets wether the color curves effect is enabled.
  48150. */
  48151. /**
  48152. * Sets wether the color curves effect is enabled.
  48153. */
  48154. cameraColorCurvesEnabled: boolean;
  48155. /**
  48156. * Gets wether the color grading effect is enabled.
  48157. */
  48158. /**
  48159. * Gets wether the color grading effect is enabled.
  48160. */
  48161. cameraColorGradingEnabled: boolean;
  48162. /**
  48163. * Gets wether tonemapping is enabled or not.
  48164. */
  48165. /**
  48166. * Sets wether tonemapping is enabled or not
  48167. */
  48168. cameraToneMappingEnabled: boolean;
  48169. /**
  48170. * The camera exposure used on this material.
  48171. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48172. * This corresponds to a photographic exposure.
  48173. */
  48174. /**
  48175. * The camera exposure used on this material.
  48176. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48177. * This corresponds to a photographic exposure.
  48178. */
  48179. cameraExposure: number;
  48180. /**
  48181. * Gets The camera contrast used on this material.
  48182. */
  48183. /**
  48184. * Sets The camera contrast used on this material.
  48185. */
  48186. cameraContrast: number;
  48187. /**
  48188. * Gets the Color Grading 2D Lookup Texture.
  48189. */
  48190. /**
  48191. * Sets the Color Grading 2D Lookup Texture.
  48192. */
  48193. cameraColorGradingTexture: Nullable<BaseTexture>;
  48194. /**
  48195. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48196. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48197. * 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;
  48198. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48199. */
  48200. /**
  48201. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48202. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48203. * 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;
  48204. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48205. */
  48206. cameraColorCurves: Nullable<ColorCurves>;
  48207. /**
  48208. * Instantiates a new PBRMaterial instance.
  48209. *
  48210. * @param name The material name
  48211. * @param scene The scene the material will be use in.
  48212. */
  48213. constructor(name: string, scene: Scene);
  48214. /**
  48215. * Returns the name of this material class.
  48216. */
  48217. getClassName(): string;
  48218. /**
  48219. * Makes a duplicate of the current material.
  48220. * @param name - name to use for the new material.
  48221. */
  48222. clone(name: string): PBRMaterial;
  48223. /**
  48224. * Serializes this PBR Material.
  48225. * @returns - An object with the serialized material.
  48226. */
  48227. serialize(): any;
  48228. /**
  48229. * Parses a PBR Material from a serialized object.
  48230. * @param source - Serialized object.
  48231. * @param scene - BJS scene instance.
  48232. * @param rootUrl - url for the scene object
  48233. * @returns - PBRMaterial
  48234. */
  48235. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48236. }
  48237. }
  48238. declare module BABYLON {
  48239. /**
  48240. * Direct draw surface info
  48241. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48242. */
  48243. export interface DDSInfo {
  48244. /**
  48245. * Width of the texture
  48246. */
  48247. width: number;
  48248. /**
  48249. * Width of the texture
  48250. */
  48251. height: number;
  48252. /**
  48253. * Number of Mipmaps for the texture
  48254. * @see https://en.wikipedia.org/wiki/Mipmap
  48255. */
  48256. mipmapCount: number;
  48257. /**
  48258. * If the textures format is a known fourCC format
  48259. * @see https://www.fourcc.org/
  48260. */
  48261. isFourCC: boolean;
  48262. /**
  48263. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48264. */
  48265. isRGB: boolean;
  48266. /**
  48267. * If the texture is a lumincance format
  48268. */
  48269. isLuminance: boolean;
  48270. /**
  48271. * If this is a cube texture
  48272. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48273. */
  48274. isCube: boolean;
  48275. /**
  48276. * If the texture is a compressed format eg. FOURCC_DXT1
  48277. */
  48278. isCompressed: boolean;
  48279. /**
  48280. * The dxgiFormat of the texture
  48281. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48282. */
  48283. dxgiFormat: number;
  48284. /**
  48285. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48286. */
  48287. textureType: number;
  48288. /**
  48289. * Sphericle polynomial created for the dds texture
  48290. */
  48291. sphericalPolynomial?: SphericalPolynomial;
  48292. }
  48293. /**
  48294. * Class used to provide DDS decompression tools
  48295. */
  48296. export class DDSTools {
  48297. /**
  48298. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48299. */
  48300. static StoreLODInAlphaChannel: boolean;
  48301. /**
  48302. * Gets DDS information from an array buffer
  48303. * @param arrayBuffer defines the array buffer to read data from
  48304. * @returns the DDS information
  48305. */
  48306. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48307. private static _FloatView;
  48308. private static _Int32View;
  48309. private static _ToHalfFloat;
  48310. private static _FromHalfFloat;
  48311. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48312. private static _GetHalfFloatRGBAArrayBuffer;
  48313. private static _GetFloatRGBAArrayBuffer;
  48314. private static _GetFloatAsUIntRGBAArrayBuffer;
  48315. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48316. private static _GetRGBAArrayBuffer;
  48317. private static _ExtractLongWordOrder;
  48318. private static _GetRGBArrayBuffer;
  48319. private static _GetLuminanceArrayBuffer;
  48320. /**
  48321. * Uploads DDS Levels to a Babylon Texture
  48322. * @hidden
  48323. */
  48324. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48325. }
  48326. interface ThinEngine {
  48327. /**
  48328. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48329. * @param rootUrl defines the url where the file to load is located
  48330. * @param scene defines the current scene
  48331. * @param lodScale defines scale to apply to the mip map selection
  48332. * @param lodOffset defines offset to apply to the mip map selection
  48333. * @param onLoad defines an optional callback raised when the texture is loaded
  48334. * @param onError defines an optional callback raised if there is an issue to load the texture
  48335. * @param format defines the format of the data
  48336. * @param forcedExtension defines the extension to use to pick the right loader
  48337. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48338. * @returns the cube texture as an InternalTexture
  48339. */
  48340. 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;
  48341. }
  48342. }
  48343. declare module BABYLON {
  48344. /**
  48345. * Implementation of the DDS Texture Loader.
  48346. * @hidden
  48347. */
  48348. export class _DDSTextureLoader implements IInternalTextureLoader {
  48349. /**
  48350. * Defines wether the loader supports cascade loading the different faces.
  48351. */
  48352. readonly supportCascades: boolean;
  48353. /**
  48354. * This returns if the loader support the current file information.
  48355. * @param extension defines the file extension of the file being loaded
  48356. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48357. * @param fallback defines the fallback internal texture if any
  48358. * @param isBase64 defines whether the texture is encoded as a base64
  48359. * @param isBuffer defines whether the texture data are stored as a buffer
  48360. * @returns true if the loader can load the specified file
  48361. */
  48362. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48363. /**
  48364. * Transform the url before loading if required.
  48365. * @param rootUrl the url of the texture
  48366. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48367. * @returns the transformed texture
  48368. */
  48369. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48370. /**
  48371. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48372. * @param rootUrl the url of the texture
  48373. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48374. * @returns the fallback texture
  48375. */
  48376. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48377. /**
  48378. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48379. * @param data contains the texture data
  48380. * @param texture defines the BabylonJS internal texture
  48381. * @param createPolynomials will be true if polynomials have been requested
  48382. * @param onLoad defines the callback to trigger once the texture is ready
  48383. * @param onError defines the callback to trigger in case of error
  48384. */
  48385. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48386. /**
  48387. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48388. * @param data contains the texture data
  48389. * @param texture defines the BabylonJS internal texture
  48390. * @param callback defines the method to call once ready to upload
  48391. */
  48392. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48393. }
  48394. }
  48395. declare module BABYLON {
  48396. /**
  48397. * Implementation of the ENV Texture Loader.
  48398. * @hidden
  48399. */
  48400. export class _ENVTextureLoader implements IInternalTextureLoader {
  48401. /**
  48402. * Defines wether the loader supports cascade loading the different faces.
  48403. */
  48404. readonly supportCascades: boolean;
  48405. /**
  48406. * This returns if the loader support the current file information.
  48407. * @param extension defines the file extension of the file being loaded
  48408. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48409. * @param fallback defines the fallback internal texture if any
  48410. * @param isBase64 defines whether the texture is encoded as a base64
  48411. * @param isBuffer defines whether the texture data are stored as a buffer
  48412. * @returns true if the loader can load the specified file
  48413. */
  48414. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48415. /**
  48416. * Transform the url before loading if required.
  48417. * @param rootUrl the url of the texture
  48418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48419. * @returns the transformed texture
  48420. */
  48421. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48422. /**
  48423. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48424. * @param rootUrl the url of the texture
  48425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48426. * @returns the fallback texture
  48427. */
  48428. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48429. /**
  48430. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48431. * @param data contains the texture data
  48432. * @param texture defines the BabylonJS internal texture
  48433. * @param createPolynomials will be true if polynomials have been requested
  48434. * @param onLoad defines the callback to trigger once the texture is ready
  48435. * @param onError defines the callback to trigger in case of error
  48436. */
  48437. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48438. /**
  48439. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48440. * @param data contains the texture data
  48441. * @param texture defines the BabylonJS internal texture
  48442. * @param callback defines the method to call once ready to upload
  48443. */
  48444. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48445. }
  48446. }
  48447. declare module BABYLON {
  48448. /**
  48449. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48450. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48451. */
  48452. export class KhronosTextureContainer {
  48453. /** contents of the KTX container file */
  48454. arrayBuffer: any;
  48455. private static HEADER_LEN;
  48456. private static COMPRESSED_2D;
  48457. private static COMPRESSED_3D;
  48458. private static TEX_2D;
  48459. private static TEX_3D;
  48460. /**
  48461. * Gets the openGL type
  48462. */
  48463. glType: number;
  48464. /**
  48465. * Gets the openGL type size
  48466. */
  48467. glTypeSize: number;
  48468. /**
  48469. * Gets the openGL format
  48470. */
  48471. glFormat: number;
  48472. /**
  48473. * Gets the openGL internal format
  48474. */
  48475. glInternalFormat: number;
  48476. /**
  48477. * Gets the base internal format
  48478. */
  48479. glBaseInternalFormat: number;
  48480. /**
  48481. * Gets image width in pixel
  48482. */
  48483. pixelWidth: number;
  48484. /**
  48485. * Gets image height in pixel
  48486. */
  48487. pixelHeight: number;
  48488. /**
  48489. * Gets image depth in pixels
  48490. */
  48491. pixelDepth: number;
  48492. /**
  48493. * Gets the number of array elements
  48494. */
  48495. numberOfArrayElements: number;
  48496. /**
  48497. * Gets the number of faces
  48498. */
  48499. numberOfFaces: number;
  48500. /**
  48501. * Gets the number of mipmap levels
  48502. */
  48503. numberOfMipmapLevels: number;
  48504. /**
  48505. * Gets the bytes of key value data
  48506. */
  48507. bytesOfKeyValueData: number;
  48508. /**
  48509. * Gets the load type
  48510. */
  48511. loadType: number;
  48512. /**
  48513. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48514. */
  48515. isInvalid: boolean;
  48516. /**
  48517. * Creates a new KhronosTextureContainer
  48518. * @param arrayBuffer contents of the KTX container file
  48519. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48520. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48521. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48522. */
  48523. constructor(
  48524. /** contents of the KTX container file */
  48525. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48526. /**
  48527. * Uploads KTX content to a Babylon Texture.
  48528. * It is assumed that the texture has already been created & is currently bound
  48529. * @hidden
  48530. */
  48531. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48532. private _upload2DCompressedLevels;
  48533. }
  48534. }
  48535. declare module BABYLON {
  48536. /**
  48537. * Implementation of the KTX Texture Loader.
  48538. * @hidden
  48539. */
  48540. export class _KTXTextureLoader implements IInternalTextureLoader {
  48541. /**
  48542. * Defines wether the loader supports cascade loading the different faces.
  48543. */
  48544. readonly supportCascades: boolean;
  48545. /**
  48546. * This returns if the loader support the current file information.
  48547. * @param extension defines the file extension of the file being loaded
  48548. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48549. * @param fallback defines the fallback internal texture if any
  48550. * @param isBase64 defines whether the texture is encoded as a base64
  48551. * @param isBuffer defines whether the texture data are stored as a buffer
  48552. * @returns true if the loader can load the specified file
  48553. */
  48554. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48555. /**
  48556. * Transform the url before loading if required.
  48557. * @param rootUrl the url of the texture
  48558. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48559. * @returns the transformed texture
  48560. */
  48561. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48562. /**
  48563. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48564. * @param rootUrl the url of the texture
  48565. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48566. * @returns the fallback texture
  48567. */
  48568. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48569. /**
  48570. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48571. * @param data contains the texture data
  48572. * @param texture defines the BabylonJS internal texture
  48573. * @param createPolynomials will be true if polynomials have been requested
  48574. * @param onLoad defines the callback to trigger once the texture is ready
  48575. * @param onError defines the callback to trigger in case of error
  48576. */
  48577. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48578. /**
  48579. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48580. * @param data contains the texture data
  48581. * @param texture defines the BabylonJS internal texture
  48582. * @param callback defines the method to call once ready to upload
  48583. */
  48584. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48585. }
  48586. }
  48587. declare module BABYLON {
  48588. /**
  48589. * Options for the default xr helper
  48590. */
  48591. export class WebXRDefaultExperienceOptions {
  48592. /**
  48593. * Floor meshes that should be used for teleporting
  48594. */
  48595. floorMeshes: Array<AbstractMesh>;
  48596. /**
  48597. * Enable or disable default UI to enter XR
  48598. */
  48599. disableDefaultUI: boolean;
  48600. }
  48601. /**
  48602. * Default experience which provides a similar setup to the previous webVRExperience
  48603. */
  48604. export class WebXRDefaultExperience {
  48605. /**
  48606. * Base experience
  48607. */
  48608. baseExperience: WebXRExperienceHelper;
  48609. /**
  48610. * Input experience extension
  48611. */
  48612. input: WebXRInput;
  48613. /**
  48614. * Loads the controller models
  48615. */
  48616. controllerModelLoader: WebXRControllerModelLoader;
  48617. /**
  48618. * Enables laser pointer and selection
  48619. */
  48620. pointerSelection: WebXRControllerPointerSelection;
  48621. /**
  48622. * Enables teleportation
  48623. */
  48624. teleportation: WebXRControllerTeleportation;
  48625. /**
  48626. * Enables ui for enetering/exiting xr
  48627. */
  48628. enterExitUI: WebXREnterExitUI;
  48629. /**
  48630. * Default target xr should render to
  48631. */
  48632. renderTarget: WebXRRenderTarget;
  48633. /**
  48634. * Creates the default xr experience
  48635. * @param scene scene
  48636. * @param options options for basic configuration
  48637. * @returns resulting WebXRDefaultExperience
  48638. */
  48639. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48640. private constructor();
  48641. /**
  48642. * DIsposes of the experience helper
  48643. */
  48644. dispose(): void;
  48645. }
  48646. }
  48647. declare module BABYLON {
  48648. /** @hidden */
  48649. export var _forceSceneHelpersToBundle: boolean;
  48650. interface Scene {
  48651. /**
  48652. * Creates a default light for the scene.
  48653. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48654. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48655. */
  48656. createDefaultLight(replace?: boolean): void;
  48657. /**
  48658. * Creates a default camera for the scene.
  48659. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48660. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48661. * @param replace has default false, when true replaces the active camera in the scene
  48662. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48663. */
  48664. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48665. /**
  48666. * Creates a default camera and a default light.
  48667. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48668. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48669. * @param replace has the default false, when true replaces the active camera/light in the scene
  48670. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48671. */
  48672. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48673. /**
  48674. * Creates a new sky box
  48675. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48676. * @param environmentTexture defines the texture to use as environment texture
  48677. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48678. * @param scale defines the overall scale of the skybox
  48679. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48680. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48681. * @returns a new mesh holding the sky box
  48682. */
  48683. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48684. /**
  48685. * Creates a new environment
  48686. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48687. * @param options defines the options you can use to configure the environment
  48688. * @returns the new EnvironmentHelper
  48689. */
  48690. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48691. /**
  48692. * Creates a new VREXperienceHelper
  48693. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48694. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48695. * @returns a new VREXperienceHelper
  48696. */
  48697. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48698. /**
  48699. * Creates a new WebXRDefaultExperience
  48700. * @see http://doc.babylonjs.com/how_to/webxr
  48701. * @param options experience options
  48702. * @returns a promise for a new WebXRDefaultExperience
  48703. */
  48704. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48705. }
  48706. }
  48707. declare module BABYLON {
  48708. /**
  48709. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48710. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48711. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48712. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48713. */
  48714. export class VideoDome extends TransformNode {
  48715. /**
  48716. * Define the video source as a Monoscopic panoramic 360 video.
  48717. */
  48718. static readonly MODE_MONOSCOPIC: number;
  48719. /**
  48720. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48721. */
  48722. static readonly MODE_TOPBOTTOM: number;
  48723. /**
  48724. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48725. */
  48726. static readonly MODE_SIDEBYSIDE: number;
  48727. private _halfDome;
  48728. private _useDirectMapping;
  48729. /**
  48730. * The video texture being displayed on the sphere
  48731. */
  48732. protected _videoTexture: VideoTexture;
  48733. /**
  48734. * Gets the video texture being displayed on the sphere
  48735. */
  48736. readonly videoTexture: VideoTexture;
  48737. /**
  48738. * The skybox material
  48739. */
  48740. protected _material: BackgroundMaterial;
  48741. /**
  48742. * The surface used for the skybox
  48743. */
  48744. protected _mesh: Mesh;
  48745. /**
  48746. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48747. */
  48748. private _halfDomeMask;
  48749. /**
  48750. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48751. * Also see the options.resolution property.
  48752. */
  48753. fovMultiplier: number;
  48754. private _videoMode;
  48755. /**
  48756. * Gets or set the current video mode for the video. It can be:
  48757. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48758. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48759. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48760. */
  48761. videoMode: number;
  48762. /**
  48763. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48764. *
  48765. */
  48766. /**
  48767. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48768. */
  48769. halfDome: boolean;
  48770. /**
  48771. * Oberserver used in Stereoscopic VR Mode.
  48772. */
  48773. private _onBeforeCameraRenderObserver;
  48774. /**
  48775. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48776. * @param name Element's name, child elements will append suffixes for their own names.
  48777. * @param urlsOrVideo defines the url(s) or the video element to use
  48778. * @param options An object containing optional or exposed sub element properties
  48779. */
  48780. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48781. resolution?: number;
  48782. clickToPlay?: boolean;
  48783. autoPlay?: boolean;
  48784. loop?: boolean;
  48785. size?: number;
  48786. poster?: string;
  48787. faceForward?: boolean;
  48788. useDirectMapping?: boolean;
  48789. halfDomeMode?: boolean;
  48790. }, scene: Scene);
  48791. private _changeVideoMode;
  48792. /**
  48793. * Releases resources associated with this node.
  48794. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48795. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48796. */
  48797. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48798. }
  48799. }
  48800. declare module BABYLON {
  48801. /**
  48802. * This class can be used to get instrumentation data from a Babylon engine
  48803. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48804. */
  48805. export class EngineInstrumentation implements IDisposable {
  48806. /**
  48807. * Define the instrumented engine.
  48808. */
  48809. engine: Engine;
  48810. private _captureGPUFrameTime;
  48811. private _gpuFrameTimeToken;
  48812. private _gpuFrameTime;
  48813. private _captureShaderCompilationTime;
  48814. private _shaderCompilationTime;
  48815. private _onBeginFrameObserver;
  48816. private _onEndFrameObserver;
  48817. private _onBeforeShaderCompilationObserver;
  48818. private _onAfterShaderCompilationObserver;
  48819. /**
  48820. * Gets the perf counter used for GPU frame time
  48821. */
  48822. readonly gpuFrameTimeCounter: PerfCounter;
  48823. /**
  48824. * Gets the GPU frame time capture status
  48825. */
  48826. /**
  48827. * Enable or disable the GPU frame time capture
  48828. */
  48829. captureGPUFrameTime: boolean;
  48830. /**
  48831. * Gets the perf counter used for shader compilation time
  48832. */
  48833. readonly shaderCompilationTimeCounter: PerfCounter;
  48834. /**
  48835. * Gets the shader compilation time capture status
  48836. */
  48837. /**
  48838. * Enable or disable the shader compilation time capture
  48839. */
  48840. captureShaderCompilationTime: boolean;
  48841. /**
  48842. * Instantiates a new engine instrumentation.
  48843. * This class can be used to get instrumentation data from a Babylon engine
  48844. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48845. * @param engine Defines the engine to instrument
  48846. */
  48847. constructor(
  48848. /**
  48849. * Define the instrumented engine.
  48850. */
  48851. engine: Engine);
  48852. /**
  48853. * Dispose and release associated resources.
  48854. */
  48855. dispose(): void;
  48856. }
  48857. }
  48858. declare module BABYLON {
  48859. /**
  48860. * This class can be used to get instrumentation data from a Babylon engine
  48861. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48862. */
  48863. export class SceneInstrumentation implements IDisposable {
  48864. /**
  48865. * Defines the scene to instrument
  48866. */
  48867. scene: Scene;
  48868. private _captureActiveMeshesEvaluationTime;
  48869. private _activeMeshesEvaluationTime;
  48870. private _captureRenderTargetsRenderTime;
  48871. private _renderTargetsRenderTime;
  48872. private _captureFrameTime;
  48873. private _frameTime;
  48874. private _captureRenderTime;
  48875. private _renderTime;
  48876. private _captureInterFrameTime;
  48877. private _interFrameTime;
  48878. private _captureParticlesRenderTime;
  48879. private _particlesRenderTime;
  48880. private _captureSpritesRenderTime;
  48881. private _spritesRenderTime;
  48882. private _capturePhysicsTime;
  48883. private _physicsTime;
  48884. private _captureAnimationsTime;
  48885. private _animationsTime;
  48886. private _captureCameraRenderTime;
  48887. private _cameraRenderTime;
  48888. private _onBeforeActiveMeshesEvaluationObserver;
  48889. private _onAfterActiveMeshesEvaluationObserver;
  48890. private _onBeforeRenderTargetsRenderObserver;
  48891. private _onAfterRenderTargetsRenderObserver;
  48892. private _onAfterRenderObserver;
  48893. private _onBeforeDrawPhaseObserver;
  48894. private _onAfterDrawPhaseObserver;
  48895. private _onBeforeAnimationsObserver;
  48896. private _onBeforeParticlesRenderingObserver;
  48897. private _onAfterParticlesRenderingObserver;
  48898. private _onBeforeSpritesRenderingObserver;
  48899. private _onAfterSpritesRenderingObserver;
  48900. private _onBeforePhysicsObserver;
  48901. private _onAfterPhysicsObserver;
  48902. private _onAfterAnimationsObserver;
  48903. private _onBeforeCameraRenderObserver;
  48904. private _onAfterCameraRenderObserver;
  48905. /**
  48906. * Gets the perf counter used for active meshes evaluation time
  48907. */
  48908. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48909. /**
  48910. * Gets the active meshes evaluation time capture status
  48911. */
  48912. /**
  48913. * Enable or disable the active meshes evaluation time capture
  48914. */
  48915. captureActiveMeshesEvaluationTime: boolean;
  48916. /**
  48917. * Gets the perf counter used for render targets render time
  48918. */
  48919. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48920. /**
  48921. * Gets the render targets render time capture status
  48922. */
  48923. /**
  48924. * Enable or disable the render targets render time capture
  48925. */
  48926. captureRenderTargetsRenderTime: boolean;
  48927. /**
  48928. * Gets the perf counter used for particles render time
  48929. */
  48930. readonly particlesRenderTimeCounter: PerfCounter;
  48931. /**
  48932. * Gets the particles render time capture status
  48933. */
  48934. /**
  48935. * Enable or disable the particles render time capture
  48936. */
  48937. captureParticlesRenderTime: boolean;
  48938. /**
  48939. * Gets the perf counter used for sprites render time
  48940. */
  48941. readonly spritesRenderTimeCounter: PerfCounter;
  48942. /**
  48943. * Gets the sprites render time capture status
  48944. */
  48945. /**
  48946. * Enable or disable the sprites render time capture
  48947. */
  48948. captureSpritesRenderTime: boolean;
  48949. /**
  48950. * Gets the perf counter used for physics time
  48951. */
  48952. readonly physicsTimeCounter: PerfCounter;
  48953. /**
  48954. * Gets the physics time capture status
  48955. */
  48956. /**
  48957. * Enable or disable the physics time capture
  48958. */
  48959. capturePhysicsTime: boolean;
  48960. /**
  48961. * Gets the perf counter used for animations time
  48962. */
  48963. readonly animationsTimeCounter: PerfCounter;
  48964. /**
  48965. * Gets the animations time capture status
  48966. */
  48967. /**
  48968. * Enable or disable the animations time capture
  48969. */
  48970. captureAnimationsTime: boolean;
  48971. /**
  48972. * Gets the perf counter used for frame time capture
  48973. */
  48974. readonly frameTimeCounter: PerfCounter;
  48975. /**
  48976. * Gets the frame time capture status
  48977. */
  48978. /**
  48979. * Enable or disable the frame time capture
  48980. */
  48981. captureFrameTime: boolean;
  48982. /**
  48983. * Gets the perf counter used for inter-frames time capture
  48984. */
  48985. readonly interFrameTimeCounter: PerfCounter;
  48986. /**
  48987. * Gets the inter-frames time capture status
  48988. */
  48989. /**
  48990. * Enable or disable the inter-frames time capture
  48991. */
  48992. captureInterFrameTime: boolean;
  48993. /**
  48994. * Gets the perf counter used for render time capture
  48995. */
  48996. readonly renderTimeCounter: PerfCounter;
  48997. /**
  48998. * Gets the render time capture status
  48999. */
  49000. /**
  49001. * Enable or disable the render time capture
  49002. */
  49003. captureRenderTime: boolean;
  49004. /**
  49005. * Gets the perf counter used for camera render time capture
  49006. */
  49007. readonly cameraRenderTimeCounter: PerfCounter;
  49008. /**
  49009. * Gets the camera render time capture status
  49010. */
  49011. /**
  49012. * Enable or disable the camera render time capture
  49013. */
  49014. captureCameraRenderTime: boolean;
  49015. /**
  49016. * Gets the perf counter used for draw calls
  49017. */
  49018. readonly drawCallsCounter: PerfCounter;
  49019. /**
  49020. * Instantiates a new scene instrumentation.
  49021. * This class can be used to get instrumentation data from a Babylon engine
  49022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49023. * @param scene Defines the scene to instrument
  49024. */
  49025. constructor(
  49026. /**
  49027. * Defines the scene to instrument
  49028. */
  49029. scene: Scene);
  49030. /**
  49031. * Dispose and release associated resources.
  49032. */
  49033. dispose(): void;
  49034. }
  49035. }
  49036. declare module BABYLON {
  49037. /** @hidden */
  49038. export var glowMapGenerationPixelShader: {
  49039. name: string;
  49040. shader: string;
  49041. };
  49042. }
  49043. declare module BABYLON {
  49044. /** @hidden */
  49045. export var glowMapGenerationVertexShader: {
  49046. name: string;
  49047. shader: string;
  49048. };
  49049. }
  49050. declare module BABYLON {
  49051. /**
  49052. * Effect layer options. This helps customizing the behaviour
  49053. * of the effect layer.
  49054. */
  49055. export interface IEffectLayerOptions {
  49056. /**
  49057. * Multiplication factor apply to the canvas size to compute the render target size
  49058. * used to generated the objects (the smaller the faster).
  49059. */
  49060. mainTextureRatio: number;
  49061. /**
  49062. * Enforces a fixed size texture to ensure effect stability across devices.
  49063. */
  49064. mainTextureFixedSize?: number;
  49065. /**
  49066. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49067. */
  49068. alphaBlendingMode: number;
  49069. /**
  49070. * The camera attached to the layer.
  49071. */
  49072. camera: Nullable<Camera>;
  49073. /**
  49074. * The rendering group to draw the layer in.
  49075. */
  49076. renderingGroupId: number;
  49077. }
  49078. /**
  49079. * The effect layer Helps adding post process effect blended with the main pass.
  49080. *
  49081. * This can be for instance use to generate glow or higlight effects on the scene.
  49082. *
  49083. * The effect layer class can not be used directly and is intented to inherited from to be
  49084. * customized per effects.
  49085. */
  49086. export abstract class EffectLayer {
  49087. private _vertexBuffers;
  49088. private _indexBuffer;
  49089. private _cachedDefines;
  49090. private _effectLayerMapGenerationEffect;
  49091. private _effectLayerOptions;
  49092. private _mergeEffect;
  49093. protected _scene: Scene;
  49094. protected _engine: Engine;
  49095. protected _maxSize: number;
  49096. protected _mainTextureDesiredSize: ISize;
  49097. protected _mainTexture: RenderTargetTexture;
  49098. protected _shouldRender: boolean;
  49099. protected _postProcesses: PostProcess[];
  49100. protected _textures: BaseTexture[];
  49101. protected _emissiveTextureAndColor: {
  49102. texture: Nullable<BaseTexture>;
  49103. color: Color4;
  49104. };
  49105. /**
  49106. * The name of the layer
  49107. */
  49108. name: string;
  49109. /**
  49110. * The clear color of the texture used to generate the glow map.
  49111. */
  49112. neutralColor: Color4;
  49113. /**
  49114. * Specifies wether the highlight layer is enabled or not.
  49115. */
  49116. isEnabled: boolean;
  49117. /**
  49118. * Gets the camera attached to the layer.
  49119. */
  49120. readonly camera: Nullable<Camera>;
  49121. /**
  49122. * Gets the rendering group id the layer should render in.
  49123. */
  49124. renderingGroupId: number;
  49125. /**
  49126. * An event triggered when the effect layer has been disposed.
  49127. */
  49128. onDisposeObservable: Observable<EffectLayer>;
  49129. /**
  49130. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49131. */
  49132. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49133. /**
  49134. * An event triggered when the generated texture is being merged in the scene.
  49135. */
  49136. onBeforeComposeObservable: Observable<EffectLayer>;
  49137. /**
  49138. * An event triggered when the mesh is rendered into the effect render target.
  49139. */
  49140. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  49141. /**
  49142. * An event triggered after the mesh has been rendered into the effect render target.
  49143. */
  49144. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  49145. /**
  49146. * An event triggered when the generated texture has been merged in the scene.
  49147. */
  49148. onAfterComposeObservable: Observable<EffectLayer>;
  49149. /**
  49150. * An event triggered when the efffect layer changes its size.
  49151. */
  49152. onSizeChangedObservable: Observable<EffectLayer>;
  49153. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49154. /**
  49155. * Instantiates a new effect Layer and references it in the scene.
  49156. * @param name The name of the layer
  49157. * @param scene The scene to use the layer in
  49158. */
  49159. constructor(
  49160. /** The Friendly of the effect in the scene */
  49161. name: string, scene: Scene);
  49162. /**
  49163. * Get the effect name of the layer.
  49164. * @return The effect name
  49165. */
  49166. abstract getEffectName(): string;
  49167. /**
  49168. * Checks for the readiness of the element composing the layer.
  49169. * @param subMesh the mesh to check for
  49170. * @param useInstances specify wether or not to use instances to render the mesh
  49171. * @return true if ready otherwise, false
  49172. */
  49173. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49174. /**
  49175. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49176. * @returns true if the effect requires stencil during the main canvas render pass.
  49177. */
  49178. abstract needStencil(): boolean;
  49179. /**
  49180. * Create the merge effect. This is the shader use to blit the information back
  49181. * to the main canvas at the end of the scene rendering.
  49182. * @returns The effect containing the shader used to merge the effect on the main canvas
  49183. */
  49184. protected abstract _createMergeEffect(): Effect;
  49185. /**
  49186. * Creates the render target textures and post processes used in the effect layer.
  49187. */
  49188. protected abstract _createTextureAndPostProcesses(): void;
  49189. /**
  49190. * Implementation specific of rendering the generating effect on the main canvas.
  49191. * @param effect The effect used to render through
  49192. */
  49193. protected abstract _internalRender(effect: Effect): void;
  49194. /**
  49195. * Sets the required values for both the emissive texture and and the main color.
  49196. */
  49197. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49198. /**
  49199. * Free any resources and references associated to a mesh.
  49200. * Internal use
  49201. * @param mesh The mesh to free.
  49202. */
  49203. abstract _disposeMesh(mesh: Mesh): void;
  49204. /**
  49205. * Serializes this layer (Glow or Highlight for example)
  49206. * @returns a serialized layer object
  49207. */
  49208. abstract serialize?(): any;
  49209. /**
  49210. * Initializes the effect layer with the required options.
  49211. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49212. */
  49213. protected _init(options: Partial<IEffectLayerOptions>): void;
  49214. /**
  49215. * Generates the index buffer of the full screen quad blending to the main canvas.
  49216. */
  49217. private _generateIndexBuffer;
  49218. /**
  49219. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49220. */
  49221. private _generateVertexBuffer;
  49222. /**
  49223. * Sets the main texture desired size which is the closest power of two
  49224. * of the engine canvas size.
  49225. */
  49226. private _setMainTextureSize;
  49227. /**
  49228. * Creates the main texture for the effect layer.
  49229. */
  49230. protected _createMainTexture(): void;
  49231. /**
  49232. * Adds specific effects defines.
  49233. * @param defines The defines to add specifics to.
  49234. */
  49235. protected _addCustomEffectDefines(defines: string[]): void;
  49236. /**
  49237. * Checks for the readiness of the element composing the layer.
  49238. * @param subMesh the mesh to check for
  49239. * @param useInstances specify wether or not to use instances to render the mesh
  49240. * @param emissiveTexture the associated emissive texture used to generate the glow
  49241. * @return true if ready otherwise, false
  49242. */
  49243. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49244. /**
  49245. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49246. */
  49247. render(): void;
  49248. /**
  49249. * Determine if a given mesh will be used in the current effect.
  49250. * @param mesh mesh to test
  49251. * @returns true if the mesh will be used
  49252. */
  49253. hasMesh(mesh: AbstractMesh): boolean;
  49254. /**
  49255. * Returns true if the layer contains information to display, otherwise false.
  49256. * @returns true if the glow layer should be rendered
  49257. */
  49258. shouldRender(): boolean;
  49259. /**
  49260. * Returns true if the mesh should render, otherwise false.
  49261. * @param mesh The mesh to render
  49262. * @returns true if it should render otherwise false
  49263. */
  49264. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49265. /**
  49266. * Returns true if the mesh can be rendered, otherwise false.
  49267. * @param mesh The mesh to render
  49268. * @param material The material used on the mesh
  49269. * @returns true if it can be rendered otherwise false
  49270. */
  49271. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49272. /**
  49273. * Returns true if the mesh should render, otherwise false.
  49274. * @param mesh The mesh to render
  49275. * @returns true if it should render otherwise false
  49276. */
  49277. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49278. /**
  49279. * Renders the submesh passed in parameter to the generation map.
  49280. */
  49281. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49282. /**
  49283. * Defines wether the current material of the mesh should be use to render the effect.
  49284. * @param mesh defines the current mesh to render
  49285. */
  49286. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  49287. /**
  49288. * Rebuild the required buffers.
  49289. * @hidden Internal use only.
  49290. */ private _rebuild(): void;
  49291. /**
  49292. * Dispose only the render target textures and post process.
  49293. */
  49294. private _disposeTextureAndPostProcesses;
  49295. /**
  49296. * Dispose the highlight layer and free resources.
  49297. */
  49298. dispose(): void;
  49299. /**
  49300. * Gets the class name of the effect layer
  49301. * @returns the string with the class name of the effect layer
  49302. */
  49303. getClassName(): string;
  49304. /**
  49305. * Creates an effect layer from parsed effect layer data
  49306. * @param parsedEffectLayer defines effect layer data
  49307. * @param scene defines the current scene
  49308. * @param rootUrl defines the root URL containing the effect layer information
  49309. * @returns a parsed effect Layer
  49310. */
  49311. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49312. }
  49313. }
  49314. declare module BABYLON {
  49315. interface AbstractScene {
  49316. /**
  49317. * The list of effect layers (highlights/glow) added to the scene
  49318. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49319. * @see http://doc.babylonjs.com/how_to/glow_layer
  49320. */
  49321. effectLayers: Array<EffectLayer>;
  49322. /**
  49323. * Removes the given effect layer from this scene.
  49324. * @param toRemove defines the effect layer to remove
  49325. * @returns the index of the removed effect layer
  49326. */
  49327. removeEffectLayer(toRemove: EffectLayer): number;
  49328. /**
  49329. * Adds the given effect layer to this scene
  49330. * @param newEffectLayer defines the effect layer to add
  49331. */
  49332. addEffectLayer(newEffectLayer: EffectLayer): void;
  49333. }
  49334. /**
  49335. * Defines the layer scene component responsible to manage any effect layers
  49336. * in a given scene.
  49337. */
  49338. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49339. /**
  49340. * The component name helpfull to identify the component in the list of scene components.
  49341. */
  49342. readonly name: string;
  49343. /**
  49344. * The scene the component belongs to.
  49345. */
  49346. scene: Scene;
  49347. private _engine;
  49348. private _renderEffects;
  49349. private _needStencil;
  49350. private _previousStencilState;
  49351. /**
  49352. * Creates a new instance of the component for the given scene
  49353. * @param scene Defines the scene to register the component in
  49354. */
  49355. constructor(scene: Scene);
  49356. /**
  49357. * Registers the component in a given scene
  49358. */
  49359. register(): void;
  49360. /**
  49361. * Rebuilds the elements related to this component in case of
  49362. * context lost for instance.
  49363. */
  49364. rebuild(): void;
  49365. /**
  49366. * Serializes the component data to the specified json object
  49367. * @param serializationObject The object to serialize to
  49368. */
  49369. serialize(serializationObject: any): void;
  49370. /**
  49371. * Adds all the elements from the container to the scene
  49372. * @param container the container holding the elements
  49373. */
  49374. addFromContainer(container: AbstractScene): void;
  49375. /**
  49376. * Removes all the elements in the container from the scene
  49377. * @param container contains the elements to remove
  49378. * @param dispose if the removed element should be disposed (default: false)
  49379. */
  49380. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49381. /**
  49382. * Disposes the component and the associated ressources.
  49383. */
  49384. dispose(): void;
  49385. private _isReadyForMesh;
  49386. private _renderMainTexture;
  49387. private _setStencil;
  49388. private _setStencilBack;
  49389. private _draw;
  49390. private _drawCamera;
  49391. private _drawRenderingGroup;
  49392. }
  49393. }
  49394. declare module BABYLON {
  49395. /** @hidden */
  49396. export var glowMapMergePixelShader: {
  49397. name: string;
  49398. shader: string;
  49399. };
  49400. }
  49401. declare module BABYLON {
  49402. /** @hidden */
  49403. export var glowMapMergeVertexShader: {
  49404. name: string;
  49405. shader: string;
  49406. };
  49407. }
  49408. declare module BABYLON {
  49409. interface AbstractScene {
  49410. /**
  49411. * Return a the first highlight layer of the scene with a given name.
  49412. * @param name The name of the highlight layer to look for.
  49413. * @return The highlight layer if found otherwise null.
  49414. */
  49415. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49416. }
  49417. /**
  49418. * Glow layer options. This helps customizing the behaviour
  49419. * of the glow layer.
  49420. */
  49421. export interface IGlowLayerOptions {
  49422. /**
  49423. * Multiplication factor apply to the canvas size to compute the render target size
  49424. * used to generated the glowing objects (the smaller the faster).
  49425. */
  49426. mainTextureRatio: number;
  49427. /**
  49428. * Enforces a fixed size texture to ensure resize independant blur.
  49429. */
  49430. mainTextureFixedSize?: number;
  49431. /**
  49432. * How big is the kernel of the blur texture.
  49433. */
  49434. blurKernelSize: number;
  49435. /**
  49436. * The camera attached to the layer.
  49437. */
  49438. camera: Nullable<Camera>;
  49439. /**
  49440. * Enable MSAA by chosing the number of samples.
  49441. */
  49442. mainTextureSamples?: number;
  49443. /**
  49444. * The rendering group to draw the layer in.
  49445. */
  49446. renderingGroupId: number;
  49447. }
  49448. /**
  49449. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49450. *
  49451. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  49452. *
  49453. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49454. */
  49455. export class GlowLayer extends EffectLayer {
  49456. /**
  49457. * Effect Name of the layer.
  49458. */
  49459. static readonly EffectName: string;
  49460. /**
  49461. * The default blur kernel size used for the glow.
  49462. */
  49463. static DefaultBlurKernelSize: number;
  49464. /**
  49465. * The default texture size ratio used for the glow.
  49466. */
  49467. static DefaultTextureRatio: number;
  49468. /**
  49469. * Sets the kernel size of the blur.
  49470. */
  49471. /**
  49472. * Gets the kernel size of the blur.
  49473. */
  49474. blurKernelSize: number;
  49475. /**
  49476. * Sets the glow intensity.
  49477. */
  49478. /**
  49479. * Gets the glow intensity.
  49480. */
  49481. intensity: number;
  49482. private _options;
  49483. private _intensity;
  49484. private _horizontalBlurPostprocess1;
  49485. private _verticalBlurPostprocess1;
  49486. private _horizontalBlurPostprocess2;
  49487. private _verticalBlurPostprocess2;
  49488. private _blurTexture1;
  49489. private _blurTexture2;
  49490. private _postProcesses1;
  49491. private _postProcesses2;
  49492. private _includedOnlyMeshes;
  49493. private _excludedMeshes;
  49494. private _meshesUsingTheirOwnMaterials;
  49495. /**
  49496. * Callback used to let the user override the color selection on a per mesh basis
  49497. */
  49498. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49499. /**
  49500. * Callback used to let the user override the texture selection on a per mesh basis
  49501. */
  49502. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49503. /**
  49504. * Instantiates a new glow Layer and references it to the scene.
  49505. * @param name The name of the layer
  49506. * @param scene The scene to use the layer in
  49507. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49508. */
  49509. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49510. /**
  49511. * Get the effect name of the layer.
  49512. * @return The effect name
  49513. */
  49514. getEffectName(): string;
  49515. /**
  49516. * Create the merge effect. This is the shader use to blit the information back
  49517. * to the main canvas at the end of the scene rendering.
  49518. */
  49519. protected _createMergeEffect(): Effect;
  49520. /**
  49521. * Creates the render target textures and post processes used in the glow layer.
  49522. */
  49523. protected _createTextureAndPostProcesses(): void;
  49524. /**
  49525. * Checks for the readiness of the element composing the layer.
  49526. * @param subMesh the mesh to check for
  49527. * @param useInstances specify wether or not to use instances to render the mesh
  49528. * @param emissiveTexture the associated emissive texture used to generate the glow
  49529. * @return true if ready otherwise, false
  49530. */
  49531. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49532. /**
  49533. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49534. */
  49535. needStencil(): boolean;
  49536. /**
  49537. * Returns true if the mesh can be rendered, otherwise false.
  49538. * @param mesh The mesh to render
  49539. * @param material The material used on the mesh
  49540. * @returns true if it can be rendered otherwise false
  49541. */
  49542. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49543. /**
  49544. * Implementation specific of rendering the generating effect on the main canvas.
  49545. * @param effect The effect used to render through
  49546. */
  49547. protected _internalRender(effect: Effect): void;
  49548. /**
  49549. * Sets the required values for both the emissive texture and and the main color.
  49550. */
  49551. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49552. /**
  49553. * Returns true if the mesh should render, otherwise false.
  49554. * @param mesh The mesh to render
  49555. * @returns true if it should render otherwise false
  49556. */
  49557. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49558. /**
  49559. * Adds specific effects defines.
  49560. * @param defines The defines to add specifics to.
  49561. */
  49562. protected _addCustomEffectDefines(defines: string[]): void;
  49563. /**
  49564. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49565. * @param mesh The mesh to exclude from the glow layer
  49566. */
  49567. addExcludedMesh(mesh: Mesh): void;
  49568. /**
  49569. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49570. * @param mesh The mesh to remove
  49571. */
  49572. removeExcludedMesh(mesh: Mesh): void;
  49573. /**
  49574. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49575. * @param mesh The mesh to include in the glow layer
  49576. */
  49577. addIncludedOnlyMesh(mesh: Mesh): void;
  49578. /**
  49579. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49580. * @param mesh The mesh to remove
  49581. */
  49582. removeIncludedOnlyMesh(mesh: Mesh): void;
  49583. /**
  49584. * Determine if a given mesh will be used in the glow layer
  49585. * @param mesh The mesh to test
  49586. * @returns true if the mesh will be highlighted by the current glow layer
  49587. */
  49588. hasMesh(mesh: AbstractMesh): boolean;
  49589. /**
  49590. * Defines wether the current material of the mesh should be use to render the effect.
  49591. * @param mesh defines the current mesh to render
  49592. */
  49593. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  49594. /**
  49595. * Add a mesh to be rendered through its own material and not with emissive only.
  49596. * @param mesh The mesh for which we need to use its material
  49597. */
  49598. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  49599. /**
  49600. * Remove a mesh from being rendered through its own material and not with emissive only.
  49601. * @param mesh The mesh for which we need to not use its material
  49602. */
  49603. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  49604. /**
  49605. * Free any resources and references associated to a mesh.
  49606. * Internal use
  49607. * @param mesh The mesh to free.
  49608. * @hidden
  49609. */ private _disposeMesh(mesh: Mesh): void;
  49610. /**
  49611. * Gets the class name of the effect layer
  49612. * @returns the string with the class name of the effect layer
  49613. */
  49614. getClassName(): string;
  49615. /**
  49616. * Serializes this glow layer
  49617. * @returns a serialized glow layer object
  49618. */
  49619. serialize(): any;
  49620. /**
  49621. * Creates a Glow Layer from parsed glow layer data
  49622. * @param parsedGlowLayer defines glow layer data
  49623. * @param scene defines the current scene
  49624. * @param rootUrl defines the root URL containing the glow layer information
  49625. * @returns a parsed Glow Layer
  49626. */
  49627. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49628. }
  49629. }
  49630. declare module BABYLON {
  49631. /** @hidden */
  49632. export var glowBlurPostProcessPixelShader: {
  49633. name: string;
  49634. shader: string;
  49635. };
  49636. }
  49637. declare module BABYLON {
  49638. interface AbstractScene {
  49639. /**
  49640. * Return a the first highlight layer of the scene with a given name.
  49641. * @param name The name of the highlight layer to look for.
  49642. * @return The highlight layer if found otherwise null.
  49643. */
  49644. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49645. }
  49646. /**
  49647. * Highlight layer options. This helps customizing the behaviour
  49648. * of the highlight layer.
  49649. */
  49650. export interface IHighlightLayerOptions {
  49651. /**
  49652. * Multiplication factor apply to the canvas size to compute the render target size
  49653. * used to generated the glowing objects (the smaller the faster).
  49654. */
  49655. mainTextureRatio: number;
  49656. /**
  49657. * Enforces a fixed size texture to ensure resize independant blur.
  49658. */
  49659. mainTextureFixedSize?: number;
  49660. /**
  49661. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49662. * of the picture to blur (the smaller the faster).
  49663. */
  49664. blurTextureSizeRatio: number;
  49665. /**
  49666. * How big in texel of the blur texture is the vertical blur.
  49667. */
  49668. blurVerticalSize: number;
  49669. /**
  49670. * How big in texel of the blur texture is the horizontal blur.
  49671. */
  49672. blurHorizontalSize: number;
  49673. /**
  49674. * Alpha blending mode used to apply the blur. Default is combine.
  49675. */
  49676. alphaBlendingMode: number;
  49677. /**
  49678. * The camera attached to the layer.
  49679. */
  49680. camera: Nullable<Camera>;
  49681. /**
  49682. * Should we display highlight as a solid stroke?
  49683. */
  49684. isStroke?: boolean;
  49685. /**
  49686. * The rendering group to draw the layer in.
  49687. */
  49688. renderingGroupId: number;
  49689. }
  49690. /**
  49691. * The highlight layer Helps adding a glow effect around a mesh.
  49692. *
  49693. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  49694. * glowy meshes to your scene.
  49695. *
  49696. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49697. */
  49698. export class HighlightLayer extends EffectLayer {
  49699. name: string;
  49700. /**
  49701. * Effect Name of the highlight layer.
  49702. */
  49703. static readonly EffectName: string;
  49704. /**
  49705. * The neutral color used during the preparation of the glow effect.
  49706. * This is black by default as the blend operation is a blend operation.
  49707. */
  49708. static NeutralColor: Color4;
  49709. /**
  49710. * Stencil value used for glowing meshes.
  49711. */
  49712. static GlowingMeshStencilReference: number;
  49713. /**
  49714. * Stencil value used for the other meshes in the scene.
  49715. */
  49716. static NormalMeshStencilReference: number;
  49717. /**
  49718. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49719. */
  49720. innerGlow: boolean;
  49721. /**
  49722. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49723. */
  49724. outerGlow: boolean;
  49725. /**
  49726. * Specifies the horizontal size of the blur.
  49727. */
  49728. /**
  49729. * Gets the horizontal size of the blur.
  49730. */
  49731. blurHorizontalSize: number;
  49732. /**
  49733. * Specifies the vertical size of the blur.
  49734. */
  49735. /**
  49736. * Gets the vertical size of the blur.
  49737. */
  49738. blurVerticalSize: number;
  49739. /**
  49740. * An event triggered when the highlight layer is being blurred.
  49741. */
  49742. onBeforeBlurObservable: Observable<HighlightLayer>;
  49743. /**
  49744. * An event triggered when the highlight layer has been blurred.
  49745. */
  49746. onAfterBlurObservable: Observable<HighlightLayer>;
  49747. private _instanceGlowingMeshStencilReference;
  49748. private _options;
  49749. private _downSamplePostprocess;
  49750. private _horizontalBlurPostprocess;
  49751. private _verticalBlurPostprocess;
  49752. private _blurTexture;
  49753. private _meshes;
  49754. private _excludedMeshes;
  49755. /**
  49756. * Instantiates a new highlight Layer and references it to the scene..
  49757. * @param name The name of the layer
  49758. * @param scene The scene to use the layer in
  49759. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49760. */
  49761. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49762. /**
  49763. * Get the effect name of the layer.
  49764. * @return The effect name
  49765. */
  49766. getEffectName(): string;
  49767. /**
  49768. * Create the merge effect. This is the shader use to blit the information back
  49769. * to the main canvas at the end of the scene rendering.
  49770. */
  49771. protected _createMergeEffect(): Effect;
  49772. /**
  49773. * Creates the render target textures and post processes used in the highlight layer.
  49774. */
  49775. protected _createTextureAndPostProcesses(): void;
  49776. /**
  49777. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49778. */
  49779. needStencil(): boolean;
  49780. /**
  49781. * Checks for the readiness of the element composing the layer.
  49782. * @param subMesh the mesh to check for
  49783. * @param useInstances specify wether or not to use instances to render the mesh
  49784. * @param emissiveTexture the associated emissive texture used to generate the glow
  49785. * @return true if ready otherwise, false
  49786. */
  49787. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49788. /**
  49789. * Implementation specific of rendering the generating effect on the main canvas.
  49790. * @param effect The effect used to render through
  49791. */
  49792. protected _internalRender(effect: Effect): void;
  49793. /**
  49794. * Returns true if the layer contains information to display, otherwise false.
  49795. */
  49796. shouldRender(): boolean;
  49797. /**
  49798. * Returns true if the mesh should render, otherwise false.
  49799. * @param mesh The mesh to render
  49800. * @returns true if it should render otherwise false
  49801. */
  49802. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49803. /**
  49804. * Sets the required values for both the emissive texture and and the main color.
  49805. */
  49806. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49807. /**
  49808. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49809. * @param mesh The mesh to exclude from the highlight layer
  49810. */
  49811. addExcludedMesh(mesh: Mesh): void;
  49812. /**
  49813. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49814. * @param mesh The mesh to highlight
  49815. */
  49816. removeExcludedMesh(mesh: Mesh): void;
  49817. /**
  49818. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49819. * @param mesh mesh to test
  49820. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49821. */
  49822. hasMesh(mesh: AbstractMesh): boolean;
  49823. /**
  49824. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49825. * @param mesh The mesh to highlight
  49826. * @param color The color of the highlight
  49827. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49828. */
  49829. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49830. /**
  49831. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49832. * @param mesh The mesh to highlight
  49833. */
  49834. removeMesh(mesh: Mesh): void;
  49835. /**
  49836. * Force the stencil to the normal expected value for none glowing parts
  49837. */
  49838. private _defaultStencilReference;
  49839. /**
  49840. * Free any resources and references associated to a mesh.
  49841. * Internal use
  49842. * @param mesh The mesh to free.
  49843. * @hidden
  49844. */ private _disposeMesh(mesh: Mesh): void;
  49845. /**
  49846. * Dispose the highlight layer and free resources.
  49847. */
  49848. dispose(): void;
  49849. /**
  49850. * Gets the class name of the effect layer
  49851. * @returns the string with the class name of the effect layer
  49852. */
  49853. getClassName(): string;
  49854. /**
  49855. * Serializes this Highlight layer
  49856. * @returns a serialized Highlight layer object
  49857. */
  49858. serialize(): any;
  49859. /**
  49860. * Creates a Highlight layer from parsed Highlight layer data
  49861. * @param parsedHightlightLayer defines the Highlight layer data
  49862. * @param scene defines the current scene
  49863. * @param rootUrl defines the root URL containing the Highlight layer information
  49864. * @returns a parsed Highlight layer
  49865. */
  49866. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49867. }
  49868. }
  49869. declare module BABYLON {
  49870. interface AbstractScene {
  49871. /**
  49872. * The list of layers (background and foreground) of the scene
  49873. */
  49874. layers: Array<Layer>;
  49875. }
  49876. /**
  49877. * Defines the layer scene component responsible to manage any layers
  49878. * in a given scene.
  49879. */
  49880. export class LayerSceneComponent implements ISceneComponent {
  49881. /**
  49882. * The component name helpfull to identify the component in the list of scene components.
  49883. */
  49884. readonly name: string;
  49885. /**
  49886. * The scene the component belongs to.
  49887. */
  49888. scene: Scene;
  49889. private _engine;
  49890. /**
  49891. * Creates a new instance of the component for the given scene
  49892. * @param scene Defines the scene to register the component in
  49893. */
  49894. constructor(scene: Scene);
  49895. /**
  49896. * Registers the component in a given scene
  49897. */
  49898. register(): void;
  49899. /**
  49900. * Rebuilds the elements related to this component in case of
  49901. * context lost for instance.
  49902. */
  49903. rebuild(): void;
  49904. /**
  49905. * Disposes the component and the associated ressources.
  49906. */
  49907. dispose(): void;
  49908. private _draw;
  49909. private _drawCameraPredicate;
  49910. private _drawCameraBackground;
  49911. private _drawCameraForeground;
  49912. private _drawRenderTargetPredicate;
  49913. private _drawRenderTargetBackground;
  49914. private _drawRenderTargetForeground;
  49915. /**
  49916. * Adds all the elements from the container to the scene
  49917. * @param container the container holding the elements
  49918. */
  49919. addFromContainer(container: AbstractScene): void;
  49920. /**
  49921. * Removes all the elements in the container from the scene
  49922. * @param container contains the elements to remove
  49923. * @param dispose if the removed element should be disposed (default: false)
  49924. */
  49925. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49926. }
  49927. }
  49928. declare module BABYLON {
  49929. /** @hidden */
  49930. export var layerPixelShader: {
  49931. name: string;
  49932. shader: string;
  49933. };
  49934. }
  49935. declare module BABYLON {
  49936. /** @hidden */
  49937. export var layerVertexShader: {
  49938. name: string;
  49939. shader: string;
  49940. };
  49941. }
  49942. declare module BABYLON {
  49943. /**
  49944. * This represents a full screen 2d layer.
  49945. * This can be useful to display a picture in the background of your scene for instance.
  49946. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49947. */
  49948. export class Layer {
  49949. /**
  49950. * Define the name of the layer.
  49951. */
  49952. name: string;
  49953. /**
  49954. * Define the texture the layer should display.
  49955. */
  49956. texture: Nullable<Texture>;
  49957. /**
  49958. * Is the layer in background or foreground.
  49959. */
  49960. isBackground: boolean;
  49961. /**
  49962. * Define the color of the layer (instead of texture).
  49963. */
  49964. color: Color4;
  49965. /**
  49966. * Define the scale of the layer in order to zoom in out of the texture.
  49967. */
  49968. scale: Vector2;
  49969. /**
  49970. * Define an offset for the layer in order to shift the texture.
  49971. */
  49972. offset: Vector2;
  49973. /**
  49974. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49975. */
  49976. alphaBlendingMode: number;
  49977. /**
  49978. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49979. * Alpha test will not mix with the background color in case of transparency.
  49980. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49981. */
  49982. alphaTest: boolean;
  49983. /**
  49984. * Define a mask to restrict the layer to only some of the scene cameras.
  49985. */
  49986. layerMask: number;
  49987. /**
  49988. * Define the list of render target the layer is visible into.
  49989. */
  49990. renderTargetTextures: RenderTargetTexture[];
  49991. /**
  49992. * Define if the layer is only used in renderTarget or if it also
  49993. * renders in the main frame buffer of the canvas.
  49994. */
  49995. renderOnlyInRenderTargetTextures: boolean;
  49996. private _scene;
  49997. private _vertexBuffers;
  49998. private _indexBuffer;
  49999. private _effect;
  50000. private _alphaTestEffect;
  50001. /**
  50002. * An event triggered when the layer is disposed.
  50003. */
  50004. onDisposeObservable: Observable<Layer>;
  50005. private _onDisposeObserver;
  50006. /**
  50007. * Back compatibility with callback before the onDisposeObservable existed.
  50008. * The set callback will be triggered when the layer has been disposed.
  50009. */
  50010. onDispose: () => void;
  50011. /**
  50012. * An event triggered before rendering the scene
  50013. */
  50014. onBeforeRenderObservable: Observable<Layer>;
  50015. private _onBeforeRenderObserver;
  50016. /**
  50017. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50018. * The set callback will be triggered just before rendering the layer.
  50019. */
  50020. onBeforeRender: () => void;
  50021. /**
  50022. * An event triggered after rendering the scene
  50023. */
  50024. onAfterRenderObservable: Observable<Layer>;
  50025. private _onAfterRenderObserver;
  50026. /**
  50027. * Back compatibility with callback before the onAfterRenderObservable existed.
  50028. * The set callback will be triggered just after rendering the layer.
  50029. */
  50030. onAfterRender: () => void;
  50031. /**
  50032. * Instantiates a new layer.
  50033. * This represents a full screen 2d layer.
  50034. * This can be useful to display a picture in the background of your scene for instance.
  50035. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50036. * @param name Define the name of the layer in the scene
  50037. * @param imgUrl Define the url of the texture to display in the layer
  50038. * @param scene Define the scene the layer belongs to
  50039. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50040. * @param color Defines a color for the layer
  50041. */
  50042. constructor(
  50043. /**
  50044. * Define the name of the layer.
  50045. */
  50046. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50047. private _createIndexBuffer;
  50048. /** @hidden */ private _rebuild(): void;
  50049. /**
  50050. * Renders the layer in the scene.
  50051. */
  50052. render(): void;
  50053. /**
  50054. * Disposes and releases the associated ressources.
  50055. */
  50056. dispose(): void;
  50057. }
  50058. }
  50059. declare module BABYLON {
  50060. /** @hidden */
  50061. export var lensFlarePixelShader: {
  50062. name: string;
  50063. shader: string;
  50064. };
  50065. }
  50066. declare module BABYLON {
  50067. /** @hidden */
  50068. export var lensFlareVertexShader: {
  50069. name: string;
  50070. shader: string;
  50071. };
  50072. }
  50073. declare module BABYLON {
  50074. /**
  50075. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50076. * It is usually composed of several `lensFlare`.
  50077. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50078. */
  50079. export class LensFlareSystem {
  50080. /**
  50081. * Define the name of the lens flare system
  50082. */
  50083. name: string;
  50084. /**
  50085. * List of lens flares used in this system.
  50086. */
  50087. lensFlares: LensFlare[];
  50088. /**
  50089. * Define a limit from the border the lens flare can be visible.
  50090. */
  50091. borderLimit: number;
  50092. /**
  50093. * Define a viewport border we do not want to see the lens flare in.
  50094. */
  50095. viewportBorder: number;
  50096. /**
  50097. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50098. */
  50099. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50100. /**
  50101. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50102. */
  50103. layerMask: number;
  50104. /**
  50105. * Define the id of the lens flare system in the scene.
  50106. * (equal to name by default)
  50107. */
  50108. id: string;
  50109. private _scene;
  50110. private _emitter;
  50111. private _vertexBuffers;
  50112. private _indexBuffer;
  50113. private _effect;
  50114. private _positionX;
  50115. private _positionY;
  50116. private _isEnabled;
  50117. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  50118. /**
  50119. * Instantiates a lens flare system.
  50120. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50121. * It is usually composed of several `lensFlare`.
  50122. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50123. * @param name Define the name of the lens flare system in the scene
  50124. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50125. * @param scene Define the scene the lens flare system belongs to
  50126. */
  50127. constructor(
  50128. /**
  50129. * Define the name of the lens flare system
  50130. */
  50131. name: string, emitter: any, scene: Scene);
  50132. /**
  50133. * Define if the lens flare system is enabled.
  50134. */
  50135. isEnabled: boolean;
  50136. /**
  50137. * Get the scene the effects belongs to.
  50138. * @returns the scene holding the lens flare system
  50139. */
  50140. getScene(): Scene;
  50141. /**
  50142. * Get the emitter of the lens flare system.
  50143. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50144. * @returns the emitter of the lens flare system
  50145. */
  50146. getEmitter(): any;
  50147. /**
  50148. * Set the emitter of the lens flare system.
  50149. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50150. * @param newEmitter Define the new emitter of the system
  50151. */
  50152. setEmitter(newEmitter: any): void;
  50153. /**
  50154. * Get the lens flare system emitter position.
  50155. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50156. * @returns the position
  50157. */
  50158. getEmitterPosition(): Vector3;
  50159. /**
  50160. * @hidden
  50161. */
  50162. computeEffectivePosition(globalViewport: Viewport): boolean;
  50163. /** @hidden */ private _isVisible(): boolean;
  50164. /**
  50165. * @hidden
  50166. */
  50167. render(): boolean;
  50168. /**
  50169. * Dispose and release the lens flare with its associated resources.
  50170. */
  50171. dispose(): void;
  50172. /**
  50173. * Parse a lens flare system from a JSON repressentation
  50174. * @param parsedLensFlareSystem Define the JSON to parse
  50175. * @param scene Define the scene the parsed system should be instantiated in
  50176. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50177. * @returns the parsed system
  50178. */
  50179. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50180. /**
  50181. * Serialize the current Lens Flare System into a JSON representation.
  50182. * @returns the serialized JSON
  50183. */
  50184. serialize(): any;
  50185. }
  50186. }
  50187. declare module BABYLON {
  50188. /**
  50189. * This represents one of the lens effect in a `lensFlareSystem`.
  50190. * It controls one of the indiviual texture used in the effect.
  50191. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50192. */
  50193. export class LensFlare {
  50194. /**
  50195. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50196. */
  50197. size: number;
  50198. /**
  50199. * 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.
  50200. */
  50201. position: number;
  50202. /**
  50203. * Define the lens color.
  50204. */
  50205. color: Color3;
  50206. /**
  50207. * Define the lens texture.
  50208. */
  50209. texture: Nullable<Texture>;
  50210. /**
  50211. * Define the alpha mode to render this particular lens.
  50212. */
  50213. alphaMode: number;
  50214. private _system;
  50215. /**
  50216. * Creates a new Lens Flare.
  50217. * This represents one of the lens effect in a `lensFlareSystem`.
  50218. * It controls one of the indiviual texture used in the effect.
  50219. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50220. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50221. * @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.
  50222. * @param color Define the lens color
  50223. * @param imgUrl Define the lens texture url
  50224. * @param system Define the `lensFlareSystem` this flare is part of
  50225. * @returns The newly created Lens Flare
  50226. */
  50227. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50228. /**
  50229. * Instantiates a new Lens Flare.
  50230. * This represents one of the lens effect in a `lensFlareSystem`.
  50231. * It controls one of the indiviual texture used in the effect.
  50232. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50233. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50234. * @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.
  50235. * @param color Define the lens color
  50236. * @param imgUrl Define the lens texture url
  50237. * @param system Define the `lensFlareSystem` this flare is part of
  50238. */
  50239. constructor(
  50240. /**
  50241. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50242. */
  50243. size: number,
  50244. /**
  50245. * 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.
  50246. */
  50247. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50248. /**
  50249. * Dispose and release the lens flare with its associated resources.
  50250. */
  50251. dispose(): void;
  50252. }
  50253. }
  50254. declare module BABYLON {
  50255. interface AbstractScene {
  50256. /**
  50257. * The list of lens flare system added to the scene
  50258. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50259. */
  50260. lensFlareSystems: Array<LensFlareSystem>;
  50261. /**
  50262. * Removes the given lens flare system from this scene.
  50263. * @param toRemove The lens flare system to remove
  50264. * @returns The index of the removed lens flare system
  50265. */
  50266. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50267. /**
  50268. * Adds the given lens flare system to this scene
  50269. * @param newLensFlareSystem The lens flare system to add
  50270. */
  50271. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50272. /**
  50273. * Gets a lens flare system using its name
  50274. * @param name defines the name to look for
  50275. * @returns the lens flare system or null if not found
  50276. */
  50277. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50278. /**
  50279. * Gets a lens flare system using its id
  50280. * @param id defines the id to look for
  50281. * @returns the lens flare system or null if not found
  50282. */
  50283. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50284. }
  50285. /**
  50286. * Defines the lens flare scene component responsible to manage any lens flares
  50287. * in a given scene.
  50288. */
  50289. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50290. /**
  50291. * The component name helpfull to identify the component in the list of scene components.
  50292. */
  50293. readonly name: string;
  50294. /**
  50295. * The scene the component belongs to.
  50296. */
  50297. scene: Scene;
  50298. /**
  50299. * Creates a new instance of the component for the given scene
  50300. * @param scene Defines the scene to register the component in
  50301. */
  50302. constructor(scene: Scene);
  50303. /**
  50304. * Registers the component in a given scene
  50305. */
  50306. register(): void;
  50307. /**
  50308. * Rebuilds the elements related to this component in case of
  50309. * context lost for instance.
  50310. */
  50311. rebuild(): void;
  50312. /**
  50313. * Adds all the elements from the container to the scene
  50314. * @param container the container holding the elements
  50315. */
  50316. addFromContainer(container: AbstractScene): void;
  50317. /**
  50318. * Removes all the elements in the container from the scene
  50319. * @param container contains the elements to remove
  50320. * @param dispose if the removed element should be disposed (default: false)
  50321. */
  50322. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50323. /**
  50324. * Serializes the component data to the specified json object
  50325. * @param serializationObject The object to serialize to
  50326. */
  50327. serialize(serializationObject: any): void;
  50328. /**
  50329. * Disposes the component and the associated ressources.
  50330. */
  50331. dispose(): void;
  50332. private _draw;
  50333. }
  50334. }
  50335. declare module BABYLON {
  50336. /**
  50337. * Defines the shadow generator component responsible to manage any shadow generators
  50338. * in a given scene.
  50339. */
  50340. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50341. /**
  50342. * The component name helpfull to identify the component in the list of scene components.
  50343. */
  50344. readonly name: string;
  50345. /**
  50346. * The scene the component belongs to.
  50347. */
  50348. scene: Scene;
  50349. /**
  50350. * Creates a new instance of the component for the given scene
  50351. * @param scene Defines the scene to register the component in
  50352. */
  50353. constructor(scene: Scene);
  50354. /**
  50355. * Registers the component in a given scene
  50356. */
  50357. register(): void;
  50358. /**
  50359. * Rebuilds the elements related to this component in case of
  50360. * context lost for instance.
  50361. */
  50362. rebuild(): void;
  50363. /**
  50364. * Serializes the component data to the specified json object
  50365. * @param serializationObject The object to serialize to
  50366. */
  50367. serialize(serializationObject: any): void;
  50368. /**
  50369. * Adds all the elements from the container to the scene
  50370. * @param container the container holding the elements
  50371. */
  50372. addFromContainer(container: AbstractScene): void;
  50373. /**
  50374. * Removes all the elements in the container from the scene
  50375. * @param container contains the elements to remove
  50376. * @param dispose if the removed element should be disposed (default: false)
  50377. */
  50378. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50379. /**
  50380. * Rebuilds the elements related to this component in case of
  50381. * context lost for instance.
  50382. */
  50383. dispose(): void;
  50384. private _gatherRenderTargets;
  50385. }
  50386. }
  50387. declare module BABYLON {
  50388. /**
  50389. * A point light is a light defined by an unique point in world space.
  50390. * The light is emitted in every direction from this point.
  50391. * A good example of a point light is a standard light bulb.
  50392. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50393. */
  50394. export class PointLight extends ShadowLight {
  50395. private _shadowAngle;
  50396. /**
  50397. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50398. * This specifies what angle the shadow will use to be created.
  50399. *
  50400. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50401. */
  50402. /**
  50403. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50404. * This specifies what angle the shadow will use to be created.
  50405. *
  50406. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50407. */
  50408. shadowAngle: number;
  50409. /**
  50410. * Gets the direction if it has been set.
  50411. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50412. */
  50413. /**
  50414. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50415. */
  50416. direction: Vector3;
  50417. /**
  50418. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50419. * A PointLight emits the light in every direction.
  50420. * It can cast shadows.
  50421. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50422. * ```javascript
  50423. * var pointLight = new PointLight("pl", camera.position, scene);
  50424. * ```
  50425. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50426. * @param name The light friendly name
  50427. * @param position The position of the point light in the scene
  50428. * @param scene The scene the lights belongs to
  50429. */
  50430. constructor(name: string, position: Vector3, scene: Scene);
  50431. /**
  50432. * Returns the string "PointLight"
  50433. * @returns the class name
  50434. */
  50435. getClassName(): string;
  50436. /**
  50437. * Returns the integer 0.
  50438. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50439. */
  50440. getTypeID(): number;
  50441. /**
  50442. * Specifies wether or not the shadowmap should be a cube texture.
  50443. * @returns true if the shadowmap needs to be a cube texture.
  50444. */
  50445. needCube(): boolean;
  50446. /**
  50447. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50448. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50449. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50450. */
  50451. getShadowDirection(faceIndex?: number): Vector3;
  50452. /**
  50453. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50454. * - fov = PI / 2
  50455. * - aspect ratio : 1.0
  50456. * - z-near and far equal to the active camera minZ and maxZ.
  50457. * Returns the PointLight.
  50458. */
  50459. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50460. protected _buildUniformLayout(): void;
  50461. /**
  50462. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50463. * @param effect The effect to update
  50464. * @param lightIndex The index of the light in the effect to update
  50465. * @returns The point light
  50466. */
  50467. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50468. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50469. /**
  50470. * Prepares the list of defines specific to the light type.
  50471. * @param defines the list of defines
  50472. * @param lightIndex defines the index of the light for the effect
  50473. */
  50474. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50475. }
  50476. }
  50477. declare module BABYLON {
  50478. /**
  50479. * Header information of HDR texture files.
  50480. */
  50481. export interface HDRInfo {
  50482. /**
  50483. * The height of the texture in pixels.
  50484. */
  50485. height: number;
  50486. /**
  50487. * The width of the texture in pixels.
  50488. */
  50489. width: number;
  50490. /**
  50491. * The index of the beginning of the data in the binary file.
  50492. */
  50493. dataPosition: number;
  50494. }
  50495. /**
  50496. * This groups tools to convert HDR texture to native colors array.
  50497. */
  50498. export class HDRTools {
  50499. private static Ldexp;
  50500. private static Rgbe2float;
  50501. private static readStringLine;
  50502. /**
  50503. * Reads header information from an RGBE texture stored in a native array.
  50504. * More information on this format are available here:
  50505. * https://en.wikipedia.org/wiki/RGBE_image_format
  50506. *
  50507. * @param uint8array The binary file stored in native array.
  50508. * @return The header information.
  50509. */
  50510. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50511. /**
  50512. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50513. * This RGBE texture needs to store the information as a panorama.
  50514. *
  50515. * More information on this format are available here:
  50516. * https://en.wikipedia.org/wiki/RGBE_image_format
  50517. *
  50518. * @param buffer The binary file stored in an array buffer.
  50519. * @param size The expected size of the extracted cubemap.
  50520. * @return The Cube Map information.
  50521. */
  50522. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50523. /**
  50524. * Returns the pixels data extracted from an RGBE texture.
  50525. * This pixels will be stored left to right up to down in the R G B order in one array.
  50526. *
  50527. * More information on this format are available here:
  50528. * https://en.wikipedia.org/wiki/RGBE_image_format
  50529. *
  50530. * @param uint8array The binary file stored in an array buffer.
  50531. * @param hdrInfo The header information of the file.
  50532. * @return The pixels data in RGB right to left up to down order.
  50533. */
  50534. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50535. private static RGBE_ReadPixels_RLE;
  50536. }
  50537. }
  50538. declare module BABYLON {
  50539. /**
  50540. * This represents a texture coming from an HDR input.
  50541. *
  50542. * The only supported format is currently panorama picture stored in RGBE format.
  50543. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50544. */
  50545. export class HDRCubeTexture extends BaseTexture {
  50546. private static _facesMapping;
  50547. private _generateHarmonics;
  50548. private _noMipmap;
  50549. private _textureMatrix;
  50550. private _size;
  50551. private _onLoad;
  50552. private _onError;
  50553. /**
  50554. * The texture URL.
  50555. */
  50556. url: string;
  50557. /**
  50558. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50559. */
  50560. coordinatesMode: number;
  50561. protected _isBlocking: boolean;
  50562. /**
  50563. * Sets wether or not the texture is blocking during loading.
  50564. */
  50565. /**
  50566. * Gets wether or not the texture is blocking during loading.
  50567. */
  50568. isBlocking: boolean;
  50569. protected _rotationY: number;
  50570. /**
  50571. * Sets texture matrix rotation angle around Y axis in radians.
  50572. */
  50573. /**
  50574. * Gets texture matrix rotation angle around Y axis radians.
  50575. */
  50576. rotationY: number;
  50577. /**
  50578. * Gets or sets the center of the bounding box associated with the cube texture
  50579. * It must define where the camera used to render the texture was set
  50580. */
  50581. boundingBoxPosition: Vector3;
  50582. private _boundingBoxSize;
  50583. /**
  50584. * Gets or sets the size of the bounding box associated with the cube texture
  50585. * When defined, the cubemap will switch to local mode
  50586. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50587. * @example https://www.babylonjs-playground.com/#RNASML
  50588. */
  50589. boundingBoxSize: Vector3;
  50590. /**
  50591. * Instantiates an HDRTexture from the following parameters.
  50592. *
  50593. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50594. * @param scene The scene the texture will be used in
  50595. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50596. * @param noMipmap Forces to not generate the mipmap if true
  50597. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50598. * @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)
  50599. * @param reserved Reserved flag for internal use.
  50600. */
  50601. 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>);
  50602. /**
  50603. * Get the current class name of the texture useful for serialization or dynamic coding.
  50604. * @returns "HDRCubeTexture"
  50605. */
  50606. getClassName(): string;
  50607. /**
  50608. * Occurs when the file is raw .hdr file.
  50609. */
  50610. private loadTexture;
  50611. clone(): HDRCubeTexture;
  50612. delayLoad(): void;
  50613. /**
  50614. * Get the texture reflection matrix used to rotate/transform the reflection.
  50615. * @returns the reflection matrix
  50616. */
  50617. getReflectionTextureMatrix(): Matrix;
  50618. /**
  50619. * Set the texture reflection matrix used to rotate/transform the reflection.
  50620. * @param value Define the reflection matrix to set
  50621. */
  50622. setReflectionTextureMatrix(value: Matrix): void;
  50623. /**
  50624. * Parses a JSON representation of an HDR Texture in order to create the texture
  50625. * @param parsedTexture Define the JSON representation
  50626. * @param scene Define the scene the texture should be created in
  50627. * @param rootUrl Define the root url in case we need to load relative dependencies
  50628. * @returns the newly created texture after parsing
  50629. */
  50630. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50631. serialize(): any;
  50632. }
  50633. }
  50634. declare module BABYLON {
  50635. /**
  50636. * Class used to control physics engine
  50637. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50638. */
  50639. export class PhysicsEngine implements IPhysicsEngine {
  50640. private _physicsPlugin;
  50641. /**
  50642. * Global value used to control the smallest number supported by the simulation
  50643. */
  50644. static Epsilon: number;
  50645. private _impostors;
  50646. private _joints;
  50647. /**
  50648. * Gets the gravity vector used by the simulation
  50649. */
  50650. gravity: Vector3;
  50651. /**
  50652. * Factory used to create the default physics plugin.
  50653. * @returns The default physics plugin
  50654. */
  50655. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50656. /**
  50657. * Creates a new Physics Engine
  50658. * @param gravity defines the gravity vector used by the simulation
  50659. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50660. */
  50661. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50662. /**
  50663. * Sets the gravity vector used by the simulation
  50664. * @param gravity defines the gravity vector to use
  50665. */
  50666. setGravity(gravity: Vector3): void;
  50667. /**
  50668. * Set the time step of the physics engine.
  50669. * Default is 1/60.
  50670. * To slow it down, enter 1/600 for example.
  50671. * To speed it up, 1/30
  50672. * @param newTimeStep defines the new timestep to apply to this world.
  50673. */
  50674. setTimeStep(newTimeStep?: number): void;
  50675. /**
  50676. * Get the time step of the physics engine.
  50677. * @returns the current time step
  50678. */
  50679. getTimeStep(): number;
  50680. /**
  50681. * Release all resources
  50682. */
  50683. dispose(): void;
  50684. /**
  50685. * Gets the name of the current physics plugin
  50686. * @returns the name of the plugin
  50687. */
  50688. getPhysicsPluginName(): string;
  50689. /**
  50690. * Adding a new impostor for the impostor tracking.
  50691. * This will be done by the impostor itself.
  50692. * @param impostor the impostor to add
  50693. */
  50694. addImpostor(impostor: PhysicsImpostor): void;
  50695. /**
  50696. * Remove an impostor from the engine.
  50697. * This impostor and its mesh will not longer be updated by the physics engine.
  50698. * @param impostor the impostor to remove
  50699. */
  50700. removeImpostor(impostor: PhysicsImpostor): void;
  50701. /**
  50702. * Add a joint to the physics engine
  50703. * @param mainImpostor defines the main impostor to which the joint is added.
  50704. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50705. * @param joint defines the joint that will connect both impostors.
  50706. */
  50707. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50708. /**
  50709. * Removes a joint from the simulation
  50710. * @param mainImpostor defines the impostor used with the joint
  50711. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50712. * @param joint defines the joint to remove
  50713. */
  50714. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50715. /**
  50716. * Called by the scene. No need to call it.
  50717. * @param delta defines the timespam between frames
  50718. */ private _step(delta: number): void;
  50719. /**
  50720. * Gets the current plugin used to run the simulation
  50721. * @returns current plugin
  50722. */
  50723. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50724. /**
  50725. * Gets the list of physic impostors
  50726. * @returns an array of PhysicsImpostor
  50727. */
  50728. getImpostors(): Array<PhysicsImpostor>;
  50729. /**
  50730. * Gets the impostor for a physics enabled object
  50731. * @param object defines the object impersonated by the impostor
  50732. * @returns the PhysicsImpostor or null if not found
  50733. */
  50734. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50735. /**
  50736. * Gets the impostor for a physics body object
  50737. * @param body defines physics body used by the impostor
  50738. * @returns the PhysicsImpostor or null if not found
  50739. */
  50740. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50741. /**
  50742. * Does a raycast in the physics world
  50743. * @param from when should the ray start?
  50744. * @param to when should the ray end?
  50745. * @returns PhysicsRaycastResult
  50746. */
  50747. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50748. }
  50749. }
  50750. declare module BABYLON {
  50751. /** @hidden */
  50752. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50753. private _useDeltaForWorldStep;
  50754. world: any;
  50755. name: string;
  50756. private _physicsMaterials;
  50757. private _fixedTimeStep;
  50758. private _cannonRaycastResult;
  50759. private _raycastResult;
  50760. private _physicsBodysToRemoveAfterStep;
  50761. BJSCANNON: any;
  50762. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50763. setGravity(gravity: Vector3): void;
  50764. setTimeStep(timeStep: number): void;
  50765. getTimeStep(): number;
  50766. executeStep(delta: number): void;
  50767. private _removeMarkedPhysicsBodiesFromWorld;
  50768. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50769. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50770. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50771. private _processChildMeshes;
  50772. removePhysicsBody(impostor: PhysicsImpostor): void;
  50773. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50774. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50775. private _addMaterial;
  50776. private _checkWithEpsilon;
  50777. private _createShape;
  50778. private _createHeightmap;
  50779. private _minus90X;
  50780. private _plus90X;
  50781. private _tmpPosition;
  50782. private _tmpDeltaPosition;
  50783. private _tmpUnityRotation;
  50784. private _updatePhysicsBodyTransformation;
  50785. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50786. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50787. isSupported(): boolean;
  50788. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50789. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50790. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50791. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50792. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50793. getBodyMass(impostor: PhysicsImpostor): number;
  50794. getBodyFriction(impostor: PhysicsImpostor): number;
  50795. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50796. getBodyRestitution(impostor: PhysicsImpostor): number;
  50797. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50798. sleepBody(impostor: PhysicsImpostor): void;
  50799. wakeUpBody(impostor: PhysicsImpostor): void;
  50800. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50801. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50802. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50803. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50804. getRadius(impostor: PhysicsImpostor): number;
  50805. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50806. dispose(): void;
  50807. private _extendNamespace;
  50808. /**
  50809. * Does a raycast in the physics world
  50810. * @param from when should the ray start?
  50811. * @param to when should the ray end?
  50812. * @returns PhysicsRaycastResult
  50813. */
  50814. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50815. }
  50816. }
  50817. declare module BABYLON {
  50818. /** @hidden */
  50819. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50820. world: any;
  50821. name: string;
  50822. BJSOIMO: any;
  50823. private _raycastResult;
  50824. constructor(iterations?: number, oimoInjection?: any);
  50825. setGravity(gravity: Vector3): void;
  50826. setTimeStep(timeStep: number): void;
  50827. getTimeStep(): number;
  50828. private _tmpImpostorsArray;
  50829. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50830. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50831. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50832. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50833. private _tmpPositionVector;
  50834. removePhysicsBody(impostor: PhysicsImpostor): void;
  50835. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50836. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50837. isSupported(): boolean;
  50838. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50839. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50840. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50841. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50842. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50843. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50844. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50845. getBodyMass(impostor: PhysicsImpostor): number;
  50846. getBodyFriction(impostor: PhysicsImpostor): number;
  50847. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50848. getBodyRestitution(impostor: PhysicsImpostor): number;
  50849. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50850. sleepBody(impostor: PhysicsImpostor): void;
  50851. wakeUpBody(impostor: PhysicsImpostor): void;
  50852. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50853. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50854. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50855. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50856. getRadius(impostor: PhysicsImpostor): number;
  50857. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50858. dispose(): void;
  50859. /**
  50860. * Does a raycast in the physics world
  50861. * @param from when should the ray start?
  50862. * @param to when should the ray end?
  50863. * @returns PhysicsRaycastResult
  50864. */
  50865. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50866. }
  50867. }
  50868. declare module BABYLON {
  50869. /**
  50870. * Class containing static functions to help procedurally build meshes
  50871. */
  50872. export class RibbonBuilder {
  50873. /**
  50874. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50875. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50876. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50877. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50878. * * 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
  50879. * * 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
  50880. * * 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
  50881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50882. * * 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
  50883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50884. * * 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
  50885. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50886. * * 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
  50887. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50889. * @param name defines the name of the mesh
  50890. * @param options defines the options used to create the mesh
  50891. * @param scene defines the hosting scene
  50892. * @returns the ribbon mesh
  50893. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50894. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50895. */
  50896. static CreateRibbon(name: string, options: {
  50897. pathArray: Vector3[][];
  50898. closeArray?: boolean;
  50899. closePath?: boolean;
  50900. offset?: number;
  50901. updatable?: boolean;
  50902. sideOrientation?: number;
  50903. frontUVs?: Vector4;
  50904. backUVs?: Vector4;
  50905. instance?: Mesh;
  50906. invertUV?: boolean;
  50907. uvs?: Vector2[];
  50908. colors?: Color4[];
  50909. }, scene?: Nullable<Scene>): Mesh;
  50910. }
  50911. }
  50912. declare module BABYLON {
  50913. /**
  50914. * Class containing static functions to help procedurally build meshes
  50915. */
  50916. export class ShapeBuilder {
  50917. /**
  50918. * 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.
  50919. * * 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.
  50920. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50921. * * 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.
  50922. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50923. * * 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
  50924. * * 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
  50925. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50927. * * 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
  50928. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50930. * @param name defines the name of the mesh
  50931. * @param options defines the options used to create the mesh
  50932. * @param scene defines the hosting scene
  50933. * @returns the extruded shape mesh
  50934. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50935. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50936. */
  50937. static ExtrudeShape(name: string, options: {
  50938. shape: Vector3[];
  50939. path: Vector3[];
  50940. scale?: number;
  50941. rotation?: number;
  50942. cap?: number;
  50943. updatable?: boolean;
  50944. sideOrientation?: number;
  50945. frontUVs?: Vector4;
  50946. backUVs?: Vector4;
  50947. instance?: Mesh;
  50948. invertUV?: boolean;
  50949. }, scene?: Nullable<Scene>): Mesh;
  50950. /**
  50951. * Creates an custom extruded shape mesh.
  50952. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50953. * * 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.
  50954. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50955. * * 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
  50956. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50957. * * 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
  50958. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50959. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50960. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50961. * * 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
  50962. * * 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
  50963. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50965. * * 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
  50966. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50968. * @param name defines the name of the mesh
  50969. * @param options defines the options used to create the mesh
  50970. * @param scene defines the hosting scene
  50971. * @returns the custom extruded shape mesh
  50972. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50973. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50975. */
  50976. static ExtrudeShapeCustom(name: string, options: {
  50977. shape: Vector3[];
  50978. path: Vector3[];
  50979. scaleFunction?: any;
  50980. rotationFunction?: any;
  50981. ribbonCloseArray?: boolean;
  50982. ribbonClosePath?: boolean;
  50983. cap?: number;
  50984. updatable?: boolean;
  50985. sideOrientation?: number;
  50986. frontUVs?: Vector4;
  50987. backUVs?: Vector4;
  50988. instance?: Mesh;
  50989. invertUV?: boolean;
  50990. }, scene?: Nullable<Scene>): Mesh;
  50991. private static _ExtrudeShapeGeneric;
  50992. }
  50993. }
  50994. declare module BABYLON {
  50995. /**
  50996. * AmmoJS Physics plugin
  50997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50998. * @see https://github.com/kripken/ammo.js/
  50999. */
  51000. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51001. private _useDeltaForWorldStep;
  51002. /**
  51003. * Reference to the Ammo library
  51004. */
  51005. bjsAMMO: any;
  51006. /**
  51007. * Created ammoJS world which physics bodies are added to
  51008. */
  51009. world: any;
  51010. /**
  51011. * Name of the plugin
  51012. */
  51013. name: string;
  51014. private _timeStep;
  51015. private _fixedTimeStep;
  51016. private _maxSteps;
  51017. private _tmpQuaternion;
  51018. private _tmpAmmoTransform;
  51019. private _tmpAmmoQuaternion;
  51020. private _tmpAmmoConcreteContactResultCallback;
  51021. private _collisionConfiguration;
  51022. private _dispatcher;
  51023. private _overlappingPairCache;
  51024. private _solver;
  51025. private _softBodySolver;
  51026. private _tmpAmmoVectorA;
  51027. private _tmpAmmoVectorB;
  51028. private _tmpAmmoVectorC;
  51029. private _tmpAmmoVectorD;
  51030. private _tmpContactCallbackResult;
  51031. private _tmpAmmoVectorRCA;
  51032. private _tmpAmmoVectorRCB;
  51033. private _raycastResult;
  51034. private static readonly DISABLE_COLLISION_FLAG;
  51035. private static readonly KINEMATIC_FLAG;
  51036. private static readonly DISABLE_DEACTIVATION_FLAG;
  51037. /**
  51038. * Initializes the ammoJS plugin
  51039. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51040. * @param ammoInjection can be used to inject your own ammo reference
  51041. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51042. */
  51043. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51044. /**
  51045. * Sets the gravity of the physics world (m/(s^2))
  51046. * @param gravity Gravity to set
  51047. */
  51048. setGravity(gravity: Vector3): void;
  51049. /**
  51050. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51051. * @param timeStep timestep to use in seconds
  51052. */
  51053. setTimeStep(timeStep: number): void;
  51054. /**
  51055. * 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)
  51056. * @param fixedTimeStep fixedTimeStep to use in seconds
  51057. */
  51058. setFixedTimeStep(fixedTimeStep: number): void;
  51059. /**
  51060. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51061. * @param maxSteps the maximum number of steps by the physics engine per frame
  51062. */
  51063. setMaxSteps(maxSteps: number): void;
  51064. /**
  51065. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51066. * @returns the current timestep in seconds
  51067. */
  51068. getTimeStep(): number;
  51069. private _isImpostorInContact;
  51070. private _isImpostorPairInContact;
  51071. private _stepSimulation;
  51072. /**
  51073. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51074. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51075. * After the step the babylon meshes are set to the position of the physics imposters
  51076. * @param delta amount of time to step forward
  51077. * @param impostors array of imposters to update before/after the step
  51078. */
  51079. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51080. /**
  51081. * Update babylon mesh to match physics world object
  51082. * @param impostor imposter to match
  51083. */
  51084. private _afterSoftStep;
  51085. /**
  51086. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51087. * @param impostor imposter to match
  51088. */
  51089. private _ropeStep;
  51090. /**
  51091. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51092. * @param impostor imposter to match
  51093. */
  51094. private _softbodyOrClothStep;
  51095. private _tmpVector;
  51096. private _tmpMatrix;
  51097. /**
  51098. * Applies an impulse on the imposter
  51099. * @param impostor imposter to apply impulse to
  51100. * @param force amount of force to be applied to the imposter
  51101. * @param contactPoint the location to apply the impulse on the imposter
  51102. */
  51103. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51104. /**
  51105. * Applies a force on the imposter
  51106. * @param impostor imposter to apply force
  51107. * @param force amount of force to be applied to the imposter
  51108. * @param contactPoint the location to apply the force on the imposter
  51109. */
  51110. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51111. /**
  51112. * Creates a physics body using the plugin
  51113. * @param impostor the imposter to create the physics body on
  51114. */
  51115. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51116. /**
  51117. * Removes the physics body from the imposter and disposes of the body's memory
  51118. * @param impostor imposter to remove the physics body from
  51119. */
  51120. removePhysicsBody(impostor: PhysicsImpostor): void;
  51121. /**
  51122. * Generates a joint
  51123. * @param impostorJoint the imposter joint to create the joint with
  51124. */
  51125. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51126. /**
  51127. * Removes a joint
  51128. * @param impostorJoint the imposter joint to remove the joint from
  51129. */
  51130. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51131. private _addMeshVerts;
  51132. /**
  51133. * Initialise the soft body vertices to match its object's (mesh) vertices
  51134. * Softbody vertices (nodes) are in world space and to match this
  51135. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51136. * @param impostor to create the softbody for
  51137. */
  51138. private _softVertexData;
  51139. /**
  51140. * Create an impostor's soft body
  51141. * @param impostor to create the softbody for
  51142. */
  51143. private _createSoftbody;
  51144. /**
  51145. * Create cloth for an impostor
  51146. * @param impostor to create the softbody for
  51147. */
  51148. private _createCloth;
  51149. /**
  51150. * Create rope for an impostor
  51151. * @param impostor to create the softbody for
  51152. */
  51153. private _createRope;
  51154. private _addHullVerts;
  51155. private _createShape;
  51156. /**
  51157. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51158. * @param impostor imposter containing the physics body and babylon object
  51159. */
  51160. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51161. /**
  51162. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51163. * @param impostor imposter containing the physics body and babylon object
  51164. * @param newPosition new position
  51165. * @param newRotation new rotation
  51166. */
  51167. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51168. /**
  51169. * If this plugin is supported
  51170. * @returns true if its supported
  51171. */
  51172. isSupported(): boolean;
  51173. /**
  51174. * Sets the linear velocity of the physics body
  51175. * @param impostor imposter to set the velocity on
  51176. * @param velocity velocity to set
  51177. */
  51178. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51179. /**
  51180. * Sets the angular velocity of the physics body
  51181. * @param impostor imposter to set the velocity on
  51182. * @param velocity velocity to set
  51183. */
  51184. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51185. /**
  51186. * gets the linear velocity
  51187. * @param impostor imposter to get linear velocity from
  51188. * @returns linear velocity
  51189. */
  51190. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51191. /**
  51192. * gets the angular velocity
  51193. * @param impostor imposter to get angular velocity from
  51194. * @returns angular velocity
  51195. */
  51196. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51197. /**
  51198. * Sets the mass of physics body
  51199. * @param impostor imposter to set the mass on
  51200. * @param mass mass to set
  51201. */
  51202. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51203. /**
  51204. * Gets the mass of the physics body
  51205. * @param impostor imposter to get the mass from
  51206. * @returns mass
  51207. */
  51208. getBodyMass(impostor: PhysicsImpostor): number;
  51209. /**
  51210. * Gets friction of the impostor
  51211. * @param impostor impostor to get friction from
  51212. * @returns friction value
  51213. */
  51214. getBodyFriction(impostor: PhysicsImpostor): number;
  51215. /**
  51216. * Sets friction of the impostor
  51217. * @param impostor impostor to set friction on
  51218. * @param friction friction value
  51219. */
  51220. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51221. /**
  51222. * Gets restitution of the impostor
  51223. * @param impostor impostor to get restitution from
  51224. * @returns restitution value
  51225. */
  51226. getBodyRestitution(impostor: PhysicsImpostor): number;
  51227. /**
  51228. * Sets resitution of the impostor
  51229. * @param impostor impostor to set resitution on
  51230. * @param restitution resitution value
  51231. */
  51232. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51233. /**
  51234. * Gets pressure inside the impostor
  51235. * @param impostor impostor to get pressure from
  51236. * @returns pressure value
  51237. */
  51238. getBodyPressure(impostor: PhysicsImpostor): number;
  51239. /**
  51240. * Sets pressure inside a soft body impostor
  51241. * Cloth and rope must remain 0 pressure
  51242. * @param impostor impostor to set pressure on
  51243. * @param pressure pressure value
  51244. */
  51245. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51246. /**
  51247. * Gets stiffness of the impostor
  51248. * @param impostor impostor to get stiffness from
  51249. * @returns pressure value
  51250. */
  51251. getBodyStiffness(impostor: PhysicsImpostor): number;
  51252. /**
  51253. * Sets stiffness of the impostor
  51254. * @param impostor impostor to set stiffness on
  51255. * @param stiffness stiffness value from 0 to 1
  51256. */
  51257. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51258. /**
  51259. * Gets velocityIterations of the impostor
  51260. * @param impostor impostor to get velocity iterations from
  51261. * @returns velocityIterations value
  51262. */
  51263. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51264. /**
  51265. * Sets velocityIterations of the impostor
  51266. * @param impostor impostor to set velocity iterations on
  51267. * @param velocityIterations velocityIterations value
  51268. */
  51269. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51270. /**
  51271. * Gets positionIterations of the impostor
  51272. * @param impostor impostor to get position iterations from
  51273. * @returns positionIterations value
  51274. */
  51275. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51276. /**
  51277. * Sets positionIterations of the impostor
  51278. * @param impostor impostor to set position on
  51279. * @param positionIterations positionIterations value
  51280. */
  51281. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51282. /**
  51283. * Append an anchor to a cloth object
  51284. * @param impostor is the cloth impostor to add anchor to
  51285. * @param otherImpostor is the rigid impostor to anchor to
  51286. * @param width ratio across width from 0 to 1
  51287. * @param height ratio up height from 0 to 1
  51288. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51289. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51290. */
  51291. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51292. /**
  51293. * Append an hook to a rope object
  51294. * @param impostor is the rope impostor to add hook to
  51295. * @param otherImpostor is the rigid impostor to hook to
  51296. * @param length ratio along the rope from 0 to 1
  51297. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51298. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51299. */
  51300. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51301. /**
  51302. * Sleeps the physics body and stops it from being active
  51303. * @param impostor impostor to sleep
  51304. */
  51305. sleepBody(impostor: PhysicsImpostor): void;
  51306. /**
  51307. * Activates the physics body
  51308. * @param impostor impostor to activate
  51309. */
  51310. wakeUpBody(impostor: PhysicsImpostor): void;
  51311. /**
  51312. * Updates the distance parameters of the joint
  51313. * @param joint joint to update
  51314. * @param maxDistance maximum distance of the joint
  51315. * @param minDistance minimum distance of the joint
  51316. */
  51317. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51318. /**
  51319. * Sets a motor on the joint
  51320. * @param joint joint to set motor on
  51321. * @param speed speed of the motor
  51322. * @param maxForce maximum force of the motor
  51323. * @param motorIndex index of the motor
  51324. */
  51325. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51326. /**
  51327. * Sets the motors limit
  51328. * @param joint joint to set limit on
  51329. * @param upperLimit upper limit
  51330. * @param lowerLimit lower limit
  51331. */
  51332. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51333. /**
  51334. * Syncs the position and rotation of a mesh with the impostor
  51335. * @param mesh mesh to sync
  51336. * @param impostor impostor to update the mesh with
  51337. */
  51338. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51339. /**
  51340. * Gets the radius of the impostor
  51341. * @param impostor impostor to get radius from
  51342. * @returns the radius
  51343. */
  51344. getRadius(impostor: PhysicsImpostor): number;
  51345. /**
  51346. * Gets the box size of the impostor
  51347. * @param impostor impostor to get box size from
  51348. * @param result the resulting box size
  51349. */
  51350. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51351. /**
  51352. * Disposes of the impostor
  51353. */
  51354. dispose(): void;
  51355. /**
  51356. * Does a raycast in the physics world
  51357. * @param from when should the ray start?
  51358. * @param to when should the ray end?
  51359. * @returns PhysicsRaycastResult
  51360. */
  51361. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51362. }
  51363. }
  51364. declare module BABYLON {
  51365. interface AbstractScene {
  51366. /**
  51367. * The list of reflection probes added to the scene
  51368. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51369. */
  51370. reflectionProbes: Array<ReflectionProbe>;
  51371. /**
  51372. * Removes the given reflection probe from this scene.
  51373. * @param toRemove The reflection probe to remove
  51374. * @returns The index of the removed reflection probe
  51375. */
  51376. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51377. /**
  51378. * Adds the given reflection probe to this scene.
  51379. * @param newReflectionProbe The reflection probe to add
  51380. */
  51381. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51382. }
  51383. /**
  51384. * Class used to generate realtime reflection / refraction cube textures
  51385. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51386. */
  51387. export class ReflectionProbe {
  51388. /** defines the name of the probe */
  51389. name: string;
  51390. private _scene;
  51391. private _renderTargetTexture;
  51392. private _projectionMatrix;
  51393. private _viewMatrix;
  51394. private _target;
  51395. private _add;
  51396. private _attachedMesh;
  51397. private _invertYAxis;
  51398. /** Gets or sets probe position (center of the cube map) */
  51399. position: Vector3;
  51400. /**
  51401. * Creates a new reflection probe
  51402. * @param name defines the name of the probe
  51403. * @param size defines the texture resolution (for each face)
  51404. * @param scene defines the hosting scene
  51405. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51406. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51407. */
  51408. constructor(
  51409. /** defines the name of the probe */
  51410. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51411. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51412. samples: number;
  51413. /** Gets or sets the refresh rate to use (on every frame by default) */
  51414. refreshRate: number;
  51415. /**
  51416. * Gets the hosting scene
  51417. * @returns a Scene
  51418. */
  51419. getScene(): Scene;
  51420. /** Gets the internal CubeTexture used to render to */
  51421. readonly cubeTexture: RenderTargetTexture;
  51422. /** Gets the list of meshes to render */
  51423. readonly renderList: Nullable<AbstractMesh[]>;
  51424. /**
  51425. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51426. * @param mesh defines the mesh to attach to
  51427. */
  51428. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51429. /**
  51430. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51431. * @param renderingGroupId The rendering group id corresponding to its index
  51432. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51433. */
  51434. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51435. /**
  51436. * Clean all associated resources
  51437. */
  51438. dispose(): void;
  51439. /**
  51440. * Converts the reflection probe information to a readable string for debug purpose.
  51441. * @param fullDetails Supports for multiple levels of logging within scene loading
  51442. * @returns the human readable reflection probe info
  51443. */
  51444. toString(fullDetails?: boolean): string;
  51445. /**
  51446. * Get the class name of the relfection probe.
  51447. * @returns "ReflectionProbe"
  51448. */
  51449. getClassName(): string;
  51450. /**
  51451. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51452. * @returns The JSON representation of the texture
  51453. */
  51454. serialize(): any;
  51455. /**
  51456. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51457. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51458. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51459. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51460. * @returns The parsed reflection probe if successful
  51461. */
  51462. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51463. }
  51464. }
  51465. declare module BABYLON {
  51466. /** @hidden */
  51467. export var _BabylonLoaderRegistered: boolean;
  51468. /**
  51469. * Helps setting up some configuration for the babylon file loader.
  51470. */
  51471. export class BabylonFileLoaderConfiguration {
  51472. /**
  51473. * The loader does not allow injecting custom physix engine into the plugins.
  51474. * Unfortunately in ES6, we need to manually inject them into the plugin.
  51475. * So you could set this variable to your engine import to make it work.
  51476. */
  51477. static LoaderInjectedPhysicsEngine: any;
  51478. }
  51479. }
  51480. declare module BABYLON {
  51481. /**
  51482. * The Physically based simple base material of BJS.
  51483. *
  51484. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51485. * It is used as the base class for both the specGloss and metalRough conventions.
  51486. */
  51487. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51488. /**
  51489. * Number of Simultaneous lights allowed on the material.
  51490. */
  51491. maxSimultaneousLights: number;
  51492. /**
  51493. * If sets to true, disables all the lights affecting the material.
  51494. */
  51495. disableLighting: boolean;
  51496. /**
  51497. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51498. */
  51499. environmentTexture: BaseTexture;
  51500. /**
  51501. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51502. */
  51503. invertNormalMapX: boolean;
  51504. /**
  51505. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51506. */
  51507. invertNormalMapY: boolean;
  51508. /**
  51509. * Normal map used in the model.
  51510. */
  51511. normalTexture: BaseTexture;
  51512. /**
  51513. * Emissivie color used to self-illuminate the model.
  51514. */
  51515. emissiveColor: Color3;
  51516. /**
  51517. * Emissivie texture used to self-illuminate the model.
  51518. */
  51519. emissiveTexture: BaseTexture;
  51520. /**
  51521. * Occlusion Channel Strenght.
  51522. */
  51523. occlusionStrength: number;
  51524. /**
  51525. * Occlusion Texture of the material (adding extra occlusion effects).
  51526. */
  51527. occlusionTexture: BaseTexture;
  51528. /**
  51529. * Defines the alpha limits in alpha test mode.
  51530. */
  51531. alphaCutOff: number;
  51532. /**
  51533. * Gets the current double sided mode.
  51534. */
  51535. /**
  51536. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51537. */
  51538. doubleSided: boolean;
  51539. /**
  51540. * Stores the pre-calculated light information of a mesh in a texture.
  51541. */
  51542. lightmapTexture: BaseTexture;
  51543. /**
  51544. * If true, the light map contains occlusion information instead of lighting info.
  51545. */
  51546. useLightmapAsShadowmap: boolean;
  51547. /**
  51548. * Instantiates a new PBRMaterial instance.
  51549. *
  51550. * @param name The material name
  51551. * @param scene The scene the material will be use in.
  51552. */
  51553. constructor(name: string, scene: Scene);
  51554. getClassName(): string;
  51555. }
  51556. }
  51557. declare module BABYLON {
  51558. /**
  51559. * The PBR material of BJS following the metal roughness convention.
  51560. *
  51561. * This fits to the PBR convention in the GLTF definition:
  51562. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51563. */
  51564. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51565. /**
  51566. * The base color has two different interpretations depending on the value of metalness.
  51567. * When the material is a metal, the base color is the specific measured reflectance value
  51568. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51569. * of the material.
  51570. */
  51571. baseColor: Color3;
  51572. /**
  51573. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51574. * well as opacity information in the alpha channel.
  51575. */
  51576. baseTexture: BaseTexture;
  51577. /**
  51578. * Specifies the metallic scalar value of the material.
  51579. * Can also be used to scale the metalness values of the metallic texture.
  51580. */
  51581. metallic: number;
  51582. /**
  51583. * Specifies the roughness scalar value of the material.
  51584. * Can also be used to scale the roughness values of the metallic texture.
  51585. */
  51586. roughness: number;
  51587. /**
  51588. * Texture containing both the metallic value in the B channel and the
  51589. * roughness value in the G channel to keep better precision.
  51590. */
  51591. metallicRoughnessTexture: BaseTexture;
  51592. /**
  51593. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51594. *
  51595. * @param name The material name
  51596. * @param scene The scene the material will be use in.
  51597. */
  51598. constructor(name: string, scene: Scene);
  51599. /**
  51600. * Return the currrent class name of the material.
  51601. */
  51602. getClassName(): string;
  51603. /**
  51604. * Makes a duplicate of the current material.
  51605. * @param name - name to use for the new material.
  51606. */
  51607. clone(name: string): PBRMetallicRoughnessMaterial;
  51608. /**
  51609. * Serialize the material to a parsable JSON object.
  51610. */
  51611. serialize(): any;
  51612. /**
  51613. * Parses a JSON object correponding to the serialize function.
  51614. */
  51615. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51616. }
  51617. }
  51618. declare module BABYLON {
  51619. /**
  51620. * The PBR material of BJS following the specular glossiness convention.
  51621. *
  51622. * This fits to the PBR convention in the GLTF definition:
  51623. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51624. */
  51625. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51626. /**
  51627. * Specifies the diffuse color of the material.
  51628. */
  51629. diffuseColor: Color3;
  51630. /**
  51631. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51632. * channel.
  51633. */
  51634. diffuseTexture: BaseTexture;
  51635. /**
  51636. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51637. */
  51638. specularColor: Color3;
  51639. /**
  51640. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51641. */
  51642. glossiness: number;
  51643. /**
  51644. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51645. */
  51646. specularGlossinessTexture: BaseTexture;
  51647. /**
  51648. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51649. *
  51650. * @param name The material name
  51651. * @param scene The scene the material will be use in.
  51652. */
  51653. constructor(name: string, scene: Scene);
  51654. /**
  51655. * Return the currrent class name of the material.
  51656. */
  51657. getClassName(): string;
  51658. /**
  51659. * Makes a duplicate of the current material.
  51660. * @param name - name to use for the new material.
  51661. */
  51662. clone(name: string): PBRSpecularGlossinessMaterial;
  51663. /**
  51664. * Serialize the material to a parsable JSON object.
  51665. */
  51666. serialize(): any;
  51667. /**
  51668. * Parses a JSON object correponding to the serialize function.
  51669. */
  51670. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51671. }
  51672. }
  51673. declare module BABYLON {
  51674. /**
  51675. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51676. * It can help converting any input color in a desired output one. This can then be used to create effects
  51677. * from sepia, black and white to sixties or futuristic rendering...
  51678. *
  51679. * The only supported format is currently 3dl.
  51680. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51681. */
  51682. export class ColorGradingTexture extends BaseTexture {
  51683. /**
  51684. * The current texture matrix. (will always be identity in color grading texture)
  51685. */
  51686. private _textureMatrix;
  51687. /**
  51688. * The texture URL.
  51689. */
  51690. url: string;
  51691. /**
  51692. * Empty line regex stored for GC.
  51693. */
  51694. private static _noneEmptyLineRegex;
  51695. private _engine;
  51696. /**
  51697. * Instantiates a ColorGradingTexture from the following parameters.
  51698. *
  51699. * @param url The location of the color gradind data (currently only supporting 3dl)
  51700. * @param scene The scene the texture will be used in
  51701. */
  51702. constructor(url: string, scene: Scene);
  51703. /**
  51704. * Returns the texture matrix used in most of the material.
  51705. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51706. */
  51707. getTextureMatrix(): Matrix;
  51708. /**
  51709. * Occurs when the file being loaded is a .3dl LUT file.
  51710. */
  51711. private load3dlTexture;
  51712. /**
  51713. * Starts the loading process of the texture.
  51714. */
  51715. private loadTexture;
  51716. /**
  51717. * Clones the color gradind texture.
  51718. */
  51719. clone(): ColorGradingTexture;
  51720. /**
  51721. * Called during delayed load for textures.
  51722. */
  51723. delayLoad(): void;
  51724. /**
  51725. * Parses a color grading texture serialized by Babylon.
  51726. * @param parsedTexture The texture information being parsedTexture
  51727. * @param scene The scene to load the texture in
  51728. * @param rootUrl The root url of the data assets to load
  51729. * @return A color gradind texture
  51730. */
  51731. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51732. /**
  51733. * Serializes the LUT texture to json format.
  51734. */
  51735. serialize(): any;
  51736. }
  51737. }
  51738. declare module BABYLON {
  51739. /**
  51740. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51741. */
  51742. export class EquiRectangularCubeTexture extends BaseTexture {
  51743. /** The six faces of the cube. */
  51744. private static _FacesMapping;
  51745. private _noMipmap;
  51746. private _onLoad;
  51747. private _onError;
  51748. /** The size of the cubemap. */
  51749. private _size;
  51750. /** The buffer of the image. */
  51751. private _buffer;
  51752. /** The width of the input image. */
  51753. private _width;
  51754. /** The height of the input image. */
  51755. private _height;
  51756. /** The URL to the image. */
  51757. url: string;
  51758. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51759. coordinatesMode: number;
  51760. /**
  51761. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51762. * @param url The location of the image
  51763. * @param scene The scene the texture will be used in
  51764. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51765. * @param noMipmap Forces to not generate the mipmap if true
  51766. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51767. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51768. * @param onLoad — defines a callback called when texture is loaded
  51769. * @param onError — defines a callback called if there is an error
  51770. */
  51771. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51772. /**
  51773. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51774. */
  51775. private loadImage;
  51776. /**
  51777. * Convert the image buffer into a cubemap and create a CubeTexture.
  51778. */
  51779. private loadTexture;
  51780. /**
  51781. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51782. * @param buffer The ArrayBuffer that should be converted.
  51783. * @returns The buffer as Float32Array.
  51784. */
  51785. private getFloat32ArrayFromArrayBuffer;
  51786. /**
  51787. * Get the current class name of the texture useful for serialization or dynamic coding.
  51788. * @returns "EquiRectangularCubeTexture"
  51789. */
  51790. getClassName(): string;
  51791. /**
  51792. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51793. * @returns A clone of the current EquiRectangularCubeTexture.
  51794. */
  51795. clone(): EquiRectangularCubeTexture;
  51796. }
  51797. }
  51798. declare module BABYLON {
  51799. /**
  51800. * Based on jsTGALoader - Javascript loader for TGA file
  51801. * By Vincent Thibault
  51802. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51803. */
  51804. export class TGATools {
  51805. private static _TYPE_INDEXED;
  51806. private static _TYPE_RGB;
  51807. private static _TYPE_GREY;
  51808. private static _TYPE_RLE_INDEXED;
  51809. private static _TYPE_RLE_RGB;
  51810. private static _TYPE_RLE_GREY;
  51811. private static _ORIGIN_MASK;
  51812. private static _ORIGIN_SHIFT;
  51813. private static _ORIGIN_BL;
  51814. private static _ORIGIN_BR;
  51815. private static _ORIGIN_UL;
  51816. private static _ORIGIN_UR;
  51817. /**
  51818. * Gets the header of a TGA file
  51819. * @param data defines the TGA data
  51820. * @returns the header
  51821. */
  51822. static GetTGAHeader(data: Uint8Array): any;
  51823. /**
  51824. * Uploads TGA content to a Babylon Texture
  51825. * @hidden
  51826. */
  51827. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51828. /** @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;
  51829. /** @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;
  51830. /** @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;
  51831. /** @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;
  51832. /** @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;
  51833. /** @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;
  51834. }
  51835. }
  51836. declare module BABYLON {
  51837. /**
  51838. * Implementation of the TGA Texture Loader.
  51839. * @hidden
  51840. */
  51841. export class _TGATextureLoader implements IInternalTextureLoader {
  51842. /**
  51843. * Defines wether the loader supports cascade loading the different faces.
  51844. */
  51845. readonly supportCascades: boolean;
  51846. /**
  51847. * This returns if the loader support the current file information.
  51848. * @param extension defines the file extension of the file being loaded
  51849. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51850. * @param fallback defines the fallback internal texture if any
  51851. * @param isBase64 defines whether the texture is encoded as a base64
  51852. * @param isBuffer defines whether the texture data are stored as a buffer
  51853. * @returns true if the loader can load the specified file
  51854. */
  51855. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51856. /**
  51857. * Transform the url before loading if required.
  51858. * @param rootUrl the url of the texture
  51859. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51860. * @returns the transformed texture
  51861. */
  51862. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51863. /**
  51864. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51865. * @param rootUrl the url of the texture
  51866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51867. * @returns the fallback texture
  51868. */
  51869. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51870. /**
  51871. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51872. * @param data contains the texture data
  51873. * @param texture defines the BabylonJS internal texture
  51874. * @param createPolynomials will be true if polynomials have been requested
  51875. * @param onLoad defines the callback to trigger once the texture is ready
  51876. * @param onError defines the callback to trigger in case of error
  51877. */
  51878. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51879. /**
  51880. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51881. * @param data contains the texture data
  51882. * @param texture defines the BabylonJS internal texture
  51883. * @param callback defines the method to call once ready to upload
  51884. */
  51885. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51886. }
  51887. }
  51888. declare module BABYLON {
  51889. /**
  51890. * Info about the .basis files
  51891. */
  51892. class BasisFileInfo {
  51893. /**
  51894. * If the file has alpha
  51895. */
  51896. hasAlpha: boolean;
  51897. /**
  51898. * Info about each image of the basis file
  51899. */
  51900. images: Array<{
  51901. levels: Array<{
  51902. width: number;
  51903. height: number;
  51904. transcodedPixels: ArrayBufferView;
  51905. }>;
  51906. }>;
  51907. }
  51908. /**
  51909. * Result of transcoding a basis file
  51910. */
  51911. class TranscodeResult {
  51912. /**
  51913. * Info about the .basis file
  51914. */
  51915. fileInfo: BasisFileInfo;
  51916. /**
  51917. * Format to use when loading the file
  51918. */
  51919. format: number;
  51920. }
  51921. /**
  51922. * Configuration options for the Basis transcoder
  51923. */
  51924. export class BasisTranscodeConfiguration {
  51925. /**
  51926. * Supported compression formats used to determine the supported output format of the transcoder
  51927. */
  51928. supportedCompressionFormats?: {
  51929. /**
  51930. * etc1 compression format
  51931. */
  51932. etc1?: boolean;
  51933. /**
  51934. * s3tc compression format
  51935. */
  51936. s3tc?: boolean;
  51937. /**
  51938. * pvrtc compression format
  51939. */
  51940. pvrtc?: boolean;
  51941. /**
  51942. * etc2 compression format
  51943. */
  51944. etc2?: boolean;
  51945. };
  51946. /**
  51947. * If mipmap levels should be loaded for transcoded images (Default: true)
  51948. */
  51949. loadMipmapLevels?: boolean;
  51950. /**
  51951. * Index of a single image to load (Default: all images)
  51952. */
  51953. loadSingleImage?: number;
  51954. }
  51955. /**
  51956. * Used to load .Basis files
  51957. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51958. */
  51959. export class BasisTools {
  51960. private static _IgnoreSupportedFormats;
  51961. /**
  51962. * URL to use when loading the basis transcoder
  51963. */
  51964. static JSModuleURL: string;
  51965. /**
  51966. * URL to use when loading the wasm module for the transcoder
  51967. */
  51968. static WasmModuleURL: string;
  51969. /**
  51970. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51971. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51972. * @returns internal format corresponding to the Basis format
  51973. */
  51974. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51975. private static _WorkerPromise;
  51976. private static _Worker;
  51977. private static _actionId;
  51978. private static _CreateWorkerAsync;
  51979. /**
  51980. * Transcodes a loaded image file to compressed pixel data
  51981. * @param imageData image data to transcode
  51982. * @param config configuration options for the transcoding
  51983. * @returns a promise resulting in the transcoded image
  51984. */
  51985. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51986. /**
  51987. * Loads a texture from the transcode result
  51988. * @param texture texture load to
  51989. * @param transcodeResult the result of transcoding the basis file to load from
  51990. */
  51991. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51992. }
  51993. }
  51994. declare module BABYLON {
  51995. /**
  51996. * Loader for .basis file format
  51997. */
  51998. export class _BasisTextureLoader implements IInternalTextureLoader {
  51999. /**
  52000. * Defines whether the loader supports cascade loading the different faces.
  52001. */
  52002. readonly supportCascades: boolean;
  52003. /**
  52004. * This returns if the loader support the current file information.
  52005. * @param extension defines the file extension of the file being loaded
  52006. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52007. * @param fallback defines the fallback internal texture if any
  52008. * @param isBase64 defines whether the texture is encoded as a base64
  52009. * @param isBuffer defines whether the texture data are stored as a buffer
  52010. * @returns true if the loader can load the specified file
  52011. */
  52012. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52013. /**
  52014. * Transform the url before loading if required.
  52015. * @param rootUrl the url of the texture
  52016. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52017. * @returns the transformed texture
  52018. */
  52019. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52020. /**
  52021. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52022. * @param rootUrl the url of the texture
  52023. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52024. * @returns the fallback texture
  52025. */
  52026. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52027. /**
  52028. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52029. * @param data contains the texture data
  52030. * @param texture defines the BabylonJS internal texture
  52031. * @param createPolynomials will be true if polynomials have been requested
  52032. * @param onLoad defines the callback to trigger once the texture is ready
  52033. * @param onError defines the callback to trigger in case of error
  52034. */
  52035. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52036. /**
  52037. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52038. * @param data contains the texture data
  52039. * @param texture defines the BabylonJS internal texture
  52040. * @param callback defines the method to call once ready to upload
  52041. */
  52042. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52043. }
  52044. }
  52045. declare module BABYLON {
  52046. /**
  52047. * 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.
  52048. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52049. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52050. */
  52051. export class CustomProceduralTexture extends ProceduralTexture {
  52052. private _animate;
  52053. private _time;
  52054. private _config;
  52055. private _texturePath;
  52056. /**
  52057. * Instantiates a new Custom Procedural Texture.
  52058. * 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.
  52059. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52060. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52061. * @param name Define the name of the texture
  52062. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52063. * @param size Define the size of the texture to create
  52064. * @param scene Define the scene the texture belongs to
  52065. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52066. * @param generateMipMaps Define if the texture should creates mip maps or not
  52067. */
  52068. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52069. private _loadJson;
  52070. /**
  52071. * Is the texture ready to be used ? (rendered at least once)
  52072. * @returns true if ready, otherwise, false.
  52073. */
  52074. isReady(): boolean;
  52075. /**
  52076. * Render the texture to its associated render target.
  52077. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52078. */
  52079. render(useCameraPostProcess?: boolean): void;
  52080. /**
  52081. * Update the list of dependant textures samplers in the shader.
  52082. */
  52083. updateTextures(): void;
  52084. /**
  52085. * Update the uniform values of the procedural texture in the shader.
  52086. */
  52087. updateShaderUniforms(): void;
  52088. /**
  52089. * Define if the texture animates or not.
  52090. */
  52091. animate: boolean;
  52092. }
  52093. }
  52094. declare module BABYLON {
  52095. /** @hidden */
  52096. export var noisePixelShader: {
  52097. name: string;
  52098. shader: string;
  52099. };
  52100. }
  52101. declare module BABYLON {
  52102. /**
  52103. * Class used to generate noise procedural textures
  52104. */
  52105. export class NoiseProceduralTexture extends ProceduralTexture {
  52106. private _time;
  52107. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52108. brightness: number;
  52109. /** Defines the number of octaves to process */
  52110. octaves: number;
  52111. /** Defines the level of persistence (0.8 by default) */
  52112. persistence: number;
  52113. /** Gets or sets animation speed factor (default is 1) */
  52114. animationSpeedFactor: number;
  52115. /**
  52116. * Creates a new NoiseProceduralTexture
  52117. * @param name defines the name fo the texture
  52118. * @param size defines the size of the texture (default is 256)
  52119. * @param scene defines the hosting scene
  52120. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52121. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52122. */
  52123. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52124. private _updateShaderUniforms;
  52125. protected _getDefines(): string;
  52126. /** Generate the current state of the procedural texture */
  52127. render(useCameraPostProcess?: boolean): void;
  52128. /**
  52129. * Serializes this noise procedural texture
  52130. * @returns a serialized noise procedural texture object
  52131. */
  52132. serialize(): any;
  52133. /**
  52134. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52135. * @param parsedTexture defines parsed texture data
  52136. * @param scene defines the current scene
  52137. * @param rootUrl defines the root URL containing noise procedural texture information
  52138. * @returns a parsed NoiseProceduralTexture
  52139. */
  52140. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52141. }
  52142. }
  52143. declare module BABYLON {
  52144. /**
  52145. * Raw cube texture where the raw buffers are passed in
  52146. */
  52147. export class RawCubeTexture extends CubeTexture {
  52148. /**
  52149. * Creates a cube texture where the raw buffers are passed in.
  52150. * @param scene defines the scene the texture is attached to
  52151. * @param data defines the array of data to use to create each face
  52152. * @param size defines the size of the textures
  52153. * @param format defines the format of the data
  52154. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52155. * @param generateMipMaps defines if the engine should generate the mip levels
  52156. * @param invertY defines if data must be stored with Y axis inverted
  52157. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52158. * @param compression defines the compression used (null by default)
  52159. */
  52160. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52161. /**
  52162. * Updates the raw cube texture.
  52163. * @param data defines the data to store
  52164. * @param format defines the data format
  52165. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52166. * @param invertY defines if data must be stored with Y axis inverted
  52167. * @param compression defines the compression used (null by default)
  52168. * @param level defines which level of the texture to update
  52169. */
  52170. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52171. /**
  52172. * Updates a raw cube texture with RGBD encoded data.
  52173. * @param data defines the array of data [mipmap][face] to use to create each face
  52174. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52175. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52176. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52177. * @returns a promsie that resolves when the operation is complete
  52178. */
  52179. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52180. /**
  52181. * Clones the raw cube texture.
  52182. * @return a new cube texture
  52183. */
  52184. clone(): CubeTexture;
  52185. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52186. }
  52187. }
  52188. declare module BABYLON {
  52189. /**
  52190. * Class used to store 3D textures containing user data
  52191. */
  52192. export class RawTexture3D extends Texture {
  52193. /** Gets or sets the texture format to use */
  52194. format: number;
  52195. private _engine;
  52196. /**
  52197. * Create a new RawTexture3D
  52198. * @param data defines the data of the texture
  52199. * @param width defines the width of the texture
  52200. * @param height defines the height of the texture
  52201. * @param depth defines the depth of the texture
  52202. * @param format defines the texture format to use
  52203. * @param scene defines the hosting scene
  52204. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52205. * @param invertY defines if texture must be stored with Y axis inverted
  52206. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52207. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52208. */
  52209. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52210. /** Gets or sets the texture format to use */
  52211. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52212. /**
  52213. * Update the texture with new data
  52214. * @param data defines the data to store in the texture
  52215. */
  52216. update(data: ArrayBufferView): void;
  52217. }
  52218. }
  52219. declare module BABYLON {
  52220. /**
  52221. * Class used to store 2D array textures containing user data
  52222. */
  52223. export class RawTexture2DArray extends Texture {
  52224. /** Gets or sets the texture format to use */
  52225. format: number;
  52226. private _engine;
  52227. /**
  52228. * Create a new RawTexture2DArray
  52229. * @param data defines the data of the texture
  52230. * @param width defines the width of the texture
  52231. * @param height defines the height of the texture
  52232. * @param depth defines the number of layers of the texture
  52233. * @param format defines the texture format to use
  52234. * @param scene defines the hosting scene
  52235. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52236. * @param invertY defines if texture must be stored with Y axis inverted
  52237. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52238. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52239. */
  52240. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52241. /** Gets or sets the texture format to use */
  52242. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52243. /**
  52244. * Update the texture with new data
  52245. * @param data defines the data to store in the texture
  52246. */
  52247. update(data: ArrayBufferView): void;
  52248. }
  52249. }
  52250. declare module BABYLON {
  52251. /**
  52252. * Creates a refraction texture used by refraction channel of the standard material.
  52253. * It is like a mirror but to see through a material.
  52254. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52255. */
  52256. export class RefractionTexture extends RenderTargetTexture {
  52257. /**
  52258. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52259. * 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.
  52260. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52261. */
  52262. refractionPlane: Plane;
  52263. /**
  52264. * Define how deep under the surface we should see.
  52265. */
  52266. depth: number;
  52267. /**
  52268. * Creates a refraction texture used by refraction channel of the standard material.
  52269. * It is like a mirror but to see through a material.
  52270. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52271. * @param name Define the texture name
  52272. * @param size Define the size of the underlying texture
  52273. * @param scene Define the scene the refraction belongs to
  52274. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52275. */
  52276. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52277. /**
  52278. * Clone the refraction texture.
  52279. * @returns the cloned texture
  52280. */
  52281. clone(): RefractionTexture;
  52282. /**
  52283. * Serialize the texture to a JSON representation you could use in Parse later on
  52284. * @returns the serialized JSON representation
  52285. */
  52286. serialize(): any;
  52287. }
  52288. }
  52289. declare module BABYLON {
  52290. /**
  52291. * Defines the options related to the creation of an HtmlElementTexture
  52292. */
  52293. export interface IHtmlElementTextureOptions {
  52294. /**
  52295. * Defines wether mip maps should be created or not.
  52296. */
  52297. generateMipMaps?: boolean;
  52298. /**
  52299. * Defines the sampling mode of the texture.
  52300. */
  52301. samplingMode?: number;
  52302. /**
  52303. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52304. */
  52305. engine: Nullable<ThinEngine>;
  52306. /**
  52307. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52308. */
  52309. scene: Nullable<Scene>;
  52310. }
  52311. /**
  52312. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52313. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52314. * is automatically managed.
  52315. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52316. * in your application.
  52317. *
  52318. * As the update is not automatic, you need to call them manually.
  52319. */
  52320. export class HtmlElementTexture extends BaseTexture {
  52321. /**
  52322. * The texture URL.
  52323. */
  52324. element: HTMLVideoElement | HTMLCanvasElement;
  52325. private static readonly DefaultOptions;
  52326. private _textureMatrix;
  52327. private _engine;
  52328. private _isVideo;
  52329. private _generateMipMaps;
  52330. private _samplingMode;
  52331. /**
  52332. * Instantiates a HtmlElementTexture from the following parameters.
  52333. *
  52334. * @param name Defines the name of the texture
  52335. * @param element Defines the video or canvas the texture is filled with
  52336. * @param options Defines the other none mandatory texture creation options
  52337. */
  52338. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52339. private _createInternalTexture;
  52340. /**
  52341. * Returns the texture matrix used in most of the material.
  52342. */
  52343. getTextureMatrix(): Matrix;
  52344. /**
  52345. * Updates the content of the texture.
  52346. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52347. */
  52348. update(invertY?: Nullable<boolean>): void;
  52349. }
  52350. }
  52351. declare module BABYLON {
  52352. /**
  52353. * Enum used to define the target of a block
  52354. */
  52355. export enum NodeMaterialBlockTargets {
  52356. /** Vertex shader */
  52357. Vertex = 1,
  52358. /** Fragment shader */
  52359. Fragment = 2,
  52360. /** Neutral */
  52361. Neutral = 4,
  52362. /** Vertex and Fragment */
  52363. VertexAndFragment = 3
  52364. }
  52365. }
  52366. declare module BABYLON {
  52367. /**
  52368. * Defines the kind of connection point for node based material
  52369. */
  52370. export enum NodeMaterialBlockConnectionPointTypes {
  52371. /** Float */
  52372. Float = 1,
  52373. /** Int */
  52374. Int = 2,
  52375. /** Vector2 */
  52376. Vector2 = 4,
  52377. /** Vector3 */
  52378. Vector3 = 8,
  52379. /** Vector4 */
  52380. Vector4 = 16,
  52381. /** Color3 */
  52382. Color3 = 32,
  52383. /** Color4 */
  52384. Color4 = 64,
  52385. /** Matrix */
  52386. Matrix = 128,
  52387. /** Detect type based on connection */
  52388. AutoDetect = 1024,
  52389. /** Output type that will be defined by input type */
  52390. BasedOnInput = 2048
  52391. }
  52392. }
  52393. declare module BABYLON {
  52394. /**
  52395. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52396. */
  52397. export enum NodeMaterialBlockConnectionPointMode {
  52398. /** Value is an uniform */
  52399. Uniform = 0,
  52400. /** Value is a mesh attribute */
  52401. Attribute = 1,
  52402. /** Value is a varying between vertex and fragment shaders */
  52403. Varying = 2,
  52404. /** Mode is undefined */
  52405. Undefined = 3
  52406. }
  52407. }
  52408. declare module BABYLON {
  52409. /**
  52410. * Enum used to define system values e.g. values automatically provided by the system
  52411. */
  52412. export enum NodeMaterialSystemValues {
  52413. /** World */
  52414. World = 1,
  52415. /** View */
  52416. View = 2,
  52417. /** Projection */
  52418. Projection = 3,
  52419. /** ViewProjection */
  52420. ViewProjection = 4,
  52421. /** WorldView */
  52422. WorldView = 5,
  52423. /** WorldViewProjection */
  52424. WorldViewProjection = 6,
  52425. /** CameraPosition */
  52426. CameraPosition = 7,
  52427. /** Fog Color */
  52428. FogColor = 8,
  52429. /** Delta time */
  52430. DeltaTime = 9
  52431. }
  52432. }
  52433. declare module BABYLON {
  52434. /**
  52435. * Root class for all node material optimizers
  52436. */
  52437. export class NodeMaterialOptimizer {
  52438. /**
  52439. * Function used to optimize a NodeMaterial graph
  52440. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52441. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52442. */
  52443. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52444. }
  52445. }
  52446. declare module BABYLON {
  52447. /**
  52448. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52449. */
  52450. export class TransformBlock extends NodeMaterialBlock {
  52451. /**
  52452. * Defines the value to use to complement W value to transform it to a Vector4
  52453. */
  52454. complementW: number;
  52455. /**
  52456. * Defines the value to use to complement z value to transform it to a Vector4
  52457. */
  52458. complementZ: number;
  52459. /**
  52460. * Creates a new TransformBlock
  52461. * @param name defines the block name
  52462. */
  52463. constructor(name: string);
  52464. /**
  52465. * Gets the current class name
  52466. * @returns the class name
  52467. */
  52468. getClassName(): string;
  52469. /**
  52470. * Gets the vector input
  52471. */
  52472. readonly vector: NodeMaterialConnectionPoint;
  52473. /**
  52474. * Gets the output component
  52475. */
  52476. readonly output: NodeMaterialConnectionPoint;
  52477. /**
  52478. * Gets the matrix transform input
  52479. */
  52480. readonly transform: NodeMaterialConnectionPoint;
  52481. protected _buildBlock(state: NodeMaterialBuildState): this;
  52482. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52483. protected _dumpPropertiesCode(): string;
  52484. }
  52485. }
  52486. declare module BABYLON {
  52487. /**
  52488. * Block used to output the vertex position
  52489. */
  52490. export class VertexOutputBlock extends NodeMaterialBlock {
  52491. /**
  52492. * Creates a new VertexOutputBlock
  52493. * @param name defines the block name
  52494. */
  52495. constructor(name: string);
  52496. /**
  52497. * Gets the current class name
  52498. * @returns the class name
  52499. */
  52500. getClassName(): string;
  52501. /**
  52502. * Gets the vector input component
  52503. */
  52504. readonly vector: NodeMaterialConnectionPoint;
  52505. protected _buildBlock(state: NodeMaterialBuildState): this;
  52506. }
  52507. }
  52508. declare module BABYLON {
  52509. /**
  52510. * Block used to output the final color
  52511. */
  52512. export class FragmentOutputBlock extends NodeMaterialBlock {
  52513. /**
  52514. * Create a new FragmentOutputBlock
  52515. * @param name defines the block name
  52516. */
  52517. constructor(name: string);
  52518. /**
  52519. * Gets the current class name
  52520. * @returns the class name
  52521. */
  52522. getClassName(): string;
  52523. /**
  52524. * Gets the rgba input component
  52525. */
  52526. readonly rgba: NodeMaterialConnectionPoint;
  52527. /**
  52528. * Gets the rgb input component
  52529. */
  52530. readonly rgb: NodeMaterialConnectionPoint;
  52531. /**
  52532. * Gets the a input component
  52533. */
  52534. readonly a: NodeMaterialConnectionPoint;
  52535. protected _buildBlock(state: NodeMaterialBuildState): this;
  52536. }
  52537. }
  52538. declare module BABYLON {
  52539. /**
  52540. * Block used to read a reflection texture from a sampler
  52541. */
  52542. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52543. private _define3DName;
  52544. private _defineCubicName;
  52545. private _defineExplicitName;
  52546. private _defineProjectionName;
  52547. private _defineLocalCubicName;
  52548. private _defineSphericalName;
  52549. private _definePlanarName;
  52550. private _defineEquirectangularName;
  52551. private _defineMirroredEquirectangularFixedName;
  52552. private _defineEquirectangularFixedName;
  52553. private _defineSkyboxName;
  52554. private _cubeSamplerName;
  52555. private _2DSamplerName;
  52556. private _positionUVWName;
  52557. private _directionWName;
  52558. private _reflectionCoordsName;
  52559. private _reflection2DCoordsName;
  52560. private _reflectionColorName;
  52561. private _reflectionMatrixName;
  52562. /**
  52563. * Gets or sets the texture associated with the node
  52564. */
  52565. texture: Nullable<BaseTexture>;
  52566. /**
  52567. * Create a new TextureBlock
  52568. * @param name defines the block name
  52569. */
  52570. constructor(name: string);
  52571. /**
  52572. * Gets the current class name
  52573. * @returns the class name
  52574. */
  52575. getClassName(): string;
  52576. /**
  52577. * Gets the world position input component
  52578. */
  52579. readonly position: NodeMaterialConnectionPoint;
  52580. /**
  52581. * Gets the world position input component
  52582. */
  52583. readonly worldPosition: NodeMaterialConnectionPoint;
  52584. /**
  52585. * Gets the world normal input component
  52586. */
  52587. readonly worldNormal: NodeMaterialConnectionPoint;
  52588. /**
  52589. * Gets the world input component
  52590. */
  52591. readonly world: NodeMaterialConnectionPoint;
  52592. /**
  52593. * Gets the camera (or eye) position component
  52594. */
  52595. readonly cameraPosition: NodeMaterialConnectionPoint;
  52596. /**
  52597. * Gets the view input component
  52598. */
  52599. readonly view: NodeMaterialConnectionPoint;
  52600. /**
  52601. * Gets the rgb output component
  52602. */
  52603. readonly rgb: NodeMaterialConnectionPoint;
  52604. /**
  52605. * Gets the r output component
  52606. */
  52607. readonly r: NodeMaterialConnectionPoint;
  52608. /**
  52609. * Gets the g output component
  52610. */
  52611. readonly g: NodeMaterialConnectionPoint;
  52612. /**
  52613. * Gets the b output component
  52614. */
  52615. readonly b: NodeMaterialConnectionPoint;
  52616. autoConfigure(material: NodeMaterial): void;
  52617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52618. isReady(): boolean;
  52619. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52620. private _injectVertexCode;
  52621. private _writeOutput;
  52622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52623. protected _dumpPropertiesCode(): string;
  52624. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52625. }
  52626. }
  52627. declare module BABYLON {
  52628. /**
  52629. * Interface used to configure the node material editor
  52630. */
  52631. export interface INodeMaterialEditorOptions {
  52632. /** Define the URl to load node editor script */
  52633. editorURL?: string;
  52634. }
  52635. /** @hidden */
  52636. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52637. /** BONES */
  52638. NUM_BONE_INFLUENCERS: number;
  52639. BonesPerMesh: number;
  52640. BONETEXTURE: boolean;
  52641. /** MORPH TARGETS */
  52642. MORPHTARGETS: boolean;
  52643. MORPHTARGETS_NORMAL: boolean;
  52644. MORPHTARGETS_TANGENT: boolean;
  52645. MORPHTARGETS_UV: boolean;
  52646. NUM_MORPH_INFLUENCERS: number;
  52647. /** IMAGE PROCESSING */
  52648. IMAGEPROCESSING: boolean;
  52649. VIGNETTE: boolean;
  52650. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52651. VIGNETTEBLENDMODEOPAQUE: boolean;
  52652. TONEMAPPING: boolean;
  52653. TONEMAPPING_ACES: boolean;
  52654. CONTRAST: boolean;
  52655. EXPOSURE: boolean;
  52656. COLORCURVES: boolean;
  52657. COLORGRADING: boolean;
  52658. COLORGRADING3D: boolean;
  52659. SAMPLER3DGREENDEPTH: boolean;
  52660. SAMPLER3DBGRMAP: boolean;
  52661. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52662. /** MISC. */
  52663. BUMPDIRECTUV: number;
  52664. constructor();
  52665. setValue(name: string, value: boolean): void;
  52666. }
  52667. /**
  52668. * Class used to configure NodeMaterial
  52669. */
  52670. export interface INodeMaterialOptions {
  52671. /**
  52672. * Defines if blocks should emit comments
  52673. */
  52674. emitComments: boolean;
  52675. }
  52676. /**
  52677. * Class used to create a node based material built by assembling shader blocks
  52678. */
  52679. export class NodeMaterial extends PushMaterial {
  52680. private static _BuildIdGenerator;
  52681. private _options;
  52682. private _vertexCompilationState;
  52683. private _fragmentCompilationState;
  52684. private _sharedData;
  52685. private _buildId;
  52686. private _buildWasSuccessful;
  52687. private _cachedWorldViewMatrix;
  52688. private _cachedWorldViewProjectionMatrix;
  52689. private _optimizers;
  52690. private _animationFrame;
  52691. /** Define the URl to load node editor script */
  52692. static EditorURL: string;
  52693. private BJSNODEMATERIALEDITOR;
  52694. /** Get the inspector from bundle or global */
  52695. private _getGlobalNodeMaterialEditor;
  52696. /**
  52697. * 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)
  52698. */
  52699. ignoreAlpha: boolean;
  52700. /**
  52701. * Defines the maximum number of lights that can be used in the material
  52702. */
  52703. maxSimultaneousLights: number;
  52704. /**
  52705. * Observable raised when the material is built
  52706. */
  52707. onBuildObservable: Observable<NodeMaterial>;
  52708. /**
  52709. * Gets or sets the root nodes of the material vertex shader
  52710. */ private _vertexOutputNodes: NodeMaterialBlock[];
  52711. /**
  52712. * Gets or sets the root nodes of the material fragment (pixel) shader
  52713. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  52714. /** Gets or sets options to control the node material overall behavior */
  52715. options: INodeMaterialOptions;
  52716. /**
  52717. * Default configuration related to image processing available in the standard Material.
  52718. */
  52719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52720. /**
  52721. * Gets the image processing configuration used either in this material.
  52722. */
  52723. /**
  52724. * Sets the Default image processing configuration used either in the this material.
  52725. *
  52726. * If sets to null, the scene one is in use.
  52727. */
  52728. imageProcessingConfiguration: ImageProcessingConfiguration;
  52729. /**
  52730. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52731. */
  52732. attachedBlocks: NodeMaterialBlock[];
  52733. /**
  52734. * Create a new node based material
  52735. * @param name defines the material name
  52736. * @param scene defines the hosting scene
  52737. * @param options defines creation option
  52738. */
  52739. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52740. /**
  52741. * Gets the current class name of the material e.g. "NodeMaterial"
  52742. * @returns the class name
  52743. */
  52744. getClassName(): string;
  52745. /**
  52746. * Keep track of the image processing observer to allow dispose and replace.
  52747. */
  52748. private _imageProcessingObserver;
  52749. /**
  52750. * Attaches a new image processing configuration to the Standard Material.
  52751. * @param configuration
  52752. */
  52753. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52754. /**
  52755. * Get a block by its name
  52756. * @param name defines the name of the block to retrieve
  52757. * @returns the required block or null if not found
  52758. */
  52759. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52760. /**
  52761. * Get a block by its name
  52762. * @param predicate defines the predicate used to find the good candidate
  52763. * @returns the required block or null if not found
  52764. */
  52765. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52766. /**
  52767. * Get an input block by its name
  52768. * @param predicate defines the predicate used to find the good candidate
  52769. * @returns the required input block or null if not found
  52770. */
  52771. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52772. /**
  52773. * Gets the list of input blocks attached to this material
  52774. * @returns an array of InputBlocks
  52775. */
  52776. getInputBlocks(): InputBlock[];
  52777. /**
  52778. * Adds a new optimizer to the list of optimizers
  52779. * @param optimizer defines the optimizers to add
  52780. * @returns the current material
  52781. */
  52782. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52783. /**
  52784. * Remove an optimizer from the list of optimizers
  52785. * @param optimizer defines the optimizers to remove
  52786. * @returns the current material
  52787. */
  52788. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52789. /**
  52790. * Add a new block to the list of output nodes
  52791. * @param node defines the node to add
  52792. * @returns the current material
  52793. */
  52794. addOutputNode(node: NodeMaterialBlock): this;
  52795. /**
  52796. * Remove a block from the list of root nodes
  52797. * @param node defines the node to remove
  52798. * @returns the current material
  52799. */
  52800. removeOutputNode(node: NodeMaterialBlock): this;
  52801. private _addVertexOutputNode;
  52802. private _removeVertexOutputNode;
  52803. private _addFragmentOutputNode;
  52804. private _removeFragmentOutputNode;
  52805. /**
  52806. * Specifies if the material will require alpha blending
  52807. * @returns a boolean specifying if alpha blending is needed
  52808. */
  52809. needAlphaBlending(): boolean;
  52810. /**
  52811. * Specifies if this material should be rendered in alpha test mode
  52812. * @returns a boolean specifying if an alpha test is needed.
  52813. */
  52814. needAlphaTesting(): boolean;
  52815. private _initializeBlock;
  52816. private _resetDualBlocks;
  52817. /**
  52818. * Build the material and generates the inner effect
  52819. * @param verbose defines if the build should log activity
  52820. */
  52821. build(verbose?: boolean): void;
  52822. /**
  52823. * Runs an otpimization phase to try to improve the shader code
  52824. */
  52825. optimize(): void;
  52826. private _prepareDefinesForAttributes;
  52827. /**
  52828. * Get if the submesh is ready to be used and all its information available.
  52829. * Child classes can use it to update shaders
  52830. * @param mesh defines the mesh to check
  52831. * @param subMesh defines which submesh to check
  52832. * @param useInstances specifies that instances should be used
  52833. * @returns a boolean indicating that the submesh is ready or not
  52834. */
  52835. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52836. /**
  52837. * Get a string representing the shaders built by the current node graph
  52838. */
  52839. readonly compiledShaders: string;
  52840. /**
  52841. * Binds the world matrix to the material
  52842. * @param world defines the world transformation matrix
  52843. */
  52844. bindOnlyWorldMatrix(world: Matrix): void;
  52845. /**
  52846. * Binds the submesh to this material by preparing the effect and shader to draw
  52847. * @param world defines the world transformation matrix
  52848. * @param mesh defines the mesh containing the submesh
  52849. * @param subMesh defines the submesh to bind the material to
  52850. */
  52851. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52852. /**
  52853. * Gets the active textures from the material
  52854. * @returns an array of textures
  52855. */
  52856. getActiveTextures(): BaseTexture[];
  52857. /**
  52858. * Gets the list of texture blocks
  52859. * @returns an array of texture blocks
  52860. */
  52861. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52862. /**
  52863. * Specifies if the material uses a texture
  52864. * @param texture defines the texture to check against the material
  52865. * @returns a boolean specifying if the material uses the texture
  52866. */
  52867. hasTexture(texture: BaseTexture): boolean;
  52868. /**
  52869. * Disposes the material
  52870. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52871. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52872. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52873. */
  52874. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52875. /** Creates the node editor window. */
  52876. private _createNodeEditor;
  52877. /**
  52878. * Launch the node material editor
  52879. * @param config Define the configuration of the editor
  52880. * @return a promise fulfilled when the node editor is visible
  52881. */
  52882. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52883. /**
  52884. * Clear the current material
  52885. */
  52886. clear(): void;
  52887. /**
  52888. * Clear the current material and set it to a default state
  52889. */
  52890. setToDefault(): void;
  52891. /**
  52892. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52893. * @param url defines the url to load from
  52894. * @returns a promise that will fullfil when the material is fully loaded
  52895. */
  52896. loadAsync(url: string): Promise<void>;
  52897. private _gatherBlocks;
  52898. /**
  52899. * Generate a string containing the code declaration required to create an equivalent of this material
  52900. * @returns a string
  52901. */
  52902. generateCode(): string;
  52903. /**
  52904. * Serializes this material in a JSON representation
  52905. * @returns the serialized material object
  52906. */
  52907. serialize(): any;
  52908. private _restoreConnections;
  52909. /**
  52910. * Clear the current graph and load a new one from a serialization object
  52911. * @param source defines the JSON representation of the material
  52912. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52913. */
  52914. loadFromSerialization(source: any, rootUrl?: string): void;
  52915. /**
  52916. * Creates a node material from parsed material data
  52917. * @param source defines the JSON representation of the material
  52918. * @param scene defines the hosting scene
  52919. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52920. * @returns a new node material
  52921. */
  52922. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52923. /**
  52924. * Creates a new node material set to default basic configuration
  52925. * @param name defines the name of the material
  52926. * @param scene defines the hosting scene
  52927. * @returns a new NodeMaterial
  52928. */
  52929. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52930. }
  52931. }
  52932. declare module BABYLON {
  52933. /**
  52934. * Block used to read a texture from a sampler
  52935. */
  52936. export class TextureBlock extends NodeMaterialBlock {
  52937. private _defineName;
  52938. private _linearDefineName;
  52939. private _samplerName;
  52940. private _transformedUVName;
  52941. private _textureTransformName;
  52942. private _textureInfoName;
  52943. private _mainUVName;
  52944. private _mainUVDefineName;
  52945. /**
  52946. * Gets or sets the texture associated with the node
  52947. */
  52948. texture: Nullable<Texture>;
  52949. /**
  52950. * Create a new TextureBlock
  52951. * @param name defines the block name
  52952. */
  52953. constructor(name: string);
  52954. /**
  52955. * Gets the current class name
  52956. * @returns the class name
  52957. */
  52958. getClassName(): string;
  52959. /**
  52960. * Gets the uv input component
  52961. */
  52962. readonly uv: NodeMaterialConnectionPoint;
  52963. /**
  52964. * Gets the rgba output component
  52965. */
  52966. readonly rgba: NodeMaterialConnectionPoint;
  52967. /**
  52968. * Gets the rgb output component
  52969. */
  52970. readonly rgb: NodeMaterialConnectionPoint;
  52971. /**
  52972. * Gets the r output component
  52973. */
  52974. readonly r: NodeMaterialConnectionPoint;
  52975. /**
  52976. * Gets the g output component
  52977. */
  52978. readonly g: NodeMaterialConnectionPoint;
  52979. /**
  52980. * Gets the b output component
  52981. */
  52982. readonly b: NodeMaterialConnectionPoint;
  52983. /**
  52984. * Gets the a output component
  52985. */
  52986. readonly a: NodeMaterialConnectionPoint;
  52987. readonly target: NodeMaterialBlockTargets;
  52988. autoConfigure(material: NodeMaterial): void;
  52989. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52990. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52991. isReady(): boolean;
  52992. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52993. private readonly _isMixed;
  52994. private _injectVertexCode;
  52995. private _writeOutput;
  52996. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52997. protected _dumpPropertiesCode(): string;
  52998. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52999. }
  53000. }
  53001. declare module BABYLON {
  53002. /**
  53003. * Class used to store shared data between 2 NodeMaterialBuildState
  53004. */
  53005. export class NodeMaterialBuildStateSharedData {
  53006. /**
  53007. * Gets the list of emitted varyings
  53008. */
  53009. temps: string[];
  53010. /**
  53011. * Gets the list of emitted varyings
  53012. */
  53013. varyings: string[];
  53014. /**
  53015. * Gets the varying declaration string
  53016. */
  53017. varyingDeclaration: string;
  53018. /**
  53019. * Input blocks
  53020. */
  53021. inputBlocks: InputBlock[];
  53022. /**
  53023. * Input blocks
  53024. */
  53025. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53026. /**
  53027. * Bindable blocks (Blocks that need to set data to the effect)
  53028. */
  53029. bindableBlocks: NodeMaterialBlock[];
  53030. /**
  53031. * List of blocks that can provide a compilation fallback
  53032. */
  53033. blocksWithFallbacks: NodeMaterialBlock[];
  53034. /**
  53035. * List of blocks that can provide a define update
  53036. */
  53037. blocksWithDefines: NodeMaterialBlock[];
  53038. /**
  53039. * List of blocks that can provide a repeatable content
  53040. */
  53041. repeatableContentBlocks: NodeMaterialBlock[];
  53042. /**
  53043. * List of blocks that can provide a dynamic list of uniforms
  53044. */
  53045. dynamicUniformBlocks: NodeMaterialBlock[];
  53046. /**
  53047. * List of blocks that can block the isReady function for the material
  53048. */
  53049. blockingBlocks: NodeMaterialBlock[];
  53050. /**
  53051. * Gets the list of animated inputs
  53052. */
  53053. animatedInputs: InputBlock[];
  53054. /**
  53055. * Build Id used to avoid multiple recompilations
  53056. */
  53057. buildId: number;
  53058. /** List of emitted variables */
  53059. variableNames: {
  53060. [key: string]: number;
  53061. };
  53062. /** List of emitted defines */
  53063. defineNames: {
  53064. [key: string]: number;
  53065. };
  53066. /** Should emit comments? */
  53067. emitComments: boolean;
  53068. /** Emit build activity */
  53069. verbose: boolean;
  53070. /** Gets or sets the hosting scene */
  53071. scene: Scene;
  53072. /**
  53073. * Gets the compilation hints emitted at compilation time
  53074. */
  53075. hints: {
  53076. needWorldViewMatrix: boolean;
  53077. needWorldViewProjectionMatrix: boolean;
  53078. needAlphaBlending: boolean;
  53079. needAlphaTesting: boolean;
  53080. };
  53081. /**
  53082. * List of compilation checks
  53083. */
  53084. checks: {
  53085. emitVertex: boolean;
  53086. emitFragment: boolean;
  53087. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53088. };
  53089. /** Creates a new shared data */
  53090. constructor();
  53091. /**
  53092. * Emits console errors and exceptions if there is a failing check
  53093. */
  53094. emitErrors(): void;
  53095. }
  53096. }
  53097. declare module BABYLON {
  53098. /**
  53099. * Class used to store node based material build state
  53100. */
  53101. export class NodeMaterialBuildState {
  53102. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53103. supportUniformBuffers: boolean;
  53104. /**
  53105. * Gets the list of emitted attributes
  53106. */
  53107. attributes: string[];
  53108. /**
  53109. * Gets the list of emitted uniforms
  53110. */
  53111. uniforms: string[];
  53112. /**
  53113. * Gets the list of emitted constants
  53114. */
  53115. constants: string[];
  53116. /**
  53117. * Gets the list of emitted samplers
  53118. */
  53119. samplers: string[];
  53120. /**
  53121. * Gets the list of emitted functions
  53122. */
  53123. functions: {
  53124. [key: string]: string;
  53125. };
  53126. /**
  53127. * Gets the list of emitted extensions
  53128. */
  53129. extensions: {
  53130. [key: string]: string;
  53131. };
  53132. /**
  53133. * Gets the target of the compilation state
  53134. */
  53135. target: NodeMaterialBlockTargets;
  53136. /**
  53137. * Gets the list of emitted counters
  53138. */
  53139. counters: {
  53140. [key: string]: number;
  53141. };
  53142. /**
  53143. * Shared data between multiple NodeMaterialBuildState instances
  53144. */
  53145. sharedData: NodeMaterialBuildStateSharedData;
  53146. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  53147. /** @hidden */ private _attributeDeclaration: string;
  53148. /** @hidden */ private _uniformDeclaration: string;
  53149. /** @hidden */ private _constantDeclaration: string;
  53150. /** @hidden */ private _samplerDeclaration: string;
  53151. /** @hidden */ private _varyingTransfer: string;
  53152. private _repeatableContentAnchorIndex;
  53153. /** @hidden */ private _builtCompilationString: string;
  53154. /**
  53155. * Gets the emitted compilation strings
  53156. */
  53157. compilationString: string;
  53158. /**
  53159. * Finalize the compilation strings
  53160. * @param state defines the current compilation state
  53161. */
  53162. finalize(state: NodeMaterialBuildState): void;
  53163. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  53164. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  53165. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  53166. /** @hidden */ private _excludeVariableName(name: string): void;
  53167. /** @hidden */ private _emit2DSampler(name: string): void;
  53168. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53169. /** @hidden */ private _emitExtension(name: string, extension: string): void;
  53170. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  53171. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53172. replaceStrings?: {
  53173. search: RegExp;
  53174. replace: string;
  53175. }[];
  53176. repeatKey?: string;
  53177. }): string;
  53178. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53179. repeatKey?: string;
  53180. removeAttributes?: boolean;
  53181. removeUniforms?: boolean;
  53182. removeVaryings?: boolean;
  53183. removeIfDef?: boolean;
  53184. replaceStrings?: {
  53185. search: RegExp;
  53186. replace: string;
  53187. }[];
  53188. }, storeKey?: string): void;
  53189. /** @hidden */ private _registerTempVariable(name: string): boolean;
  53190. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53191. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53192. /** @hidden */ private _emitFloat(value: number): string;
  53193. }
  53194. }
  53195. declare module BABYLON {
  53196. /**
  53197. * Defines a block that can be used inside a node based material
  53198. */
  53199. export class NodeMaterialBlock {
  53200. private _buildId;
  53201. private _buildTarget;
  53202. private _target;
  53203. private _isFinalMerger;
  53204. private _isInput;
  53205. protected _isUnique: boolean;
  53206. /** @hidden */ private _codeVariableName: string;
  53207. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  53208. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  53209. /** @hidden */ private _preparationId: number;
  53210. /**
  53211. * Gets or sets the name of the block
  53212. */
  53213. name: string;
  53214. /**
  53215. * Gets or sets the unique id of the node
  53216. */
  53217. uniqueId: number;
  53218. /**
  53219. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  53220. */
  53221. readonly isUnique: boolean;
  53222. /**
  53223. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53224. */
  53225. readonly isFinalMerger: boolean;
  53226. /**
  53227. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53228. */
  53229. readonly isInput: boolean;
  53230. /**
  53231. * Gets or sets the build Id
  53232. */
  53233. buildId: number;
  53234. /**
  53235. * Gets or sets the target of the block
  53236. */
  53237. target: NodeMaterialBlockTargets;
  53238. /**
  53239. * Gets the list of input points
  53240. */
  53241. readonly inputs: NodeMaterialConnectionPoint[];
  53242. /** Gets the list of output points */
  53243. readonly outputs: NodeMaterialConnectionPoint[];
  53244. /**
  53245. * Find an input by its name
  53246. * @param name defines the name of the input to look for
  53247. * @returns the input or null if not found
  53248. */
  53249. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53250. /**
  53251. * Find an output by its name
  53252. * @param name defines the name of the outputto look for
  53253. * @returns the output or null if not found
  53254. */
  53255. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53256. /**
  53257. * Creates a new NodeMaterialBlock
  53258. * @param name defines the block name
  53259. * @param target defines the target of that block (Vertex by default)
  53260. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53261. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53262. */
  53263. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53264. /**
  53265. * Initialize the block and prepare the context for build
  53266. * @param state defines the state that will be used for the build
  53267. */
  53268. initialize(state: NodeMaterialBuildState): void;
  53269. /**
  53270. * Bind data to effect. Will only be called for blocks with isBindable === true
  53271. * @param effect defines the effect to bind data to
  53272. * @param nodeMaterial defines the hosting NodeMaterial
  53273. * @param mesh defines the mesh that will be rendered
  53274. */
  53275. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53276. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53277. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53278. protected _writeFloat(value: number): string;
  53279. /**
  53280. * Gets the current class name e.g. "NodeMaterialBlock"
  53281. * @returns the class name
  53282. */
  53283. getClassName(): string;
  53284. /**
  53285. * Register a new input. Must be called inside a block constructor
  53286. * @param name defines the connection point name
  53287. * @param type defines the connection point type
  53288. * @param isOptional defines a boolean indicating that this input can be omitted
  53289. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53290. * @returns the current block
  53291. */
  53292. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53293. /**
  53294. * Register a new output. Must be called inside a block constructor
  53295. * @param name defines the connection point name
  53296. * @param type defines the connection point type
  53297. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53298. * @returns the current block
  53299. */
  53300. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53301. /**
  53302. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53303. * @param forOutput defines an optional connection point to check compatibility with
  53304. * @returns the first available input or null
  53305. */
  53306. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53307. /**
  53308. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53309. * @param forBlock defines an optional block to check compatibility with
  53310. * @returns the first available input or null
  53311. */
  53312. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53313. /**
  53314. * Gets the sibling of the given output
  53315. * @param current defines the current output
  53316. * @returns the next output in the list or null
  53317. */
  53318. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53319. /**
  53320. * Connect current block with another block
  53321. * @param other defines the block to connect with
  53322. * @param options define the various options to help pick the right connections
  53323. * @returns the current block
  53324. */
  53325. connectTo(other: NodeMaterialBlock, options?: {
  53326. input?: string;
  53327. output?: string;
  53328. outputSwizzle?: string;
  53329. }): this | undefined;
  53330. protected _buildBlock(state: NodeMaterialBuildState): void;
  53331. /**
  53332. * Add uniforms, samplers and uniform buffers at compilation time
  53333. * @param state defines the state to update
  53334. * @param nodeMaterial defines the node material requesting the update
  53335. * @param defines defines the material defines to update
  53336. * @param uniformBuffers defines the list of uniform buffer names
  53337. */
  53338. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  53339. /**
  53340. * Add potential fallbacks if shader compilation fails
  53341. * @param mesh defines the mesh to be rendered
  53342. * @param fallbacks defines the current prioritized list of fallbacks
  53343. */
  53344. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53345. /**
  53346. * Initialize defines for shader compilation
  53347. * @param mesh defines the mesh to be rendered
  53348. * @param nodeMaterial defines the node material requesting the update
  53349. * @param defines defines the material defines to update
  53350. * @param useInstances specifies that instances should be used
  53351. */
  53352. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53353. /**
  53354. * Update defines for shader compilation
  53355. * @param mesh defines the mesh to be rendered
  53356. * @param nodeMaterial defines the node material requesting the update
  53357. * @param defines defines the material defines to update
  53358. * @param useInstances specifies that instances should be used
  53359. */
  53360. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53361. /**
  53362. * Lets the block try to connect some inputs automatically
  53363. * @param material defines the hosting NodeMaterial
  53364. */
  53365. autoConfigure(material: NodeMaterial): void;
  53366. /**
  53367. * Function called when a block is declared as repeatable content generator
  53368. * @param vertexShaderState defines the current compilation state for the vertex shader
  53369. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53370. * @param mesh defines the mesh to be rendered
  53371. * @param defines defines the material defines to update
  53372. */
  53373. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53374. /**
  53375. * Checks if the block is ready
  53376. * @param mesh defines the mesh to be rendered
  53377. * @param nodeMaterial defines the node material requesting the update
  53378. * @param defines defines the material defines to update
  53379. * @param useInstances specifies that instances should be used
  53380. * @returns true if the block is ready
  53381. */
  53382. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53383. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53384. private _processBuild;
  53385. /**
  53386. * Compile the current node and generate the shader code
  53387. * @param state defines the current compilation state (uniforms, samplers, current string)
  53388. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53389. * @returns true if already built
  53390. */
  53391. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53392. protected _inputRename(name: string): string;
  53393. protected _outputRename(name: string): string;
  53394. protected _dumpPropertiesCode(): string;
  53395. /** @hidden */ private _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53396. /** @hidden */ private _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  53397. /**
  53398. * Clone the current block to a new identical block
  53399. * @param scene defines the hosting scene
  53400. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53401. * @returns a copy of the current block
  53402. */
  53403. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53404. /**
  53405. * Serializes this block in a JSON representation
  53406. * @returns the serialized block object
  53407. */
  53408. serialize(): any;
  53409. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53410. /**
  53411. * Release resources
  53412. */
  53413. dispose(): void;
  53414. }
  53415. }
  53416. declare module BABYLON {
  53417. /**
  53418. * Enum defining the type of animations supported by InputBlock
  53419. */
  53420. export enum AnimatedInputBlockTypes {
  53421. /** No animation */
  53422. None = 0,
  53423. /** Time based animation. Will only work for floats */
  53424. Time = 1
  53425. }
  53426. }
  53427. declare module BABYLON {
  53428. /**
  53429. * Block used to expose an input value
  53430. */
  53431. export class InputBlock extends NodeMaterialBlock {
  53432. private _mode;
  53433. private _associatedVariableName;
  53434. private _storedValue;
  53435. private _valueCallback;
  53436. private _type;
  53437. private _animationType;
  53438. /** Gets or set a value used to limit the range of float values */
  53439. min: number;
  53440. /** Gets or set a value used to limit the range of float values */
  53441. max: number;
  53442. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53443. matrixMode: number;
  53444. /** @hidden */ private _systemValue: Nullable<NodeMaterialSystemValues>;
  53445. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53446. visibleInInspector: boolean;
  53447. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53448. isConstant: boolean;
  53449. /**
  53450. * Gets or sets the connection point type (default is float)
  53451. */
  53452. readonly type: NodeMaterialBlockConnectionPointTypes;
  53453. /**
  53454. * Creates a new InputBlock
  53455. * @param name defines the block name
  53456. * @param target defines the target of that block (Vertex by default)
  53457. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53458. */
  53459. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53460. /**
  53461. * Gets the output component
  53462. */
  53463. readonly output: NodeMaterialConnectionPoint;
  53464. /**
  53465. * Set the source of this connection point to a vertex attribute
  53466. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53467. * @returns the current connection point
  53468. */
  53469. setAsAttribute(attributeName?: string): InputBlock;
  53470. /**
  53471. * Set the source of this connection point to a system value
  53472. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53473. * @returns the current connection point
  53474. */
  53475. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53476. /**
  53477. * Gets or sets the value of that point.
  53478. * Please note that this value will be ignored if valueCallback is defined
  53479. */
  53480. value: any;
  53481. /**
  53482. * Gets or sets a callback used to get the value of that point.
  53483. * Please note that setting this value will force the connection point to ignore the value property
  53484. */
  53485. valueCallback: () => any;
  53486. /**
  53487. * Gets or sets the associated variable name in the shader
  53488. */
  53489. associatedVariableName: string;
  53490. /** Gets or sets the type of animation applied to the input */
  53491. animationType: AnimatedInputBlockTypes;
  53492. /**
  53493. * Gets a boolean indicating that this connection point not defined yet
  53494. */
  53495. readonly isUndefined: boolean;
  53496. /**
  53497. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53498. * In this case the connection point name must be the name of the uniform to use.
  53499. * Can only be set on inputs
  53500. */
  53501. isUniform: boolean;
  53502. /**
  53503. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53504. * In this case the connection point name must be the name of the attribute to use
  53505. * Can only be set on inputs
  53506. */
  53507. isAttribute: boolean;
  53508. /**
  53509. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53510. * Can only be set on exit points
  53511. */
  53512. isVarying: boolean;
  53513. /**
  53514. * Gets a boolean indicating that the current connection point is a system value
  53515. */
  53516. readonly isSystemValue: boolean;
  53517. /**
  53518. * Gets or sets the current well known value or null if not defined as a system value
  53519. */
  53520. systemValue: Nullable<NodeMaterialSystemValues>;
  53521. /**
  53522. * Gets the current class name
  53523. * @returns the class name
  53524. */
  53525. getClassName(): string;
  53526. /**
  53527. * Animate the input if animationType !== None
  53528. * @param scene defines the rendering scene
  53529. */
  53530. animate(scene: Scene): void;
  53531. private _emitDefine;
  53532. initialize(state: NodeMaterialBuildState): void;
  53533. /**
  53534. * Set the input block to its default value (based on its type)
  53535. */
  53536. setDefaultValue(): void;
  53537. private _emitConstant;
  53538. private _emit;
  53539. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53540. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  53541. protected _buildBlock(state: NodeMaterialBuildState): void;
  53542. protected _dumpPropertiesCode(): string;
  53543. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53544. }
  53545. }
  53546. declare module BABYLON {
  53547. /**
  53548. * Enum used to define the compatibility state between two connection points
  53549. */
  53550. export enum NodeMaterialConnectionPointCompatibilityStates {
  53551. /** Points are compatibles */
  53552. Compatible = 0,
  53553. /** Points are incompatible because of their types */
  53554. TypeIncompatible = 1,
  53555. /** Points are incompatible because of their targets (vertex vs fragment) */
  53556. TargetIncompatible = 2
  53557. }
  53558. /**
  53559. * Defines a connection point for a block
  53560. */
  53561. export class NodeMaterialConnectionPoint {
  53562. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  53563. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53564. private _endpoints;
  53565. private _associatedVariableName;
  53566. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53567. /** @hidden */ private _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53568. private _type;
  53569. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  53570. /**
  53571. * Gets or sets the additional types supported by this connection point
  53572. */
  53573. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53574. /**
  53575. * Gets or sets the additional types excluded by this connection point
  53576. */
  53577. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53578. /**
  53579. * Observable triggered when this point is connected
  53580. */
  53581. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  53582. /**
  53583. * Gets or sets the associated variable name in the shader
  53584. */
  53585. associatedVariableName: string;
  53586. /**
  53587. * Gets or sets the connection point type (default is float)
  53588. */
  53589. type: NodeMaterialBlockConnectionPointTypes;
  53590. /**
  53591. * Gets or sets the connection point name
  53592. */
  53593. name: string;
  53594. /**
  53595. * Gets or sets a boolean indicating that this connection point can be omitted
  53596. */
  53597. isOptional: boolean;
  53598. /**
  53599. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53600. */
  53601. define: string;
  53602. /** @hidden */ private _prioritizeVertex: boolean;
  53603. private _target;
  53604. /** Gets or sets the target of that connection point */
  53605. target: NodeMaterialBlockTargets;
  53606. /**
  53607. * Gets a boolean indicating that the current point is connected
  53608. */
  53609. readonly isConnected: boolean;
  53610. /**
  53611. * Gets a boolean indicating that the current point is connected to an input block
  53612. */
  53613. readonly isConnectedToInputBlock: boolean;
  53614. /**
  53615. * Gets a the connected input block (if any)
  53616. */
  53617. readonly connectInputBlock: Nullable<InputBlock>;
  53618. /** Get the other side of the connection (if any) */
  53619. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53620. /** Get the block that owns this connection point */
  53621. readonly ownerBlock: NodeMaterialBlock;
  53622. /** Get the block connected on the other side of this connection (if any) */
  53623. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53624. /** Get the block connected on the endpoints of this connection (if any) */
  53625. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53626. /** Gets the list of connected endpoints */
  53627. readonly endpoints: NodeMaterialConnectionPoint[];
  53628. /** Gets a boolean indicating if that output point is connected to at least one input */
  53629. readonly hasEndpoints: boolean;
  53630. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  53631. readonly isConnectedInVertexShader: boolean;
  53632. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  53633. readonly isConnectedInFragmentShader: boolean;
  53634. /**
  53635. * Creates a new connection point
  53636. * @param name defines the connection point name
  53637. * @param ownerBlock defines the block hosting this connection point
  53638. */
  53639. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53640. /**
  53641. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53642. * @returns the class name
  53643. */
  53644. getClassName(): string;
  53645. /**
  53646. * Gets a boolean indicating if the current point can be connected to another point
  53647. * @param connectionPoint defines the other connection point
  53648. * @returns a boolean
  53649. */
  53650. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53651. /**
  53652. * Gets a number indicating if the current point can be connected to another point
  53653. * @param connectionPoint defines the other connection point
  53654. * @returns a number defining the compatibility state
  53655. */
  53656. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  53657. /**
  53658. * Connect this point to another connection point
  53659. * @param connectionPoint defines the other connection point
  53660. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53661. * @returns the current connection point
  53662. */
  53663. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53664. /**
  53665. * Disconnect this point from one of his endpoint
  53666. * @param endpoint defines the other connection point
  53667. * @returns the current connection point
  53668. */
  53669. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53670. /**
  53671. * Serializes this point in a JSON representation
  53672. * @returns the serialized point object
  53673. */
  53674. serialize(): any;
  53675. /**
  53676. * Release resources
  53677. */
  53678. dispose(): void;
  53679. }
  53680. }
  53681. declare module BABYLON {
  53682. /**
  53683. * Block used to add support for vertex skinning (bones)
  53684. */
  53685. export class BonesBlock extends NodeMaterialBlock {
  53686. /**
  53687. * Creates a new BonesBlock
  53688. * @param name defines the block name
  53689. */
  53690. constructor(name: string);
  53691. /**
  53692. * Initialize the block and prepare the context for build
  53693. * @param state defines the state that will be used for the build
  53694. */
  53695. initialize(state: NodeMaterialBuildState): void;
  53696. /**
  53697. * Gets the current class name
  53698. * @returns the class name
  53699. */
  53700. getClassName(): string;
  53701. /**
  53702. * Gets the matrix indices input component
  53703. */
  53704. readonly matricesIndices: NodeMaterialConnectionPoint;
  53705. /**
  53706. * Gets the matrix weights input component
  53707. */
  53708. readonly matricesWeights: NodeMaterialConnectionPoint;
  53709. /**
  53710. * Gets the extra matrix indices input component
  53711. */
  53712. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53713. /**
  53714. * Gets the extra matrix weights input component
  53715. */
  53716. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53717. /**
  53718. * Gets the world input component
  53719. */
  53720. readonly world: NodeMaterialConnectionPoint;
  53721. /**
  53722. * Gets the output component
  53723. */
  53724. readonly output: NodeMaterialConnectionPoint;
  53725. autoConfigure(material: NodeMaterial): void;
  53726. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53727. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53729. protected _buildBlock(state: NodeMaterialBuildState): this;
  53730. }
  53731. }
  53732. declare module BABYLON {
  53733. /**
  53734. * Block used to add support for instances
  53735. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53736. */
  53737. export class InstancesBlock extends NodeMaterialBlock {
  53738. /**
  53739. * Creates a new InstancesBlock
  53740. * @param name defines the block name
  53741. */
  53742. constructor(name: string);
  53743. /**
  53744. * Gets the current class name
  53745. * @returns the class name
  53746. */
  53747. getClassName(): string;
  53748. /**
  53749. * Gets the first world row input component
  53750. */
  53751. readonly world0: NodeMaterialConnectionPoint;
  53752. /**
  53753. * Gets the second world row input component
  53754. */
  53755. readonly world1: NodeMaterialConnectionPoint;
  53756. /**
  53757. * Gets the third world row input component
  53758. */
  53759. readonly world2: NodeMaterialConnectionPoint;
  53760. /**
  53761. * Gets the forth world row input component
  53762. */
  53763. readonly world3: NodeMaterialConnectionPoint;
  53764. /**
  53765. * Gets the world input component
  53766. */
  53767. readonly world: NodeMaterialConnectionPoint;
  53768. /**
  53769. * Gets the output component
  53770. */
  53771. readonly output: NodeMaterialConnectionPoint;
  53772. autoConfigure(material: NodeMaterial): void;
  53773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53774. protected _buildBlock(state: NodeMaterialBuildState): this;
  53775. }
  53776. }
  53777. declare module BABYLON {
  53778. /**
  53779. * Block used to add morph targets support to vertex shader
  53780. */
  53781. export class MorphTargetsBlock extends NodeMaterialBlock {
  53782. private _repeatableContentAnchor;
  53783. private _repeatebleContentGenerated;
  53784. /**
  53785. * Create a new MorphTargetsBlock
  53786. * @param name defines the block name
  53787. */
  53788. constructor(name: string);
  53789. /**
  53790. * Gets the current class name
  53791. * @returns the class name
  53792. */
  53793. getClassName(): string;
  53794. /**
  53795. * Gets the position input component
  53796. */
  53797. readonly position: NodeMaterialConnectionPoint;
  53798. /**
  53799. * Gets the normal input component
  53800. */
  53801. readonly normal: NodeMaterialConnectionPoint;
  53802. /**
  53803. * Gets the tangent input component
  53804. */
  53805. readonly tangent: NodeMaterialConnectionPoint;
  53806. /**
  53807. * Gets the tangent input component
  53808. */
  53809. readonly uv: NodeMaterialConnectionPoint;
  53810. /**
  53811. * Gets the position output component
  53812. */
  53813. readonly positionOutput: NodeMaterialConnectionPoint;
  53814. /**
  53815. * Gets the normal output component
  53816. */
  53817. readonly normalOutput: NodeMaterialConnectionPoint;
  53818. /**
  53819. * Gets the tangent output component
  53820. */
  53821. readonly tangentOutput: NodeMaterialConnectionPoint;
  53822. /**
  53823. * Gets the tangent output component
  53824. */
  53825. readonly uvOutput: NodeMaterialConnectionPoint;
  53826. initialize(state: NodeMaterialBuildState): void;
  53827. autoConfigure(material: NodeMaterial): void;
  53828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53829. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53830. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53831. protected _buildBlock(state: NodeMaterialBuildState): this;
  53832. }
  53833. }
  53834. declare module BABYLON {
  53835. /**
  53836. * Block used to get data information from a light
  53837. */
  53838. export class LightInformationBlock extends NodeMaterialBlock {
  53839. private _lightDataUniformName;
  53840. private _lightColorUniformName;
  53841. private _lightTypeDefineName;
  53842. /**
  53843. * Gets or sets the light associated with this block
  53844. */
  53845. light: Nullable<Light>;
  53846. /**
  53847. * Creates a new LightInformationBlock
  53848. * @param name defines the block name
  53849. */
  53850. constructor(name: string);
  53851. /**
  53852. * Gets the current class name
  53853. * @returns the class name
  53854. */
  53855. getClassName(): string;
  53856. /**
  53857. * Gets the world position input component
  53858. */
  53859. readonly worldPosition: NodeMaterialConnectionPoint;
  53860. /**
  53861. * Gets the direction output component
  53862. */
  53863. readonly direction: NodeMaterialConnectionPoint;
  53864. /**
  53865. * Gets the direction output component
  53866. */
  53867. readonly color: NodeMaterialConnectionPoint;
  53868. /**
  53869. * Gets the direction output component
  53870. */
  53871. readonly intensity: NodeMaterialConnectionPoint;
  53872. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53874. protected _buildBlock(state: NodeMaterialBuildState): this;
  53875. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53876. }
  53877. }
  53878. declare module BABYLON {
  53879. /**
  53880. * Block used to add image processing support to fragment shader
  53881. */
  53882. export class ImageProcessingBlock extends NodeMaterialBlock {
  53883. /**
  53884. * Create a new ImageProcessingBlock
  53885. * @param name defines the block name
  53886. */
  53887. constructor(name: string);
  53888. /**
  53889. * Gets the current class name
  53890. * @returns the class name
  53891. */
  53892. getClassName(): string;
  53893. /**
  53894. * Gets the color input component
  53895. */
  53896. readonly color: NodeMaterialConnectionPoint;
  53897. /**
  53898. * Gets the output component
  53899. */
  53900. readonly output: NodeMaterialConnectionPoint;
  53901. /**
  53902. * Initialize the block and prepare the context for build
  53903. * @param state defines the state that will be used for the build
  53904. */
  53905. initialize(state: NodeMaterialBuildState): void;
  53906. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53908. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53909. protected _buildBlock(state: NodeMaterialBuildState): this;
  53910. }
  53911. }
  53912. declare module BABYLON {
  53913. /**
  53914. * Block used to pertub normals based on a normal map
  53915. */
  53916. export class PerturbNormalBlock extends NodeMaterialBlock {
  53917. private _tangentSpaceParameterName;
  53918. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53919. invertX: boolean;
  53920. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53921. invertY: boolean;
  53922. /**
  53923. * Create a new PerturbNormalBlock
  53924. * @param name defines the block name
  53925. */
  53926. constructor(name: string);
  53927. /**
  53928. * Gets the current class name
  53929. * @returns the class name
  53930. */
  53931. getClassName(): string;
  53932. /**
  53933. * Gets the world position input component
  53934. */
  53935. readonly worldPosition: NodeMaterialConnectionPoint;
  53936. /**
  53937. * Gets the world normal input component
  53938. */
  53939. readonly worldNormal: NodeMaterialConnectionPoint;
  53940. /**
  53941. * Gets the uv input component
  53942. */
  53943. readonly uv: NodeMaterialConnectionPoint;
  53944. /**
  53945. * Gets the normal map color input component
  53946. */
  53947. readonly normalMapColor: NodeMaterialConnectionPoint;
  53948. /**
  53949. * Gets the strength input component
  53950. */
  53951. readonly strength: NodeMaterialConnectionPoint;
  53952. /**
  53953. * Gets the output component
  53954. */
  53955. readonly output: NodeMaterialConnectionPoint;
  53956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53957. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53958. autoConfigure(material: NodeMaterial): void;
  53959. protected _buildBlock(state: NodeMaterialBuildState): this;
  53960. protected _dumpPropertiesCode(): string;
  53961. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53962. }
  53963. }
  53964. declare module BABYLON {
  53965. /**
  53966. * Block used to discard a pixel if a value is smaller than a cutoff
  53967. */
  53968. export class DiscardBlock extends NodeMaterialBlock {
  53969. /**
  53970. * Create a new DiscardBlock
  53971. * @param name defines the block name
  53972. */
  53973. constructor(name: string);
  53974. /**
  53975. * Gets the current class name
  53976. * @returns the class name
  53977. */
  53978. getClassName(): string;
  53979. /**
  53980. * Gets the color input component
  53981. */
  53982. readonly value: NodeMaterialConnectionPoint;
  53983. /**
  53984. * Gets the cutoff input component
  53985. */
  53986. readonly cutoff: NodeMaterialConnectionPoint;
  53987. protected _buildBlock(state: NodeMaterialBuildState): this;
  53988. }
  53989. }
  53990. declare module BABYLON {
  53991. /**
  53992. * Block used to test if the fragment shader is front facing
  53993. */
  53994. export class FrontFacingBlock extends NodeMaterialBlock {
  53995. /**
  53996. * Creates a new FrontFacingBlock
  53997. * @param name defines the block name
  53998. */
  53999. constructor(name: string);
  54000. /**
  54001. * Gets the current class name
  54002. * @returns the class name
  54003. */
  54004. getClassName(): string;
  54005. /**
  54006. * Gets the output component
  54007. */
  54008. readonly output: NodeMaterialConnectionPoint;
  54009. protected _buildBlock(state: NodeMaterialBuildState): this;
  54010. }
  54011. }
  54012. declare module BABYLON {
  54013. /**
  54014. * Block used to add support for scene fog
  54015. */
  54016. export class FogBlock extends NodeMaterialBlock {
  54017. private _fogDistanceName;
  54018. private _fogParameters;
  54019. /**
  54020. * Create a new FogBlock
  54021. * @param name defines the block name
  54022. */
  54023. constructor(name: string);
  54024. /**
  54025. * Gets the current class name
  54026. * @returns the class name
  54027. */
  54028. getClassName(): string;
  54029. /**
  54030. * Gets the world position input component
  54031. */
  54032. readonly worldPosition: NodeMaterialConnectionPoint;
  54033. /**
  54034. * Gets the view input component
  54035. */
  54036. readonly view: NodeMaterialConnectionPoint;
  54037. /**
  54038. * Gets the color input component
  54039. */
  54040. readonly input: NodeMaterialConnectionPoint;
  54041. /**
  54042. * Gets the fog color input component
  54043. */
  54044. readonly fogColor: NodeMaterialConnectionPoint;
  54045. /**
  54046. * Gets the output component
  54047. */
  54048. readonly output: NodeMaterialConnectionPoint;
  54049. autoConfigure(material: NodeMaterial): void;
  54050. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54051. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54052. protected _buildBlock(state: NodeMaterialBuildState): this;
  54053. }
  54054. }
  54055. declare module BABYLON {
  54056. /**
  54057. * Block used to add light in the fragment shader
  54058. */
  54059. export class LightBlock extends NodeMaterialBlock {
  54060. private _lightId;
  54061. /**
  54062. * Gets or sets the light associated with this block
  54063. */
  54064. light: Nullable<Light>;
  54065. /**
  54066. * Create a new LightBlock
  54067. * @param name defines the block name
  54068. */
  54069. constructor(name: string);
  54070. /**
  54071. * Gets the current class name
  54072. * @returns the class name
  54073. */
  54074. getClassName(): string;
  54075. /**
  54076. * Gets the world position input component
  54077. */
  54078. readonly worldPosition: NodeMaterialConnectionPoint;
  54079. /**
  54080. * Gets the world normal input component
  54081. */
  54082. readonly worldNormal: NodeMaterialConnectionPoint;
  54083. /**
  54084. * Gets the camera (or eye) position component
  54085. */
  54086. readonly cameraPosition: NodeMaterialConnectionPoint;
  54087. /**
  54088. * Gets the glossiness component
  54089. */
  54090. readonly glossiness: NodeMaterialConnectionPoint;
  54091. /**
  54092. * Gets the glossinness power component
  54093. */
  54094. readonly glossPower: NodeMaterialConnectionPoint;
  54095. /**
  54096. * Gets the diffuse color component
  54097. */
  54098. readonly diffuseColor: NodeMaterialConnectionPoint;
  54099. /**
  54100. * Gets the specular color component
  54101. */
  54102. readonly specularColor: NodeMaterialConnectionPoint;
  54103. /**
  54104. * Gets the diffuse output component
  54105. */
  54106. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54107. /**
  54108. * Gets the specular output component
  54109. */
  54110. readonly specularOutput: NodeMaterialConnectionPoint;
  54111. autoConfigure(material: NodeMaterial): void;
  54112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54113. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54115. private _injectVertexCode;
  54116. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54117. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54118. }
  54119. }
  54120. declare module BABYLON {
  54121. /**
  54122. * Block used to multiply 2 values
  54123. */
  54124. export class MultiplyBlock extends NodeMaterialBlock {
  54125. /**
  54126. * Creates a new MultiplyBlock
  54127. * @param name defines the block name
  54128. */
  54129. constructor(name: string);
  54130. /**
  54131. * Gets the current class name
  54132. * @returns the class name
  54133. */
  54134. getClassName(): string;
  54135. /**
  54136. * Gets the left operand input component
  54137. */
  54138. readonly left: NodeMaterialConnectionPoint;
  54139. /**
  54140. * Gets the right operand input component
  54141. */
  54142. readonly right: NodeMaterialConnectionPoint;
  54143. /**
  54144. * Gets the output component
  54145. */
  54146. readonly output: NodeMaterialConnectionPoint;
  54147. protected _buildBlock(state: NodeMaterialBuildState): this;
  54148. }
  54149. }
  54150. declare module BABYLON {
  54151. /**
  54152. * Block used to add 2 vectors
  54153. */
  54154. export class AddBlock extends NodeMaterialBlock {
  54155. /**
  54156. * Creates a new AddBlock
  54157. * @param name defines the block name
  54158. */
  54159. constructor(name: string);
  54160. /**
  54161. * Gets the current class name
  54162. * @returns the class name
  54163. */
  54164. getClassName(): string;
  54165. /**
  54166. * Gets the left operand input component
  54167. */
  54168. readonly left: NodeMaterialConnectionPoint;
  54169. /**
  54170. * Gets the right operand input component
  54171. */
  54172. readonly right: NodeMaterialConnectionPoint;
  54173. /**
  54174. * Gets the output component
  54175. */
  54176. readonly output: NodeMaterialConnectionPoint;
  54177. protected _buildBlock(state: NodeMaterialBuildState): this;
  54178. }
  54179. }
  54180. declare module BABYLON {
  54181. /**
  54182. * Block used to scale a vector by a float
  54183. */
  54184. export class ScaleBlock extends NodeMaterialBlock {
  54185. /**
  54186. * Creates a new ScaleBlock
  54187. * @param name defines the block name
  54188. */
  54189. constructor(name: string);
  54190. /**
  54191. * Gets the current class name
  54192. * @returns the class name
  54193. */
  54194. getClassName(): string;
  54195. /**
  54196. * Gets the input component
  54197. */
  54198. readonly input: NodeMaterialConnectionPoint;
  54199. /**
  54200. * Gets the factor input component
  54201. */
  54202. readonly factor: NodeMaterialConnectionPoint;
  54203. /**
  54204. * Gets the output component
  54205. */
  54206. readonly output: NodeMaterialConnectionPoint;
  54207. protected _buildBlock(state: NodeMaterialBuildState): this;
  54208. }
  54209. }
  54210. declare module BABYLON {
  54211. /**
  54212. * Block used to clamp a float
  54213. */
  54214. export class ClampBlock extends NodeMaterialBlock {
  54215. /** Gets or sets the minimum range */
  54216. minimum: number;
  54217. /** Gets or sets the maximum range */
  54218. maximum: number;
  54219. /**
  54220. * Creates a new ClampBlock
  54221. * @param name defines the block name
  54222. */
  54223. constructor(name: string);
  54224. /**
  54225. * Gets the current class name
  54226. * @returns the class name
  54227. */
  54228. getClassName(): string;
  54229. /**
  54230. * Gets the value input component
  54231. */
  54232. readonly value: NodeMaterialConnectionPoint;
  54233. /**
  54234. * Gets the output component
  54235. */
  54236. readonly output: NodeMaterialConnectionPoint;
  54237. protected _buildBlock(state: NodeMaterialBuildState): this;
  54238. protected _dumpPropertiesCode(): string;
  54239. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54240. }
  54241. }
  54242. declare module BABYLON {
  54243. /**
  54244. * Block used to apply a cross product between 2 vectors
  54245. */
  54246. export class CrossBlock extends NodeMaterialBlock {
  54247. /**
  54248. * Creates a new CrossBlock
  54249. * @param name defines the block name
  54250. */
  54251. constructor(name: string);
  54252. /**
  54253. * Gets the current class name
  54254. * @returns the class name
  54255. */
  54256. getClassName(): string;
  54257. /**
  54258. * Gets the left operand input component
  54259. */
  54260. readonly left: NodeMaterialConnectionPoint;
  54261. /**
  54262. * Gets the right operand input component
  54263. */
  54264. readonly right: NodeMaterialConnectionPoint;
  54265. /**
  54266. * Gets the output component
  54267. */
  54268. readonly output: NodeMaterialConnectionPoint;
  54269. protected _buildBlock(state: NodeMaterialBuildState): this;
  54270. }
  54271. }
  54272. declare module BABYLON {
  54273. /**
  54274. * Block used to apply a dot product between 2 vectors
  54275. */
  54276. export class DotBlock extends NodeMaterialBlock {
  54277. /**
  54278. * Creates a new DotBlock
  54279. * @param name defines the block name
  54280. */
  54281. constructor(name: string);
  54282. /**
  54283. * Gets the current class name
  54284. * @returns the class name
  54285. */
  54286. getClassName(): string;
  54287. /**
  54288. * Gets the left operand input component
  54289. */
  54290. readonly left: NodeMaterialConnectionPoint;
  54291. /**
  54292. * Gets the right operand input component
  54293. */
  54294. readonly right: NodeMaterialConnectionPoint;
  54295. /**
  54296. * Gets the output component
  54297. */
  54298. readonly output: NodeMaterialConnectionPoint;
  54299. protected _buildBlock(state: NodeMaterialBuildState): this;
  54300. }
  54301. }
  54302. declare module BABYLON {
  54303. /**
  54304. * Block used to remap a float from a range to a new one
  54305. */
  54306. export class RemapBlock extends NodeMaterialBlock {
  54307. /**
  54308. * Gets or sets the source range
  54309. */
  54310. sourceRange: Vector2;
  54311. /**
  54312. * Gets or sets the target range
  54313. */
  54314. targetRange: Vector2;
  54315. /**
  54316. * Creates a new RemapBlock
  54317. * @param name defines the block name
  54318. */
  54319. constructor(name: string);
  54320. /**
  54321. * Gets the current class name
  54322. * @returns the class name
  54323. */
  54324. getClassName(): string;
  54325. /**
  54326. * Gets the input component
  54327. */
  54328. readonly input: NodeMaterialConnectionPoint;
  54329. /**
  54330. * Gets the source min input component
  54331. */
  54332. readonly sourceMin: NodeMaterialConnectionPoint;
  54333. /**
  54334. * Gets the source max input component
  54335. */
  54336. readonly sourceMax: NodeMaterialConnectionPoint;
  54337. /**
  54338. * Gets the target min input component
  54339. */
  54340. readonly targetMin: NodeMaterialConnectionPoint;
  54341. /**
  54342. * Gets the target max input component
  54343. */
  54344. readonly targetMax: NodeMaterialConnectionPoint;
  54345. /**
  54346. * Gets the output component
  54347. */
  54348. readonly output: NodeMaterialConnectionPoint;
  54349. protected _buildBlock(state: NodeMaterialBuildState): this;
  54350. protected _dumpPropertiesCode(): string;
  54351. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54352. }
  54353. }
  54354. declare module BABYLON {
  54355. /**
  54356. * Block used to normalize a vector
  54357. */
  54358. export class NormalizeBlock extends NodeMaterialBlock {
  54359. /**
  54360. * Creates a new NormalizeBlock
  54361. * @param name defines the block name
  54362. */
  54363. constructor(name: string);
  54364. /**
  54365. * Gets the current class name
  54366. * @returns the class name
  54367. */
  54368. getClassName(): string;
  54369. /**
  54370. * Gets the input component
  54371. */
  54372. readonly input: NodeMaterialConnectionPoint;
  54373. /**
  54374. * Gets the output component
  54375. */
  54376. readonly output: NodeMaterialConnectionPoint;
  54377. protected _buildBlock(state: NodeMaterialBuildState): this;
  54378. }
  54379. }
  54380. declare module BABYLON {
  54381. /**
  54382. * Operations supported by the Trigonometry block
  54383. */
  54384. export enum TrigonometryBlockOperations {
  54385. /** Cos */
  54386. Cos = 0,
  54387. /** Sin */
  54388. Sin = 1,
  54389. /** Abs */
  54390. Abs = 2,
  54391. /** Exp */
  54392. Exp = 3,
  54393. /** Exp2 */
  54394. Exp2 = 4,
  54395. /** Round */
  54396. Round = 5,
  54397. /** Floor */
  54398. Floor = 6,
  54399. /** Ceiling */
  54400. Ceiling = 7,
  54401. /** Square root */
  54402. Sqrt = 8,
  54403. /** Log */
  54404. Log = 9,
  54405. /** Tangent */
  54406. Tan = 10,
  54407. /** Arc tangent */
  54408. ArcTan = 11,
  54409. /** Arc cosinus */
  54410. ArcCos = 12,
  54411. /** Arc sinus */
  54412. ArcSin = 13,
  54413. /** Fraction */
  54414. Fract = 14,
  54415. /** Sign */
  54416. Sign = 15,
  54417. /** To radians (from degrees) */
  54418. Radians = 16,
  54419. /** To degrees (from radians) */
  54420. Degrees = 17
  54421. }
  54422. /**
  54423. * Block used to apply trigonometry operation to floats
  54424. */
  54425. export class TrigonometryBlock extends NodeMaterialBlock {
  54426. /**
  54427. * Gets or sets the operation applied by the block
  54428. */
  54429. operation: TrigonometryBlockOperations;
  54430. /**
  54431. * Creates a new TrigonometryBlock
  54432. * @param name defines the block name
  54433. */
  54434. constructor(name: string);
  54435. /**
  54436. * Gets the current class name
  54437. * @returns the class name
  54438. */
  54439. getClassName(): string;
  54440. /**
  54441. * Gets the input component
  54442. */
  54443. readonly input: NodeMaterialConnectionPoint;
  54444. /**
  54445. * Gets the output component
  54446. */
  54447. readonly output: NodeMaterialConnectionPoint;
  54448. protected _buildBlock(state: NodeMaterialBuildState): this;
  54449. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54450. }
  54451. }
  54452. declare module BABYLON {
  54453. /**
  54454. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54455. */
  54456. export class ColorMergerBlock extends NodeMaterialBlock {
  54457. /**
  54458. * Create a new ColorMergerBlock
  54459. * @param name defines the block name
  54460. */
  54461. constructor(name: string);
  54462. /**
  54463. * Gets the current class name
  54464. * @returns the class name
  54465. */
  54466. getClassName(): string;
  54467. /**
  54468. * Gets the r component (input)
  54469. */
  54470. readonly r: NodeMaterialConnectionPoint;
  54471. /**
  54472. * Gets the g component (input)
  54473. */
  54474. readonly g: NodeMaterialConnectionPoint;
  54475. /**
  54476. * Gets the b component (input)
  54477. */
  54478. readonly b: NodeMaterialConnectionPoint;
  54479. /**
  54480. * Gets the a component (input)
  54481. */
  54482. readonly a: NodeMaterialConnectionPoint;
  54483. /**
  54484. * Gets the rgba component (output)
  54485. */
  54486. readonly rgba: NodeMaterialConnectionPoint;
  54487. /**
  54488. * Gets the rgb component (output)
  54489. */
  54490. readonly rgb: NodeMaterialConnectionPoint;
  54491. protected _buildBlock(state: NodeMaterialBuildState): this;
  54492. }
  54493. }
  54494. declare module BABYLON {
  54495. /**
  54496. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54497. */
  54498. export class VectorMergerBlock extends NodeMaterialBlock {
  54499. /**
  54500. * Create a new VectorMergerBlock
  54501. * @param name defines the block name
  54502. */
  54503. constructor(name: string);
  54504. /**
  54505. * Gets the current class name
  54506. * @returns the class name
  54507. */
  54508. getClassName(): string;
  54509. /**
  54510. * Gets the x component (input)
  54511. */
  54512. readonly x: NodeMaterialConnectionPoint;
  54513. /**
  54514. * Gets the y component (input)
  54515. */
  54516. readonly y: NodeMaterialConnectionPoint;
  54517. /**
  54518. * Gets the z component (input)
  54519. */
  54520. readonly z: NodeMaterialConnectionPoint;
  54521. /**
  54522. * Gets the w component (input)
  54523. */
  54524. readonly w: NodeMaterialConnectionPoint;
  54525. /**
  54526. * Gets the xyzw component (output)
  54527. */
  54528. readonly xyzw: NodeMaterialConnectionPoint;
  54529. /**
  54530. * Gets the xyz component (output)
  54531. */
  54532. readonly xyz: NodeMaterialConnectionPoint;
  54533. /**
  54534. * Gets the xy component (output)
  54535. */
  54536. readonly xy: NodeMaterialConnectionPoint;
  54537. protected _buildBlock(state: NodeMaterialBuildState): this;
  54538. }
  54539. }
  54540. declare module BABYLON {
  54541. /**
  54542. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54543. */
  54544. export class ColorSplitterBlock extends NodeMaterialBlock {
  54545. /**
  54546. * Create a new ColorSplitterBlock
  54547. * @param name defines the block name
  54548. */
  54549. constructor(name: string);
  54550. /**
  54551. * Gets the current class name
  54552. * @returns the class name
  54553. */
  54554. getClassName(): string;
  54555. /**
  54556. * Gets the rgba component (input)
  54557. */
  54558. readonly rgba: NodeMaterialConnectionPoint;
  54559. /**
  54560. * Gets the rgb component (input)
  54561. */
  54562. readonly rgbIn: NodeMaterialConnectionPoint;
  54563. /**
  54564. * Gets the rgb component (output)
  54565. */
  54566. readonly rgbOut: NodeMaterialConnectionPoint;
  54567. /**
  54568. * Gets the r component (output)
  54569. */
  54570. readonly r: NodeMaterialConnectionPoint;
  54571. /**
  54572. * Gets the g component (output)
  54573. */
  54574. readonly g: NodeMaterialConnectionPoint;
  54575. /**
  54576. * Gets the b component (output)
  54577. */
  54578. readonly b: NodeMaterialConnectionPoint;
  54579. /**
  54580. * Gets the a component (output)
  54581. */
  54582. readonly a: NodeMaterialConnectionPoint;
  54583. protected _inputRename(name: string): string;
  54584. protected _outputRename(name: string): string;
  54585. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54586. }
  54587. }
  54588. declare module BABYLON {
  54589. /**
  54590. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54591. */
  54592. export class VectorSplitterBlock extends NodeMaterialBlock {
  54593. /**
  54594. * Create a new VectorSplitterBlock
  54595. * @param name defines the block name
  54596. */
  54597. constructor(name: string);
  54598. /**
  54599. * Gets the current class name
  54600. * @returns the class name
  54601. */
  54602. getClassName(): string;
  54603. /**
  54604. * Gets the xyzw component (input)
  54605. */
  54606. readonly xyzw: NodeMaterialConnectionPoint;
  54607. /**
  54608. * Gets the xyz component (input)
  54609. */
  54610. readonly xyzIn: NodeMaterialConnectionPoint;
  54611. /**
  54612. * Gets the xy component (input)
  54613. */
  54614. readonly xyIn: NodeMaterialConnectionPoint;
  54615. /**
  54616. * Gets the xyz component (output)
  54617. */
  54618. readonly xyzOut: NodeMaterialConnectionPoint;
  54619. /**
  54620. * Gets the xy component (output)
  54621. */
  54622. readonly xyOut: NodeMaterialConnectionPoint;
  54623. /**
  54624. * Gets the x component (output)
  54625. */
  54626. readonly x: NodeMaterialConnectionPoint;
  54627. /**
  54628. * Gets the y component (output)
  54629. */
  54630. readonly y: NodeMaterialConnectionPoint;
  54631. /**
  54632. * Gets the z component (output)
  54633. */
  54634. readonly z: NodeMaterialConnectionPoint;
  54635. /**
  54636. * Gets the w component (output)
  54637. */
  54638. readonly w: NodeMaterialConnectionPoint;
  54639. protected _inputRename(name: string): string;
  54640. protected _outputRename(name: string): string;
  54641. protected _buildBlock(state: NodeMaterialBuildState): this;
  54642. }
  54643. }
  54644. declare module BABYLON {
  54645. /**
  54646. * Block used to lerp between 2 values
  54647. */
  54648. export class LerpBlock extends NodeMaterialBlock {
  54649. /**
  54650. * Creates a new LerpBlock
  54651. * @param name defines the block name
  54652. */
  54653. constructor(name: string);
  54654. /**
  54655. * Gets the current class name
  54656. * @returns the class name
  54657. */
  54658. getClassName(): string;
  54659. /**
  54660. * Gets the left operand input component
  54661. */
  54662. readonly left: NodeMaterialConnectionPoint;
  54663. /**
  54664. * Gets the right operand input component
  54665. */
  54666. readonly right: NodeMaterialConnectionPoint;
  54667. /**
  54668. * Gets the gradient operand input component
  54669. */
  54670. readonly gradient: NodeMaterialConnectionPoint;
  54671. /**
  54672. * Gets the output component
  54673. */
  54674. readonly output: NodeMaterialConnectionPoint;
  54675. protected _buildBlock(state: NodeMaterialBuildState): this;
  54676. }
  54677. }
  54678. declare module BABYLON {
  54679. /**
  54680. * Block used to divide 2 vectors
  54681. */
  54682. export class DivideBlock extends NodeMaterialBlock {
  54683. /**
  54684. * Creates a new DivideBlock
  54685. * @param name defines the block name
  54686. */
  54687. constructor(name: string);
  54688. /**
  54689. * Gets the current class name
  54690. * @returns the class name
  54691. */
  54692. getClassName(): string;
  54693. /**
  54694. * Gets the left operand input component
  54695. */
  54696. readonly left: NodeMaterialConnectionPoint;
  54697. /**
  54698. * Gets the right operand input component
  54699. */
  54700. readonly right: NodeMaterialConnectionPoint;
  54701. /**
  54702. * Gets the output component
  54703. */
  54704. readonly output: NodeMaterialConnectionPoint;
  54705. protected _buildBlock(state: NodeMaterialBuildState): this;
  54706. }
  54707. }
  54708. declare module BABYLON {
  54709. /**
  54710. * Block used to subtract 2 vectors
  54711. */
  54712. export class SubtractBlock extends NodeMaterialBlock {
  54713. /**
  54714. * Creates a new SubtractBlock
  54715. * @param name defines the block name
  54716. */
  54717. constructor(name: string);
  54718. /**
  54719. * Gets the current class name
  54720. * @returns the class name
  54721. */
  54722. getClassName(): string;
  54723. /**
  54724. * Gets the left operand input component
  54725. */
  54726. readonly left: NodeMaterialConnectionPoint;
  54727. /**
  54728. * Gets the right operand input component
  54729. */
  54730. readonly right: NodeMaterialConnectionPoint;
  54731. /**
  54732. * Gets the output component
  54733. */
  54734. readonly output: NodeMaterialConnectionPoint;
  54735. protected _buildBlock(state: NodeMaterialBuildState): this;
  54736. }
  54737. }
  54738. declare module BABYLON {
  54739. /**
  54740. * Block used to step a value
  54741. */
  54742. export class StepBlock extends NodeMaterialBlock {
  54743. /**
  54744. * Creates a new StepBlock
  54745. * @param name defines the block name
  54746. */
  54747. constructor(name: string);
  54748. /**
  54749. * Gets the current class name
  54750. * @returns the class name
  54751. */
  54752. getClassName(): string;
  54753. /**
  54754. * Gets the value operand input component
  54755. */
  54756. readonly value: NodeMaterialConnectionPoint;
  54757. /**
  54758. * Gets the edge operand input component
  54759. */
  54760. readonly edge: NodeMaterialConnectionPoint;
  54761. /**
  54762. * Gets the output component
  54763. */
  54764. readonly output: NodeMaterialConnectionPoint;
  54765. protected _buildBlock(state: NodeMaterialBuildState): this;
  54766. }
  54767. }
  54768. declare module BABYLON {
  54769. /**
  54770. * Block used to get the opposite (1 - x) of a value
  54771. */
  54772. export class OneMinusBlock extends NodeMaterialBlock {
  54773. /**
  54774. * Creates a new OneMinusBlock
  54775. * @param name defines the block name
  54776. */
  54777. constructor(name: string);
  54778. /**
  54779. * Gets the current class name
  54780. * @returns the class name
  54781. */
  54782. getClassName(): string;
  54783. /**
  54784. * Gets the input component
  54785. */
  54786. readonly input: NodeMaterialConnectionPoint;
  54787. /**
  54788. * Gets the output component
  54789. */
  54790. readonly output: NodeMaterialConnectionPoint;
  54791. protected _buildBlock(state: NodeMaterialBuildState): this;
  54792. }
  54793. }
  54794. declare module BABYLON {
  54795. /**
  54796. * Block used to get the view direction
  54797. */
  54798. export class ViewDirectionBlock extends NodeMaterialBlock {
  54799. /**
  54800. * Creates a new ViewDirectionBlock
  54801. * @param name defines the block name
  54802. */
  54803. constructor(name: string);
  54804. /**
  54805. * Gets the current class name
  54806. * @returns the class name
  54807. */
  54808. getClassName(): string;
  54809. /**
  54810. * Gets the world position component
  54811. */
  54812. readonly worldPosition: NodeMaterialConnectionPoint;
  54813. /**
  54814. * Gets the camera position component
  54815. */
  54816. readonly cameraPosition: NodeMaterialConnectionPoint;
  54817. /**
  54818. * Gets the output component
  54819. */
  54820. readonly output: NodeMaterialConnectionPoint;
  54821. autoConfigure(material: NodeMaterial): void;
  54822. protected _buildBlock(state: NodeMaterialBuildState): this;
  54823. }
  54824. }
  54825. declare module BABYLON {
  54826. /**
  54827. * Block used to compute fresnel value
  54828. */
  54829. export class FresnelBlock extends NodeMaterialBlock {
  54830. /**
  54831. * Create a new FresnelBlock
  54832. * @param name defines the block name
  54833. */
  54834. constructor(name: string);
  54835. /**
  54836. * Gets the current class name
  54837. * @returns the class name
  54838. */
  54839. getClassName(): string;
  54840. /**
  54841. * Gets the world normal input component
  54842. */
  54843. readonly worldNormal: NodeMaterialConnectionPoint;
  54844. /**
  54845. * Gets the view direction input component
  54846. */
  54847. readonly viewDirection: NodeMaterialConnectionPoint;
  54848. /**
  54849. * Gets the bias input component
  54850. */
  54851. readonly bias: NodeMaterialConnectionPoint;
  54852. /**
  54853. * Gets the camera (or eye) position component
  54854. */
  54855. readonly power: NodeMaterialConnectionPoint;
  54856. /**
  54857. * Gets the fresnel output component
  54858. */
  54859. readonly fresnel: NodeMaterialConnectionPoint;
  54860. autoConfigure(material: NodeMaterial): void;
  54861. protected _buildBlock(state: NodeMaterialBuildState): this;
  54862. }
  54863. }
  54864. declare module BABYLON {
  54865. /**
  54866. * Block used to get the max of 2 values
  54867. */
  54868. export class MaxBlock extends NodeMaterialBlock {
  54869. /**
  54870. * Creates a new MaxBlock
  54871. * @param name defines the block name
  54872. */
  54873. constructor(name: string);
  54874. /**
  54875. * Gets the current class name
  54876. * @returns the class name
  54877. */
  54878. getClassName(): string;
  54879. /**
  54880. * Gets the left operand input component
  54881. */
  54882. readonly left: NodeMaterialConnectionPoint;
  54883. /**
  54884. * Gets the right operand input component
  54885. */
  54886. readonly right: NodeMaterialConnectionPoint;
  54887. /**
  54888. * Gets the output component
  54889. */
  54890. readonly output: NodeMaterialConnectionPoint;
  54891. protected _buildBlock(state: NodeMaterialBuildState): this;
  54892. }
  54893. }
  54894. declare module BABYLON {
  54895. /**
  54896. * Block used to get the min of 2 values
  54897. */
  54898. export class MinBlock extends NodeMaterialBlock {
  54899. /**
  54900. * Creates a new MinBlock
  54901. * @param name defines the block name
  54902. */
  54903. constructor(name: string);
  54904. /**
  54905. * Gets the current class name
  54906. * @returns the class name
  54907. */
  54908. getClassName(): string;
  54909. /**
  54910. * Gets the left operand input component
  54911. */
  54912. readonly left: NodeMaterialConnectionPoint;
  54913. /**
  54914. * Gets the right operand input component
  54915. */
  54916. readonly right: NodeMaterialConnectionPoint;
  54917. /**
  54918. * Gets the output component
  54919. */
  54920. readonly output: NodeMaterialConnectionPoint;
  54921. protected _buildBlock(state: NodeMaterialBuildState): this;
  54922. }
  54923. }
  54924. declare module BABYLON {
  54925. /**
  54926. * Block used to get the distance between 2 values
  54927. */
  54928. export class DistanceBlock extends NodeMaterialBlock {
  54929. /**
  54930. * Creates a new DistanceBlock
  54931. * @param name defines the block name
  54932. */
  54933. constructor(name: string);
  54934. /**
  54935. * Gets the current class name
  54936. * @returns the class name
  54937. */
  54938. getClassName(): string;
  54939. /**
  54940. * Gets the left operand input component
  54941. */
  54942. readonly left: NodeMaterialConnectionPoint;
  54943. /**
  54944. * Gets the right operand input component
  54945. */
  54946. readonly right: NodeMaterialConnectionPoint;
  54947. /**
  54948. * Gets the output component
  54949. */
  54950. readonly output: NodeMaterialConnectionPoint;
  54951. protected _buildBlock(state: NodeMaterialBuildState): this;
  54952. }
  54953. }
  54954. declare module BABYLON {
  54955. /**
  54956. * Block used to get the length of a vector
  54957. */
  54958. export class LengthBlock extends NodeMaterialBlock {
  54959. /**
  54960. * Creates a new LengthBlock
  54961. * @param name defines the block name
  54962. */
  54963. constructor(name: string);
  54964. /**
  54965. * Gets the current class name
  54966. * @returns the class name
  54967. */
  54968. getClassName(): string;
  54969. /**
  54970. * Gets the value input component
  54971. */
  54972. readonly value: NodeMaterialConnectionPoint;
  54973. /**
  54974. * Gets the output component
  54975. */
  54976. readonly output: NodeMaterialConnectionPoint;
  54977. protected _buildBlock(state: NodeMaterialBuildState): this;
  54978. }
  54979. }
  54980. declare module BABYLON {
  54981. /**
  54982. * Block used to get negative version of a value (i.e. x * -1)
  54983. */
  54984. export class NegateBlock extends NodeMaterialBlock {
  54985. /**
  54986. * Creates a new NegateBlock
  54987. * @param name defines the block name
  54988. */
  54989. constructor(name: string);
  54990. /**
  54991. * Gets the current class name
  54992. * @returns the class name
  54993. */
  54994. getClassName(): string;
  54995. /**
  54996. * Gets the value input component
  54997. */
  54998. readonly value: NodeMaterialConnectionPoint;
  54999. /**
  55000. * Gets the output component
  55001. */
  55002. readonly output: NodeMaterialConnectionPoint;
  55003. protected _buildBlock(state: NodeMaterialBuildState): this;
  55004. }
  55005. }
  55006. declare module BABYLON {
  55007. /**
  55008. * Block used to get the value of the first parameter raised to the power of the second
  55009. */
  55010. export class PowBlock extends NodeMaterialBlock {
  55011. /**
  55012. * Creates a new PowBlock
  55013. * @param name defines the block name
  55014. */
  55015. constructor(name: string);
  55016. /**
  55017. * Gets the current class name
  55018. * @returns the class name
  55019. */
  55020. getClassName(): string;
  55021. /**
  55022. * Gets the value operand input component
  55023. */
  55024. readonly value: NodeMaterialConnectionPoint;
  55025. /**
  55026. * Gets the power operand input component
  55027. */
  55028. readonly power: NodeMaterialConnectionPoint;
  55029. /**
  55030. * Gets the output component
  55031. */
  55032. readonly output: NodeMaterialConnectionPoint;
  55033. protected _buildBlock(state: NodeMaterialBuildState): this;
  55034. }
  55035. }
  55036. declare module BABYLON {
  55037. /**
  55038. * Block used to get a random number
  55039. */
  55040. export class RandomNumberBlock extends NodeMaterialBlock {
  55041. /**
  55042. * Creates a new RandomNumberBlock
  55043. * @param name defines the block name
  55044. */
  55045. constructor(name: string);
  55046. /**
  55047. * Gets the current class name
  55048. * @returns the class name
  55049. */
  55050. getClassName(): string;
  55051. /**
  55052. * Gets the seed input component
  55053. */
  55054. readonly seed: NodeMaterialConnectionPoint;
  55055. /**
  55056. * Gets the output component
  55057. */
  55058. readonly output: NodeMaterialConnectionPoint;
  55059. protected _buildBlock(state: NodeMaterialBuildState): this;
  55060. }
  55061. }
  55062. declare module BABYLON {
  55063. /**
  55064. * Block used to compute arc tangent of 2 values
  55065. */
  55066. export class ArcTan2Block extends NodeMaterialBlock {
  55067. /**
  55068. * Creates a new ArcTan2Block
  55069. * @param name defines the block name
  55070. */
  55071. constructor(name: string);
  55072. /**
  55073. * Gets the current class name
  55074. * @returns the class name
  55075. */
  55076. getClassName(): string;
  55077. /**
  55078. * Gets the x operand input component
  55079. */
  55080. readonly x: NodeMaterialConnectionPoint;
  55081. /**
  55082. * Gets the y operand input component
  55083. */
  55084. readonly y: NodeMaterialConnectionPoint;
  55085. /**
  55086. * Gets the output component
  55087. */
  55088. readonly output: NodeMaterialConnectionPoint;
  55089. protected _buildBlock(state: NodeMaterialBuildState): this;
  55090. }
  55091. }
  55092. declare module BABYLON {
  55093. /**
  55094. * Block used to smooth step a value
  55095. */
  55096. export class SmoothStepBlock extends NodeMaterialBlock {
  55097. /**
  55098. * Creates a new SmoothStepBlock
  55099. * @param name defines the block name
  55100. */
  55101. constructor(name: string);
  55102. /**
  55103. * Gets the current class name
  55104. * @returns the class name
  55105. */
  55106. getClassName(): string;
  55107. /**
  55108. * Gets the value operand input component
  55109. */
  55110. readonly value: NodeMaterialConnectionPoint;
  55111. /**
  55112. * Gets the first edge operand input component
  55113. */
  55114. readonly edge0: NodeMaterialConnectionPoint;
  55115. /**
  55116. * Gets the second edge operand input component
  55117. */
  55118. readonly edge1: NodeMaterialConnectionPoint;
  55119. /**
  55120. * Gets the output component
  55121. */
  55122. readonly output: NodeMaterialConnectionPoint;
  55123. protected _buildBlock(state: NodeMaterialBuildState): this;
  55124. }
  55125. }
  55126. declare module BABYLON {
  55127. /**
  55128. * Block used to get the reciprocal (1 / x) of a value
  55129. */
  55130. export class ReciprocalBlock extends NodeMaterialBlock {
  55131. /**
  55132. * Creates a new ReciprocalBlock
  55133. * @param name defines the block name
  55134. */
  55135. constructor(name: string);
  55136. /**
  55137. * Gets the current class name
  55138. * @returns the class name
  55139. */
  55140. getClassName(): string;
  55141. /**
  55142. * Gets the input component
  55143. */
  55144. readonly input: NodeMaterialConnectionPoint;
  55145. /**
  55146. * Gets the output component
  55147. */
  55148. readonly output: NodeMaterialConnectionPoint;
  55149. protected _buildBlock(state: NodeMaterialBuildState): this;
  55150. }
  55151. }
  55152. declare module BABYLON {
  55153. /**
  55154. * Block used to replace a color by another one
  55155. */
  55156. export class ReplaceColorBlock extends NodeMaterialBlock {
  55157. /**
  55158. * Creates a new ReplaceColorBlock
  55159. * @param name defines the block name
  55160. */
  55161. constructor(name: string);
  55162. /**
  55163. * Gets the current class name
  55164. * @returns the class name
  55165. */
  55166. getClassName(): string;
  55167. /**
  55168. * Gets the value input component
  55169. */
  55170. readonly value: NodeMaterialConnectionPoint;
  55171. /**
  55172. * Gets the reference input component
  55173. */
  55174. readonly reference: NodeMaterialConnectionPoint;
  55175. /**
  55176. * Gets the distance input component
  55177. */
  55178. readonly distance: NodeMaterialConnectionPoint;
  55179. /**
  55180. * Gets the replacement input component
  55181. */
  55182. readonly replacement: NodeMaterialConnectionPoint;
  55183. /**
  55184. * Gets the output component
  55185. */
  55186. readonly output: NodeMaterialConnectionPoint;
  55187. protected _buildBlock(state: NodeMaterialBuildState): this;
  55188. }
  55189. }
  55190. declare module BABYLON {
  55191. /**
  55192. * Block used to posterize a value
  55193. * @see https://en.wikipedia.org/wiki/Posterization
  55194. */
  55195. export class PosterizeBlock extends NodeMaterialBlock {
  55196. /**
  55197. * Creates a new PosterizeBlock
  55198. * @param name defines the block name
  55199. */
  55200. constructor(name: string);
  55201. /**
  55202. * Gets the current class name
  55203. * @returns the class name
  55204. */
  55205. getClassName(): string;
  55206. /**
  55207. * Gets the value input component
  55208. */
  55209. readonly value: NodeMaterialConnectionPoint;
  55210. /**
  55211. * Gets the steps input component
  55212. */
  55213. readonly steps: NodeMaterialConnectionPoint;
  55214. /**
  55215. * Gets the output component
  55216. */
  55217. readonly output: NodeMaterialConnectionPoint;
  55218. protected _buildBlock(state: NodeMaterialBuildState): this;
  55219. }
  55220. }
  55221. declare module BABYLON {
  55222. /**
  55223. * Operations supported by the Wave block
  55224. */
  55225. export enum WaveBlockKind {
  55226. /** SawTooth */
  55227. SawTooth = 0,
  55228. /** Square */
  55229. Square = 1,
  55230. /** Triangle */
  55231. Triangle = 2
  55232. }
  55233. /**
  55234. * Block used to apply wave operation to floats
  55235. */
  55236. export class WaveBlock extends NodeMaterialBlock {
  55237. /**
  55238. * Gets or sets the kibnd of wave to be applied by the block
  55239. */
  55240. kind: WaveBlockKind;
  55241. /**
  55242. * Creates a new WaveBlock
  55243. * @param name defines the block name
  55244. */
  55245. constructor(name: string);
  55246. /**
  55247. * Gets the current class name
  55248. * @returns the class name
  55249. */
  55250. getClassName(): string;
  55251. /**
  55252. * Gets the input component
  55253. */
  55254. readonly input: NodeMaterialConnectionPoint;
  55255. /**
  55256. * Gets the output component
  55257. */
  55258. readonly output: NodeMaterialConnectionPoint;
  55259. protected _buildBlock(state: NodeMaterialBuildState): this;
  55260. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55261. }
  55262. }
  55263. declare module BABYLON {
  55264. /**
  55265. * Class used to store a color step for the GradientBlock
  55266. */
  55267. export class GradientBlockColorStep {
  55268. /**
  55269. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55270. */
  55271. step: number;
  55272. /**
  55273. * Gets or sets the color associated with this step
  55274. */
  55275. color: Color3;
  55276. /**
  55277. * Creates a new GradientBlockColorStep
  55278. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55279. * @param color defines the color associated with this step
  55280. */
  55281. constructor(
  55282. /**
  55283. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55284. */
  55285. step: number,
  55286. /**
  55287. * Gets or sets the color associated with this step
  55288. */
  55289. color: Color3);
  55290. }
  55291. /**
  55292. * Block used to return a color from a gradient based on an input value between 0 and 1
  55293. */
  55294. export class GradientBlock extends NodeMaterialBlock {
  55295. /**
  55296. * Gets or sets the list of color steps
  55297. */
  55298. colorSteps: GradientBlockColorStep[];
  55299. /**
  55300. * Creates a new GradientBlock
  55301. * @param name defines the block name
  55302. */
  55303. constructor(name: string);
  55304. /**
  55305. * Gets the current class name
  55306. * @returns the class name
  55307. */
  55308. getClassName(): string;
  55309. /**
  55310. * Gets the gradient input component
  55311. */
  55312. readonly gradient: NodeMaterialConnectionPoint;
  55313. /**
  55314. * Gets the output component
  55315. */
  55316. readonly output: NodeMaterialConnectionPoint;
  55317. private _writeColorConstant;
  55318. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55319. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55320. protected _dumpPropertiesCode(): string;
  55321. }
  55322. }
  55323. declare module BABYLON {
  55324. /**
  55325. * Block used to normalize lerp between 2 values
  55326. */
  55327. export class NLerpBlock extends NodeMaterialBlock {
  55328. /**
  55329. * Creates a new NLerpBlock
  55330. * @param name defines the block name
  55331. */
  55332. constructor(name: string);
  55333. /**
  55334. * Gets the current class name
  55335. * @returns the class name
  55336. */
  55337. getClassName(): string;
  55338. /**
  55339. * Gets the left operand input component
  55340. */
  55341. readonly left: NodeMaterialConnectionPoint;
  55342. /**
  55343. * Gets the right operand input component
  55344. */
  55345. readonly right: NodeMaterialConnectionPoint;
  55346. /**
  55347. * Gets the gradient operand input component
  55348. */
  55349. readonly gradient: NodeMaterialConnectionPoint;
  55350. /**
  55351. * Gets the output component
  55352. */
  55353. readonly output: NodeMaterialConnectionPoint;
  55354. protected _buildBlock(state: NodeMaterialBuildState): this;
  55355. }
  55356. }
  55357. declare module BABYLON {
  55358. /**
  55359. * Effect Render Options
  55360. */
  55361. export interface IEffectRendererOptions {
  55362. /**
  55363. * Defines the vertices positions.
  55364. */
  55365. positions?: number[];
  55366. /**
  55367. * Defines the indices.
  55368. */
  55369. indices?: number[];
  55370. }
  55371. /**
  55372. * Helper class to render one or more effects
  55373. */
  55374. export class EffectRenderer {
  55375. private engine;
  55376. private static _DefaultOptions;
  55377. private _vertexBuffers;
  55378. private _indexBuffer;
  55379. private _ringBufferIndex;
  55380. private _ringScreenBuffer;
  55381. private _fullscreenViewport;
  55382. private _getNextFrameBuffer;
  55383. /**
  55384. * Creates an effect renderer
  55385. * @param engine the engine to use for rendering
  55386. * @param options defines the options of the effect renderer
  55387. */
  55388. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  55389. /**
  55390. * Sets the current viewport in normalized coordinates 0-1
  55391. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55392. */
  55393. setViewport(viewport?: Viewport): void;
  55394. /**
  55395. * Binds the embedded attributes buffer to the effect.
  55396. * @param effect Defines the effect to bind the attributes for
  55397. */
  55398. bindBuffers(effect: Effect): void;
  55399. /**
  55400. * Sets the current effect wrapper to use during draw.
  55401. * The effect needs to be ready before calling this api.
  55402. * This also sets the default full screen position attribute.
  55403. * @param effectWrapper Defines the effect to draw with
  55404. */
  55405. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55406. /**
  55407. * Draws a full screen quad.
  55408. */
  55409. draw(): void;
  55410. /**
  55411. * renders one or more effects to a specified texture
  55412. * @param effectWrappers list of effects to renderer
  55413. * @param outputTexture texture to draw to, if null it will render to the screen
  55414. */
  55415. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55416. /**
  55417. * Disposes of the effect renderer
  55418. */
  55419. dispose(): void;
  55420. }
  55421. /**
  55422. * Options to create an EffectWrapper
  55423. */
  55424. interface EffectWrapperCreationOptions {
  55425. /**
  55426. * Engine to use to create the effect
  55427. */
  55428. engine: ThinEngine;
  55429. /**
  55430. * Fragment shader for the effect
  55431. */
  55432. fragmentShader: string;
  55433. /**
  55434. * Vertex shader for the effect
  55435. */
  55436. vertexShader?: string;
  55437. /**
  55438. * Attributes to use in the shader
  55439. */
  55440. attributeNames?: Array<string>;
  55441. /**
  55442. * Uniforms to use in the shader
  55443. */
  55444. uniformNames?: Array<string>;
  55445. /**
  55446. * Texture sampler names to use in the shader
  55447. */
  55448. samplerNames?: Array<string>;
  55449. /**
  55450. * The friendly name of the effect displayed in Spector.
  55451. */
  55452. name?: string;
  55453. }
  55454. /**
  55455. * Wraps an effect to be used for rendering
  55456. */
  55457. export class EffectWrapper {
  55458. /**
  55459. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55460. */
  55461. onApplyObservable: Observable<{}>;
  55462. /**
  55463. * The underlying effect
  55464. */
  55465. effect: Effect;
  55466. /**
  55467. * Creates an effect to be renderer
  55468. * @param creationOptions options to create the effect
  55469. */
  55470. constructor(creationOptions: EffectWrapperCreationOptions);
  55471. /**
  55472. * Disposes of the effect wrapper
  55473. */
  55474. dispose(): void;
  55475. }
  55476. }
  55477. declare module BABYLON {
  55478. /**
  55479. * Helper class to push actions to a pool of workers.
  55480. */
  55481. export class WorkerPool implements IDisposable {
  55482. private _workerInfos;
  55483. private _pendingActions;
  55484. /**
  55485. * Constructor
  55486. * @param workers Array of workers to use for actions
  55487. */
  55488. constructor(workers: Array<Worker>);
  55489. /**
  55490. * Terminates all workers and clears any pending actions.
  55491. */
  55492. dispose(): void;
  55493. /**
  55494. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55495. * pended until a worker has completed its action.
  55496. * @param action The action to perform. Call onComplete when the action is complete.
  55497. */
  55498. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55499. private _execute;
  55500. }
  55501. }
  55502. declare module BABYLON {
  55503. /**
  55504. * Configuration for Draco compression
  55505. */
  55506. export interface IDracoCompressionConfiguration {
  55507. /**
  55508. * Configuration for the decoder.
  55509. */
  55510. decoder: {
  55511. /**
  55512. * The url to the WebAssembly module.
  55513. */
  55514. wasmUrl?: string;
  55515. /**
  55516. * The url to the WebAssembly binary.
  55517. */
  55518. wasmBinaryUrl?: string;
  55519. /**
  55520. * The url to the fallback JavaScript module.
  55521. */
  55522. fallbackUrl?: string;
  55523. };
  55524. }
  55525. /**
  55526. * Draco compression (https://google.github.io/draco/)
  55527. *
  55528. * This class wraps the Draco module.
  55529. *
  55530. * **Encoder**
  55531. *
  55532. * The encoder is not currently implemented.
  55533. *
  55534. * **Decoder**
  55535. *
  55536. * 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.
  55537. *
  55538. * To update the configuration, use the following code:
  55539. * ```javascript
  55540. * DracoCompression.Configuration = {
  55541. * decoder: {
  55542. * wasmUrl: "<url to the WebAssembly library>",
  55543. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55544. * fallbackUrl: "<url to the fallback JavaScript library>",
  55545. * }
  55546. * };
  55547. * ```
  55548. *
  55549. * 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.
  55550. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55551. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55552. *
  55553. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55554. * ```javascript
  55555. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55556. * ```
  55557. *
  55558. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55559. */
  55560. export class DracoCompression implements IDisposable {
  55561. private _workerPoolPromise?;
  55562. private _decoderModulePromise?;
  55563. /**
  55564. * The configuration. Defaults to the following urls:
  55565. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55566. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55567. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55568. */
  55569. static Configuration: IDracoCompressionConfiguration;
  55570. /**
  55571. * Returns true if the decoder configuration is available.
  55572. */
  55573. static readonly DecoderAvailable: boolean;
  55574. /**
  55575. * Default number of workers to create when creating the draco compression object.
  55576. */
  55577. static DefaultNumWorkers: number;
  55578. private static GetDefaultNumWorkers;
  55579. private static _Default;
  55580. /**
  55581. * Default instance for the draco compression object.
  55582. */
  55583. static readonly Default: DracoCompression;
  55584. /**
  55585. * Constructor
  55586. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55587. */
  55588. constructor(numWorkers?: number);
  55589. /**
  55590. * Stop all async operations and release resources.
  55591. */
  55592. dispose(): void;
  55593. /**
  55594. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55595. * @returns a promise that resolves when ready
  55596. */
  55597. whenReadyAsync(): Promise<void>;
  55598. /**
  55599. * Decode Draco compressed mesh data to vertex data.
  55600. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55601. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55602. * @returns A promise that resolves with the decoded vertex data
  55603. */
  55604. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55605. [kind: string]: number;
  55606. }): Promise<VertexData>;
  55607. }
  55608. }
  55609. declare module BABYLON {
  55610. /**
  55611. * Class for building Constructive Solid Geometry
  55612. */
  55613. export class CSG {
  55614. private polygons;
  55615. /**
  55616. * The world matrix
  55617. */
  55618. matrix: Matrix;
  55619. /**
  55620. * Stores the position
  55621. */
  55622. position: Vector3;
  55623. /**
  55624. * Stores the rotation
  55625. */
  55626. rotation: Vector3;
  55627. /**
  55628. * Stores the rotation quaternion
  55629. */
  55630. rotationQuaternion: Nullable<Quaternion>;
  55631. /**
  55632. * Stores the scaling vector
  55633. */
  55634. scaling: Vector3;
  55635. /**
  55636. * Convert the Mesh to CSG
  55637. * @param mesh The Mesh to convert to CSG
  55638. * @returns A new CSG from the Mesh
  55639. */
  55640. static FromMesh(mesh: Mesh): CSG;
  55641. /**
  55642. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55643. * @param polygons Polygons used to construct a CSG solid
  55644. */
  55645. private static FromPolygons;
  55646. /**
  55647. * Clones, or makes a deep copy, of the CSG
  55648. * @returns A new CSG
  55649. */
  55650. clone(): CSG;
  55651. /**
  55652. * Unions this CSG with another CSG
  55653. * @param csg The CSG to union against this CSG
  55654. * @returns The unioned CSG
  55655. */
  55656. union(csg: CSG): CSG;
  55657. /**
  55658. * Unions this CSG with another CSG in place
  55659. * @param csg The CSG to union against this CSG
  55660. */
  55661. unionInPlace(csg: CSG): void;
  55662. /**
  55663. * Subtracts this CSG with another CSG
  55664. * @param csg The CSG to subtract against this CSG
  55665. * @returns A new CSG
  55666. */
  55667. subtract(csg: CSG): CSG;
  55668. /**
  55669. * Subtracts this CSG with another CSG in place
  55670. * @param csg The CSG to subtact against this CSG
  55671. */
  55672. subtractInPlace(csg: CSG): void;
  55673. /**
  55674. * Intersect this CSG with another CSG
  55675. * @param csg The CSG to intersect against this CSG
  55676. * @returns A new CSG
  55677. */
  55678. intersect(csg: CSG): CSG;
  55679. /**
  55680. * Intersects this CSG with another CSG in place
  55681. * @param csg The CSG to intersect against this CSG
  55682. */
  55683. intersectInPlace(csg: CSG): void;
  55684. /**
  55685. * Return a new CSG solid with solid and empty space switched. This solid is
  55686. * not modified.
  55687. * @returns A new CSG solid with solid and empty space switched
  55688. */
  55689. inverse(): CSG;
  55690. /**
  55691. * Inverses the CSG in place
  55692. */
  55693. inverseInPlace(): void;
  55694. /**
  55695. * This is used to keep meshes transformations so they can be restored
  55696. * when we build back a Babylon Mesh
  55697. * NB : All CSG operations are performed in world coordinates
  55698. * @param csg The CSG to copy the transform attributes from
  55699. * @returns This CSG
  55700. */
  55701. copyTransformAttributes(csg: CSG): CSG;
  55702. /**
  55703. * Build Raw mesh from CSG
  55704. * Coordinates here are in world space
  55705. * @param name The name of the mesh geometry
  55706. * @param scene The Scene
  55707. * @param keepSubMeshes Specifies if the submeshes should be kept
  55708. * @returns A new Mesh
  55709. */
  55710. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55711. /**
  55712. * Build Mesh from CSG taking material and transforms into account
  55713. * @param name The name of the Mesh
  55714. * @param material The material of the Mesh
  55715. * @param scene The Scene
  55716. * @param keepSubMeshes Specifies if submeshes should be kept
  55717. * @returns The new Mesh
  55718. */
  55719. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55720. }
  55721. }
  55722. declare module BABYLON {
  55723. /**
  55724. * Class used to create a trail following a mesh
  55725. */
  55726. export class TrailMesh extends Mesh {
  55727. private _generator;
  55728. private _autoStart;
  55729. private _running;
  55730. private _diameter;
  55731. private _length;
  55732. private _sectionPolygonPointsCount;
  55733. private _sectionVectors;
  55734. private _sectionNormalVectors;
  55735. private _beforeRenderObserver;
  55736. /**
  55737. * @constructor
  55738. * @param name The value used by scene.getMeshByName() to do a lookup.
  55739. * @param generator The mesh to generate a trail.
  55740. * @param scene The scene to add this mesh to.
  55741. * @param diameter Diameter of trailing mesh. Default is 1.
  55742. * @param length Length of trailing mesh. Default is 60.
  55743. * @param autoStart Automatically start trailing mesh. Default true.
  55744. */
  55745. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55746. /**
  55747. * "TrailMesh"
  55748. * @returns "TrailMesh"
  55749. */
  55750. getClassName(): string;
  55751. private _createMesh;
  55752. /**
  55753. * Start trailing mesh.
  55754. */
  55755. start(): void;
  55756. /**
  55757. * Stop trailing mesh.
  55758. */
  55759. stop(): void;
  55760. /**
  55761. * Update trailing mesh geometry.
  55762. */
  55763. update(): void;
  55764. /**
  55765. * Returns a new TrailMesh object.
  55766. * @param name is a string, the name given to the new mesh
  55767. * @param newGenerator use new generator object for cloned trail mesh
  55768. * @returns a new mesh
  55769. */
  55770. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55771. /**
  55772. * Serializes this trail mesh
  55773. * @param serializationObject object to write serialization to
  55774. */
  55775. serialize(serializationObject: any): void;
  55776. /**
  55777. * Parses a serialized trail mesh
  55778. * @param parsedMesh the serialized mesh
  55779. * @param scene the scene to create the trail mesh in
  55780. * @returns the created trail mesh
  55781. */
  55782. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55783. }
  55784. }
  55785. declare module BABYLON {
  55786. /**
  55787. * Class containing static functions to help procedurally build meshes
  55788. */
  55789. export class TiledBoxBuilder {
  55790. /**
  55791. * Creates a box mesh
  55792. * 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)
  55793. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55795. * * 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
  55796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55797. * @param name defines the name of the mesh
  55798. * @param options defines the options used to create the mesh
  55799. * @param scene defines the hosting scene
  55800. * @returns the box mesh
  55801. */
  55802. static CreateTiledBox(name: string, options: {
  55803. pattern?: number;
  55804. width?: number;
  55805. height?: number;
  55806. depth?: number;
  55807. tileSize?: number;
  55808. tileWidth?: number;
  55809. tileHeight?: number;
  55810. alignHorizontal?: number;
  55811. alignVertical?: number;
  55812. faceUV?: Vector4[];
  55813. faceColors?: Color4[];
  55814. sideOrientation?: number;
  55815. updatable?: boolean;
  55816. }, scene?: Nullable<Scene>): Mesh;
  55817. }
  55818. }
  55819. declare module BABYLON {
  55820. /**
  55821. * Class containing static functions to help procedurally build meshes
  55822. */
  55823. export class TorusKnotBuilder {
  55824. /**
  55825. * Creates a torus knot mesh
  55826. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55827. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55828. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55829. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55831. * * 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
  55832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55833. * @param name defines the name of the mesh
  55834. * @param options defines the options used to create the mesh
  55835. * @param scene defines the hosting scene
  55836. * @returns the torus knot mesh
  55837. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55838. */
  55839. static CreateTorusKnot(name: string, options: {
  55840. radius?: number;
  55841. tube?: number;
  55842. radialSegments?: number;
  55843. tubularSegments?: number;
  55844. p?: number;
  55845. q?: number;
  55846. updatable?: boolean;
  55847. sideOrientation?: number;
  55848. frontUVs?: Vector4;
  55849. backUVs?: Vector4;
  55850. }, scene: any): Mesh;
  55851. }
  55852. }
  55853. declare module BABYLON {
  55854. /**
  55855. * Polygon
  55856. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55857. */
  55858. export class Polygon {
  55859. /**
  55860. * Creates a rectangle
  55861. * @param xmin bottom X coord
  55862. * @param ymin bottom Y coord
  55863. * @param xmax top X coord
  55864. * @param ymax top Y coord
  55865. * @returns points that make the resulting rectation
  55866. */
  55867. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55868. /**
  55869. * Creates a circle
  55870. * @param radius radius of circle
  55871. * @param cx scale in x
  55872. * @param cy scale in y
  55873. * @param numberOfSides number of sides that make up the circle
  55874. * @returns points that make the resulting circle
  55875. */
  55876. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55877. /**
  55878. * Creates a polygon from input string
  55879. * @param input Input polygon data
  55880. * @returns the parsed points
  55881. */
  55882. static Parse(input: string): Vector2[];
  55883. /**
  55884. * Starts building a polygon from x and y coordinates
  55885. * @param x x coordinate
  55886. * @param y y coordinate
  55887. * @returns the started path2
  55888. */
  55889. static StartingAt(x: number, y: number): Path2;
  55890. }
  55891. /**
  55892. * Builds a polygon
  55893. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55894. */
  55895. export class PolygonMeshBuilder {
  55896. private _points;
  55897. private _outlinepoints;
  55898. private _holes;
  55899. private _name;
  55900. private _scene;
  55901. private _epoints;
  55902. private _eholes;
  55903. private _addToepoint;
  55904. /**
  55905. * Babylon reference to the earcut plugin.
  55906. */
  55907. bjsEarcut: any;
  55908. /**
  55909. * Creates a PolygonMeshBuilder
  55910. * @param name name of the builder
  55911. * @param contours Path of the polygon
  55912. * @param scene scene to add to when creating the mesh
  55913. * @param earcutInjection can be used to inject your own earcut reference
  55914. */
  55915. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55916. /**
  55917. * Adds a whole within the polygon
  55918. * @param hole Array of points defining the hole
  55919. * @returns this
  55920. */
  55921. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55922. /**
  55923. * Creates the polygon
  55924. * @param updatable If the mesh should be updatable
  55925. * @param depth The depth of the mesh created
  55926. * @returns the created mesh
  55927. */
  55928. build(updatable?: boolean, depth?: number): Mesh;
  55929. /**
  55930. * Creates the polygon
  55931. * @param depth The depth of the mesh created
  55932. * @returns the created VertexData
  55933. */
  55934. buildVertexData(depth?: number): VertexData;
  55935. /**
  55936. * Adds a side to the polygon
  55937. * @param positions points that make the polygon
  55938. * @param normals normals of the polygon
  55939. * @param uvs uvs of the polygon
  55940. * @param indices indices of the polygon
  55941. * @param bounds bounds of the polygon
  55942. * @param points points of the polygon
  55943. * @param depth depth of the polygon
  55944. * @param flip flip of the polygon
  55945. */
  55946. private addSide;
  55947. }
  55948. }
  55949. declare module BABYLON {
  55950. /**
  55951. * Class containing static functions to help procedurally build meshes
  55952. */
  55953. export class PolygonBuilder {
  55954. /**
  55955. * Creates a polygon mesh
  55956. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55957. * * 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
  55958. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55960. * * 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)
  55961. * * Remember you can only change the shape positions, not their number when updating a polygon
  55962. * @param name defines the name of the mesh
  55963. * @param options defines the options used to create the mesh
  55964. * @param scene defines the hosting scene
  55965. * @param earcutInjection can be used to inject your own earcut reference
  55966. * @returns the polygon mesh
  55967. */
  55968. static CreatePolygon(name: string, options: {
  55969. shape: Vector3[];
  55970. holes?: Vector3[][];
  55971. depth?: number;
  55972. faceUV?: Vector4[];
  55973. faceColors?: Color4[];
  55974. updatable?: boolean;
  55975. sideOrientation?: number;
  55976. frontUVs?: Vector4;
  55977. backUVs?: Vector4;
  55978. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55979. /**
  55980. * Creates an extruded polygon mesh, with depth in the Y direction.
  55981. * * 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)
  55982. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55983. * @param name defines the name of the mesh
  55984. * @param options defines the options used to create the mesh
  55985. * @param scene defines the hosting scene
  55986. * @param earcutInjection can be used to inject your own earcut reference
  55987. * @returns the polygon mesh
  55988. */
  55989. static ExtrudePolygon(name: string, options: {
  55990. shape: Vector3[];
  55991. holes?: Vector3[][];
  55992. depth?: number;
  55993. faceUV?: Vector4[];
  55994. faceColors?: Color4[];
  55995. updatable?: boolean;
  55996. sideOrientation?: number;
  55997. frontUVs?: Vector4;
  55998. backUVs?: Vector4;
  55999. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56000. }
  56001. }
  56002. declare module BABYLON {
  56003. /**
  56004. * Class containing static functions to help procedurally build meshes
  56005. */
  56006. export class LatheBuilder {
  56007. /**
  56008. * Creates lathe mesh.
  56009. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56010. * * 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
  56011. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56012. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56013. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56014. * * 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
  56015. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56016. * * 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
  56017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56018. * * 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
  56019. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56021. * @param name defines the name of the mesh
  56022. * @param options defines the options used to create the mesh
  56023. * @param scene defines the hosting scene
  56024. * @returns the lathe mesh
  56025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56026. */
  56027. static CreateLathe(name: string, options: {
  56028. shape: Vector3[];
  56029. radius?: number;
  56030. tessellation?: number;
  56031. clip?: number;
  56032. arc?: number;
  56033. closed?: boolean;
  56034. updatable?: boolean;
  56035. sideOrientation?: number;
  56036. frontUVs?: Vector4;
  56037. backUVs?: Vector4;
  56038. cap?: number;
  56039. invertUV?: boolean;
  56040. }, scene?: Nullable<Scene>): Mesh;
  56041. }
  56042. }
  56043. declare module BABYLON {
  56044. /**
  56045. * Class containing static functions to help procedurally build meshes
  56046. */
  56047. export class TiledPlaneBuilder {
  56048. /**
  56049. * Creates a tiled plane mesh
  56050. * * The parameter `pattern` will, depending on value, do nothing or
  56051. * * * flip (reflect about central vertical) alternate tiles across and up
  56052. * * * flip every tile on alternate rows
  56053. * * * rotate (180 degs) alternate tiles across and up
  56054. * * * rotate every tile on alternate rows
  56055. * * * flip and rotate alternate tiles across and up
  56056. * * * flip and rotate every tile on alternate rows
  56057. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56058. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56059. * * 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
  56060. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56061. * * 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)
  56062. * * 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)
  56063. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56064. * @param name defines the name of the mesh
  56065. * @param options defines the options used to create the mesh
  56066. * @param scene defines the hosting scene
  56067. * @returns the box mesh
  56068. */
  56069. static CreateTiledPlane(name: string, options: {
  56070. pattern?: number;
  56071. tileSize?: number;
  56072. tileWidth?: number;
  56073. tileHeight?: number;
  56074. size?: number;
  56075. width?: number;
  56076. height?: number;
  56077. alignHorizontal?: number;
  56078. alignVertical?: number;
  56079. sideOrientation?: number;
  56080. frontUVs?: Vector4;
  56081. backUVs?: Vector4;
  56082. updatable?: boolean;
  56083. }, scene?: Nullable<Scene>): Mesh;
  56084. }
  56085. }
  56086. declare module BABYLON {
  56087. /**
  56088. * Class containing static functions to help procedurally build meshes
  56089. */
  56090. export class TubeBuilder {
  56091. /**
  56092. * Creates a tube mesh.
  56093. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56094. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56095. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56096. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56097. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56098. * * 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)
  56099. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56100. * * 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
  56101. * * 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
  56102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56103. * * 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
  56104. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56106. * @param name defines the name of the mesh
  56107. * @param options defines the options used to create the mesh
  56108. * @param scene defines the hosting scene
  56109. * @returns the tube mesh
  56110. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56111. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56112. */
  56113. static CreateTube(name: string, options: {
  56114. path: Vector3[];
  56115. radius?: number;
  56116. tessellation?: number;
  56117. radiusFunction?: {
  56118. (i: number, distance: number): number;
  56119. };
  56120. cap?: number;
  56121. arc?: number;
  56122. updatable?: boolean;
  56123. sideOrientation?: number;
  56124. frontUVs?: Vector4;
  56125. backUVs?: Vector4;
  56126. instance?: Mesh;
  56127. invertUV?: boolean;
  56128. }, scene?: Nullable<Scene>): Mesh;
  56129. }
  56130. }
  56131. declare module BABYLON {
  56132. /**
  56133. * Class containing static functions to help procedurally build meshes
  56134. */
  56135. export class IcoSphereBuilder {
  56136. /**
  56137. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56138. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56139. * * 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`)
  56140. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56141. * * 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
  56142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56143. * * 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
  56144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56145. * @param name defines the name of the mesh
  56146. * @param options defines the options used to create the mesh
  56147. * @param scene defines the hosting scene
  56148. * @returns the icosahedron mesh
  56149. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56150. */
  56151. static CreateIcoSphere(name: string, options: {
  56152. radius?: number;
  56153. radiusX?: number;
  56154. radiusY?: number;
  56155. radiusZ?: number;
  56156. flat?: boolean;
  56157. subdivisions?: number;
  56158. sideOrientation?: number;
  56159. frontUVs?: Vector4;
  56160. backUVs?: Vector4;
  56161. updatable?: boolean;
  56162. }, scene?: Nullable<Scene>): Mesh;
  56163. }
  56164. }
  56165. declare module BABYLON {
  56166. /**
  56167. * Class containing static functions to help procedurally build meshes
  56168. */
  56169. export class DecalBuilder {
  56170. /**
  56171. * Creates a decal mesh.
  56172. * 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
  56173. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56174. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56175. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56176. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56177. * @param name defines the name of the mesh
  56178. * @param sourceMesh defines the mesh where the decal must be applied
  56179. * @param options defines the options used to create the mesh
  56180. * @param scene defines the hosting scene
  56181. * @returns the decal mesh
  56182. * @see https://doc.babylonjs.com/how_to/decals
  56183. */
  56184. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56185. position?: Vector3;
  56186. normal?: Vector3;
  56187. size?: Vector3;
  56188. angle?: number;
  56189. }): Mesh;
  56190. }
  56191. }
  56192. declare module BABYLON {
  56193. /**
  56194. * Class containing static functions to help procedurally build meshes
  56195. */
  56196. export class MeshBuilder {
  56197. /**
  56198. * Creates a box mesh
  56199. * * The parameter `size` sets the size (float) of each box side (default 1)
  56200. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56201. * * 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)
  56202. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56204. * * 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
  56205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56206. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56207. * @param name defines the name of the mesh
  56208. * @param options defines the options used to create the mesh
  56209. * @param scene defines the hosting scene
  56210. * @returns the box mesh
  56211. */
  56212. static CreateBox(name: string, options: {
  56213. size?: number;
  56214. width?: number;
  56215. height?: number;
  56216. depth?: number;
  56217. faceUV?: Vector4[];
  56218. faceColors?: Color4[];
  56219. sideOrientation?: number;
  56220. frontUVs?: Vector4;
  56221. backUVs?: Vector4;
  56222. updatable?: boolean;
  56223. }, scene?: Nullable<Scene>): Mesh;
  56224. /**
  56225. * Creates a tiled box mesh
  56226. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56228. * @param name defines the name of the mesh
  56229. * @param options defines the options used to create the mesh
  56230. * @param scene defines the hosting scene
  56231. * @returns the tiled box mesh
  56232. */
  56233. static CreateTiledBox(name: string, options: {
  56234. pattern?: number;
  56235. size?: number;
  56236. width?: number;
  56237. height?: number;
  56238. depth: number;
  56239. tileSize?: number;
  56240. tileWidth?: number;
  56241. tileHeight?: number;
  56242. faceUV?: Vector4[];
  56243. faceColors?: Color4[];
  56244. alignHorizontal?: number;
  56245. alignVertical?: number;
  56246. sideOrientation?: number;
  56247. updatable?: boolean;
  56248. }, scene?: Nullable<Scene>): Mesh;
  56249. /**
  56250. * Creates a sphere mesh
  56251. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56252. * * 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`)
  56253. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56254. * * 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
  56255. * * 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)
  56256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56257. * * 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
  56258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56259. * @param name defines the name of the mesh
  56260. * @param options defines the options used to create the mesh
  56261. * @param scene defines the hosting scene
  56262. * @returns the sphere mesh
  56263. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56264. */
  56265. static CreateSphere(name: string, options: {
  56266. segments?: number;
  56267. diameter?: number;
  56268. diameterX?: number;
  56269. diameterY?: number;
  56270. diameterZ?: number;
  56271. arc?: number;
  56272. slice?: number;
  56273. sideOrientation?: number;
  56274. frontUVs?: Vector4;
  56275. backUVs?: Vector4;
  56276. updatable?: boolean;
  56277. }, scene?: Nullable<Scene>): Mesh;
  56278. /**
  56279. * Creates a plane polygonal mesh. By default, this is a disc
  56280. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56281. * * 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
  56282. * * 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
  56283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56284. * * 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
  56285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56286. * @param name defines the name of the mesh
  56287. * @param options defines the options used to create the mesh
  56288. * @param scene defines the hosting scene
  56289. * @returns the plane polygonal mesh
  56290. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56291. */
  56292. static CreateDisc(name: string, options: {
  56293. radius?: number;
  56294. tessellation?: number;
  56295. arc?: number;
  56296. updatable?: boolean;
  56297. sideOrientation?: number;
  56298. frontUVs?: Vector4;
  56299. backUVs?: Vector4;
  56300. }, scene?: Nullable<Scene>): Mesh;
  56301. /**
  56302. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56303. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56304. * * 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`)
  56305. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56306. * * 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
  56307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56308. * * 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
  56309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56310. * @param name defines the name of the mesh
  56311. * @param options defines the options used to create the mesh
  56312. * @param scene defines the hosting scene
  56313. * @returns the icosahedron mesh
  56314. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56315. */
  56316. static CreateIcoSphere(name: string, options: {
  56317. radius?: number;
  56318. radiusX?: number;
  56319. radiusY?: number;
  56320. radiusZ?: number;
  56321. flat?: boolean;
  56322. subdivisions?: number;
  56323. sideOrientation?: number;
  56324. frontUVs?: Vector4;
  56325. backUVs?: Vector4;
  56326. updatable?: boolean;
  56327. }, scene?: Nullable<Scene>): Mesh;
  56328. /**
  56329. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56330. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56331. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56332. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56333. * * 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
  56334. * * 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
  56335. * * 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
  56336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56337. * * 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
  56338. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56339. * * 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
  56340. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56341. * * 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
  56342. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56344. * @param name defines the name of the mesh
  56345. * @param options defines the options used to create the mesh
  56346. * @param scene defines the hosting scene
  56347. * @returns the ribbon mesh
  56348. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56349. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56350. */
  56351. static CreateRibbon(name: string, options: {
  56352. pathArray: Vector3[][];
  56353. closeArray?: boolean;
  56354. closePath?: boolean;
  56355. offset?: number;
  56356. updatable?: boolean;
  56357. sideOrientation?: number;
  56358. frontUVs?: Vector4;
  56359. backUVs?: Vector4;
  56360. instance?: Mesh;
  56361. invertUV?: boolean;
  56362. uvs?: Vector2[];
  56363. colors?: Color4[];
  56364. }, scene?: Nullable<Scene>): Mesh;
  56365. /**
  56366. * Creates a cylinder or a cone mesh
  56367. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56368. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56369. * * 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.
  56370. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56371. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56372. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56373. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56374. * * 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).
  56375. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56376. * * 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).
  56377. * * 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
  56378. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56379. * * 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
  56380. * * 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.
  56381. * * If `enclose` is false, a ring surface is one element.
  56382. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56383. * * 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
  56384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56385. * * 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
  56386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56387. * @param name defines the name of the mesh
  56388. * @param options defines the options used to create the mesh
  56389. * @param scene defines the hosting scene
  56390. * @returns the cylinder mesh
  56391. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56392. */
  56393. static CreateCylinder(name: string, options: {
  56394. height?: number;
  56395. diameterTop?: number;
  56396. diameterBottom?: number;
  56397. diameter?: number;
  56398. tessellation?: number;
  56399. subdivisions?: number;
  56400. arc?: number;
  56401. faceColors?: Color4[];
  56402. faceUV?: Vector4[];
  56403. updatable?: boolean;
  56404. hasRings?: boolean;
  56405. enclose?: boolean;
  56406. cap?: number;
  56407. sideOrientation?: number;
  56408. frontUVs?: Vector4;
  56409. backUVs?: Vector4;
  56410. }, scene?: Nullable<Scene>): Mesh;
  56411. /**
  56412. * Creates a torus mesh
  56413. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56414. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56415. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56417. * * 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
  56418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56419. * @param name defines the name of the mesh
  56420. * @param options defines the options used to create the mesh
  56421. * @param scene defines the hosting scene
  56422. * @returns the torus mesh
  56423. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56424. */
  56425. static CreateTorus(name: string, options: {
  56426. diameter?: number;
  56427. thickness?: number;
  56428. tessellation?: number;
  56429. updatable?: boolean;
  56430. sideOrientation?: number;
  56431. frontUVs?: Vector4;
  56432. backUVs?: Vector4;
  56433. }, scene?: Nullable<Scene>): Mesh;
  56434. /**
  56435. * Creates a torus knot mesh
  56436. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56437. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56438. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56439. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56441. * * 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
  56442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56443. * @param name defines the name of the mesh
  56444. * @param options defines the options used to create the mesh
  56445. * @param scene defines the hosting scene
  56446. * @returns the torus knot mesh
  56447. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56448. */
  56449. static CreateTorusKnot(name: string, options: {
  56450. radius?: number;
  56451. tube?: number;
  56452. radialSegments?: number;
  56453. tubularSegments?: number;
  56454. p?: number;
  56455. q?: number;
  56456. updatable?: boolean;
  56457. sideOrientation?: number;
  56458. frontUVs?: Vector4;
  56459. backUVs?: Vector4;
  56460. }, scene?: Nullable<Scene>): Mesh;
  56461. /**
  56462. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56463. * * 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
  56464. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56465. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56466. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56467. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56468. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56469. * * 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
  56470. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56473. * @param name defines the name of the new line system
  56474. * @param options defines the options used to create the line system
  56475. * @param scene defines the hosting scene
  56476. * @returns a new line system mesh
  56477. */
  56478. static CreateLineSystem(name: string, options: {
  56479. lines: Vector3[][];
  56480. updatable?: boolean;
  56481. instance?: Nullable<LinesMesh>;
  56482. colors?: Nullable<Color4[][]>;
  56483. useVertexAlpha?: boolean;
  56484. }, scene: Nullable<Scene>): LinesMesh;
  56485. /**
  56486. * Creates a line mesh
  56487. * 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
  56488. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56489. * * The parameter `points` is an array successive Vector3
  56490. * * 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
  56491. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56492. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56493. * * When updating an instance, remember that only point positions can change, not the number of points
  56494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56496. * @param name defines the name of the new line system
  56497. * @param options defines the options used to create the line system
  56498. * @param scene defines the hosting scene
  56499. * @returns a new line mesh
  56500. */
  56501. static CreateLines(name: string, options: {
  56502. points: Vector3[];
  56503. updatable?: boolean;
  56504. instance?: Nullable<LinesMesh>;
  56505. colors?: Color4[];
  56506. useVertexAlpha?: boolean;
  56507. }, scene?: Nullable<Scene>): LinesMesh;
  56508. /**
  56509. * Creates a dashed line mesh
  56510. * * 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
  56511. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56512. * * The parameter `points` is an array successive Vector3
  56513. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56514. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56515. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56516. * * 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
  56517. * * When updating an instance, remember that only point positions can change, not the number of points
  56518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56519. * @param name defines the name of the mesh
  56520. * @param options defines the options used to create the mesh
  56521. * @param scene defines the hosting scene
  56522. * @returns the dashed line mesh
  56523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56524. */
  56525. static CreateDashedLines(name: string, options: {
  56526. points: Vector3[];
  56527. dashSize?: number;
  56528. gapSize?: number;
  56529. dashNb?: number;
  56530. updatable?: boolean;
  56531. instance?: LinesMesh;
  56532. }, scene?: Nullable<Scene>): LinesMesh;
  56533. /**
  56534. * 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.
  56535. * * 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.
  56536. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56537. * * 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.
  56538. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56539. * * 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
  56540. * * 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
  56541. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56543. * * 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
  56544. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56546. * @param name defines the name of the mesh
  56547. * @param options defines the options used to create the mesh
  56548. * @param scene defines the hosting scene
  56549. * @returns the extruded shape mesh
  56550. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56552. */
  56553. static ExtrudeShape(name: string, options: {
  56554. shape: Vector3[];
  56555. path: Vector3[];
  56556. scale?: number;
  56557. rotation?: number;
  56558. cap?: number;
  56559. updatable?: boolean;
  56560. sideOrientation?: number;
  56561. frontUVs?: Vector4;
  56562. backUVs?: Vector4;
  56563. instance?: Mesh;
  56564. invertUV?: boolean;
  56565. }, scene?: Nullable<Scene>): Mesh;
  56566. /**
  56567. * Creates an custom extruded shape mesh.
  56568. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56569. * * 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.
  56570. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56571. * * 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
  56572. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56573. * * 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
  56574. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56575. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56576. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56577. * * 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
  56578. * * 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
  56579. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56581. * * 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
  56582. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56584. * @param name defines the name of the mesh
  56585. * @param options defines the options used to create the mesh
  56586. * @param scene defines the hosting scene
  56587. * @returns the custom extruded shape mesh
  56588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56589. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56591. */
  56592. static ExtrudeShapeCustom(name: string, options: {
  56593. shape: Vector3[];
  56594. path: Vector3[];
  56595. scaleFunction?: any;
  56596. rotationFunction?: any;
  56597. ribbonCloseArray?: boolean;
  56598. ribbonClosePath?: boolean;
  56599. cap?: number;
  56600. updatable?: boolean;
  56601. sideOrientation?: number;
  56602. frontUVs?: Vector4;
  56603. backUVs?: Vector4;
  56604. instance?: Mesh;
  56605. invertUV?: boolean;
  56606. }, scene?: Nullable<Scene>): Mesh;
  56607. /**
  56608. * Creates lathe mesh.
  56609. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56610. * * 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
  56611. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56612. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56613. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56614. * * 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
  56615. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56616. * * 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
  56617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56618. * * 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
  56619. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56621. * @param name defines the name of the mesh
  56622. * @param options defines the options used to create the mesh
  56623. * @param scene defines the hosting scene
  56624. * @returns the lathe mesh
  56625. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56626. */
  56627. static CreateLathe(name: string, options: {
  56628. shape: Vector3[];
  56629. radius?: number;
  56630. tessellation?: number;
  56631. clip?: number;
  56632. arc?: number;
  56633. closed?: boolean;
  56634. updatable?: boolean;
  56635. sideOrientation?: number;
  56636. frontUVs?: Vector4;
  56637. backUVs?: Vector4;
  56638. cap?: number;
  56639. invertUV?: boolean;
  56640. }, scene?: Nullable<Scene>): Mesh;
  56641. /**
  56642. * Creates a tiled plane mesh
  56643. * * You can set a limited pattern arrangement with the tiles
  56644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56645. * * 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
  56646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56647. * @param name defines the name of the mesh
  56648. * @param options defines the options used to create the mesh
  56649. * @param scene defines the hosting scene
  56650. * @returns the plane mesh
  56651. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56652. */
  56653. static CreateTiledPlane(name: string, options: {
  56654. pattern?: number;
  56655. tileSize?: number;
  56656. tileWidth?: number;
  56657. tileHeight?: number;
  56658. size?: number;
  56659. width?: number;
  56660. height?: number;
  56661. alignHorizontal?: number;
  56662. alignVertical?: number;
  56663. sideOrientation?: number;
  56664. frontUVs?: Vector4;
  56665. backUVs?: Vector4;
  56666. updatable?: boolean;
  56667. }, scene?: Nullable<Scene>): Mesh;
  56668. /**
  56669. * Creates a plane mesh
  56670. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56671. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56672. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56674. * * 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
  56675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56676. * @param name defines the name of the mesh
  56677. * @param options defines the options used to create the mesh
  56678. * @param scene defines the hosting scene
  56679. * @returns the plane mesh
  56680. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56681. */
  56682. static CreatePlane(name: string, options: {
  56683. size?: number;
  56684. width?: number;
  56685. height?: number;
  56686. sideOrientation?: number;
  56687. frontUVs?: Vector4;
  56688. backUVs?: Vector4;
  56689. updatable?: boolean;
  56690. sourcePlane?: Plane;
  56691. }, scene?: Nullable<Scene>): Mesh;
  56692. /**
  56693. * Creates a ground mesh
  56694. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56695. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56697. * @param name defines the name of the mesh
  56698. * @param options defines the options used to create the mesh
  56699. * @param scene defines the hosting scene
  56700. * @returns the ground mesh
  56701. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56702. */
  56703. static CreateGround(name: string, options: {
  56704. width?: number;
  56705. height?: number;
  56706. subdivisions?: number;
  56707. subdivisionsX?: number;
  56708. subdivisionsY?: number;
  56709. updatable?: boolean;
  56710. }, scene?: Nullable<Scene>): Mesh;
  56711. /**
  56712. * Creates a tiled ground mesh
  56713. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56714. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56715. * * 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
  56716. * * 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
  56717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56718. * @param name defines the name of the mesh
  56719. * @param options defines the options used to create the mesh
  56720. * @param scene defines the hosting scene
  56721. * @returns the tiled ground mesh
  56722. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56723. */
  56724. static CreateTiledGround(name: string, options: {
  56725. xmin: number;
  56726. zmin: number;
  56727. xmax: number;
  56728. zmax: number;
  56729. subdivisions?: {
  56730. w: number;
  56731. h: number;
  56732. };
  56733. precision?: {
  56734. w: number;
  56735. h: number;
  56736. };
  56737. updatable?: boolean;
  56738. }, scene?: Nullable<Scene>): Mesh;
  56739. /**
  56740. * Creates a ground mesh from a height map
  56741. * * The parameter `url` sets the URL of the height map image resource.
  56742. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56743. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56744. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56745. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56746. * * 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.
  56747. * * 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).
  56748. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56750. * @param name defines the name of the mesh
  56751. * @param url defines the url to the height map
  56752. * @param options defines the options used to create the mesh
  56753. * @param scene defines the hosting scene
  56754. * @returns the ground mesh
  56755. * @see https://doc.babylonjs.com/babylon101/height_map
  56756. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56757. */
  56758. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56759. width?: number;
  56760. height?: number;
  56761. subdivisions?: number;
  56762. minHeight?: number;
  56763. maxHeight?: number;
  56764. colorFilter?: Color3;
  56765. alphaFilter?: number;
  56766. updatable?: boolean;
  56767. onReady?: (mesh: GroundMesh) => void;
  56768. }, scene?: Nullable<Scene>): GroundMesh;
  56769. /**
  56770. * Creates a polygon mesh
  56771. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56772. * * 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
  56773. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56775. * * 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)
  56776. * * Remember you can only change the shape positions, not their number when updating a polygon
  56777. * @param name defines the name of the mesh
  56778. * @param options defines the options used to create the mesh
  56779. * @param scene defines the hosting scene
  56780. * @param earcutInjection can be used to inject your own earcut reference
  56781. * @returns the polygon mesh
  56782. */
  56783. static CreatePolygon(name: string, options: {
  56784. shape: Vector3[];
  56785. holes?: Vector3[][];
  56786. depth?: number;
  56787. faceUV?: Vector4[];
  56788. faceColors?: Color4[];
  56789. updatable?: boolean;
  56790. sideOrientation?: number;
  56791. frontUVs?: Vector4;
  56792. backUVs?: Vector4;
  56793. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56794. /**
  56795. * Creates an extruded polygon mesh, with depth in the Y direction.
  56796. * * 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)
  56797. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56798. * @param name defines the name of the mesh
  56799. * @param options defines the options used to create the mesh
  56800. * @param scene defines the hosting scene
  56801. * @param earcutInjection can be used to inject your own earcut reference
  56802. * @returns the polygon mesh
  56803. */
  56804. static ExtrudePolygon(name: string, options: {
  56805. shape: Vector3[];
  56806. holes?: Vector3[][];
  56807. depth?: number;
  56808. faceUV?: Vector4[];
  56809. faceColors?: Color4[];
  56810. updatable?: boolean;
  56811. sideOrientation?: number;
  56812. frontUVs?: Vector4;
  56813. backUVs?: Vector4;
  56814. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56815. /**
  56816. * Creates a tube mesh.
  56817. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56818. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56819. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56820. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56821. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56822. * * 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)
  56823. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56824. * * 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
  56825. * * 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
  56826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56827. * * 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
  56828. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56830. * @param name defines the name of the mesh
  56831. * @param options defines the options used to create the mesh
  56832. * @param scene defines the hosting scene
  56833. * @returns the tube mesh
  56834. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56835. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56836. */
  56837. static CreateTube(name: string, options: {
  56838. path: Vector3[];
  56839. radius?: number;
  56840. tessellation?: number;
  56841. radiusFunction?: {
  56842. (i: number, distance: number): number;
  56843. };
  56844. cap?: number;
  56845. arc?: number;
  56846. updatable?: boolean;
  56847. sideOrientation?: number;
  56848. frontUVs?: Vector4;
  56849. backUVs?: Vector4;
  56850. instance?: Mesh;
  56851. invertUV?: boolean;
  56852. }, scene?: Nullable<Scene>): Mesh;
  56853. /**
  56854. * Creates a polyhedron mesh
  56855. * * 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
  56856. * * The parameter `size` (positive float, default 1) sets the polygon size
  56857. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56858. * * 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`
  56859. * * 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
  56860. * * 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)`)
  56861. * * 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
  56862. * * 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
  56863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56864. * * 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
  56865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56866. * @param name defines the name of the mesh
  56867. * @param options defines the options used to create the mesh
  56868. * @param scene defines the hosting scene
  56869. * @returns the polyhedron mesh
  56870. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56871. */
  56872. static CreatePolyhedron(name: string, options: {
  56873. type?: number;
  56874. size?: number;
  56875. sizeX?: number;
  56876. sizeY?: number;
  56877. sizeZ?: number;
  56878. custom?: any;
  56879. faceUV?: Vector4[];
  56880. faceColors?: Color4[];
  56881. flat?: boolean;
  56882. updatable?: boolean;
  56883. sideOrientation?: number;
  56884. frontUVs?: Vector4;
  56885. backUVs?: Vector4;
  56886. }, scene?: Nullable<Scene>): Mesh;
  56887. /**
  56888. * Creates a decal mesh.
  56889. * 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
  56890. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56891. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56892. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56893. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56894. * @param name defines the name of the mesh
  56895. * @param sourceMesh defines the mesh where the decal must be applied
  56896. * @param options defines the options used to create the mesh
  56897. * @param scene defines the hosting scene
  56898. * @returns the decal mesh
  56899. * @see https://doc.babylonjs.com/how_to/decals
  56900. */
  56901. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56902. position?: Vector3;
  56903. normal?: Vector3;
  56904. size?: Vector3;
  56905. angle?: number;
  56906. }): Mesh;
  56907. }
  56908. }
  56909. declare module BABYLON {
  56910. /**
  56911. * A simplifier interface for future simplification implementations
  56912. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56913. */
  56914. export interface ISimplifier {
  56915. /**
  56916. * Simplification of a given mesh according to the given settings.
  56917. * Since this requires computation, it is assumed that the function runs async.
  56918. * @param settings The settings of the simplification, including quality and distance
  56919. * @param successCallback A callback that will be called after the mesh was simplified.
  56920. * @param errorCallback in case of an error, this callback will be called. optional.
  56921. */
  56922. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56923. }
  56924. /**
  56925. * Expected simplification settings.
  56926. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56927. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56928. */
  56929. export interface ISimplificationSettings {
  56930. /**
  56931. * Gets or sets the expected quality
  56932. */
  56933. quality: number;
  56934. /**
  56935. * Gets or sets the distance when this optimized version should be used
  56936. */
  56937. distance: number;
  56938. /**
  56939. * Gets an already optimized mesh
  56940. */
  56941. optimizeMesh?: boolean;
  56942. }
  56943. /**
  56944. * Class used to specify simplification options
  56945. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56946. */
  56947. export class SimplificationSettings implements ISimplificationSettings {
  56948. /** expected quality */
  56949. quality: number;
  56950. /** distance when this optimized version should be used */
  56951. distance: number;
  56952. /** already optimized mesh */
  56953. optimizeMesh?: boolean | undefined;
  56954. /**
  56955. * Creates a SimplificationSettings
  56956. * @param quality expected quality
  56957. * @param distance distance when this optimized version should be used
  56958. * @param optimizeMesh already optimized mesh
  56959. */
  56960. constructor(
  56961. /** expected quality */
  56962. quality: number,
  56963. /** distance when this optimized version should be used */
  56964. distance: number,
  56965. /** already optimized mesh */
  56966. optimizeMesh?: boolean | undefined);
  56967. }
  56968. /**
  56969. * Interface used to define a simplification task
  56970. */
  56971. export interface ISimplificationTask {
  56972. /**
  56973. * Array of settings
  56974. */
  56975. settings: Array<ISimplificationSettings>;
  56976. /**
  56977. * Simplification type
  56978. */
  56979. simplificationType: SimplificationType;
  56980. /**
  56981. * Mesh to simplify
  56982. */
  56983. mesh: Mesh;
  56984. /**
  56985. * Callback called on success
  56986. */
  56987. successCallback?: () => void;
  56988. /**
  56989. * Defines if parallel processing can be used
  56990. */
  56991. parallelProcessing: boolean;
  56992. }
  56993. /**
  56994. * Queue used to order the simplification tasks
  56995. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56996. */
  56997. export class SimplificationQueue {
  56998. private _simplificationArray;
  56999. /**
  57000. * Gets a boolean indicating that the process is still running
  57001. */
  57002. running: boolean;
  57003. /**
  57004. * Creates a new queue
  57005. */
  57006. constructor();
  57007. /**
  57008. * Adds a new simplification task
  57009. * @param task defines a task to add
  57010. */
  57011. addTask(task: ISimplificationTask): void;
  57012. /**
  57013. * Execute next task
  57014. */
  57015. executeNext(): void;
  57016. /**
  57017. * Execute a simplification task
  57018. * @param task defines the task to run
  57019. */
  57020. runSimplification(task: ISimplificationTask): void;
  57021. private getSimplifier;
  57022. }
  57023. /**
  57024. * The implemented types of simplification
  57025. * At the moment only Quadratic Error Decimation is implemented
  57026. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57027. */
  57028. export enum SimplificationType {
  57029. /** Quadratic error decimation */
  57030. QUADRATIC = 0
  57031. }
  57032. }
  57033. declare module BABYLON {
  57034. interface Scene {
  57035. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  57036. /**
  57037. * Gets or sets the simplification queue attached to the scene
  57038. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57039. */
  57040. simplificationQueue: SimplificationQueue;
  57041. }
  57042. interface Mesh {
  57043. /**
  57044. * Simplify the mesh according to the given array of settings.
  57045. * Function will return immediately and will simplify async
  57046. * @param settings a collection of simplification settings
  57047. * @param parallelProcessing should all levels calculate parallel or one after the other
  57048. * @param simplificationType the type of simplification to run
  57049. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57050. * @returns the current mesh
  57051. */
  57052. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57053. }
  57054. /**
  57055. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57056. * created in a scene
  57057. */
  57058. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57059. /**
  57060. * The component name helpfull to identify the component in the list of scene components.
  57061. */
  57062. readonly name: string;
  57063. /**
  57064. * The scene the component belongs to.
  57065. */
  57066. scene: Scene;
  57067. /**
  57068. * Creates a new instance of the component for the given scene
  57069. * @param scene Defines the scene to register the component in
  57070. */
  57071. constructor(scene: Scene);
  57072. /**
  57073. * Registers the component in a given scene
  57074. */
  57075. register(): void;
  57076. /**
  57077. * Rebuilds the elements related to this component in case of
  57078. * context lost for instance.
  57079. */
  57080. rebuild(): void;
  57081. /**
  57082. * Disposes the component and the associated ressources
  57083. */
  57084. dispose(): void;
  57085. private _beforeCameraUpdate;
  57086. }
  57087. }
  57088. declare module BABYLON {
  57089. /**
  57090. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57091. */
  57092. export interface INavigationEnginePlugin {
  57093. /**
  57094. * plugin name
  57095. */
  57096. name: string;
  57097. /**
  57098. * Creates a navigation mesh
  57099. * @param meshes array of all the geometry used to compute the navigatio mesh
  57100. * @param parameters bunch of parameters used to filter geometry
  57101. */
  57102. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57103. /**
  57104. * Create a navigation mesh debug mesh
  57105. * @param scene is where the mesh will be added
  57106. * @returns debug display mesh
  57107. */
  57108. createDebugNavMesh(scene: Scene): Mesh;
  57109. /**
  57110. * Get a navigation mesh constrained position, closest to the parameter position
  57111. * @param position world position
  57112. * @returns the closest point to position constrained by the navigation mesh
  57113. */
  57114. getClosestPoint(position: Vector3): Vector3;
  57115. /**
  57116. * Get a navigation mesh constrained position, within a particular radius
  57117. * @param position world position
  57118. * @param maxRadius the maximum distance to the constrained world position
  57119. * @returns the closest point to position constrained by the navigation mesh
  57120. */
  57121. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57122. /**
  57123. * Compute the final position from a segment made of destination-position
  57124. * @param position world position
  57125. * @param destination world position
  57126. * @returns the resulting point along the navmesh
  57127. */
  57128. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57129. /**
  57130. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57131. * @param start world position
  57132. * @param end world position
  57133. * @returns array containing world position composing the path
  57134. */
  57135. computePath(start: Vector3, end: Vector3): Vector3[];
  57136. /**
  57137. * If this plugin is supported
  57138. * @returns true if plugin is supported
  57139. */
  57140. isSupported(): boolean;
  57141. /**
  57142. * Create a new Crowd so you can add agents
  57143. * @param maxAgents the maximum agent count in the crowd
  57144. * @param maxAgentRadius the maximum radius an agent can have
  57145. * @param scene to attach the crowd to
  57146. * @returns the crowd you can add agents to
  57147. */
  57148. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57149. /**
  57150. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57151. * The queries will try to find a solution within those bounds
  57152. * default is (1,1,1)
  57153. * @param extent x,y,z value that define the extent around the queries point of reference
  57154. */
  57155. setDefaultQueryExtent(extent: Vector3): void;
  57156. /**
  57157. * Get the Bounding box extent specified by setDefaultQueryExtent
  57158. * @returns the box extent values
  57159. */
  57160. getDefaultQueryExtent(): Vector3;
  57161. /**
  57162. * Release all resources
  57163. */
  57164. dispose(): void;
  57165. }
  57166. /**
  57167. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57168. */
  57169. export interface ICrowd {
  57170. /**
  57171. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57172. * You can attach anything to that node. The node position is updated in the scene update tick.
  57173. * @param pos world position that will be constrained by the navigation mesh
  57174. * @param parameters agent parameters
  57175. * @param transform hooked to the agent that will be update by the scene
  57176. * @returns agent index
  57177. */
  57178. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57179. /**
  57180. * Returns the agent position in world space
  57181. * @param index agent index returned by addAgent
  57182. * @returns world space position
  57183. */
  57184. getAgentPosition(index: number): Vector3;
  57185. /**
  57186. * Gets the agent velocity in world space
  57187. * @param index agent index returned by addAgent
  57188. * @returns world space velocity
  57189. */
  57190. getAgentVelocity(index: number): Vector3;
  57191. /**
  57192. * remove a particular agent previously created
  57193. * @param index agent index returned by addAgent
  57194. */
  57195. removeAgent(index: number): void;
  57196. /**
  57197. * get the list of all agents attached to this crowd
  57198. * @returns list of agent indices
  57199. */
  57200. getAgents(): number[];
  57201. /**
  57202. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57203. * @param deltaTime in seconds
  57204. */
  57205. update(deltaTime: number): void;
  57206. /**
  57207. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57208. * @param index agent index returned by addAgent
  57209. * @param destination targeted world position
  57210. */
  57211. agentGoto(index: number, destination: Vector3): void;
  57212. /**
  57213. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57214. * The queries will try to find a solution within those bounds
  57215. * default is (1,1,1)
  57216. * @param extent x,y,z value that define the extent around the queries point of reference
  57217. */
  57218. setDefaultQueryExtent(extent: Vector3): void;
  57219. /**
  57220. * Get the Bounding box extent specified by setDefaultQueryExtent
  57221. * @returns the box extent values
  57222. */
  57223. getDefaultQueryExtent(): Vector3;
  57224. /**
  57225. * Release all resources
  57226. */
  57227. dispose(): void;
  57228. }
  57229. /**
  57230. * Configures an agent
  57231. */
  57232. export interface IAgentParameters {
  57233. /**
  57234. * Agent radius. [Limit: >= 0]
  57235. */
  57236. radius: number;
  57237. /**
  57238. * Agent height. [Limit: > 0]
  57239. */
  57240. height: number;
  57241. /**
  57242. * Maximum allowed acceleration. [Limit: >= 0]
  57243. */
  57244. maxAcceleration: number;
  57245. /**
  57246. * Maximum allowed speed. [Limit: >= 0]
  57247. */
  57248. maxSpeed: number;
  57249. /**
  57250. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57251. */
  57252. collisionQueryRange: number;
  57253. /**
  57254. * The path visibility optimization range. [Limit: > 0]
  57255. */
  57256. pathOptimizationRange: number;
  57257. /**
  57258. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57259. */
  57260. separationWeight: number;
  57261. }
  57262. /**
  57263. * Configures the navigation mesh creation
  57264. */
  57265. export interface INavMeshParameters {
  57266. /**
  57267. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57268. */
  57269. cs: number;
  57270. /**
  57271. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57272. */
  57273. ch: number;
  57274. /**
  57275. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57276. */
  57277. walkableSlopeAngle: number;
  57278. /**
  57279. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57280. * be considered walkable. [Limit: >= 3] [Units: vx]
  57281. */
  57282. walkableHeight: number;
  57283. /**
  57284. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57285. */
  57286. walkableClimb: number;
  57287. /**
  57288. * The distance to erode/shrink the walkable area of the heightfield away from
  57289. * obstructions. [Limit: >=0] [Units: vx]
  57290. */
  57291. walkableRadius: number;
  57292. /**
  57293. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57294. */
  57295. maxEdgeLen: number;
  57296. /**
  57297. * The maximum distance a simplfied contour's border edges should deviate
  57298. * the original raw contour. [Limit: >=0] [Units: vx]
  57299. */
  57300. maxSimplificationError: number;
  57301. /**
  57302. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57303. */
  57304. minRegionArea: number;
  57305. /**
  57306. * Any regions with a span count smaller than this value will, if possible,
  57307. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57308. */
  57309. mergeRegionArea: number;
  57310. /**
  57311. * The maximum number of vertices allowed for polygons generated during the
  57312. * contour to polygon conversion process. [Limit: >= 3]
  57313. */
  57314. maxVertsPerPoly: number;
  57315. /**
  57316. * Sets the sampling distance to use when generating the detail mesh.
  57317. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57318. */
  57319. detailSampleDist: number;
  57320. /**
  57321. * The maximum distance the detail mesh surface should deviate from heightfield
  57322. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57323. */
  57324. detailSampleMaxError: number;
  57325. }
  57326. }
  57327. declare module BABYLON {
  57328. /**
  57329. * RecastJS navigation plugin
  57330. */
  57331. export class RecastJSPlugin implements INavigationEnginePlugin {
  57332. /**
  57333. * Reference to the Recast library
  57334. */
  57335. bjsRECAST: any;
  57336. /**
  57337. * plugin name
  57338. */
  57339. name: string;
  57340. /**
  57341. * the first navmesh created. We might extend this to support multiple navmeshes
  57342. */
  57343. navMesh: any;
  57344. /**
  57345. * Initializes the recastJS plugin
  57346. * @param recastInjection can be used to inject your own recast reference
  57347. */
  57348. constructor(recastInjection?: any);
  57349. /**
  57350. * Creates a navigation mesh
  57351. * @param meshes array of all the geometry used to compute the navigatio mesh
  57352. * @param parameters bunch of parameters used to filter geometry
  57353. */
  57354. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57355. /**
  57356. * Create a navigation mesh debug mesh
  57357. * @param scene is where the mesh will be added
  57358. * @returns debug display mesh
  57359. */
  57360. createDebugNavMesh(scene: Scene): Mesh;
  57361. /**
  57362. * Get a navigation mesh constrained position, closest to the parameter position
  57363. * @param position world position
  57364. * @returns the closest point to position constrained by the navigation mesh
  57365. */
  57366. getClosestPoint(position: Vector3): Vector3;
  57367. /**
  57368. * Get a navigation mesh constrained position, within a particular radius
  57369. * @param position world position
  57370. * @param maxRadius the maximum distance to the constrained world position
  57371. * @returns the closest point to position constrained by the navigation mesh
  57372. */
  57373. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57374. /**
  57375. * Compute the final position from a segment made of destination-position
  57376. * @param position world position
  57377. * @param destination world position
  57378. * @returns the resulting point along the navmesh
  57379. */
  57380. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57381. /**
  57382. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57383. * @param start world position
  57384. * @param end world position
  57385. * @returns array containing world position composing the path
  57386. */
  57387. computePath(start: Vector3, end: Vector3): Vector3[];
  57388. /**
  57389. * Create a new Crowd so you can add agents
  57390. * @param maxAgents the maximum agent count in the crowd
  57391. * @param maxAgentRadius the maximum radius an agent can have
  57392. * @param scene to attach the crowd to
  57393. * @returns the crowd you can add agents to
  57394. */
  57395. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57396. /**
  57397. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57398. * The queries will try to find a solution within those bounds
  57399. * default is (1,1,1)
  57400. * @param extent x,y,z value that define the extent around the queries point of reference
  57401. */
  57402. setDefaultQueryExtent(extent: Vector3): void;
  57403. /**
  57404. * Get the Bounding box extent specified by setDefaultQueryExtent
  57405. * @returns the box extent values
  57406. */
  57407. getDefaultQueryExtent(): Vector3;
  57408. /**
  57409. * Disposes
  57410. */
  57411. dispose(): void;
  57412. /**
  57413. * If this plugin is supported
  57414. * @returns true if plugin is supported
  57415. */
  57416. isSupported(): boolean;
  57417. }
  57418. /**
  57419. * Recast detour crowd implementation
  57420. */
  57421. export class RecastJSCrowd implements ICrowd {
  57422. /**
  57423. * Recast/detour plugin
  57424. */
  57425. bjsRECASTPlugin: RecastJSPlugin;
  57426. /**
  57427. * Link to the detour crowd
  57428. */
  57429. recastCrowd: any;
  57430. /**
  57431. * One transform per agent
  57432. */
  57433. transforms: TransformNode[];
  57434. /**
  57435. * All agents created
  57436. */
  57437. agents: number[];
  57438. /**
  57439. * Link to the scene is kept to unregister the crowd from the scene
  57440. */
  57441. private _scene;
  57442. /**
  57443. * Observer for crowd updates
  57444. */
  57445. private _onBeforeAnimationsObserver;
  57446. /**
  57447. * Constructor
  57448. * @param plugin recastJS plugin
  57449. * @param maxAgents the maximum agent count in the crowd
  57450. * @param maxAgentRadius the maximum radius an agent can have
  57451. * @param scene to attach the crowd to
  57452. * @returns the crowd you can add agents to
  57453. */
  57454. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57455. /**
  57456. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57457. * You can attach anything to that node. The node position is updated in the scene update tick.
  57458. * @param pos world position that will be constrained by the navigation mesh
  57459. * @param parameters agent parameters
  57460. * @param transform hooked to the agent that will be update by the scene
  57461. * @returns agent index
  57462. */
  57463. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57464. /**
  57465. * Returns the agent position in world space
  57466. * @param index agent index returned by addAgent
  57467. * @returns world space position
  57468. */
  57469. getAgentPosition(index: number): Vector3;
  57470. /**
  57471. * Returns the agent velocity in world space
  57472. * @param index agent index returned by addAgent
  57473. * @returns world space velocity
  57474. */
  57475. getAgentVelocity(index: number): Vector3;
  57476. /**
  57477. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57478. * @param index agent index returned by addAgent
  57479. * @param destination targeted world position
  57480. */
  57481. agentGoto(index: number, destination: Vector3): void;
  57482. /**
  57483. * remove a particular agent previously created
  57484. * @param index agent index returned by addAgent
  57485. */
  57486. removeAgent(index: number): void;
  57487. /**
  57488. * get the list of all agents attached to this crowd
  57489. * @returns list of agent indices
  57490. */
  57491. getAgents(): number[];
  57492. /**
  57493. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57494. * @param deltaTime in seconds
  57495. */
  57496. update(deltaTime: number): void;
  57497. /**
  57498. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57499. * The queries will try to find a solution within those bounds
  57500. * default is (1,1,1)
  57501. * @param extent x,y,z value that define the extent around the queries point of reference
  57502. */
  57503. setDefaultQueryExtent(extent: Vector3): void;
  57504. /**
  57505. * Get the Bounding box extent specified by setDefaultQueryExtent
  57506. * @returns the box extent values
  57507. */
  57508. getDefaultQueryExtent(): Vector3;
  57509. /**
  57510. * Release all resources
  57511. */
  57512. dispose(): void;
  57513. }
  57514. }
  57515. declare module BABYLON {
  57516. /**
  57517. * Class used to enable access to IndexedDB
  57518. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57519. */
  57520. export class Database implements IOfflineProvider {
  57521. private _callbackManifestChecked;
  57522. private _currentSceneUrl;
  57523. private _db;
  57524. private _enableSceneOffline;
  57525. private _enableTexturesOffline;
  57526. private _manifestVersionFound;
  57527. private _mustUpdateRessources;
  57528. private _hasReachedQuota;
  57529. private _isSupported;
  57530. private _idbFactory;
  57531. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57532. private static IsUASupportingBlobStorage;
  57533. /**
  57534. * Gets a boolean indicating if Database storate is enabled (off by default)
  57535. */
  57536. static IDBStorageEnabled: boolean;
  57537. /**
  57538. * Gets a boolean indicating if scene must be saved in the database
  57539. */
  57540. readonly enableSceneOffline: boolean;
  57541. /**
  57542. * Gets a boolean indicating if textures must be saved in the database
  57543. */
  57544. readonly enableTexturesOffline: boolean;
  57545. /**
  57546. * Creates a new Database
  57547. * @param urlToScene defines the url to load the scene
  57548. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57549. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57550. */
  57551. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57552. private static _ParseURL;
  57553. private static _ReturnFullUrlLocation;
  57554. private _checkManifestFile;
  57555. /**
  57556. * Open the database and make it available
  57557. * @param successCallback defines the callback to call on success
  57558. * @param errorCallback defines the callback to call on error
  57559. */
  57560. open(successCallback: () => void, errorCallback: () => void): void;
  57561. /**
  57562. * Loads an image from the database
  57563. * @param url defines the url to load from
  57564. * @param image defines the target DOM image
  57565. */
  57566. loadImage(url: string, image: HTMLImageElement): void;
  57567. private _loadImageFromDBAsync;
  57568. private _saveImageIntoDBAsync;
  57569. private _checkVersionFromDB;
  57570. private _loadVersionFromDBAsync;
  57571. private _saveVersionIntoDBAsync;
  57572. /**
  57573. * Loads a file from database
  57574. * @param url defines the URL to load from
  57575. * @param sceneLoaded defines a callback to call on success
  57576. * @param progressCallBack defines a callback to call when progress changed
  57577. * @param errorCallback defines a callback to call on error
  57578. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57579. */
  57580. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57581. private _loadFileAsync;
  57582. private _saveFileAsync;
  57583. /**
  57584. * Validates if xhr data is correct
  57585. * @param xhr defines the request to validate
  57586. * @param dataType defines the expected data type
  57587. * @returns true if data is correct
  57588. */
  57589. private static _ValidateXHRData;
  57590. }
  57591. }
  57592. declare module BABYLON {
  57593. /** @hidden */
  57594. export var gpuUpdateParticlesPixelShader: {
  57595. name: string;
  57596. shader: string;
  57597. };
  57598. }
  57599. declare module BABYLON {
  57600. /** @hidden */
  57601. export var gpuUpdateParticlesVertexShader: {
  57602. name: string;
  57603. shader: string;
  57604. };
  57605. }
  57606. declare module BABYLON {
  57607. /** @hidden */
  57608. export var clipPlaneFragmentDeclaration2: {
  57609. name: string;
  57610. shader: string;
  57611. };
  57612. }
  57613. declare module BABYLON {
  57614. /** @hidden */
  57615. export var gpuRenderParticlesPixelShader: {
  57616. name: string;
  57617. shader: string;
  57618. };
  57619. }
  57620. declare module BABYLON {
  57621. /** @hidden */
  57622. export var clipPlaneVertexDeclaration2: {
  57623. name: string;
  57624. shader: string;
  57625. };
  57626. }
  57627. declare module BABYLON {
  57628. /** @hidden */
  57629. export var gpuRenderParticlesVertexShader: {
  57630. name: string;
  57631. shader: string;
  57632. };
  57633. }
  57634. declare module BABYLON {
  57635. /**
  57636. * This represents a GPU particle system in Babylon
  57637. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57638. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57639. */
  57640. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57641. /**
  57642. * The layer mask we are rendering the particles through.
  57643. */
  57644. layerMask: number;
  57645. private _capacity;
  57646. private _activeCount;
  57647. private _currentActiveCount;
  57648. private _accumulatedCount;
  57649. private _renderEffect;
  57650. private _updateEffect;
  57651. private _buffer0;
  57652. private _buffer1;
  57653. private _spriteBuffer;
  57654. private _updateVAO;
  57655. private _renderVAO;
  57656. private _targetIndex;
  57657. private _sourceBuffer;
  57658. private _targetBuffer;
  57659. private _engine;
  57660. private _currentRenderId;
  57661. private _started;
  57662. private _stopped;
  57663. private _timeDelta;
  57664. private _randomTexture;
  57665. private _randomTexture2;
  57666. private _attributesStrideSize;
  57667. private _updateEffectOptions;
  57668. private _randomTextureSize;
  57669. private _actualFrame;
  57670. private readonly _rawTextureWidth;
  57671. /**
  57672. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57673. */
  57674. static readonly IsSupported: boolean;
  57675. /**
  57676. * An event triggered when the system is disposed.
  57677. */
  57678. onDisposeObservable: Observable<GPUParticleSystem>;
  57679. /**
  57680. * Gets the maximum number of particles active at the same time.
  57681. * @returns The max number of active particles.
  57682. */
  57683. getCapacity(): number;
  57684. /**
  57685. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57686. * to override the particles.
  57687. */
  57688. forceDepthWrite: boolean;
  57689. /**
  57690. * Gets or set the number of active particles
  57691. */
  57692. activeParticleCount: number;
  57693. private _preWarmDone;
  57694. /**
  57695. * Is this system ready to be used/rendered
  57696. * @return true if the system is ready
  57697. */
  57698. isReady(): boolean;
  57699. /**
  57700. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57701. * @returns True if it has been started, otherwise false.
  57702. */
  57703. isStarted(): boolean;
  57704. /**
  57705. * Starts the particle system and begins to emit
  57706. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57707. */
  57708. start(delay?: number): void;
  57709. /**
  57710. * Stops the particle system.
  57711. */
  57712. stop(): void;
  57713. /**
  57714. * Remove all active particles
  57715. */
  57716. reset(): void;
  57717. /**
  57718. * Returns the string "GPUParticleSystem"
  57719. * @returns a string containing the class name
  57720. */
  57721. getClassName(): string;
  57722. private _colorGradientsTexture;
  57723. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57724. /**
  57725. * Adds a new color gradient
  57726. * @param gradient defines the gradient to use (between 0 and 1)
  57727. * @param color1 defines the color to affect to the specified gradient
  57728. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57729. * @returns the current particle system
  57730. */
  57731. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57732. /**
  57733. * Remove a specific color gradient
  57734. * @param gradient defines the gradient to remove
  57735. * @returns the current particle system
  57736. */
  57737. removeColorGradient(gradient: number): GPUParticleSystem;
  57738. private _angularSpeedGradientsTexture;
  57739. private _sizeGradientsTexture;
  57740. private _velocityGradientsTexture;
  57741. private _limitVelocityGradientsTexture;
  57742. private _dragGradientsTexture;
  57743. private _addFactorGradient;
  57744. /**
  57745. * Adds a new size gradient
  57746. * @param gradient defines the gradient to use (between 0 and 1)
  57747. * @param factor defines the size factor to affect to the specified gradient
  57748. * @returns the current particle system
  57749. */
  57750. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57751. /**
  57752. * Remove a specific size gradient
  57753. * @param gradient defines the gradient to remove
  57754. * @returns the current particle system
  57755. */
  57756. removeSizeGradient(gradient: number): GPUParticleSystem;
  57757. /**
  57758. * Adds a new angular speed gradient
  57759. * @param gradient defines the gradient to use (between 0 and 1)
  57760. * @param factor defines the angular speed to affect to the specified gradient
  57761. * @returns the current particle system
  57762. */
  57763. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57764. /**
  57765. * Remove a specific angular speed gradient
  57766. * @param gradient defines the gradient to remove
  57767. * @returns the current particle system
  57768. */
  57769. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57770. /**
  57771. * Adds a new velocity gradient
  57772. * @param gradient defines the gradient to use (between 0 and 1)
  57773. * @param factor defines the velocity to affect to the specified gradient
  57774. * @returns the current particle system
  57775. */
  57776. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57777. /**
  57778. * Remove a specific velocity gradient
  57779. * @param gradient defines the gradient to remove
  57780. * @returns the current particle system
  57781. */
  57782. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57783. /**
  57784. * Adds a new limit velocity gradient
  57785. * @param gradient defines the gradient to use (between 0 and 1)
  57786. * @param factor defines the limit velocity value to affect to the specified gradient
  57787. * @returns the current particle system
  57788. */
  57789. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57790. /**
  57791. * Remove a specific limit velocity gradient
  57792. * @param gradient defines the gradient to remove
  57793. * @returns the current particle system
  57794. */
  57795. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57796. /**
  57797. * Adds a new drag gradient
  57798. * @param gradient defines the gradient to use (between 0 and 1)
  57799. * @param factor defines the drag value to affect to the specified gradient
  57800. * @returns the current particle system
  57801. */
  57802. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57803. /**
  57804. * Remove a specific drag gradient
  57805. * @param gradient defines the gradient to remove
  57806. * @returns the current particle system
  57807. */
  57808. removeDragGradient(gradient: number): GPUParticleSystem;
  57809. /**
  57810. * Not supported by GPUParticleSystem
  57811. * @param gradient defines the gradient to use (between 0 and 1)
  57812. * @param factor defines the emit rate value to affect to the specified gradient
  57813. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57814. * @returns the current particle system
  57815. */
  57816. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57817. /**
  57818. * Not supported by GPUParticleSystem
  57819. * @param gradient defines the gradient to remove
  57820. * @returns the current particle system
  57821. */
  57822. removeEmitRateGradient(gradient: number): IParticleSystem;
  57823. /**
  57824. * Not supported by GPUParticleSystem
  57825. * @param gradient defines the gradient to use (between 0 and 1)
  57826. * @param factor defines the start size value to affect to the specified gradient
  57827. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57828. * @returns the current particle system
  57829. */
  57830. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57831. /**
  57832. * Not supported by GPUParticleSystem
  57833. * @param gradient defines the gradient to remove
  57834. * @returns the current particle system
  57835. */
  57836. removeStartSizeGradient(gradient: number): IParticleSystem;
  57837. /**
  57838. * Not supported by GPUParticleSystem
  57839. * @param gradient defines the gradient to use (between 0 and 1)
  57840. * @param min defines the color remap minimal range
  57841. * @param max defines the color remap maximal range
  57842. * @returns the current particle system
  57843. */
  57844. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57845. /**
  57846. * Not supported by GPUParticleSystem
  57847. * @param gradient defines the gradient to remove
  57848. * @returns the current particle system
  57849. */
  57850. removeColorRemapGradient(): IParticleSystem;
  57851. /**
  57852. * Not supported by GPUParticleSystem
  57853. * @param gradient defines the gradient to use (between 0 and 1)
  57854. * @param min defines the alpha remap minimal range
  57855. * @param max defines the alpha remap maximal range
  57856. * @returns the current particle system
  57857. */
  57858. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57859. /**
  57860. * Not supported by GPUParticleSystem
  57861. * @param gradient defines the gradient to remove
  57862. * @returns the current particle system
  57863. */
  57864. removeAlphaRemapGradient(): IParticleSystem;
  57865. /**
  57866. * Not supported by GPUParticleSystem
  57867. * @param gradient defines the gradient to use (between 0 and 1)
  57868. * @param color defines the color to affect to the specified gradient
  57869. * @returns the current particle system
  57870. */
  57871. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57872. /**
  57873. * Not supported by GPUParticleSystem
  57874. * @param gradient defines the gradient to remove
  57875. * @returns the current particle system
  57876. */
  57877. removeRampGradient(): IParticleSystem;
  57878. /**
  57879. * Not supported by GPUParticleSystem
  57880. * @returns the list of ramp gradients
  57881. */
  57882. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57883. /**
  57884. * Not supported by GPUParticleSystem
  57885. * Gets or sets a boolean indicating that ramp gradients must be used
  57886. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57887. */
  57888. useRampGradients: boolean;
  57889. /**
  57890. * Not supported by GPUParticleSystem
  57891. * @param gradient defines the gradient to use (between 0 and 1)
  57892. * @param factor defines the life time factor to affect to the specified gradient
  57893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57894. * @returns the current particle system
  57895. */
  57896. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57897. /**
  57898. * Not supported by GPUParticleSystem
  57899. * @param gradient defines the gradient to remove
  57900. * @returns the current particle system
  57901. */
  57902. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57903. /**
  57904. * Instantiates a GPU particle system.
  57905. * 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.
  57906. * @param name The name of the particle system
  57907. * @param options The options used to create the system
  57908. * @param scene The scene the particle system belongs to
  57909. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57910. */
  57911. constructor(name: string, options: Partial<{
  57912. capacity: number;
  57913. randomTextureSize: number;
  57914. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57915. protected _reset(): void;
  57916. private _createUpdateVAO;
  57917. private _createRenderVAO;
  57918. private _initialize;
  57919. /** @hidden */ private _recreateUpdateEffect(): void;
  57920. /** @hidden */ private _recreateRenderEffect(): void;
  57921. /**
  57922. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57923. * @param preWarm defines if we are in the pre-warmimg phase
  57924. */
  57925. animate(preWarm?: boolean): void;
  57926. private _createFactorGradientTexture;
  57927. private _createSizeGradientTexture;
  57928. private _createAngularSpeedGradientTexture;
  57929. private _createVelocityGradientTexture;
  57930. private _createLimitVelocityGradientTexture;
  57931. private _createDragGradientTexture;
  57932. private _createColorGradientTexture;
  57933. /**
  57934. * Renders the particle system in its current state
  57935. * @param preWarm defines if the system should only update the particles but not render them
  57936. * @returns the current number of particles
  57937. */
  57938. render(preWarm?: boolean): number;
  57939. /**
  57940. * Rebuilds the particle system
  57941. */
  57942. rebuild(): void;
  57943. private _releaseBuffers;
  57944. private _releaseVAOs;
  57945. /**
  57946. * Disposes the particle system and free the associated resources
  57947. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57948. */
  57949. dispose(disposeTexture?: boolean): void;
  57950. /**
  57951. * Clones the particle system.
  57952. * @param name The name of the cloned object
  57953. * @param newEmitter The new emitter to use
  57954. * @returns the cloned particle system
  57955. */
  57956. clone(name: string, newEmitter: any): GPUParticleSystem;
  57957. /**
  57958. * Serializes the particle system to a JSON object.
  57959. * @returns the JSON object
  57960. */
  57961. serialize(): any;
  57962. /**
  57963. * Parses a JSON object to create a GPU particle system.
  57964. * @param parsedParticleSystem The JSON object to parse
  57965. * @param scene The scene to create the particle system in
  57966. * @param rootUrl The root url to use to load external dependencies like texture
  57967. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57968. * @returns the parsed GPU particle system
  57969. */
  57970. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57971. }
  57972. }
  57973. declare module BABYLON {
  57974. /**
  57975. * Represents a set of particle systems working together to create a specific effect
  57976. */
  57977. export class ParticleSystemSet implements IDisposable {
  57978. /**
  57979. * Gets or sets base Assets URL
  57980. */
  57981. static BaseAssetsUrl: string;
  57982. private _emitterCreationOptions;
  57983. private _emitterNode;
  57984. /**
  57985. * Gets the particle system list
  57986. */
  57987. systems: IParticleSystem[];
  57988. /**
  57989. * Gets the emitter node used with this set
  57990. */
  57991. readonly emitterNode: Nullable<TransformNode>;
  57992. /**
  57993. * Creates a new emitter mesh as a sphere
  57994. * @param options defines the options used to create the sphere
  57995. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57996. * @param scene defines the hosting scene
  57997. */
  57998. setEmitterAsSphere(options: {
  57999. diameter: number;
  58000. segments: number;
  58001. color: Color3;
  58002. }, renderingGroupId: number, scene: Scene): void;
  58003. /**
  58004. * Starts all particle systems of the set
  58005. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58006. */
  58007. start(emitter?: AbstractMesh): void;
  58008. /**
  58009. * Release all associated resources
  58010. */
  58011. dispose(): void;
  58012. /**
  58013. * Serialize the set into a JSON compatible object
  58014. * @returns a JSON compatible representation of the set
  58015. */
  58016. serialize(): any;
  58017. /**
  58018. * Parse a new ParticleSystemSet from a serialized source
  58019. * @param data defines a JSON compatible representation of the set
  58020. * @param scene defines the hosting scene
  58021. * @param gpu defines if we want GPU particles or CPU particles
  58022. * @returns a new ParticleSystemSet
  58023. */
  58024. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58025. }
  58026. }
  58027. declare module BABYLON {
  58028. /**
  58029. * This class is made for on one-liner static method to help creating particle system set.
  58030. */
  58031. export class ParticleHelper {
  58032. /**
  58033. * Gets or sets base Assets URL
  58034. */
  58035. static BaseAssetsUrl: string;
  58036. /**
  58037. * Create a default particle system that you can tweak
  58038. * @param emitter defines the emitter to use
  58039. * @param capacity defines the system capacity (default is 500 particles)
  58040. * @param scene defines the hosting scene
  58041. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58042. * @returns the new Particle system
  58043. */
  58044. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58045. /**
  58046. * This is the main static method (one-liner) of this helper to create different particle systems
  58047. * @param type This string represents the type to the particle system to create
  58048. * @param scene The scene where the particle system should live
  58049. * @param gpu If the system will use gpu
  58050. * @returns the ParticleSystemSet created
  58051. */
  58052. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58053. /**
  58054. * Static function used to export a particle system to a ParticleSystemSet variable.
  58055. * Please note that the emitter shape is not exported
  58056. * @param systems defines the particle systems to export
  58057. * @returns the created particle system set
  58058. */
  58059. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58060. }
  58061. }
  58062. declare module BABYLON {
  58063. interface Engine {
  58064. /**
  58065. * Create an effect to use with particle systems.
  58066. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58067. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58068. * @param uniformsNames defines a list of attribute names
  58069. * @param samplers defines an array of string used to represent textures
  58070. * @param defines defines the string containing the defines to use to compile the shaders
  58071. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58072. * @param onCompiled defines a function to call when the effect creation is successful
  58073. * @param onError defines a function to call when the effect creation has failed
  58074. * @returns the new Effect
  58075. */
  58076. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58077. }
  58078. interface Mesh {
  58079. /**
  58080. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58081. * @returns an array of IParticleSystem
  58082. */
  58083. getEmittedParticleSystems(): IParticleSystem[];
  58084. /**
  58085. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58086. * @returns an array of IParticleSystem
  58087. */
  58088. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58089. }
  58090. /**
  58091. * @hidden
  58092. */
  58093. export var _IDoNeedToBeInTheBuild: number;
  58094. }
  58095. declare module BABYLON {
  58096. /** Defines the 4 color options */
  58097. export enum PointColor {
  58098. /** color value */
  58099. Color = 2,
  58100. /** uv value */
  58101. UV = 1,
  58102. /** random value */
  58103. Random = 0,
  58104. /** stated value */
  58105. Stated = 3
  58106. }
  58107. /**
  58108. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  58109. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  58110. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  58111. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  58112. *
  58113. * Full documentation here : TO BE ENTERED
  58114. */
  58115. export class PointsCloudSystem implements IDisposable {
  58116. /**
  58117. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  58118. * Example : var p = SPS.particles[i];
  58119. */
  58120. particles: CloudPoint[];
  58121. /**
  58122. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  58123. */
  58124. nbParticles: number;
  58125. /**
  58126. * This a counter for your own usage. It's not set by any SPS functions.
  58127. */
  58128. counter: number;
  58129. /**
  58130. * The PCS name. This name is also given to the underlying mesh.
  58131. */
  58132. name: string;
  58133. /**
  58134. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  58135. */
  58136. mesh: Mesh;
  58137. /**
  58138. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  58139. * Please read :
  58140. */
  58141. vars: any;
  58142. /**
  58143. * @hidden
  58144. */ private _size: number;
  58145. private _scene;
  58146. private _promises;
  58147. private _positions;
  58148. private _indices;
  58149. private _normals;
  58150. private _colors;
  58151. private _uvs;
  58152. private _indices32;
  58153. private _positions32;
  58154. private _colors32;
  58155. private _uvs32;
  58156. private _updatable;
  58157. private _isVisibilityBoxLocked;
  58158. private _alwaysVisible;
  58159. private _groups;
  58160. private _groupCounter;
  58161. private _computeParticleColor;
  58162. private _computeParticleTexture;
  58163. private _computeParticleRotation;
  58164. private _computeBoundingBox;
  58165. private _isReady;
  58166. /**
  58167. * Creates a PCS (Points Cloud System) object
  58168. * @param name (String) is the PCS name, this will be the underlying mesh name
  58169. * @param pointSize (number) is the size for each point
  58170. * @param scene (Scene) is the scene in which the PCS is added
  58171. * @param options defines the options of the PCS e.g.
  58172. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  58173. */
  58174. constructor(name: string, pointSize: number, scene: Scene, options?: {
  58175. updatable?: boolean;
  58176. });
  58177. /**
  58178. * Builds the PCS underlying mesh. Returns a standard Mesh.
  58179. * If no points were added to the PCS, the returned mesh is just a single point.
  58180. * @returns a promise for the created mesh
  58181. */
  58182. buildMeshAsync(): Promise<Mesh>;
  58183. /**
  58184. * @hidden
  58185. */
  58186. private _buildMesh;
  58187. private _addParticle;
  58188. private _randomUnitVector;
  58189. private _getColorIndicesForCoord;
  58190. private _setPointsColorOrUV;
  58191. private _colorFromTexture;
  58192. private _calculateDensity;
  58193. /**
  58194. * Adds points to the PCS in random positions within a unit sphere
  58195. * @param nb (positive integer) the number of particles to be created from this model
  58196. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  58197. * @returns the number of groups in the system
  58198. */
  58199. addPoints(nb: number, pointFunction?: any): number;
  58200. /**
  58201. * Adds points to the PCS from the surface of the model shape
  58202. * @param mesh is any Mesh object that will be used as a surface model for the points
  58203. * @param nb (positive integer) the number of particles to be created from this model
  58204. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  58205. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  58206. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58207. * @returns the number of groups in the system
  58208. */
  58209. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  58210. /**
  58211. * Adds points to the PCS inside the model shape
  58212. * @param mesh is any Mesh object that will be used as a surface model for the points
  58213. * @param nb (positive integer) the number of particles to be created from this model
  58214. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  58215. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  58216. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58217. * @returns the number of groups in the system
  58218. */
  58219. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  58220. /**
  58221. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  58222. * This method calls `updateParticle()` for each particle of the SPS.
  58223. * For an animated SPS, it is usually called within the render loop.
  58224. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  58225. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  58226. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  58227. * @returns the PCS.
  58228. */
  58229. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  58230. /**
  58231. * Disposes the PCS.
  58232. */
  58233. dispose(): void;
  58234. /**
  58235. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  58236. * doc :
  58237. * @returns the PCS.
  58238. */
  58239. refreshVisibleSize(): PointsCloudSystem;
  58240. /**
  58241. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  58242. * @param size the size (float) of the visibility box
  58243. * note : this doesn't lock the PCS mesh bounding box.
  58244. * doc :
  58245. */
  58246. setVisibilityBox(size: number): void;
  58247. /**
  58248. * Gets whether the PCS is always visible or not
  58249. * doc :
  58250. */
  58251. /**
  58252. * Sets the PCS as always visible or not
  58253. * doc :
  58254. */
  58255. isAlwaysVisible: boolean;
  58256. /**
  58257. * Tells to `setParticles()` to compute the particle rotations or not
  58258. * Default value : false. The PCS is faster when it's set to false
  58259. * Note : particle rotations are only applied to parent particles
  58260. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  58261. */
  58262. computeParticleRotation: boolean;
  58263. /**
  58264. * Tells to `setParticles()` to compute the particle colors or not.
  58265. * Default value : true. The PCS is faster when it's set to false.
  58266. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58267. */
  58268. /**
  58269. * Gets if `setParticles()` computes the particle colors or not.
  58270. * Default value : false. The PCS is faster when it's set to false.
  58271. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58272. */
  58273. computeParticleColor: boolean;
  58274. /**
  58275. * Gets if `setParticles()` computes the particle textures or not.
  58276. * Default value : false. The PCS is faster when it's set to false.
  58277. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  58278. */
  58279. computeParticleTexture: boolean;
  58280. /**
  58281. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  58282. */
  58283. /**
  58284. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  58285. */
  58286. computeBoundingBox: boolean;
  58287. /**
  58288. * This function does nothing. It may be overwritten to set all the particle first values.
  58289. * The PCS doesn't call this function, you may have to call it by your own.
  58290. * doc :
  58291. */
  58292. initParticles(): void;
  58293. /**
  58294. * This function does nothing. It may be overwritten to recycle a particle
  58295. * The PCS doesn't call this function, you can to call it
  58296. * doc :
  58297. * @param particle The particle to recycle
  58298. * @returns the recycled particle
  58299. */
  58300. recycleParticle(particle: CloudPoint): CloudPoint;
  58301. /**
  58302. * Updates a particle : this function should be overwritten by the user.
  58303. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  58304. * doc :
  58305. * @example : just set a particle position or velocity and recycle conditions
  58306. * @param particle The particle to update
  58307. * @returns the updated particle
  58308. */
  58309. updateParticle(particle: CloudPoint): CloudPoint;
  58310. /**
  58311. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  58312. * This does nothing and may be overwritten by the user.
  58313. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58314. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58315. * @param update the boolean update value actually passed to setParticles()
  58316. */
  58317. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58318. /**
  58319. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  58320. * This will be passed three parameters.
  58321. * This does nothing and may be overwritten by the user.
  58322. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58323. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58324. * @param update the boolean update value actually passed to setParticles()
  58325. */
  58326. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58327. }
  58328. }
  58329. declare module BABYLON {
  58330. /**
  58331. * Represents one particle of a points cloud system.
  58332. */
  58333. export class CloudPoint {
  58334. /**
  58335. * particle global index
  58336. */
  58337. idx: number;
  58338. /**
  58339. * The color of the particle
  58340. */
  58341. color: Nullable<Color4>;
  58342. /**
  58343. * The world space position of the particle.
  58344. */
  58345. position: Vector3;
  58346. /**
  58347. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  58348. */
  58349. rotation: Vector3;
  58350. /**
  58351. * The world space rotation quaternion of the particle.
  58352. */
  58353. rotationQuaternion: Nullable<Quaternion>;
  58354. /**
  58355. * The uv of the particle.
  58356. */
  58357. uv: Nullable<Vector2>;
  58358. /**
  58359. * The current speed of the particle.
  58360. */
  58361. velocity: Vector3;
  58362. /**
  58363. * The pivot point in the particle local space.
  58364. */
  58365. pivot: Vector3;
  58366. /**
  58367. * Must the particle be translated from its pivot point in its local space ?
  58368. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  58369. * Default : false
  58370. */
  58371. translateFromPivot: boolean;
  58372. /**
  58373. * Index of this particle in the global "positions" array (Internal use)
  58374. * @hidden
  58375. */ private _pos: number;
  58376. /**
  58377. * @hidden Index of this particle in the global "indices" array (Internal use)
  58378. */ private _ind: number;
  58379. /**
  58380. * Group this particle belongs to
  58381. */ private _group: PointsGroup;
  58382. /**
  58383. * Group id of this particle
  58384. */
  58385. groupId: number;
  58386. /**
  58387. * Index of the particle in its group id (Internal use)
  58388. */
  58389. idxInGroup: number;
  58390. /**
  58391. * @hidden Particle BoundingInfo object (Internal use)
  58392. */ private _boundingInfo: BoundingInfo;
  58393. /**
  58394. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  58395. */ private _pcs: PointsCloudSystem;
  58396. /**
  58397. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  58398. */ private _stillInvisible: boolean;
  58399. /**
  58400. * @hidden Last computed particle rotation matrix
  58401. */ private _rotationMatrix: number[];
  58402. /**
  58403. * Parent particle Id, if any.
  58404. * Default null.
  58405. */
  58406. parentId: Nullable<number>;
  58407. /**
  58408. * @hidden Internal global position in the PCS.
  58409. */ private _globalPosition: Vector3;
  58410. /**
  58411. * Creates a Point Cloud object.
  58412. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  58413. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  58414. * @param group (PointsGroup) is the group the particle belongs to
  58415. * @param groupId (integer) is the group identifier in the PCS.
  58416. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  58417. * @param pcs defines the PCS it is associated to
  58418. */
  58419. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  58420. /**
  58421. * get point size
  58422. */
  58423. /**
  58424. * Set point size
  58425. */
  58426. size: Vector3;
  58427. /**
  58428. * Legacy support, changed quaternion to rotationQuaternion
  58429. */
  58430. /**
  58431. * Legacy support, changed quaternion to rotationQuaternion
  58432. */
  58433. quaternion: Nullable<Quaternion>;
  58434. /**
  58435. * Returns a boolean. True if the particle intersects a mesh, else false
  58436. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  58437. * @param target is the object (point or mesh) what the intersection is computed against
  58438. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  58439. * @returns true if it intersects
  58440. */
  58441. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  58442. /**
  58443. * get the rotation matrix of the particle
  58444. * @hidden
  58445. */
  58446. getRotationMatrix(m: Matrix): void;
  58447. }
  58448. /**
  58449. * Represents a group of points in a points cloud system
  58450. * * PCS internal tool, don't use it manually.
  58451. */
  58452. export class PointsGroup {
  58453. /**
  58454. * The group id
  58455. * @hidden
  58456. */
  58457. groupID: number;
  58458. /**
  58459. * image data for group (internal use)
  58460. * @hidden
  58461. */ private _groupImageData: Nullable<ArrayBufferView>;
  58462. /**
  58463. * Image Width (internal use)
  58464. * @hidden
  58465. */ private _groupImgWidth: number;
  58466. /**
  58467. * Image Height (internal use)
  58468. * @hidden
  58469. */ private _groupImgHeight: number;
  58470. /**
  58471. * Custom position function (internal use)
  58472. * @hidden
  58473. */ private _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  58474. /**
  58475. * density per facet for surface points
  58476. * @hidden
  58477. */ private _groupDensity: number[];
  58478. /**
  58479. * Only when points are colored by texture carries pointer to texture list array
  58480. * @hidden
  58481. */ private _textureNb: number;
  58482. /**
  58483. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  58484. * PCS internal tool, don't use it manually.
  58485. * @hidden
  58486. */
  58487. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  58488. }
  58489. }
  58490. declare module BABYLON {
  58491. interface Scene {
  58492. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  58493. /**
  58494. * Gets the current physics engine
  58495. * @returns a IPhysicsEngine or null if none attached
  58496. */
  58497. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58498. /**
  58499. * Enables physics to the current scene
  58500. * @param gravity defines the scene's gravity for the physics engine
  58501. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58502. * @return a boolean indicating if the physics engine was initialized
  58503. */
  58504. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58505. /**
  58506. * Disables and disposes the physics engine associated with the scene
  58507. */
  58508. disablePhysicsEngine(): void;
  58509. /**
  58510. * Gets a boolean indicating if there is an active physics engine
  58511. * @returns a boolean indicating if there is an active physics engine
  58512. */
  58513. isPhysicsEnabled(): boolean;
  58514. /**
  58515. * Deletes a physics compound impostor
  58516. * @param compound defines the compound to delete
  58517. */
  58518. deleteCompoundImpostor(compound: any): void;
  58519. /**
  58520. * An event triggered when physic simulation is about to be run
  58521. */
  58522. onBeforePhysicsObservable: Observable<Scene>;
  58523. /**
  58524. * An event triggered when physic simulation has been done
  58525. */
  58526. onAfterPhysicsObservable: Observable<Scene>;
  58527. }
  58528. interface AbstractMesh {
  58529. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  58530. /**
  58531. * Gets or sets impostor used for physic simulation
  58532. * @see http://doc.babylonjs.com/features/physics_engine
  58533. */
  58534. physicsImpostor: Nullable<PhysicsImpostor>;
  58535. /**
  58536. * Gets the current physics impostor
  58537. * @see http://doc.babylonjs.com/features/physics_engine
  58538. * @returns a physics impostor or null
  58539. */
  58540. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58541. /** Apply a physic impulse to the mesh
  58542. * @param force defines the force to apply
  58543. * @param contactPoint defines where to apply the force
  58544. * @returns the current mesh
  58545. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58546. */
  58547. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58548. /**
  58549. * Creates a physic joint between two meshes
  58550. * @param otherMesh defines the other mesh to use
  58551. * @param pivot1 defines the pivot to use on this mesh
  58552. * @param pivot2 defines the pivot to use on the other mesh
  58553. * @param options defines additional options (can be plugin dependent)
  58554. * @returns the current mesh
  58555. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58556. */
  58557. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58558. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  58559. }
  58560. /**
  58561. * Defines the physics engine scene component responsible to manage a physics engine
  58562. */
  58563. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58564. /**
  58565. * The component name helpful to identify the component in the list of scene components.
  58566. */
  58567. readonly name: string;
  58568. /**
  58569. * The scene the component belongs to.
  58570. */
  58571. scene: Scene;
  58572. /**
  58573. * Creates a new instance of the component for the given scene
  58574. * @param scene Defines the scene to register the component in
  58575. */
  58576. constructor(scene: Scene);
  58577. /**
  58578. * Registers the component in a given scene
  58579. */
  58580. register(): void;
  58581. /**
  58582. * Rebuilds the elements related to this component in case of
  58583. * context lost for instance.
  58584. */
  58585. rebuild(): void;
  58586. /**
  58587. * Disposes the component and the associated ressources
  58588. */
  58589. dispose(): void;
  58590. }
  58591. }
  58592. declare module BABYLON {
  58593. /**
  58594. * A helper for physics simulations
  58595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58596. */
  58597. export class PhysicsHelper {
  58598. private _scene;
  58599. private _physicsEngine;
  58600. /**
  58601. * Initializes the Physics helper
  58602. * @param scene Babylon.js scene
  58603. */
  58604. constructor(scene: Scene);
  58605. /**
  58606. * Applies a radial explosion impulse
  58607. * @param origin the origin of the explosion
  58608. * @param radiusOrEventOptions the radius or the options of radial explosion
  58609. * @param strength the explosion strength
  58610. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58611. * @returns A physics radial explosion event, or null
  58612. */
  58613. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58614. /**
  58615. * Applies a radial explosion force
  58616. * @param origin the origin of the explosion
  58617. * @param radiusOrEventOptions the radius or the options of radial explosion
  58618. * @param strength the explosion strength
  58619. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58620. * @returns A physics radial explosion event, or null
  58621. */
  58622. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58623. /**
  58624. * Creates a gravitational field
  58625. * @param origin the origin of the explosion
  58626. * @param radiusOrEventOptions the radius or the options of radial explosion
  58627. * @param strength the explosion strength
  58628. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58629. * @returns A physics gravitational field event, or null
  58630. */
  58631. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58632. /**
  58633. * Creates a physics updraft event
  58634. * @param origin the origin of the updraft
  58635. * @param radiusOrEventOptions the radius or the options of the updraft
  58636. * @param strength the strength of the updraft
  58637. * @param height the height of the updraft
  58638. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58639. * @returns A physics updraft event, or null
  58640. */
  58641. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58642. /**
  58643. * Creates a physics vortex event
  58644. * @param origin the of the vortex
  58645. * @param radiusOrEventOptions the radius or the options of the vortex
  58646. * @param strength the strength of the vortex
  58647. * @param height the height of the vortex
  58648. * @returns a Physics vortex event, or null
  58649. * A physics vortex event or null
  58650. */
  58651. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58652. }
  58653. /**
  58654. * Represents a physics radial explosion event
  58655. */
  58656. class PhysicsRadialExplosionEvent {
  58657. private _scene;
  58658. private _options;
  58659. private _sphere;
  58660. private _dataFetched;
  58661. /**
  58662. * Initializes a radial explosioin event
  58663. * @param _scene BabylonJS scene
  58664. * @param _options The options for the vortex event
  58665. */
  58666. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58667. /**
  58668. * Returns the data related to the radial explosion event (sphere).
  58669. * @returns The radial explosion event data
  58670. */
  58671. getData(): PhysicsRadialExplosionEventData;
  58672. /**
  58673. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58674. * @param impostor A physics imposter
  58675. * @param origin the origin of the explosion
  58676. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58677. */
  58678. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58679. /**
  58680. * Triggers affecterd impostors callbacks
  58681. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58682. */
  58683. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58684. /**
  58685. * Disposes the sphere.
  58686. * @param force Specifies if the sphere should be disposed by force
  58687. */
  58688. dispose(force?: boolean): void;
  58689. /*** Helpers ***/
  58690. private _prepareSphere;
  58691. private _intersectsWithSphere;
  58692. }
  58693. /**
  58694. * Represents a gravitational field event
  58695. */
  58696. class PhysicsGravitationalFieldEvent {
  58697. private _physicsHelper;
  58698. private _scene;
  58699. private _origin;
  58700. private _options;
  58701. private _tickCallback;
  58702. private _sphere;
  58703. private _dataFetched;
  58704. /**
  58705. * Initializes the physics gravitational field event
  58706. * @param _physicsHelper A physics helper
  58707. * @param _scene BabylonJS scene
  58708. * @param _origin The origin position of the gravitational field event
  58709. * @param _options The options for the vortex event
  58710. */
  58711. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58712. /**
  58713. * Returns the data related to the gravitational field event (sphere).
  58714. * @returns A gravitational field event
  58715. */
  58716. getData(): PhysicsGravitationalFieldEventData;
  58717. /**
  58718. * Enables the gravitational field.
  58719. */
  58720. enable(): void;
  58721. /**
  58722. * Disables the gravitational field.
  58723. */
  58724. disable(): void;
  58725. /**
  58726. * Disposes the sphere.
  58727. * @param force The force to dispose from the gravitational field event
  58728. */
  58729. dispose(force?: boolean): void;
  58730. private _tick;
  58731. }
  58732. /**
  58733. * Represents a physics updraft event
  58734. */
  58735. class PhysicsUpdraftEvent {
  58736. private _scene;
  58737. private _origin;
  58738. private _options;
  58739. private _physicsEngine;
  58740. private _originTop;
  58741. private _originDirection;
  58742. private _tickCallback;
  58743. private _cylinder;
  58744. private _cylinderPosition;
  58745. private _dataFetched;
  58746. /**
  58747. * Initializes the physics updraft event
  58748. * @param _scene BabylonJS scene
  58749. * @param _origin The origin position of the updraft
  58750. * @param _options The options for the updraft event
  58751. */
  58752. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58753. /**
  58754. * Returns the data related to the updraft event (cylinder).
  58755. * @returns A physics updraft event
  58756. */
  58757. getData(): PhysicsUpdraftEventData;
  58758. /**
  58759. * Enables the updraft.
  58760. */
  58761. enable(): void;
  58762. /**
  58763. * Disables the updraft.
  58764. */
  58765. disable(): void;
  58766. /**
  58767. * Disposes the cylinder.
  58768. * @param force Specifies if the updraft should be disposed by force
  58769. */
  58770. dispose(force?: boolean): void;
  58771. private getImpostorHitData;
  58772. private _tick;
  58773. /*** Helpers ***/
  58774. private _prepareCylinder;
  58775. private _intersectsWithCylinder;
  58776. }
  58777. /**
  58778. * Represents a physics vortex event
  58779. */
  58780. class PhysicsVortexEvent {
  58781. private _scene;
  58782. private _origin;
  58783. private _options;
  58784. private _physicsEngine;
  58785. private _originTop;
  58786. private _tickCallback;
  58787. private _cylinder;
  58788. private _cylinderPosition;
  58789. private _dataFetched;
  58790. /**
  58791. * Initializes the physics vortex event
  58792. * @param _scene The BabylonJS scene
  58793. * @param _origin The origin position of the vortex
  58794. * @param _options The options for the vortex event
  58795. */
  58796. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58797. /**
  58798. * Returns the data related to the vortex event (cylinder).
  58799. * @returns The physics vortex event data
  58800. */
  58801. getData(): PhysicsVortexEventData;
  58802. /**
  58803. * Enables the vortex.
  58804. */
  58805. enable(): void;
  58806. /**
  58807. * Disables the cortex.
  58808. */
  58809. disable(): void;
  58810. /**
  58811. * Disposes the sphere.
  58812. * @param force
  58813. */
  58814. dispose(force?: boolean): void;
  58815. private getImpostorHitData;
  58816. private _tick;
  58817. /*** Helpers ***/
  58818. private _prepareCylinder;
  58819. private _intersectsWithCylinder;
  58820. }
  58821. /**
  58822. * Options fot the radial explosion event
  58823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58824. */
  58825. export class PhysicsRadialExplosionEventOptions {
  58826. /**
  58827. * The radius of the sphere for the radial explosion.
  58828. */
  58829. radius: number;
  58830. /**
  58831. * The strenth of the explosion.
  58832. */
  58833. strength: number;
  58834. /**
  58835. * The strenght of the force in correspondence to the distance of the affected object
  58836. */
  58837. falloff: PhysicsRadialImpulseFalloff;
  58838. /**
  58839. * Sphere options for the radial explosion.
  58840. */
  58841. sphere: {
  58842. segments: number;
  58843. diameter: number;
  58844. };
  58845. /**
  58846. * Sphere options for the radial explosion.
  58847. */
  58848. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58849. }
  58850. /**
  58851. * Options fot the updraft event
  58852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58853. */
  58854. export class PhysicsUpdraftEventOptions {
  58855. /**
  58856. * The radius of the cylinder for the vortex
  58857. */
  58858. radius: number;
  58859. /**
  58860. * The strenth of the updraft.
  58861. */
  58862. strength: number;
  58863. /**
  58864. * The height of the cylinder for the updraft.
  58865. */
  58866. height: number;
  58867. /**
  58868. * The mode for the the updraft.
  58869. */
  58870. updraftMode: PhysicsUpdraftMode;
  58871. }
  58872. /**
  58873. * Options fot the vortex event
  58874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58875. */
  58876. export class PhysicsVortexEventOptions {
  58877. /**
  58878. * The radius of the cylinder for the vortex
  58879. */
  58880. radius: number;
  58881. /**
  58882. * The strenth of the vortex.
  58883. */
  58884. strength: number;
  58885. /**
  58886. * The height of the cylinder for the vortex.
  58887. */
  58888. height: number;
  58889. /**
  58890. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58891. */
  58892. centripetalForceThreshold: number;
  58893. /**
  58894. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58895. */
  58896. centripetalForceMultiplier: number;
  58897. /**
  58898. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58899. */
  58900. centrifugalForceMultiplier: number;
  58901. /**
  58902. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58903. */
  58904. updraftForceMultiplier: number;
  58905. }
  58906. /**
  58907. * The strenght of the force in correspondence to the distance of the affected object
  58908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58909. */
  58910. export enum PhysicsRadialImpulseFalloff {
  58911. /** Defines that impulse is constant in strength across it's whole radius */
  58912. Constant = 0,
  58913. /** Defines that impulse gets weaker if it's further from the origin */
  58914. Linear = 1
  58915. }
  58916. /**
  58917. * The strength of the force in correspondence to the distance of the affected object
  58918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58919. */
  58920. export enum PhysicsUpdraftMode {
  58921. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58922. Center = 0,
  58923. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58924. Perpendicular = 1
  58925. }
  58926. /**
  58927. * Interface for a physics hit data
  58928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58929. */
  58930. export interface PhysicsHitData {
  58931. /**
  58932. * The force applied at the contact point
  58933. */
  58934. force: Vector3;
  58935. /**
  58936. * The contact point
  58937. */
  58938. contactPoint: Vector3;
  58939. /**
  58940. * The distance from the origin to the contact point
  58941. */
  58942. distanceFromOrigin: number;
  58943. }
  58944. /**
  58945. * Interface for radial explosion event data
  58946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58947. */
  58948. export interface PhysicsRadialExplosionEventData {
  58949. /**
  58950. * A sphere used for the radial explosion event
  58951. */
  58952. sphere: Mesh;
  58953. }
  58954. /**
  58955. * Interface for gravitational field event data
  58956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58957. */
  58958. export interface PhysicsGravitationalFieldEventData {
  58959. /**
  58960. * A sphere mesh used for the gravitational field event
  58961. */
  58962. sphere: Mesh;
  58963. }
  58964. /**
  58965. * Interface for updraft event data
  58966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58967. */
  58968. export interface PhysicsUpdraftEventData {
  58969. /**
  58970. * A cylinder used for the updraft event
  58971. */
  58972. cylinder: Mesh;
  58973. }
  58974. /**
  58975. * Interface for vortex event data
  58976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58977. */
  58978. export interface PhysicsVortexEventData {
  58979. /**
  58980. * A cylinder used for the vortex event
  58981. */
  58982. cylinder: Mesh;
  58983. }
  58984. /**
  58985. * Interface for an affected physics impostor
  58986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58987. */
  58988. export interface PhysicsAffectedImpostorWithData {
  58989. /**
  58990. * The impostor affected by the effect
  58991. */
  58992. impostor: PhysicsImpostor;
  58993. /**
  58994. * The data about the hit/horce from the explosion
  58995. */
  58996. hitData: PhysicsHitData;
  58997. }
  58998. }
  58999. declare module BABYLON {
  59000. /** @hidden */
  59001. export var blackAndWhitePixelShader: {
  59002. name: string;
  59003. shader: string;
  59004. };
  59005. }
  59006. declare module BABYLON {
  59007. /**
  59008. * Post process used to render in black and white
  59009. */
  59010. export class BlackAndWhitePostProcess extends PostProcess {
  59011. /**
  59012. * Linear about to convert he result to black and white (default: 1)
  59013. */
  59014. degree: number;
  59015. /**
  59016. * Creates a black and white post process
  59017. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59018. * @param name The name of the effect.
  59019. * @param options The required width/height ratio to downsize to before computing the render pass.
  59020. * @param camera The camera to apply the render pass to.
  59021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59022. * @param engine The engine which the post process will be applied. (default: current engine)
  59023. * @param reusable If the post process can be reused on the same frame. (default: false)
  59024. */
  59025. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59026. }
  59027. }
  59028. declare module BABYLON {
  59029. /**
  59030. * This represents a set of one or more post processes in Babylon.
  59031. * A post process can be used to apply a shader to a texture after it is rendered.
  59032. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59033. */
  59034. export class PostProcessRenderEffect {
  59035. private _postProcesses;
  59036. private _getPostProcesses;
  59037. private _singleInstance;
  59038. private _cameras;
  59039. private _indicesForCamera;
  59040. /**
  59041. * Name of the effect
  59042. * @hidden
  59043. */ private _name: string;
  59044. /**
  59045. * Instantiates a post process render effect.
  59046. * A post process can be used to apply a shader to a texture after it is rendered.
  59047. * @param engine The engine the effect is tied to
  59048. * @param name The name of the effect
  59049. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59050. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59051. */
  59052. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59053. /**
  59054. * Checks if all the post processes in the effect are supported.
  59055. */
  59056. readonly isSupported: boolean;
  59057. /**
  59058. * Updates the current state of the effect
  59059. * @hidden
  59060. */ private _update(): void;
  59061. /**
  59062. * Attaches the effect on cameras
  59063. * @param cameras The camera to attach to.
  59064. * @hidden
  59065. */ private _attachCameras(cameras: Camera): void;
  59066. /**
  59067. * Attaches the effect on cameras
  59068. * @param cameras The camera to attach to.
  59069. * @hidden
  59070. */ private _attachCameras(cameras: Camera[]): void;
  59071. /**
  59072. * Detaches the effect on cameras
  59073. * @param cameras The camera to detatch from.
  59074. * @hidden
  59075. */ private _detachCameras(cameras: Camera): void;
  59076. /**
  59077. * Detatches the effect on cameras
  59078. * @param cameras The camera to detatch from.
  59079. * @hidden
  59080. */ private _detachCameras(cameras: Camera[]): void;
  59081. /**
  59082. * Enables the effect on given cameras
  59083. * @param cameras The camera to enable.
  59084. * @hidden
  59085. */ private _enable(cameras: Camera): void;
  59086. /**
  59087. * Enables the effect on given cameras
  59088. * @param cameras The camera to enable.
  59089. * @hidden
  59090. */ private _enable(cameras: Nullable<Camera[]>): void;
  59091. /**
  59092. * Disables the effect on the given cameras
  59093. * @param cameras The camera to disable.
  59094. * @hidden
  59095. */ private _disable(cameras: Camera): void;
  59096. /**
  59097. * Disables the effect on the given cameras
  59098. * @param cameras The camera to disable.
  59099. * @hidden
  59100. */ private _disable(cameras: Nullable<Camera[]>): void;
  59101. /**
  59102. * Gets a list of the post processes contained in the effect.
  59103. * @param camera The camera to get the post processes on.
  59104. * @returns The list of the post processes in the effect.
  59105. */
  59106. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59107. }
  59108. }
  59109. declare module BABYLON {
  59110. /** @hidden */
  59111. export var extractHighlightsPixelShader: {
  59112. name: string;
  59113. shader: string;
  59114. };
  59115. }
  59116. declare module BABYLON {
  59117. /**
  59118. * 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.
  59119. */
  59120. export class ExtractHighlightsPostProcess extends PostProcess {
  59121. /**
  59122. * The luminance threshold, pixels below this value will be set to black.
  59123. */
  59124. threshold: number;
  59125. /** @hidden */ private _exposure: number;
  59126. /**
  59127. * Post process which has the input texture to be used when performing highlight extraction
  59128. * @hidden
  59129. */ private _inputPostProcess: Nullable<PostProcess>;
  59130. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59131. }
  59132. }
  59133. declare module BABYLON {
  59134. /** @hidden */
  59135. export var bloomMergePixelShader: {
  59136. name: string;
  59137. shader: string;
  59138. };
  59139. }
  59140. declare module BABYLON {
  59141. /**
  59142. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59143. */
  59144. export class BloomMergePostProcess extends PostProcess {
  59145. /** Weight of the bloom to be added to the original input. */
  59146. weight: number;
  59147. /**
  59148. * Creates a new instance of @see BloomMergePostProcess
  59149. * @param name The name of the effect.
  59150. * @param originalFromInput Post process which's input will be used for the merge.
  59151. * @param blurred Blurred highlights post process which's output will be used.
  59152. * @param weight Weight of the bloom to be added to the original input.
  59153. * @param options The required width/height ratio to downsize to before computing the render pass.
  59154. * @param camera The camera to apply the render pass to.
  59155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59156. * @param engine The engine which the post process will be applied. (default: current engine)
  59157. * @param reusable If the post process can be reused on the same frame. (default: false)
  59158. * @param textureType Type of textures used when performing the post process. (default: 0)
  59159. * @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)
  59160. */
  59161. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59162. /** Weight of the bloom to be added to the original input. */
  59163. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59164. }
  59165. }
  59166. declare module BABYLON {
  59167. /**
  59168. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59169. */
  59170. export class BloomEffect extends PostProcessRenderEffect {
  59171. private bloomScale;
  59172. /**
  59173. * @hidden Internal
  59174. */ private _effects: Array<PostProcess>;
  59175. /**
  59176. * @hidden Internal
  59177. */ private _downscale: ExtractHighlightsPostProcess;
  59178. private _blurX;
  59179. private _blurY;
  59180. private _merge;
  59181. /**
  59182. * The luminance threshold to find bright areas of the image to bloom.
  59183. */
  59184. threshold: number;
  59185. /**
  59186. * The strength of the bloom.
  59187. */
  59188. weight: number;
  59189. /**
  59190. * Specifies the size of the bloom blur kernel, relative to the final output size
  59191. */
  59192. kernel: number;
  59193. /**
  59194. * Creates a new instance of @see BloomEffect
  59195. * @param scene The scene the effect belongs to.
  59196. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59197. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59198. * @param bloomWeight The the strength of bloom.
  59199. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59200. * @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)
  59201. */
  59202. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59203. /**
  59204. * Disposes each of the internal effects for a given camera.
  59205. * @param camera The camera to dispose the effect on.
  59206. */
  59207. disposeEffects(camera: Camera): void;
  59208. /**
  59209. * @hidden Internal
  59210. */ private _updateEffects(): void;
  59211. /**
  59212. * Internal
  59213. * @returns if all the contained post processes are ready.
  59214. * @hidden
  59215. */ private _isReady(): boolean;
  59216. }
  59217. }
  59218. declare module BABYLON {
  59219. /** @hidden */
  59220. export var chromaticAberrationPixelShader: {
  59221. name: string;
  59222. shader: string;
  59223. };
  59224. }
  59225. declare module BABYLON {
  59226. /**
  59227. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59228. */
  59229. export class ChromaticAberrationPostProcess extends PostProcess {
  59230. /**
  59231. * The amount of seperation of rgb channels (default: 30)
  59232. */
  59233. aberrationAmount: number;
  59234. /**
  59235. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59236. */
  59237. radialIntensity: number;
  59238. /**
  59239. * 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))
  59240. */
  59241. direction: Vector2;
  59242. /**
  59243. * 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))
  59244. */
  59245. centerPosition: Vector2;
  59246. /**
  59247. * Creates a new instance ChromaticAberrationPostProcess
  59248. * @param name The name of the effect.
  59249. * @param screenWidth The width of the screen to apply the effect on.
  59250. * @param screenHeight The height of the screen to apply the effect on.
  59251. * @param options The required width/height ratio to downsize to before computing the render pass.
  59252. * @param camera The camera to apply the render pass to.
  59253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59254. * @param engine The engine which the post process will be applied. (default: current engine)
  59255. * @param reusable If the post process can be reused on the same frame. (default: false)
  59256. * @param textureType Type of textures used when performing the post process. (default: 0)
  59257. * @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)
  59258. */
  59259. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59260. }
  59261. }
  59262. declare module BABYLON {
  59263. /** @hidden */
  59264. export var circleOfConfusionPixelShader: {
  59265. name: string;
  59266. shader: string;
  59267. };
  59268. }
  59269. declare module BABYLON {
  59270. /**
  59271. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59272. */
  59273. export class CircleOfConfusionPostProcess extends PostProcess {
  59274. /**
  59275. * 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.
  59276. */
  59277. lensSize: number;
  59278. /**
  59279. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59280. */
  59281. fStop: number;
  59282. /**
  59283. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59284. */
  59285. focusDistance: number;
  59286. /**
  59287. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59288. */
  59289. focalLength: number;
  59290. private _depthTexture;
  59291. /**
  59292. * Creates a new instance CircleOfConfusionPostProcess
  59293. * @param name The name of the effect.
  59294. * @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.
  59295. * @param options The required width/height ratio to downsize to before computing the render pass.
  59296. * @param camera The camera to apply the render pass to.
  59297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59298. * @param engine The engine which the post process will be applied. (default: current engine)
  59299. * @param reusable If the post process can be reused on the same frame. (default: false)
  59300. * @param textureType Type of textures used when performing the post process. (default: 0)
  59301. * @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)
  59302. */
  59303. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59304. /**
  59305. * 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.
  59306. */
  59307. depthTexture: RenderTargetTexture;
  59308. }
  59309. }
  59310. declare module BABYLON {
  59311. /** @hidden */
  59312. export var colorCorrectionPixelShader: {
  59313. name: string;
  59314. shader: string;
  59315. };
  59316. }
  59317. declare module BABYLON {
  59318. /**
  59319. *
  59320. * This post-process allows the modification of rendered colors by using
  59321. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59322. *
  59323. * The object needs to be provided an url to a texture containing the color
  59324. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59325. * Use an image editing software to tweak the LUT to match your needs.
  59326. *
  59327. * For an example of a color LUT, see here:
  59328. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59329. * For explanations on color grading, see here:
  59330. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59331. *
  59332. */
  59333. export class ColorCorrectionPostProcess extends PostProcess {
  59334. private _colorTableTexture;
  59335. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59336. }
  59337. }
  59338. declare module BABYLON {
  59339. /** @hidden */
  59340. export var convolutionPixelShader: {
  59341. name: string;
  59342. shader: string;
  59343. };
  59344. }
  59345. declare module BABYLON {
  59346. /**
  59347. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59348. * input texture to perform effects such as edge detection or sharpening
  59349. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59350. */
  59351. export class ConvolutionPostProcess extends PostProcess {
  59352. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59353. kernel: number[];
  59354. /**
  59355. * Creates a new instance ConvolutionPostProcess
  59356. * @param name The name of the effect.
  59357. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59358. * @param options The required width/height ratio to downsize to before computing the render pass.
  59359. * @param camera The camera to apply the render pass to.
  59360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59361. * @param engine The engine which the post process will be applied. (default: current engine)
  59362. * @param reusable If the post process can be reused on the same frame. (default: false)
  59363. * @param textureType Type of textures used when performing the post process. (default: 0)
  59364. */
  59365. constructor(name: string,
  59366. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59367. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59368. /**
  59369. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59370. */
  59371. static EdgeDetect0Kernel: number[];
  59372. /**
  59373. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59374. */
  59375. static EdgeDetect1Kernel: number[];
  59376. /**
  59377. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59378. */
  59379. static EdgeDetect2Kernel: number[];
  59380. /**
  59381. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59382. */
  59383. static SharpenKernel: number[];
  59384. /**
  59385. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59386. */
  59387. static EmbossKernel: number[];
  59388. /**
  59389. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59390. */
  59391. static GaussianKernel: number[];
  59392. }
  59393. }
  59394. declare module BABYLON {
  59395. /**
  59396. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59397. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59398. * based on samples that have a large difference in distance than the center pixel.
  59399. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59400. */
  59401. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59402. direction: Vector2;
  59403. /**
  59404. * Creates a new instance CircleOfConfusionPostProcess
  59405. * @param name The name of the effect.
  59406. * @param scene The scene the effect belongs to.
  59407. * @param direction The direction the blur should be applied.
  59408. * @param kernel The size of the kernel used to blur.
  59409. * @param options The required width/height ratio to downsize to before computing the render pass.
  59410. * @param camera The camera to apply the render pass to.
  59411. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59412. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59414. * @param engine The engine which the post process will be applied. (default: current engine)
  59415. * @param reusable If the post process can be reused on the same frame. (default: false)
  59416. * @param textureType Type of textures used when performing the post process. (default: 0)
  59417. * @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)
  59418. */
  59419. 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);
  59420. }
  59421. }
  59422. declare module BABYLON {
  59423. /** @hidden */
  59424. export var depthOfFieldMergePixelShader: {
  59425. name: string;
  59426. shader: string;
  59427. };
  59428. }
  59429. declare module BABYLON {
  59430. /**
  59431. * Options to be set when merging outputs from the default pipeline.
  59432. */
  59433. export class DepthOfFieldMergePostProcessOptions {
  59434. /**
  59435. * The original image to merge on top of
  59436. */
  59437. originalFromInput: PostProcess;
  59438. /**
  59439. * Parameters to perform the merge of the depth of field effect
  59440. */
  59441. depthOfField?: {
  59442. circleOfConfusion: PostProcess;
  59443. blurSteps: Array<PostProcess>;
  59444. };
  59445. /**
  59446. * Parameters to perform the merge of bloom effect
  59447. */
  59448. bloom?: {
  59449. blurred: PostProcess;
  59450. weight: number;
  59451. };
  59452. }
  59453. /**
  59454. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59455. */
  59456. export class DepthOfFieldMergePostProcess extends PostProcess {
  59457. private blurSteps;
  59458. /**
  59459. * Creates a new instance of DepthOfFieldMergePostProcess
  59460. * @param name The name of the effect.
  59461. * @param originalFromInput Post process which's input will be used for the merge.
  59462. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59463. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59464. * @param options The required width/height ratio to downsize to before computing the render pass.
  59465. * @param camera The camera to apply the render pass to.
  59466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59467. * @param engine The engine which the post process will be applied. (default: current engine)
  59468. * @param reusable If the post process can be reused on the same frame. (default: false)
  59469. * @param textureType Type of textures used when performing the post process. (default: 0)
  59470. * @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)
  59471. */
  59472. 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);
  59473. /**
  59474. * Updates the effect with the current post process compile time values and recompiles the shader.
  59475. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59476. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59477. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59478. * @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
  59479. * @param onCompiled Called when the shader has been compiled.
  59480. * @param onError Called if there is an error when compiling a shader.
  59481. */
  59482. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59483. }
  59484. }
  59485. declare module BABYLON {
  59486. /**
  59487. * Specifies the level of max blur that should be applied when using the depth of field effect
  59488. */
  59489. export enum DepthOfFieldEffectBlurLevel {
  59490. /**
  59491. * Subtle blur
  59492. */
  59493. Low = 0,
  59494. /**
  59495. * Medium blur
  59496. */
  59497. Medium = 1,
  59498. /**
  59499. * Large blur
  59500. */
  59501. High = 2
  59502. }
  59503. /**
  59504. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59505. */
  59506. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59507. private _circleOfConfusion;
  59508. /**
  59509. * @hidden Internal, blurs from high to low
  59510. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59511. private _depthOfFieldBlurY;
  59512. private _dofMerge;
  59513. /**
  59514. * @hidden Internal post processes in depth of field effect
  59515. */ private _effects: Array<PostProcess>;
  59516. /**
  59517. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59518. */
  59519. focalLength: number;
  59520. /**
  59521. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59522. */
  59523. fStop: number;
  59524. /**
  59525. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59526. */
  59527. focusDistance: number;
  59528. /**
  59529. * 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.
  59530. */
  59531. lensSize: number;
  59532. /**
  59533. * Creates a new instance DepthOfFieldEffect
  59534. * @param scene The scene the effect belongs to.
  59535. * @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.
  59536. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59537. * @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)
  59538. */
  59539. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59540. /**
  59541. * Get the current class name of the current effet
  59542. * @returns "DepthOfFieldEffect"
  59543. */
  59544. getClassName(): string;
  59545. /**
  59546. * 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.
  59547. */
  59548. depthTexture: RenderTargetTexture;
  59549. /**
  59550. * Disposes each of the internal effects for a given camera.
  59551. * @param camera The camera to dispose the effect on.
  59552. */
  59553. disposeEffects(camera: Camera): void;
  59554. /**
  59555. * @hidden Internal
  59556. */ private _updateEffects(): void;
  59557. /**
  59558. * Internal
  59559. * @returns if all the contained post processes are ready.
  59560. * @hidden
  59561. */ private _isReady(): boolean;
  59562. }
  59563. }
  59564. declare module BABYLON {
  59565. /** @hidden */
  59566. export var displayPassPixelShader: {
  59567. name: string;
  59568. shader: string;
  59569. };
  59570. }
  59571. declare module BABYLON {
  59572. /**
  59573. * DisplayPassPostProcess which produces an output the same as it's input
  59574. */
  59575. export class DisplayPassPostProcess extends PostProcess {
  59576. /**
  59577. * Creates the DisplayPassPostProcess
  59578. * @param name The name of the effect.
  59579. * @param options The required width/height ratio to downsize to before computing the render pass.
  59580. * @param camera The camera to apply the render pass to.
  59581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59582. * @param engine The engine which the post process will be applied. (default: current engine)
  59583. * @param reusable If the post process can be reused on the same frame. (default: false)
  59584. */
  59585. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59586. }
  59587. }
  59588. declare module BABYLON {
  59589. /** @hidden */
  59590. export var filterPixelShader: {
  59591. name: string;
  59592. shader: string;
  59593. };
  59594. }
  59595. declare module BABYLON {
  59596. /**
  59597. * Applies a kernel filter to the image
  59598. */
  59599. export class FilterPostProcess extends PostProcess {
  59600. /** The matrix to be applied to the image */
  59601. kernelMatrix: Matrix;
  59602. /**
  59603. *
  59604. * @param name The name of the effect.
  59605. * @param kernelMatrix The matrix to be applied to the image
  59606. * @param options The required width/height ratio to downsize to before computing the render pass.
  59607. * @param camera The camera to apply the render pass to.
  59608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59609. * @param engine The engine which the post process will be applied. (default: current engine)
  59610. * @param reusable If the post process can be reused on the same frame. (default: false)
  59611. */
  59612. constructor(name: string,
  59613. /** The matrix to be applied to the image */
  59614. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59615. }
  59616. }
  59617. declare module BABYLON {
  59618. /** @hidden */
  59619. export var fxaaPixelShader: {
  59620. name: string;
  59621. shader: string;
  59622. };
  59623. }
  59624. declare module BABYLON {
  59625. /** @hidden */
  59626. export var fxaaVertexShader: {
  59627. name: string;
  59628. shader: string;
  59629. };
  59630. }
  59631. declare module BABYLON {
  59632. /**
  59633. * Fxaa post process
  59634. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59635. */
  59636. export class FxaaPostProcess extends PostProcess {
  59637. /** @hidden */
  59638. texelWidth: number;
  59639. /** @hidden */
  59640. texelHeight: number;
  59641. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59642. private _getDefines;
  59643. }
  59644. }
  59645. declare module BABYLON {
  59646. /** @hidden */
  59647. export var grainPixelShader: {
  59648. name: string;
  59649. shader: string;
  59650. };
  59651. }
  59652. declare module BABYLON {
  59653. /**
  59654. * The GrainPostProcess adds noise to the image at mid luminance levels
  59655. */
  59656. export class GrainPostProcess extends PostProcess {
  59657. /**
  59658. * The intensity of the grain added (default: 30)
  59659. */
  59660. intensity: number;
  59661. /**
  59662. * If the grain should be randomized on every frame
  59663. */
  59664. animated: boolean;
  59665. /**
  59666. * Creates a new instance of @see GrainPostProcess
  59667. * @param name The name of the effect.
  59668. * @param options The required width/height ratio to downsize to before computing the render pass.
  59669. * @param camera The camera to apply the render pass to.
  59670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59671. * @param engine The engine which the post process will be applied. (default: current engine)
  59672. * @param reusable If the post process can be reused on the same frame. (default: false)
  59673. * @param textureType Type of textures used when performing the post process. (default: 0)
  59674. * @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)
  59675. */
  59676. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59677. }
  59678. }
  59679. declare module BABYLON {
  59680. /** @hidden */
  59681. export var highlightsPixelShader: {
  59682. name: string;
  59683. shader: string;
  59684. };
  59685. }
  59686. declare module BABYLON {
  59687. /**
  59688. * Extracts highlights from the image
  59689. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59690. */
  59691. export class HighlightsPostProcess extends PostProcess {
  59692. /**
  59693. * Extracts highlights from the image
  59694. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59695. * @param name The name of the effect.
  59696. * @param options The required width/height ratio to downsize to before computing the render pass.
  59697. * @param camera The camera to apply the render pass to.
  59698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59699. * @param engine The engine which the post process will be applied. (default: current engine)
  59700. * @param reusable If the post process can be reused on the same frame. (default: false)
  59701. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59702. */
  59703. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59704. }
  59705. }
  59706. declare module BABYLON {
  59707. /** @hidden */
  59708. export var mrtFragmentDeclaration: {
  59709. name: string;
  59710. shader: string;
  59711. };
  59712. }
  59713. declare module BABYLON {
  59714. /** @hidden */
  59715. export var geometryPixelShader: {
  59716. name: string;
  59717. shader: string;
  59718. };
  59719. }
  59720. declare module BABYLON {
  59721. /** @hidden */
  59722. export var geometryVertexShader: {
  59723. name: string;
  59724. shader: string;
  59725. };
  59726. }
  59727. declare module BABYLON {
  59728. /** @hidden */
  59729. interface ISavedTransformationMatrix {
  59730. world: Matrix;
  59731. viewProjection: Matrix;
  59732. }
  59733. /**
  59734. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59735. */
  59736. export class GeometryBufferRenderer {
  59737. /**
  59738. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59739. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59740. */
  59741. static readonly POSITION_TEXTURE_TYPE: number;
  59742. /**
  59743. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59744. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59745. */
  59746. static readonly VELOCITY_TEXTURE_TYPE: number;
  59747. /**
  59748. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59749. * in order to compute objects velocities when enableVelocity is set to "true"
  59750. * @hidden
  59751. */ private _previousTransformationMatrices: {
  59752. [index: number]: ISavedTransformationMatrix;
  59753. };
  59754. /**
  59755. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59756. * in order to compute objects velocities when enableVelocity is set to "true"
  59757. * @hidden
  59758. */ private _previousBonesTransformationMatrices: {
  59759. [index: number]: Float32Array;
  59760. };
  59761. /**
  59762. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59763. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59764. */
  59765. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59766. private _scene;
  59767. private _multiRenderTarget;
  59768. private _ratio;
  59769. private _enablePosition;
  59770. private _enableVelocity;
  59771. private _positionIndex;
  59772. private _velocityIndex;
  59773. protected _effect: Effect;
  59774. protected _cachedDefines: string;
  59775. /**
  59776. * Set the render list (meshes to be rendered) used in the G buffer.
  59777. */
  59778. renderList: Mesh[];
  59779. /**
  59780. * Gets wether or not G buffer are supported by the running hardware.
  59781. * This requires draw buffer supports
  59782. */
  59783. readonly isSupported: boolean;
  59784. /**
  59785. * Returns the index of the given texture type in the G-Buffer textures array
  59786. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59787. * @returns the index of the given texture type in the G-Buffer textures array
  59788. */
  59789. getTextureIndex(textureType: number): number;
  59790. /**
  59791. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59792. */
  59793. /**
  59794. * Sets whether or not objects positions are enabled for the G buffer.
  59795. */
  59796. enablePosition: boolean;
  59797. /**
  59798. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59799. */
  59800. /**
  59801. * Sets wether or not objects velocities are enabled for the G buffer.
  59802. */
  59803. enableVelocity: boolean;
  59804. /**
  59805. * Gets the scene associated with the buffer.
  59806. */
  59807. readonly scene: Scene;
  59808. /**
  59809. * Gets the ratio used by the buffer during its creation.
  59810. * How big is the buffer related to the main canvas.
  59811. */
  59812. readonly ratio: number;
  59813. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  59814. /**
  59815. * Creates a new G Buffer for the scene
  59816. * @param scene The scene the buffer belongs to
  59817. * @param ratio How big is the buffer related to the main canvas.
  59818. */
  59819. constructor(scene: Scene, ratio?: number);
  59820. /**
  59821. * Checks wether everything is ready to render a submesh to the G buffer.
  59822. * @param subMesh the submesh to check readiness for
  59823. * @param useInstances is the mesh drawn using instance or not
  59824. * @returns true if ready otherwise false
  59825. */
  59826. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59827. /**
  59828. * Gets the current underlying G Buffer.
  59829. * @returns the buffer
  59830. */
  59831. getGBuffer(): MultiRenderTarget;
  59832. /**
  59833. * Gets the number of samples used to render the buffer (anti aliasing).
  59834. */
  59835. /**
  59836. * Sets the number of samples used to render the buffer (anti aliasing).
  59837. */
  59838. samples: number;
  59839. /**
  59840. * Disposes the renderer and frees up associated resources.
  59841. */
  59842. dispose(): void;
  59843. protected _createRenderTargets(): void;
  59844. private _copyBonesTransformationMatrices;
  59845. }
  59846. }
  59847. declare module BABYLON {
  59848. interface Scene {
  59849. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59850. /**
  59851. * Gets or Sets the current geometry buffer associated to the scene.
  59852. */
  59853. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59854. /**
  59855. * Enables a GeometryBufferRender and associates it with the scene
  59856. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59857. * @returns the GeometryBufferRenderer
  59858. */
  59859. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59860. /**
  59861. * Disables the GeometryBufferRender associated with the scene
  59862. */
  59863. disableGeometryBufferRenderer(): void;
  59864. }
  59865. /**
  59866. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59867. * in several rendering techniques.
  59868. */
  59869. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59870. /**
  59871. * The component name helpful to identify the component in the list of scene components.
  59872. */
  59873. readonly name: string;
  59874. /**
  59875. * The scene the component belongs to.
  59876. */
  59877. scene: Scene;
  59878. /**
  59879. * Creates a new instance of the component for the given scene
  59880. * @param scene Defines the scene to register the component in
  59881. */
  59882. constructor(scene: Scene);
  59883. /**
  59884. * Registers the component in a given scene
  59885. */
  59886. register(): void;
  59887. /**
  59888. * Rebuilds the elements related to this component in case of
  59889. * context lost for instance.
  59890. */
  59891. rebuild(): void;
  59892. /**
  59893. * Disposes the component and the associated ressources
  59894. */
  59895. dispose(): void;
  59896. private _gatherRenderTargets;
  59897. }
  59898. }
  59899. declare module BABYLON {
  59900. /** @hidden */
  59901. export var motionBlurPixelShader: {
  59902. name: string;
  59903. shader: string;
  59904. };
  59905. }
  59906. declare module BABYLON {
  59907. /**
  59908. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59909. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59910. * As an example, all you have to do is to create the post-process:
  59911. * var mb = new BABYLON.MotionBlurPostProcess(
  59912. * 'mb', // The name of the effect.
  59913. * scene, // The scene containing the objects to blur according to their velocity.
  59914. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59915. * camera // The camera to apply the render pass to.
  59916. * );
  59917. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59918. */
  59919. export class MotionBlurPostProcess extends PostProcess {
  59920. /**
  59921. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59922. */
  59923. motionStrength: number;
  59924. /**
  59925. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59926. */
  59927. /**
  59928. * Sets the number of iterations to be used for motion blur quality
  59929. */
  59930. motionBlurSamples: number;
  59931. private _motionBlurSamples;
  59932. private _geometryBufferRenderer;
  59933. /**
  59934. * Creates a new instance MotionBlurPostProcess
  59935. * @param name The name of the effect.
  59936. * @param scene The scene containing the objects to blur according to their velocity.
  59937. * @param options The required width/height ratio to downsize to before computing the render pass.
  59938. * @param camera The camera to apply the render pass to.
  59939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59940. * @param engine The engine which the post process will be applied. (default: current engine)
  59941. * @param reusable If the post process can be reused on the same frame. (default: false)
  59942. * @param textureType Type of textures used when performing the post process. (default: 0)
  59943. * @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)
  59944. */
  59945. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59946. /**
  59947. * Excludes the given skinned mesh from computing bones velocities.
  59948. * 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.
  59949. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59950. */
  59951. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59952. /**
  59953. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59954. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59955. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59956. */
  59957. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59958. /**
  59959. * Disposes the post process.
  59960. * @param camera The camera to dispose the post process on.
  59961. */
  59962. dispose(camera?: Camera): void;
  59963. }
  59964. }
  59965. declare module BABYLON {
  59966. /** @hidden */
  59967. export var refractionPixelShader: {
  59968. name: string;
  59969. shader: string;
  59970. };
  59971. }
  59972. declare module BABYLON {
  59973. /**
  59974. * Post process which applies a refractin texture
  59975. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59976. */
  59977. export class RefractionPostProcess extends PostProcess {
  59978. /** the base color of the refraction (used to taint the rendering) */
  59979. color: Color3;
  59980. /** simulated refraction depth */
  59981. depth: number;
  59982. /** the coefficient of the base color (0 to remove base color tainting) */
  59983. colorLevel: number;
  59984. private _refTexture;
  59985. private _ownRefractionTexture;
  59986. /**
  59987. * Gets or sets the refraction texture
  59988. * Please note that you are responsible for disposing the texture if you set it manually
  59989. */
  59990. refractionTexture: Texture;
  59991. /**
  59992. * Initializes the RefractionPostProcess
  59993. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59994. * @param name The name of the effect.
  59995. * @param refractionTextureUrl Url of the refraction texture to use
  59996. * @param color the base color of the refraction (used to taint the rendering)
  59997. * @param depth simulated refraction depth
  59998. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59999. * @param camera The camera to apply the render pass to.
  60000. * @param options The required width/height ratio to downsize to before computing the render pass.
  60001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60002. * @param engine The engine which the post process will be applied. (default: current engine)
  60003. * @param reusable If the post process can be reused on the same frame. (default: false)
  60004. */
  60005. constructor(name: string, refractionTextureUrl: string,
  60006. /** the base color of the refraction (used to taint the rendering) */
  60007. color: Color3,
  60008. /** simulated refraction depth */
  60009. depth: number,
  60010. /** the coefficient of the base color (0 to remove base color tainting) */
  60011. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60012. /**
  60013. * Disposes of the post process
  60014. * @param camera Camera to dispose post process on
  60015. */
  60016. dispose(camera: Camera): void;
  60017. }
  60018. }
  60019. declare module BABYLON {
  60020. /** @hidden */
  60021. export var sharpenPixelShader: {
  60022. name: string;
  60023. shader: string;
  60024. };
  60025. }
  60026. declare module BABYLON {
  60027. /**
  60028. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60029. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60030. */
  60031. export class SharpenPostProcess extends PostProcess {
  60032. /**
  60033. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60034. */
  60035. colorAmount: number;
  60036. /**
  60037. * How much sharpness should be applied (default: 0.3)
  60038. */
  60039. edgeAmount: number;
  60040. /**
  60041. * Creates a new instance ConvolutionPostProcess
  60042. * @param name The name of the effect.
  60043. * @param options The required width/height ratio to downsize to before computing the render pass.
  60044. * @param camera The camera to apply the render pass to.
  60045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60046. * @param engine The engine which the post process will be applied. (default: current engine)
  60047. * @param reusable If the post process can be reused on the same frame. (default: false)
  60048. * @param textureType Type of textures used when performing the post process. (default: 0)
  60049. * @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)
  60050. */
  60051. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60052. }
  60053. }
  60054. declare module BABYLON {
  60055. /**
  60056. * PostProcessRenderPipeline
  60057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60058. */
  60059. export class PostProcessRenderPipeline {
  60060. private engine;
  60061. private _renderEffects;
  60062. private _renderEffectsForIsolatedPass;
  60063. /**
  60064. * List of inspectable custom properties (used by the Inspector)
  60065. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60066. */
  60067. inspectableCustomProperties: IInspectable[];
  60068. /**
  60069. * @hidden
  60070. */
  60071. protected _cameras: Camera[];
  60072. /** @hidden */ private _name: string;
  60073. /**
  60074. * Gets pipeline name
  60075. */
  60076. readonly name: string;
  60077. /** Gets the list of attached cameras */
  60078. readonly cameras: Camera[];
  60079. /**
  60080. * Initializes a PostProcessRenderPipeline
  60081. * @param engine engine to add the pipeline to
  60082. * @param name name of the pipeline
  60083. */
  60084. constructor(engine: Engine, name: string);
  60085. /**
  60086. * Gets the class name
  60087. * @returns "PostProcessRenderPipeline"
  60088. */
  60089. getClassName(): string;
  60090. /**
  60091. * If all the render effects in the pipeline are supported
  60092. */
  60093. readonly isSupported: boolean;
  60094. /**
  60095. * Adds an effect to the pipeline
  60096. * @param renderEffect the effect to add
  60097. */
  60098. addEffect(renderEffect: PostProcessRenderEffect): void;
  60099. /** @hidden */ private _rebuild(): void;
  60100. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  60101. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60102. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60103. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60104. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  60105. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  60106. /** @hidden */ private _detachCameras(cameras: Camera): void;
  60107. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  60108. /** @hidden */ private _update(): void;
  60109. /** @hidden */ private _reset(): void;
  60110. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60111. /**
  60112. * Disposes of the pipeline
  60113. */
  60114. dispose(): void;
  60115. }
  60116. }
  60117. declare module BABYLON {
  60118. /**
  60119. * PostProcessRenderPipelineManager class
  60120. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60121. */
  60122. export class PostProcessRenderPipelineManager {
  60123. private _renderPipelines;
  60124. /**
  60125. * Initializes a PostProcessRenderPipelineManager
  60126. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60127. */
  60128. constructor();
  60129. /**
  60130. * Gets the list of supported render pipelines
  60131. */
  60132. readonly supportedPipelines: PostProcessRenderPipeline[];
  60133. /**
  60134. * Adds a pipeline to the manager
  60135. * @param renderPipeline The pipeline to add
  60136. */
  60137. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60138. /**
  60139. * Attaches a camera to the pipeline
  60140. * @param renderPipelineName The name of the pipeline to attach to
  60141. * @param cameras the camera to attach
  60142. * @param unique if the camera can be attached multiple times to the pipeline
  60143. */
  60144. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60145. /**
  60146. * Detaches a camera from the pipeline
  60147. * @param renderPipelineName The name of the pipeline to detach from
  60148. * @param cameras the camera to detach
  60149. */
  60150. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60151. /**
  60152. * Enables an effect by name on a pipeline
  60153. * @param renderPipelineName the name of the pipeline to enable the effect in
  60154. * @param renderEffectName the name of the effect to enable
  60155. * @param cameras the cameras that the effect should be enabled on
  60156. */
  60157. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60158. /**
  60159. * Disables an effect by name on a pipeline
  60160. * @param renderPipelineName the name of the pipeline to disable the effect in
  60161. * @param renderEffectName the name of the effect to disable
  60162. * @param cameras the cameras that the effect should be disabled on
  60163. */
  60164. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60165. /**
  60166. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60167. */
  60168. update(): void;
  60169. /** @hidden */ private _rebuild(): void;
  60170. /**
  60171. * Disposes of the manager and pipelines
  60172. */
  60173. dispose(): void;
  60174. }
  60175. }
  60176. declare module BABYLON {
  60177. interface Scene {
  60178. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60179. /**
  60180. * Gets the postprocess render pipeline manager
  60181. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60182. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60183. */
  60184. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60185. }
  60186. /**
  60187. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60188. */
  60189. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60190. /**
  60191. * The component name helpfull to identify the component in the list of scene components.
  60192. */
  60193. readonly name: string;
  60194. /**
  60195. * The scene the component belongs to.
  60196. */
  60197. scene: Scene;
  60198. /**
  60199. * Creates a new instance of the component for the given scene
  60200. * @param scene Defines the scene to register the component in
  60201. */
  60202. constructor(scene: Scene);
  60203. /**
  60204. * Registers the component in a given scene
  60205. */
  60206. register(): void;
  60207. /**
  60208. * Rebuilds the elements related to this component in case of
  60209. * context lost for instance.
  60210. */
  60211. rebuild(): void;
  60212. /**
  60213. * Disposes the component and the associated ressources
  60214. */
  60215. dispose(): void;
  60216. private _gatherRenderTargets;
  60217. }
  60218. }
  60219. declare module BABYLON {
  60220. /**
  60221. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60222. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60223. */
  60224. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60225. private _scene;
  60226. private _camerasToBeAttached;
  60227. /**
  60228. * ID of the sharpen post process,
  60229. */
  60230. private readonly SharpenPostProcessId;
  60231. /**
  60232. * @ignore
  60233. * ID of the image processing post process;
  60234. */
  60235. readonly ImageProcessingPostProcessId: string;
  60236. /**
  60237. * @ignore
  60238. * ID of the Fast Approximate Anti-Aliasing post process;
  60239. */
  60240. readonly FxaaPostProcessId: string;
  60241. /**
  60242. * ID of the chromatic aberration post process,
  60243. */
  60244. private readonly ChromaticAberrationPostProcessId;
  60245. /**
  60246. * ID of the grain post process
  60247. */
  60248. private readonly GrainPostProcessId;
  60249. /**
  60250. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60251. */
  60252. sharpen: SharpenPostProcess;
  60253. private _sharpenEffect;
  60254. private bloom;
  60255. /**
  60256. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60257. */
  60258. depthOfField: DepthOfFieldEffect;
  60259. /**
  60260. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60261. */
  60262. fxaa: FxaaPostProcess;
  60263. /**
  60264. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60265. */
  60266. imageProcessing: ImageProcessingPostProcess;
  60267. /**
  60268. * Chromatic aberration post process which will shift rgb colors in the image
  60269. */
  60270. chromaticAberration: ChromaticAberrationPostProcess;
  60271. private _chromaticAberrationEffect;
  60272. /**
  60273. * Grain post process which add noise to the image
  60274. */
  60275. grain: GrainPostProcess;
  60276. private _grainEffect;
  60277. /**
  60278. * Glow post process which adds a glow to emissive areas of the image
  60279. */
  60280. private _glowLayer;
  60281. /**
  60282. * Animations which can be used to tweak settings over a period of time
  60283. */
  60284. animations: Animation[];
  60285. private _imageProcessingConfigurationObserver;
  60286. private _sharpenEnabled;
  60287. private _bloomEnabled;
  60288. private _depthOfFieldEnabled;
  60289. private _depthOfFieldBlurLevel;
  60290. private _fxaaEnabled;
  60291. private _imageProcessingEnabled;
  60292. private _defaultPipelineTextureType;
  60293. private _bloomScale;
  60294. private _chromaticAberrationEnabled;
  60295. private _grainEnabled;
  60296. private _buildAllowed;
  60297. /**
  60298. * Gets active scene
  60299. */
  60300. readonly scene: Scene;
  60301. /**
  60302. * Enable or disable the sharpen process from the pipeline
  60303. */
  60304. sharpenEnabled: boolean;
  60305. private _resizeObserver;
  60306. private _hardwareScaleLevel;
  60307. private _bloomKernel;
  60308. /**
  60309. * Specifies the size of the bloom blur kernel, relative to the final output size
  60310. */
  60311. bloomKernel: number;
  60312. /**
  60313. * Specifies the weight of the bloom in the final rendering
  60314. */
  60315. private _bloomWeight;
  60316. /**
  60317. * Specifies the luma threshold for the area that will be blurred by the bloom
  60318. */
  60319. private _bloomThreshold;
  60320. private _hdr;
  60321. /**
  60322. * The strength of the bloom.
  60323. */
  60324. bloomWeight: number;
  60325. /**
  60326. * The strength of the bloom.
  60327. */
  60328. bloomThreshold: number;
  60329. /**
  60330. * The scale of the bloom, lower value will provide better performance.
  60331. */
  60332. bloomScale: number;
  60333. /**
  60334. * Enable or disable the bloom from the pipeline
  60335. */
  60336. bloomEnabled: boolean;
  60337. private _rebuildBloom;
  60338. /**
  60339. * If the depth of field is enabled.
  60340. */
  60341. depthOfFieldEnabled: boolean;
  60342. /**
  60343. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60344. */
  60345. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60346. /**
  60347. * If the anti aliasing is enabled.
  60348. */
  60349. fxaaEnabled: boolean;
  60350. private _samples;
  60351. /**
  60352. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60353. */
  60354. samples: number;
  60355. /**
  60356. * If image processing is enabled.
  60357. */
  60358. imageProcessingEnabled: boolean;
  60359. /**
  60360. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60361. */
  60362. glowLayerEnabled: boolean;
  60363. /**
  60364. * Gets the glow layer (or null if not defined)
  60365. */
  60366. readonly glowLayer: Nullable<GlowLayer>;
  60367. /**
  60368. * Enable or disable the chromaticAberration process from the pipeline
  60369. */
  60370. chromaticAberrationEnabled: boolean;
  60371. /**
  60372. * Enable or disable the grain process from the pipeline
  60373. */
  60374. grainEnabled: boolean;
  60375. /**
  60376. * @constructor
  60377. * @param name - The rendering pipeline name (default: "")
  60378. * @param hdr - If high dynamic range textures should be used (default: true)
  60379. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60380. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60381. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60382. */
  60383. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60384. /**
  60385. * Get the class name
  60386. * @returns "DefaultRenderingPipeline"
  60387. */
  60388. getClassName(): string;
  60389. /**
  60390. * Force the compilation of the entire pipeline.
  60391. */
  60392. prepare(): void;
  60393. private _hasCleared;
  60394. private _prevPostProcess;
  60395. private _prevPrevPostProcess;
  60396. private _setAutoClearAndTextureSharing;
  60397. private _depthOfFieldSceneObserver;
  60398. private _buildPipeline;
  60399. private _disposePostProcesses;
  60400. /**
  60401. * Adds a camera to the pipeline
  60402. * @param camera the camera to be added
  60403. */
  60404. addCamera(camera: Camera): void;
  60405. /**
  60406. * Removes a camera from the pipeline
  60407. * @param camera the camera to remove
  60408. */
  60409. removeCamera(camera: Camera): void;
  60410. /**
  60411. * Dispose of the pipeline and stop all post processes
  60412. */
  60413. dispose(): void;
  60414. /**
  60415. * Serialize the rendering pipeline (Used when exporting)
  60416. * @returns the serialized object
  60417. */
  60418. serialize(): any;
  60419. /**
  60420. * Parse the serialized pipeline
  60421. * @param source Source pipeline.
  60422. * @param scene The scene to load the pipeline to.
  60423. * @param rootUrl The URL of the serialized pipeline.
  60424. * @returns An instantiated pipeline from the serialized object.
  60425. */
  60426. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60427. }
  60428. }
  60429. declare module BABYLON {
  60430. /** @hidden */
  60431. export var lensHighlightsPixelShader: {
  60432. name: string;
  60433. shader: string;
  60434. };
  60435. }
  60436. declare module BABYLON {
  60437. /** @hidden */
  60438. export var depthOfFieldPixelShader: {
  60439. name: string;
  60440. shader: string;
  60441. };
  60442. }
  60443. declare module BABYLON {
  60444. /**
  60445. * BABYLON.JS Chromatic Aberration GLSL Shader
  60446. * Author: Olivier Guyot
  60447. * Separates very slightly R, G and B colors on the edges of the screen
  60448. * Inspired by Francois Tarlier & Martins Upitis
  60449. */
  60450. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60451. /**
  60452. * @ignore
  60453. * The chromatic aberration PostProcess id in the pipeline
  60454. */
  60455. LensChromaticAberrationEffect: string;
  60456. /**
  60457. * @ignore
  60458. * The highlights enhancing PostProcess id in the pipeline
  60459. */
  60460. HighlightsEnhancingEffect: string;
  60461. /**
  60462. * @ignore
  60463. * The depth-of-field PostProcess id in the pipeline
  60464. */
  60465. LensDepthOfFieldEffect: string;
  60466. private _scene;
  60467. private _depthTexture;
  60468. private _grainTexture;
  60469. private _chromaticAberrationPostProcess;
  60470. private _highlightsPostProcess;
  60471. private _depthOfFieldPostProcess;
  60472. private _edgeBlur;
  60473. private _grainAmount;
  60474. private _chromaticAberration;
  60475. private _distortion;
  60476. private _highlightsGain;
  60477. private _highlightsThreshold;
  60478. private _dofDistance;
  60479. private _dofAperture;
  60480. private _dofDarken;
  60481. private _dofPentagon;
  60482. private _blurNoise;
  60483. /**
  60484. * @constructor
  60485. *
  60486. * Effect parameters are as follow:
  60487. * {
  60488. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60489. * edge_blur: number; // from 0 to x (1 for realism)
  60490. * distortion: number; // from 0 to x (1 for realism)
  60491. * grain_amount: number; // from 0 to 1
  60492. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60493. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60494. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60495. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60496. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60497. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60498. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60499. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60500. * }
  60501. * Note: if an effect parameter is unset, effect is disabled
  60502. *
  60503. * @param name The rendering pipeline name
  60504. * @param parameters - An object containing all parameters (see above)
  60505. * @param scene The scene linked to this pipeline
  60506. * @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)
  60507. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60508. */
  60509. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60510. /**
  60511. * Get the class name
  60512. * @returns "LensRenderingPipeline"
  60513. */
  60514. getClassName(): string;
  60515. /**
  60516. * Gets associated scene
  60517. */
  60518. readonly scene: Scene;
  60519. /**
  60520. * Gets or sets the edge blur
  60521. */
  60522. edgeBlur: number;
  60523. /**
  60524. * Gets or sets the grain amount
  60525. */
  60526. grainAmount: number;
  60527. /**
  60528. * Gets or sets the chromatic aberration amount
  60529. */
  60530. chromaticAberration: number;
  60531. /**
  60532. * Gets or sets the depth of field aperture
  60533. */
  60534. dofAperture: number;
  60535. /**
  60536. * Gets or sets the edge distortion
  60537. */
  60538. edgeDistortion: number;
  60539. /**
  60540. * Gets or sets the depth of field distortion
  60541. */
  60542. dofDistortion: number;
  60543. /**
  60544. * Gets or sets the darken out of focus amount
  60545. */
  60546. darkenOutOfFocus: number;
  60547. /**
  60548. * Gets or sets a boolean indicating if blur noise is enabled
  60549. */
  60550. blurNoise: boolean;
  60551. /**
  60552. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60553. */
  60554. pentagonBokeh: boolean;
  60555. /**
  60556. * Gets or sets the highlight grain amount
  60557. */
  60558. highlightsGain: number;
  60559. /**
  60560. * Gets or sets the highlight threshold
  60561. */
  60562. highlightsThreshold: number;
  60563. /**
  60564. * Sets the amount of blur at the edges
  60565. * @param amount blur amount
  60566. */
  60567. setEdgeBlur(amount: number): void;
  60568. /**
  60569. * Sets edge blur to 0
  60570. */
  60571. disableEdgeBlur(): void;
  60572. /**
  60573. * Sets the amout of grain
  60574. * @param amount Amount of grain
  60575. */
  60576. setGrainAmount(amount: number): void;
  60577. /**
  60578. * Set grain amount to 0
  60579. */
  60580. disableGrain(): void;
  60581. /**
  60582. * Sets the chromatic aberration amount
  60583. * @param amount amount of chromatic aberration
  60584. */
  60585. setChromaticAberration(amount: number): void;
  60586. /**
  60587. * Sets chromatic aberration amount to 0
  60588. */
  60589. disableChromaticAberration(): void;
  60590. /**
  60591. * Sets the EdgeDistortion amount
  60592. * @param amount amount of EdgeDistortion
  60593. */
  60594. setEdgeDistortion(amount: number): void;
  60595. /**
  60596. * Sets edge distortion to 0
  60597. */
  60598. disableEdgeDistortion(): void;
  60599. /**
  60600. * Sets the FocusDistance amount
  60601. * @param amount amount of FocusDistance
  60602. */
  60603. setFocusDistance(amount: number): void;
  60604. /**
  60605. * Disables depth of field
  60606. */
  60607. disableDepthOfField(): void;
  60608. /**
  60609. * Sets the Aperture amount
  60610. * @param amount amount of Aperture
  60611. */
  60612. setAperture(amount: number): void;
  60613. /**
  60614. * Sets the DarkenOutOfFocus amount
  60615. * @param amount amount of DarkenOutOfFocus
  60616. */
  60617. setDarkenOutOfFocus(amount: number): void;
  60618. private _pentagonBokehIsEnabled;
  60619. /**
  60620. * Creates a pentagon bokeh effect
  60621. */
  60622. enablePentagonBokeh(): void;
  60623. /**
  60624. * Disables the pentagon bokeh effect
  60625. */
  60626. disablePentagonBokeh(): void;
  60627. /**
  60628. * Enables noise blur
  60629. */
  60630. enableNoiseBlur(): void;
  60631. /**
  60632. * Disables noise blur
  60633. */
  60634. disableNoiseBlur(): void;
  60635. /**
  60636. * Sets the HighlightsGain amount
  60637. * @param amount amount of HighlightsGain
  60638. */
  60639. setHighlightsGain(amount: number): void;
  60640. /**
  60641. * Sets the HighlightsThreshold amount
  60642. * @param amount amount of HighlightsThreshold
  60643. */
  60644. setHighlightsThreshold(amount: number): void;
  60645. /**
  60646. * Disables highlights
  60647. */
  60648. disableHighlights(): void;
  60649. /**
  60650. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60651. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60652. */
  60653. dispose(disableDepthRender?: boolean): void;
  60654. private _createChromaticAberrationPostProcess;
  60655. private _createHighlightsPostProcess;
  60656. private _createDepthOfFieldPostProcess;
  60657. private _createGrainTexture;
  60658. }
  60659. }
  60660. declare module BABYLON {
  60661. /** @hidden */
  60662. export var ssao2PixelShader: {
  60663. name: string;
  60664. shader: string;
  60665. };
  60666. }
  60667. declare module BABYLON {
  60668. /** @hidden */
  60669. export var ssaoCombinePixelShader: {
  60670. name: string;
  60671. shader: string;
  60672. };
  60673. }
  60674. declare module BABYLON {
  60675. /**
  60676. * Render pipeline to produce ssao effect
  60677. */
  60678. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60679. /**
  60680. * @ignore
  60681. * The PassPostProcess id in the pipeline that contains the original scene color
  60682. */
  60683. SSAOOriginalSceneColorEffect: string;
  60684. /**
  60685. * @ignore
  60686. * The SSAO PostProcess id in the pipeline
  60687. */
  60688. SSAORenderEffect: string;
  60689. /**
  60690. * @ignore
  60691. * The horizontal blur PostProcess id in the pipeline
  60692. */
  60693. SSAOBlurHRenderEffect: string;
  60694. /**
  60695. * @ignore
  60696. * The vertical blur PostProcess id in the pipeline
  60697. */
  60698. SSAOBlurVRenderEffect: string;
  60699. /**
  60700. * @ignore
  60701. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60702. */
  60703. SSAOCombineRenderEffect: string;
  60704. /**
  60705. * The output strength of the SSAO post-process. Default value is 1.0.
  60706. */
  60707. totalStrength: number;
  60708. /**
  60709. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60710. */
  60711. maxZ: number;
  60712. /**
  60713. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60714. */
  60715. minZAspect: number;
  60716. private _samples;
  60717. /**
  60718. * Number of samples used for the SSAO calculations. Default value is 8
  60719. */
  60720. samples: number;
  60721. private _textureSamples;
  60722. /**
  60723. * Number of samples to use for antialiasing
  60724. */
  60725. textureSamples: number;
  60726. /**
  60727. * Ratio object used for SSAO ratio and blur ratio
  60728. */
  60729. private _ratio;
  60730. /**
  60731. * Dynamically generated sphere sampler.
  60732. */
  60733. private _sampleSphere;
  60734. /**
  60735. * Blur filter offsets
  60736. */
  60737. private _samplerOffsets;
  60738. private _expensiveBlur;
  60739. /**
  60740. * If bilateral blur should be used
  60741. */
  60742. expensiveBlur: boolean;
  60743. /**
  60744. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60745. */
  60746. radius: number;
  60747. /**
  60748. * The base color of the SSAO post-process
  60749. * The final result is "base + ssao" between [0, 1]
  60750. */
  60751. base: number;
  60752. /**
  60753. * Support test.
  60754. */
  60755. static readonly IsSupported: boolean;
  60756. private _scene;
  60757. private _depthTexture;
  60758. private _normalTexture;
  60759. private _randomTexture;
  60760. private _originalColorPostProcess;
  60761. private _ssaoPostProcess;
  60762. private _blurHPostProcess;
  60763. private _blurVPostProcess;
  60764. private _ssaoCombinePostProcess;
  60765. /**
  60766. * Gets active scene
  60767. */
  60768. readonly scene: Scene;
  60769. /**
  60770. * @constructor
  60771. * @param name The rendering pipeline name
  60772. * @param scene The scene linked to this pipeline
  60773. * @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 }
  60774. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60775. */
  60776. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60777. /**
  60778. * Get the class name
  60779. * @returns "SSAO2RenderingPipeline"
  60780. */
  60781. getClassName(): string;
  60782. /**
  60783. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60784. */
  60785. dispose(disableGeometryBufferRenderer?: boolean): void;
  60786. private _createBlurPostProcess;
  60787. /** @hidden */ private _rebuild(): void;
  60788. private _bits;
  60789. private _radicalInverse_VdC;
  60790. private _hammersley;
  60791. private _hemisphereSample_uniform;
  60792. private _generateHemisphere;
  60793. private _createSSAOPostProcess;
  60794. private _createSSAOCombinePostProcess;
  60795. private _createRandomTexture;
  60796. /**
  60797. * Serialize the rendering pipeline (Used when exporting)
  60798. * @returns the serialized object
  60799. */
  60800. serialize(): any;
  60801. /**
  60802. * Parse the serialized pipeline
  60803. * @param source Source pipeline.
  60804. * @param scene The scene to load the pipeline to.
  60805. * @param rootUrl The URL of the serialized pipeline.
  60806. * @returns An instantiated pipeline from the serialized object.
  60807. */
  60808. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60809. }
  60810. }
  60811. declare module BABYLON {
  60812. /** @hidden */
  60813. export var ssaoPixelShader: {
  60814. name: string;
  60815. shader: string;
  60816. };
  60817. }
  60818. declare module BABYLON {
  60819. /**
  60820. * Render pipeline to produce ssao effect
  60821. */
  60822. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60823. /**
  60824. * @ignore
  60825. * The PassPostProcess id in the pipeline that contains the original scene color
  60826. */
  60827. SSAOOriginalSceneColorEffect: string;
  60828. /**
  60829. * @ignore
  60830. * The SSAO PostProcess id in the pipeline
  60831. */
  60832. SSAORenderEffect: string;
  60833. /**
  60834. * @ignore
  60835. * The horizontal blur PostProcess id in the pipeline
  60836. */
  60837. SSAOBlurHRenderEffect: string;
  60838. /**
  60839. * @ignore
  60840. * The vertical blur PostProcess id in the pipeline
  60841. */
  60842. SSAOBlurVRenderEffect: string;
  60843. /**
  60844. * @ignore
  60845. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60846. */
  60847. SSAOCombineRenderEffect: string;
  60848. /**
  60849. * The output strength of the SSAO post-process. Default value is 1.0.
  60850. */
  60851. totalStrength: number;
  60852. /**
  60853. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60854. */
  60855. radius: number;
  60856. /**
  60857. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60858. * Must not be equal to fallOff and superior to fallOff.
  60859. * Default value is 0.0075
  60860. */
  60861. area: number;
  60862. /**
  60863. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60864. * Must not be equal to area and inferior to area.
  60865. * Default value is 0.000001
  60866. */
  60867. fallOff: number;
  60868. /**
  60869. * The base color of the SSAO post-process
  60870. * The final result is "base + ssao" between [0, 1]
  60871. */
  60872. base: number;
  60873. private _scene;
  60874. private _depthTexture;
  60875. private _randomTexture;
  60876. private _originalColorPostProcess;
  60877. private _ssaoPostProcess;
  60878. private _blurHPostProcess;
  60879. private _blurVPostProcess;
  60880. private _ssaoCombinePostProcess;
  60881. private _firstUpdate;
  60882. /**
  60883. * Gets active scene
  60884. */
  60885. readonly scene: Scene;
  60886. /**
  60887. * @constructor
  60888. * @param name - The rendering pipeline name
  60889. * @param scene - The scene linked to this pipeline
  60890. * @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 }
  60891. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60892. */
  60893. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60894. /**
  60895. * Get the class name
  60896. * @returns "SSAORenderingPipeline"
  60897. */
  60898. getClassName(): string;
  60899. /**
  60900. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60901. */
  60902. dispose(disableDepthRender?: boolean): void;
  60903. private _createBlurPostProcess;
  60904. /** @hidden */ private _rebuild(): void;
  60905. private _createSSAOPostProcess;
  60906. private _createSSAOCombinePostProcess;
  60907. private _createRandomTexture;
  60908. }
  60909. }
  60910. declare module BABYLON {
  60911. /** @hidden */
  60912. export var standardPixelShader: {
  60913. name: string;
  60914. shader: string;
  60915. };
  60916. }
  60917. declare module BABYLON {
  60918. /**
  60919. * Standard rendering pipeline
  60920. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60921. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60922. */
  60923. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60924. /**
  60925. * Public members
  60926. */
  60927. /**
  60928. * Post-process which contains the original scene color before the pipeline applies all the effects
  60929. */
  60930. originalPostProcess: Nullable<PostProcess>;
  60931. /**
  60932. * Post-process used to down scale an image x4
  60933. */
  60934. downSampleX4PostProcess: Nullable<PostProcess>;
  60935. /**
  60936. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60937. */
  60938. brightPassPostProcess: Nullable<PostProcess>;
  60939. /**
  60940. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60941. */
  60942. blurHPostProcesses: PostProcess[];
  60943. /**
  60944. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60945. */
  60946. blurVPostProcesses: PostProcess[];
  60947. /**
  60948. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60949. */
  60950. textureAdderPostProcess: Nullable<PostProcess>;
  60951. /**
  60952. * Post-process used to create volumetric lighting effect
  60953. */
  60954. volumetricLightPostProcess: Nullable<PostProcess>;
  60955. /**
  60956. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60957. */
  60958. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60959. /**
  60960. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60961. */
  60962. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60963. /**
  60964. * Post-process used to merge the volumetric light effect and the real scene color
  60965. */
  60966. volumetricLightMergePostProces: Nullable<PostProcess>;
  60967. /**
  60968. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60969. */
  60970. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60971. /**
  60972. * Base post-process used to calculate the average luminance of the final image for HDR
  60973. */
  60974. luminancePostProcess: Nullable<PostProcess>;
  60975. /**
  60976. * Post-processes used to create down sample post-processes in order to get
  60977. * the average luminance of the final image for HDR
  60978. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60979. */
  60980. luminanceDownSamplePostProcesses: PostProcess[];
  60981. /**
  60982. * Post-process used to create a HDR effect (light adaptation)
  60983. */
  60984. hdrPostProcess: Nullable<PostProcess>;
  60985. /**
  60986. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60987. */
  60988. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60989. /**
  60990. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60991. */
  60992. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60993. /**
  60994. * Post-process used to merge the final HDR post-process and the real scene color
  60995. */
  60996. hdrFinalPostProcess: Nullable<PostProcess>;
  60997. /**
  60998. * Post-process used to create a lens flare effect
  60999. */
  61000. lensFlarePostProcess: Nullable<PostProcess>;
  61001. /**
  61002. * Post-process that merges the result of the lens flare post-process and the real scene color
  61003. */
  61004. lensFlareComposePostProcess: Nullable<PostProcess>;
  61005. /**
  61006. * Post-process used to create a motion blur effect
  61007. */
  61008. motionBlurPostProcess: Nullable<PostProcess>;
  61009. /**
  61010. * Post-process used to create a depth of field effect
  61011. */
  61012. depthOfFieldPostProcess: Nullable<PostProcess>;
  61013. /**
  61014. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61015. */
  61016. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61017. /**
  61018. * Represents the brightness threshold in order to configure the illuminated surfaces
  61019. */
  61020. brightThreshold: number;
  61021. /**
  61022. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61023. */
  61024. blurWidth: number;
  61025. /**
  61026. * Sets if the blur for highlighted surfaces must be only horizontal
  61027. */
  61028. horizontalBlur: boolean;
  61029. /**
  61030. * Gets the overall exposure used by the pipeline
  61031. */
  61032. /**
  61033. * Sets the overall exposure used by the pipeline
  61034. */
  61035. exposure: number;
  61036. /**
  61037. * Texture used typically to simulate "dirty" on camera lens
  61038. */
  61039. lensTexture: Nullable<Texture>;
  61040. /**
  61041. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61042. */
  61043. volumetricLightCoefficient: number;
  61044. /**
  61045. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61046. */
  61047. volumetricLightPower: number;
  61048. /**
  61049. * Used the set the blur intensity to smooth the volumetric lights
  61050. */
  61051. volumetricLightBlurScale: number;
  61052. /**
  61053. * Light (spot or directional) used to generate the volumetric lights rays
  61054. * The source light must have a shadow generate so the pipeline can get its
  61055. * depth map
  61056. */
  61057. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61058. /**
  61059. * For eye adaptation, represents the minimum luminance the eye can see
  61060. */
  61061. hdrMinimumLuminance: number;
  61062. /**
  61063. * For eye adaptation, represents the decrease luminance speed
  61064. */
  61065. hdrDecreaseRate: number;
  61066. /**
  61067. * For eye adaptation, represents the increase luminance speed
  61068. */
  61069. hdrIncreaseRate: number;
  61070. /**
  61071. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61072. */
  61073. /**
  61074. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61075. */
  61076. hdrAutoExposure: boolean;
  61077. /**
  61078. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61079. */
  61080. lensColorTexture: Nullable<Texture>;
  61081. /**
  61082. * The overall strengh for the lens flare effect
  61083. */
  61084. lensFlareStrength: number;
  61085. /**
  61086. * Dispersion coefficient for lens flare ghosts
  61087. */
  61088. lensFlareGhostDispersal: number;
  61089. /**
  61090. * Main lens flare halo width
  61091. */
  61092. lensFlareHaloWidth: number;
  61093. /**
  61094. * Based on the lens distortion effect, defines how much the lens flare result
  61095. * is distorted
  61096. */
  61097. lensFlareDistortionStrength: number;
  61098. /**
  61099. * Configures the blur intensity used for for lens flare (halo)
  61100. */
  61101. lensFlareBlurWidth: number;
  61102. /**
  61103. * Lens star texture must be used to simulate rays on the flares and is available
  61104. * in the documentation
  61105. */
  61106. lensStarTexture: Nullable<Texture>;
  61107. /**
  61108. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61109. * flare effect by taking account of the dirt texture
  61110. */
  61111. lensFlareDirtTexture: Nullable<Texture>;
  61112. /**
  61113. * Represents the focal length for the depth of field effect
  61114. */
  61115. depthOfFieldDistance: number;
  61116. /**
  61117. * Represents the blur intensity for the blurred part of the depth of field effect
  61118. */
  61119. depthOfFieldBlurWidth: number;
  61120. /**
  61121. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61122. */
  61123. /**
  61124. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61125. */
  61126. motionStrength: number;
  61127. /**
  61128. * Gets wether or not the motion blur post-process is object based or screen based.
  61129. */
  61130. /**
  61131. * Sets wether or not the motion blur post-process should be object based or screen based
  61132. */
  61133. objectBasedMotionBlur: boolean;
  61134. /**
  61135. * List of animations for the pipeline (IAnimatable implementation)
  61136. */
  61137. animations: Animation[];
  61138. /**
  61139. * Private members
  61140. */
  61141. private _scene;
  61142. private _currentDepthOfFieldSource;
  61143. private _basePostProcess;
  61144. private _fixedExposure;
  61145. private _currentExposure;
  61146. private _hdrAutoExposure;
  61147. private _hdrCurrentLuminance;
  61148. private _motionStrength;
  61149. private _isObjectBasedMotionBlur;
  61150. private _floatTextureType;
  61151. private _camerasToBeAttached;
  61152. private _ratio;
  61153. private _bloomEnabled;
  61154. private _depthOfFieldEnabled;
  61155. private _vlsEnabled;
  61156. private _lensFlareEnabled;
  61157. private _hdrEnabled;
  61158. private _motionBlurEnabled;
  61159. private _fxaaEnabled;
  61160. private _motionBlurSamples;
  61161. private _volumetricLightStepsCount;
  61162. private _samples;
  61163. /**
  61164. * @ignore
  61165. * Specifies if the bloom pipeline is enabled
  61166. */
  61167. BloomEnabled: boolean;
  61168. /**
  61169. * @ignore
  61170. * Specifies if the depth of field pipeline is enabed
  61171. */
  61172. DepthOfFieldEnabled: boolean;
  61173. /**
  61174. * @ignore
  61175. * Specifies if the lens flare pipeline is enabed
  61176. */
  61177. LensFlareEnabled: boolean;
  61178. /**
  61179. * @ignore
  61180. * Specifies if the HDR pipeline is enabled
  61181. */
  61182. HDREnabled: boolean;
  61183. /**
  61184. * @ignore
  61185. * Specifies if the volumetric lights scattering effect is enabled
  61186. */
  61187. VLSEnabled: boolean;
  61188. /**
  61189. * @ignore
  61190. * Specifies if the motion blur effect is enabled
  61191. */
  61192. MotionBlurEnabled: boolean;
  61193. /**
  61194. * Specifies if anti-aliasing is enabled
  61195. */
  61196. fxaaEnabled: boolean;
  61197. /**
  61198. * Specifies the number of steps used to calculate the volumetric lights
  61199. * Typically in interval [50, 200]
  61200. */
  61201. volumetricLightStepsCount: number;
  61202. /**
  61203. * Specifies the number of samples used for the motion blur effect
  61204. * Typically in interval [16, 64]
  61205. */
  61206. motionBlurSamples: number;
  61207. /**
  61208. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61209. */
  61210. samples: number;
  61211. /**
  61212. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61213. * @constructor
  61214. * @param name The rendering pipeline name
  61215. * @param scene The scene linked to this pipeline
  61216. * @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)
  61217. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61218. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61219. */
  61220. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61221. private _buildPipeline;
  61222. private _createDownSampleX4PostProcess;
  61223. private _createBrightPassPostProcess;
  61224. private _createBlurPostProcesses;
  61225. private _createTextureAdderPostProcess;
  61226. private _createVolumetricLightPostProcess;
  61227. private _createLuminancePostProcesses;
  61228. private _createHdrPostProcess;
  61229. private _createLensFlarePostProcess;
  61230. private _createDepthOfFieldPostProcess;
  61231. private _createMotionBlurPostProcess;
  61232. private _getDepthTexture;
  61233. private _disposePostProcesses;
  61234. /**
  61235. * Dispose of the pipeline and stop all post processes
  61236. */
  61237. dispose(): void;
  61238. /**
  61239. * Serialize the rendering pipeline (Used when exporting)
  61240. * @returns the serialized object
  61241. */
  61242. serialize(): any;
  61243. /**
  61244. * Parse the serialized pipeline
  61245. * @param source Source pipeline.
  61246. * @param scene The scene to load the pipeline to.
  61247. * @param rootUrl The URL of the serialized pipeline.
  61248. * @returns An instantiated pipeline from the serialized object.
  61249. */
  61250. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61251. /**
  61252. * Luminance steps
  61253. */
  61254. static LuminanceSteps: number;
  61255. }
  61256. }
  61257. declare module BABYLON {
  61258. /** @hidden */
  61259. export var tonemapPixelShader: {
  61260. name: string;
  61261. shader: string;
  61262. };
  61263. }
  61264. declare module BABYLON {
  61265. /** Defines operator used for tonemapping */
  61266. export enum TonemappingOperator {
  61267. /** Hable */
  61268. Hable = 0,
  61269. /** Reinhard */
  61270. Reinhard = 1,
  61271. /** HejiDawson */
  61272. HejiDawson = 2,
  61273. /** Photographic */
  61274. Photographic = 3
  61275. }
  61276. /**
  61277. * Defines a post process to apply tone mapping
  61278. */
  61279. export class TonemapPostProcess extends PostProcess {
  61280. private _operator;
  61281. /** Defines the required exposure adjustement */
  61282. exposureAdjustment: number;
  61283. /**
  61284. * Creates a new TonemapPostProcess
  61285. * @param name defines the name of the postprocess
  61286. * @param _operator defines the operator to use
  61287. * @param exposureAdjustment defines the required exposure adjustement
  61288. * @param camera defines the camera to use (can be null)
  61289. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61290. * @param engine defines the hosting engine (can be ignore if camera is set)
  61291. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61292. */
  61293. constructor(name: string, _operator: TonemappingOperator,
  61294. /** Defines the required exposure adjustement */
  61295. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61296. }
  61297. }
  61298. declare module BABYLON {
  61299. /** @hidden */
  61300. export var depthVertexShader: {
  61301. name: string;
  61302. shader: string;
  61303. };
  61304. }
  61305. declare module BABYLON {
  61306. /** @hidden */
  61307. export var volumetricLightScatteringPixelShader: {
  61308. name: string;
  61309. shader: string;
  61310. };
  61311. }
  61312. declare module BABYLON {
  61313. /** @hidden */
  61314. export var volumetricLightScatteringPassVertexShader: {
  61315. name: string;
  61316. shader: string;
  61317. };
  61318. }
  61319. declare module BABYLON {
  61320. /** @hidden */
  61321. export var volumetricLightScatteringPassPixelShader: {
  61322. name: string;
  61323. shader: string;
  61324. };
  61325. }
  61326. declare module BABYLON {
  61327. /**
  61328. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61329. */
  61330. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61331. private _volumetricLightScatteringPass;
  61332. private _volumetricLightScatteringRTT;
  61333. private _viewPort;
  61334. private _screenCoordinates;
  61335. private _cachedDefines;
  61336. /**
  61337. * If not undefined, the mesh position is computed from the attached node position
  61338. */
  61339. attachedNode: {
  61340. position: Vector3;
  61341. };
  61342. /**
  61343. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61344. */
  61345. customMeshPosition: Vector3;
  61346. /**
  61347. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61348. */
  61349. useCustomMeshPosition: boolean;
  61350. /**
  61351. * If the post-process should inverse the light scattering direction
  61352. */
  61353. invert: boolean;
  61354. /**
  61355. * The internal mesh used by the post-process
  61356. */
  61357. mesh: Mesh;
  61358. /**
  61359. * @hidden
  61360. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61361. */
  61362. useDiffuseColor: boolean;
  61363. /**
  61364. * Array containing the excluded meshes not rendered in the internal pass
  61365. */
  61366. excludedMeshes: AbstractMesh[];
  61367. /**
  61368. * Controls the overall intensity of the post-process
  61369. */
  61370. exposure: number;
  61371. /**
  61372. * Dissipates each sample's contribution in range [0, 1]
  61373. */
  61374. decay: number;
  61375. /**
  61376. * Controls the overall intensity of each sample
  61377. */
  61378. weight: number;
  61379. /**
  61380. * Controls the density of each sample
  61381. */
  61382. density: number;
  61383. /**
  61384. * @constructor
  61385. * @param name The post-process name
  61386. * @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)
  61387. * @param camera The camera that the post-process will be attached to
  61388. * @param mesh The mesh used to create the light scattering
  61389. * @param samples The post-process quality, default 100
  61390. * @param samplingModeThe post-process filtering mode
  61391. * @param engine The babylon engine
  61392. * @param reusable If the post-process is reusable
  61393. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61394. */
  61395. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61396. /**
  61397. * Returns the string "VolumetricLightScatteringPostProcess"
  61398. * @returns "VolumetricLightScatteringPostProcess"
  61399. */
  61400. getClassName(): string;
  61401. private _isReady;
  61402. /**
  61403. * Sets the new light position for light scattering effect
  61404. * @param position The new custom light position
  61405. */
  61406. setCustomMeshPosition(position: Vector3): void;
  61407. /**
  61408. * Returns the light position for light scattering effect
  61409. * @return Vector3 The custom light position
  61410. */
  61411. getCustomMeshPosition(): Vector3;
  61412. /**
  61413. * Disposes the internal assets and detaches the post-process from the camera
  61414. */
  61415. dispose(camera: Camera): void;
  61416. /**
  61417. * Returns the render target texture used by the post-process
  61418. * @return the render target texture used by the post-process
  61419. */
  61420. getPass(): RenderTargetTexture;
  61421. private _meshExcluded;
  61422. private _createPass;
  61423. private _updateMeshScreenCoordinates;
  61424. /**
  61425. * Creates a default mesh for the Volumeric Light Scattering post-process
  61426. * @param name The mesh name
  61427. * @param scene The scene where to create the mesh
  61428. * @return the default mesh
  61429. */
  61430. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61431. }
  61432. }
  61433. declare module BABYLON {
  61434. interface Scene {
  61435. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  61436. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  61437. /**
  61438. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61439. */
  61440. forceShowBoundingBoxes: boolean;
  61441. /**
  61442. * Gets the bounding box renderer associated with the scene
  61443. * @returns a BoundingBoxRenderer
  61444. */
  61445. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61446. }
  61447. interface AbstractMesh {
  61448. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  61449. /**
  61450. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61451. */
  61452. showBoundingBox: boolean;
  61453. }
  61454. /**
  61455. * Component responsible of rendering the bounding box of the meshes in a scene.
  61456. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61457. */
  61458. export class BoundingBoxRenderer implements ISceneComponent {
  61459. /**
  61460. * The component name helpfull to identify the component in the list of scene components.
  61461. */
  61462. readonly name: string;
  61463. /**
  61464. * The scene the component belongs to.
  61465. */
  61466. scene: Scene;
  61467. /**
  61468. * Color of the bounding box lines placed in front of an object
  61469. */
  61470. frontColor: Color3;
  61471. /**
  61472. * Color of the bounding box lines placed behind an object
  61473. */
  61474. backColor: Color3;
  61475. /**
  61476. * Defines if the renderer should show the back lines or not
  61477. */
  61478. showBackLines: boolean;
  61479. /**
  61480. * @hidden
  61481. */
  61482. renderList: SmartArray<BoundingBox>;
  61483. private _colorShader;
  61484. private _vertexBuffers;
  61485. private _indexBuffer;
  61486. private _fillIndexBuffer;
  61487. private _fillIndexData;
  61488. /**
  61489. * Instantiates a new bounding box renderer in a scene.
  61490. * @param scene the scene the renderer renders in
  61491. */
  61492. constructor(scene: Scene);
  61493. /**
  61494. * Registers the component in a given scene
  61495. */
  61496. register(): void;
  61497. private _evaluateSubMesh;
  61498. private _activeMesh;
  61499. private _prepareRessources;
  61500. private _createIndexBuffer;
  61501. /**
  61502. * Rebuilds the elements related to this component in case of
  61503. * context lost for instance.
  61504. */
  61505. rebuild(): void;
  61506. /**
  61507. * @hidden
  61508. */
  61509. reset(): void;
  61510. /**
  61511. * Render the bounding boxes of a specific rendering group
  61512. * @param renderingGroupId defines the rendering group to render
  61513. */
  61514. render(renderingGroupId: number): void;
  61515. /**
  61516. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61517. * @param mesh Define the mesh to render the occlusion bounding box for
  61518. */
  61519. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61520. /**
  61521. * Dispose and release the resources attached to this renderer.
  61522. */
  61523. dispose(): void;
  61524. }
  61525. }
  61526. declare module BABYLON {
  61527. /** @hidden */
  61528. export var depthPixelShader: {
  61529. name: string;
  61530. shader: string;
  61531. };
  61532. }
  61533. declare module BABYLON {
  61534. /**
  61535. * This represents a depth renderer in Babylon.
  61536. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61537. */
  61538. export class DepthRenderer {
  61539. private _scene;
  61540. private _depthMap;
  61541. private _effect;
  61542. private readonly _storeNonLinearDepth;
  61543. private readonly _clearColor;
  61544. /** Get if the depth renderer is using packed depth or not */
  61545. readonly isPacked: boolean;
  61546. private _cachedDefines;
  61547. private _camera;
  61548. /**
  61549. * Specifiess that the depth renderer will only be used within
  61550. * the camera it is created for.
  61551. * This can help forcing its rendering during the camera processing.
  61552. */
  61553. useOnlyInActiveCamera: boolean;
  61554. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  61555. /**
  61556. * Instantiates a depth renderer
  61557. * @param scene The scene the renderer belongs to
  61558. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61559. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61560. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61561. */
  61562. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61563. /**
  61564. * Creates the depth rendering effect and checks if the effect is ready.
  61565. * @param subMesh The submesh to be used to render the depth map of
  61566. * @param useInstances If multiple world instances should be used
  61567. * @returns if the depth renderer is ready to render the depth map
  61568. */
  61569. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61570. /**
  61571. * Gets the texture which the depth map will be written to.
  61572. * @returns The depth map texture
  61573. */
  61574. getDepthMap(): RenderTargetTexture;
  61575. /**
  61576. * Disposes of the depth renderer.
  61577. */
  61578. dispose(): void;
  61579. }
  61580. }
  61581. declare module BABYLON {
  61582. interface Scene {
  61583. /** @hidden (Backing field) */ private _depthRenderer: {
  61584. [id: string]: DepthRenderer;
  61585. };
  61586. /**
  61587. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61588. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61589. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61590. * @returns the created depth renderer
  61591. */
  61592. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61593. /**
  61594. * Disables a depth renderer for a given camera
  61595. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61596. */
  61597. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61598. }
  61599. /**
  61600. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61601. * in several rendering techniques.
  61602. */
  61603. export class DepthRendererSceneComponent implements ISceneComponent {
  61604. /**
  61605. * The component name helpfull to identify the component in the list of scene components.
  61606. */
  61607. readonly name: string;
  61608. /**
  61609. * The scene the component belongs to.
  61610. */
  61611. scene: Scene;
  61612. /**
  61613. * Creates a new instance of the component for the given scene
  61614. * @param scene Defines the scene to register the component in
  61615. */
  61616. constructor(scene: Scene);
  61617. /**
  61618. * Registers the component in a given scene
  61619. */
  61620. register(): void;
  61621. /**
  61622. * Rebuilds the elements related to this component in case of
  61623. * context lost for instance.
  61624. */
  61625. rebuild(): void;
  61626. /**
  61627. * Disposes the component and the associated ressources
  61628. */
  61629. dispose(): void;
  61630. private _gatherRenderTargets;
  61631. private _gatherActiveCameraRenderTargets;
  61632. }
  61633. }
  61634. declare module BABYLON {
  61635. /** @hidden */
  61636. export var outlinePixelShader: {
  61637. name: string;
  61638. shader: string;
  61639. };
  61640. }
  61641. declare module BABYLON {
  61642. /** @hidden */
  61643. export var outlineVertexShader: {
  61644. name: string;
  61645. shader: string;
  61646. };
  61647. }
  61648. declare module BABYLON {
  61649. interface Scene {
  61650. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  61651. /**
  61652. * Gets the outline renderer associated with the scene
  61653. * @returns a OutlineRenderer
  61654. */
  61655. getOutlineRenderer(): OutlineRenderer;
  61656. }
  61657. interface AbstractMesh {
  61658. /** @hidden (Backing field) */ private _renderOutline: boolean;
  61659. /**
  61660. * Gets or sets a boolean indicating if the outline must be rendered as well
  61661. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61662. */
  61663. renderOutline: boolean;
  61664. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  61665. /**
  61666. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61667. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61668. */
  61669. renderOverlay: boolean;
  61670. }
  61671. /**
  61672. * This class is responsible to draw bothe outline/overlay of meshes.
  61673. * It should not be used directly but through the available method on mesh.
  61674. */
  61675. export class OutlineRenderer implements ISceneComponent {
  61676. /**
  61677. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61678. */
  61679. private static _StencilReference;
  61680. /**
  61681. * The name of the component. Each component must have a unique name.
  61682. */
  61683. name: string;
  61684. /**
  61685. * The scene the component belongs to.
  61686. */
  61687. scene: Scene;
  61688. /**
  61689. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61690. */
  61691. zOffset: number;
  61692. private _engine;
  61693. private _effect;
  61694. private _cachedDefines;
  61695. private _savedDepthWrite;
  61696. /**
  61697. * Instantiates a new outline renderer. (There could be only one per scene).
  61698. * @param scene Defines the scene it belongs to
  61699. */
  61700. constructor(scene: Scene);
  61701. /**
  61702. * Register the component to one instance of a scene.
  61703. */
  61704. register(): void;
  61705. /**
  61706. * Rebuilds the elements related to this component in case of
  61707. * context lost for instance.
  61708. */
  61709. rebuild(): void;
  61710. /**
  61711. * Disposes the component and the associated ressources.
  61712. */
  61713. dispose(): void;
  61714. /**
  61715. * Renders the outline in the canvas.
  61716. * @param subMesh Defines the sumesh to render
  61717. * @param batch Defines the batch of meshes in case of instances
  61718. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61719. */
  61720. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61721. /**
  61722. * Returns whether or not the outline renderer is ready for a given submesh.
  61723. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61724. * @param subMesh Defines the submesh to check readyness for
  61725. * @param useInstances Defines wheter wee are trying to render instances or not
  61726. * @returns true if ready otherwise false
  61727. */
  61728. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61729. private _beforeRenderingMesh;
  61730. private _afterRenderingMesh;
  61731. }
  61732. }
  61733. declare module BABYLON {
  61734. /**
  61735. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61736. * @see http://doc.babylonjs.com/babylon101/sprites
  61737. */
  61738. export class SpritePackedManager extends SpriteManager {
  61739. /** defines the packed manager's name */
  61740. name: string;
  61741. /**
  61742. * Creates a new sprite manager from a packed sprite sheet
  61743. * @param name defines the manager's name
  61744. * @param imgUrl defines the sprite sheet url
  61745. * @param capacity defines the maximum allowed number of sprites
  61746. * @param scene defines the hosting scene
  61747. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  61748. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  61749. * @param samplingMode defines the smapling mode to use with spritesheet
  61750. * @param fromPacked set to true; do not alter
  61751. */
  61752. constructor(
  61753. /** defines the packed manager's name */
  61754. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  61755. }
  61756. }
  61757. declare module BABYLON {
  61758. /**
  61759. * Defines the list of states available for a task inside a AssetsManager
  61760. */
  61761. export enum AssetTaskState {
  61762. /**
  61763. * Initialization
  61764. */
  61765. INIT = 0,
  61766. /**
  61767. * Running
  61768. */
  61769. RUNNING = 1,
  61770. /**
  61771. * Done
  61772. */
  61773. DONE = 2,
  61774. /**
  61775. * Error
  61776. */
  61777. ERROR = 3
  61778. }
  61779. /**
  61780. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61781. */
  61782. export abstract class AbstractAssetTask {
  61783. /**
  61784. * Task name
  61785. */ name: string;
  61786. /**
  61787. * Callback called when the task is successful
  61788. */
  61789. onSuccess: (task: any) => void;
  61790. /**
  61791. * Callback called when the task is not successful
  61792. */
  61793. onError: (task: any, message?: string, exception?: any) => void;
  61794. /**
  61795. * Creates a new AssetsManager
  61796. * @param name defines the name of the task
  61797. */
  61798. constructor(
  61799. /**
  61800. * Task name
  61801. */ name: string);
  61802. private _isCompleted;
  61803. private _taskState;
  61804. private _errorObject;
  61805. /**
  61806. * Get if the task is completed
  61807. */
  61808. readonly isCompleted: boolean;
  61809. /**
  61810. * Gets the current state of the task
  61811. */
  61812. readonly taskState: AssetTaskState;
  61813. /**
  61814. * Gets the current error object (if task is in error)
  61815. */
  61816. readonly errorObject: {
  61817. message?: string;
  61818. exception?: any;
  61819. };
  61820. /**
  61821. * Internal only
  61822. * @hidden
  61823. */ private _setErrorObject(message?: string, exception?: any): void;
  61824. /**
  61825. * Execute the current task
  61826. * @param scene defines the scene where you want your assets to be loaded
  61827. * @param onSuccess is a callback called when the task is successfully executed
  61828. * @param onError is a callback called if an error occurs
  61829. */
  61830. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61831. /**
  61832. * Execute the current task
  61833. * @param scene defines the scene where you want your assets to be loaded
  61834. * @param onSuccess is a callback called when the task is successfully executed
  61835. * @param onError is a callback called if an error occurs
  61836. */
  61837. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61838. /**
  61839. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61840. * This can be used with failed tasks that have the reason for failure fixed.
  61841. */
  61842. reset(): void;
  61843. private onErrorCallback;
  61844. private onDoneCallback;
  61845. }
  61846. /**
  61847. * Define the interface used by progress events raised during assets loading
  61848. */
  61849. export interface IAssetsProgressEvent {
  61850. /**
  61851. * Defines the number of remaining tasks to process
  61852. */
  61853. remainingCount: number;
  61854. /**
  61855. * Defines the total number of tasks
  61856. */
  61857. totalCount: number;
  61858. /**
  61859. * Defines the task that was just processed
  61860. */
  61861. task: AbstractAssetTask;
  61862. }
  61863. /**
  61864. * Class used to share progress information about assets loading
  61865. */
  61866. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61867. /**
  61868. * Defines the number of remaining tasks to process
  61869. */
  61870. remainingCount: number;
  61871. /**
  61872. * Defines the total number of tasks
  61873. */
  61874. totalCount: number;
  61875. /**
  61876. * Defines the task that was just processed
  61877. */
  61878. task: AbstractAssetTask;
  61879. /**
  61880. * Creates a AssetsProgressEvent
  61881. * @param remainingCount defines the number of remaining tasks to process
  61882. * @param totalCount defines the total number of tasks
  61883. * @param task defines the task that was just processed
  61884. */
  61885. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61886. }
  61887. /**
  61888. * Define a task used by AssetsManager to load meshes
  61889. */
  61890. export class MeshAssetTask extends AbstractAssetTask {
  61891. /**
  61892. * Defines the name of the task
  61893. */
  61894. name: string;
  61895. /**
  61896. * Defines the list of mesh's names you want to load
  61897. */
  61898. meshesNames: any;
  61899. /**
  61900. * Defines the root url to use as a base to load your meshes and associated resources
  61901. */
  61902. rootUrl: string;
  61903. /**
  61904. * Defines the filename of the scene to load from
  61905. */
  61906. sceneFilename: string;
  61907. /**
  61908. * Gets the list of loaded meshes
  61909. */
  61910. loadedMeshes: Array<AbstractMesh>;
  61911. /**
  61912. * Gets the list of loaded particle systems
  61913. */
  61914. loadedParticleSystems: Array<IParticleSystem>;
  61915. /**
  61916. * Gets the list of loaded skeletons
  61917. */
  61918. loadedSkeletons: Array<Skeleton>;
  61919. /**
  61920. * Gets the list of loaded animation groups
  61921. */
  61922. loadedAnimationGroups: Array<AnimationGroup>;
  61923. /**
  61924. * Callback called when the task is successful
  61925. */
  61926. onSuccess: (task: MeshAssetTask) => void;
  61927. /**
  61928. * Callback called when the task is successful
  61929. */
  61930. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61931. /**
  61932. * Creates a new MeshAssetTask
  61933. * @param name defines the name of the task
  61934. * @param meshesNames defines the list of mesh's names you want to load
  61935. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61936. * @param sceneFilename defines the filename of the scene to load from
  61937. */
  61938. constructor(
  61939. /**
  61940. * Defines the name of the task
  61941. */
  61942. name: string,
  61943. /**
  61944. * Defines the list of mesh's names you want to load
  61945. */
  61946. meshesNames: any,
  61947. /**
  61948. * Defines the root url to use as a base to load your meshes and associated resources
  61949. */
  61950. rootUrl: string,
  61951. /**
  61952. * Defines the filename of the scene to load from
  61953. */
  61954. sceneFilename: string);
  61955. /**
  61956. * Execute the current task
  61957. * @param scene defines the scene where you want your assets to be loaded
  61958. * @param onSuccess is a callback called when the task is successfully executed
  61959. * @param onError is a callback called if an error occurs
  61960. */
  61961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61962. }
  61963. /**
  61964. * Define a task used by AssetsManager to load text content
  61965. */
  61966. export class TextFileAssetTask extends AbstractAssetTask {
  61967. /**
  61968. * Defines the name of the task
  61969. */
  61970. name: string;
  61971. /**
  61972. * Defines the location of the file to load
  61973. */
  61974. url: string;
  61975. /**
  61976. * Gets the loaded text string
  61977. */
  61978. text: string;
  61979. /**
  61980. * Callback called when the task is successful
  61981. */
  61982. onSuccess: (task: TextFileAssetTask) => void;
  61983. /**
  61984. * Callback called when the task is successful
  61985. */
  61986. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61987. /**
  61988. * Creates a new TextFileAssetTask object
  61989. * @param name defines the name of the task
  61990. * @param url defines the location of the file to load
  61991. */
  61992. constructor(
  61993. /**
  61994. * Defines the name of the task
  61995. */
  61996. name: string,
  61997. /**
  61998. * Defines the location of the file to load
  61999. */
  62000. url: string);
  62001. /**
  62002. * Execute the current task
  62003. * @param scene defines the scene where you want your assets to be loaded
  62004. * @param onSuccess is a callback called when the task is successfully executed
  62005. * @param onError is a callback called if an error occurs
  62006. */
  62007. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62008. }
  62009. /**
  62010. * Define a task used by AssetsManager to load binary data
  62011. */
  62012. export class BinaryFileAssetTask extends AbstractAssetTask {
  62013. /**
  62014. * Defines the name of the task
  62015. */
  62016. name: string;
  62017. /**
  62018. * Defines the location of the file to load
  62019. */
  62020. url: string;
  62021. /**
  62022. * Gets the lodaded data (as an array buffer)
  62023. */
  62024. data: ArrayBuffer;
  62025. /**
  62026. * Callback called when the task is successful
  62027. */
  62028. onSuccess: (task: BinaryFileAssetTask) => void;
  62029. /**
  62030. * Callback called when the task is successful
  62031. */
  62032. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62033. /**
  62034. * Creates a new BinaryFileAssetTask object
  62035. * @param name defines the name of the new task
  62036. * @param url defines the location of the file to load
  62037. */
  62038. constructor(
  62039. /**
  62040. * Defines the name of the task
  62041. */
  62042. name: string,
  62043. /**
  62044. * Defines the location of the file to load
  62045. */
  62046. url: string);
  62047. /**
  62048. * Execute the current task
  62049. * @param scene defines the scene where you want your assets to be loaded
  62050. * @param onSuccess is a callback called when the task is successfully executed
  62051. * @param onError is a callback called if an error occurs
  62052. */
  62053. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62054. }
  62055. /**
  62056. * Define a task used by AssetsManager to load images
  62057. */
  62058. export class ImageAssetTask extends AbstractAssetTask {
  62059. /**
  62060. * Defines the name of the task
  62061. */
  62062. name: string;
  62063. /**
  62064. * Defines the location of the image to load
  62065. */
  62066. url: string;
  62067. /**
  62068. * Gets the loaded images
  62069. */
  62070. image: HTMLImageElement;
  62071. /**
  62072. * Callback called when the task is successful
  62073. */
  62074. onSuccess: (task: ImageAssetTask) => void;
  62075. /**
  62076. * Callback called when the task is successful
  62077. */
  62078. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62079. /**
  62080. * Creates a new ImageAssetTask
  62081. * @param name defines the name of the task
  62082. * @param url defines the location of the image to load
  62083. */
  62084. constructor(
  62085. /**
  62086. * Defines the name of the task
  62087. */
  62088. name: string,
  62089. /**
  62090. * Defines the location of the image to load
  62091. */
  62092. url: string);
  62093. /**
  62094. * Execute the current task
  62095. * @param scene defines the scene where you want your assets to be loaded
  62096. * @param onSuccess is a callback called when the task is successfully executed
  62097. * @param onError is a callback called if an error occurs
  62098. */
  62099. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62100. }
  62101. /**
  62102. * Defines the interface used by texture loading tasks
  62103. */
  62104. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62105. /**
  62106. * Gets the loaded texture
  62107. */
  62108. texture: TEX;
  62109. }
  62110. /**
  62111. * Define a task used by AssetsManager to load 2D textures
  62112. */
  62113. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62114. /**
  62115. * Defines the name of the task
  62116. */
  62117. name: string;
  62118. /**
  62119. * Defines the location of the file to load
  62120. */
  62121. url: string;
  62122. /**
  62123. * Defines if mipmap should not be generated (default is false)
  62124. */
  62125. noMipmap?: boolean | undefined;
  62126. /**
  62127. * Defines if texture must be inverted on Y axis (default is false)
  62128. */
  62129. invertY?: boolean | undefined;
  62130. /**
  62131. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62132. */
  62133. samplingMode: number;
  62134. /**
  62135. * Gets the loaded texture
  62136. */
  62137. texture: Texture;
  62138. /**
  62139. * Callback called when the task is successful
  62140. */
  62141. onSuccess: (task: TextureAssetTask) => void;
  62142. /**
  62143. * Callback called when the task is successful
  62144. */
  62145. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62146. /**
  62147. * Creates a new TextureAssetTask object
  62148. * @param name defines the name of the task
  62149. * @param url defines the location of the file to load
  62150. * @param noMipmap defines if mipmap should not be generated (default is false)
  62151. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62152. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62153. */
  62154. constructor(
  62155. /**
  62156. * Defines the name of the task
  62157. */
  62158. name: string,
  62159. /**
  62160. * Defines the location of the file to load
  62161. */
  62162. url: string,
  62163. /**
  62164. * Defines if mipmap should not be generated (default is false)
  62165. */
  62166. noMipmap?: boolean | undefined,
  62167. /**
  62168. * Defines if texture must be inverted on Y axis (default is false)
  62169. */
  62170. invertY?: boolean | undefined,
  62171. /**
  62172. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62173. */
  62174. samplingMode?: number);
  62175. /**
  62176. * Execute the current task
  62177. * @param scene defines the scene where you want your assets to be loaded
  62178. * @param onSuccess is a callback called when the task is successfully executed
  62179. * @param onError is a callback called if an error occurs
  62180. */
  62181. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62182. }
  62183. /**
  62184. * Define a task used by AssetsManager to load cube textures
  62185. */
  62186. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62187. /**
  62188. * Defines the name of the task
  62189. */
  62190. name: string;
  62191. /**
  62192. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62193. */
  62194. url: string;
  62195. /**
  62196. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62197. */
  62198. extensions?: string[] | undefined;
  62199. /**
  62200. * Defines if mipmaps should not be generated (default is false)
  62201. */
  62202. noMipmap?: boolean | undefined;
  62203. /**
  62204. * Defines the explicit list of files (undefined by default)
  62205. */
  62206. files?: string[] | undefined;
  62207. /**
  62208. * Gets the loaded texture
  62209. */
  62210. texture: CubeTexture;
  62211. /**
  62212. * Callback called when the task is successful
  62213. */
  62214. onSuccess: (task: CubeTextureAssetTask) => void;
  62215. /**
  62216. * Callback called when the task is successful
  62217. */
  62218. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62219. /**
  62220. * Creates a new CubeTextureAssetTask
  62221. * @param name defines the name of the task
  62222. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62223. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62224. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62225. * @param files defines the explicit list of files (undefined by default)
  62226. */
  62227. constructor(
  62228. /**
  62229. * Defines the name of the task
  62230. */
  62231. name: string,
  62232. /**
  62233. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62234. */
  62235. url: string,
  62236. /**
  62237. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62238. */
  62239. extensions?: string[] | undefined,
  62240. /**
  62241. * Defines if mipmaps should not be generated (default is false)
  62242. */
  62243. noMipmap?: boolean | undefined,
  62244. /**
  62245. * Defines the explicit list of files (undefined by default)
  62246. */
  62247. files?: string[] | undefined);
  62248. /**
  62249. * Execute the current task
  62250. * @param scene defines the scene where you want your assets to be loaded
  62251. * @param onSuccess is a callback called when the task is successfully executed
  62252. * @param onError is a callback called if an error occurs
  62253. */
  62254. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62255. }
  62256. /**
  62257. * Define a task used by AssetsManager to load HDR cube textures
  62258. */
  62259. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62260. /**
  62261. * Defines the name of the task
  62262. */
  62263. name: string;
  62264. /**
  62265. * Defines the location of the file to load
  62266. */
  62267. url: string;
  62268. /**
  62269. * Defines the desired size (the more it increases the longer the generation will be)
  62270. */
  62271. size: number;
  62272. /**
  62273. * Defines if mipmaps should not be generated (default is false)
  62274. */
  62275. noMipmap: boolean;
  62276. /**
  62277. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62278. */
  62279. generateHarmonics: boolean;
  62280. /**
  62281. * 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)
  62282. */
  62283. gammaSpace: boolean;
  62284. /**
  62285. * Internal Use Only
  62286. */
  62287. reserved: boolean;
  62288. /**
  62289. * Gets the loaded texture
  62290. */
  62291. texture: HDRCubeTexture;
  62292. /**
  62293. * Callback called when the task is successful
  62294. */
  62295. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62296. /**
  62297. * Callback called when the task is successful
  62298. */
  62299. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62300. /**
  62301. * Creates a new HDRCubeTextureAssetTask object
  62302. * @param name defines the name of the task
  62303. * @param url defines the location of the file to load
  62304. * @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.
  62305. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62306. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62307. * @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)
  62308. * @param reserved Internal use only
  62309. */
  62310. constructor(
  62311. /**
  62312. * Defines the name of the task
  62313. */
  62314. name: string,
  62315. /**
  62316. * Defines the location of the file to load
  62317. */
  62318. url: string,
  62319. /**
  62320. * Defines the desired size (the more it increases the longer the generation will be)
  62321. */
  62322. size: number,
  62323. /**
  62324. * Defines if mipmaps should not be generated (default is false)
  62325. */
  62326. noMipmap?: boolean,
  62327. /**
  62328. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62329. */
  62330. generateHarmonics?: boolean,
  62331. /**
  62332. * 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)
  62333. */
  62334. gammaSpace?: boolean,
  62335. /**
  62336. * Internal Use Only
  62337. */
  62338. reserved?: boolean);
  62339. /**
  62340. * Execute the current task
  62341. * @param scene defines the scene where you want your assets to be loaded
  62342. * @param onSuccess is a callback called when the task is successfully executed
  62343. * @param onError is a callback called if an error occurs
  62344. */
  62345. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62346. }
  62347. /**
  62348. * Define a task used by AssetsManager to load Equirectangular cube textures
  62349. */
  62350. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62351. /**
  62352. * Defines the name of the task
  62353. */
  62354. name: string;
  62355. /**
  62356. * Defines the location of the file to load
  62357. */
  62358. url: string;
  62359. /**
  62360. * Defines the desired size (the more it increases the longer the generation will be)
  62361. */
  62362. size: number;
  62363. /**
  62364. * Defines if mipmaps should not be generated (default is false)
  62365. */
  62366. noMipmap: boolean;
  62367. /**
  62368. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62369. * but the standard material would require them in Gamma space) (default is true)
  62370. */
  62371. gammaSpace: boolean;
  62372. /**
  62373. * Gets the loaded texture
  62374. */
  62375. texture: EquiRectangularCubeTexture;
  62376. /**
  62377. * Callback called when the task is successful
  62378. */
  62379. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62380. /**
  62381. * Callback called when the task is successful
  62382. */
  62383. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62384. /**
  62385. * Creates a new EquiRectangularCubeTextureAssetTask object
  62386. * @param name defines the name of the task
  62387. * @param url defines the location of the file to load
  62388. * @param size defines the desired size (the more it increases the longer the generation will be)
  62389. * If the size is omitted this implies you are using a preprocessed cubemap.
  62390. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62391. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62392. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62393. * (default is true)
  62394. */
  62395. constructor(
  62396. /**
  62397. * Defines the name of the task
  62398. */
  62399. name: string,
  62400. /**
  62401. * Defines the location of the file to load
  62402. */
  62403. url: string,
  62404. /**
  62405. * Defines the desired size (the more it increases the longer the generation will be)
  62406. */
  62407. size: number,
  62408. /**
  62409. * Defines if mipmaps should not be generated (default is false)
  62410. */
  62411. noMipmap?: boolean,
  62412. /**
  62413. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62414. * but the standard material would require them in Gamma space) (default is true)
  62415. */
  62416. gammaSpace?: boolean);
  62417. /**
  62418. * Execute the current task
  62419. * @param scene defines the scene where you want your assets to be loaded
  62420. * @param onSuccess is a callback called when the task is successfully executed
  62421. * @param onError is a callback called if an error occurs
  62422. */
  62423. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62424. }
  62425. /**
  62426. * This class can be used to easily import assets into a scene
  62427. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62428. */
  62429. export class AssetsManager {
  62430. private _scene;
  62431. private _isLoading;
  62432. protected _tasks: AbstractAssetTask[];
  62433. protected _waitingTasksCount: number;
  62434. protected _totalTasksCount: number;
  62435. /**
  62436. * Callback called when all tasks are processed
  62437. */
  62438. onFinish: (tasks: AbstractAssetTask[]) => void;
  62439. /**
  62440. * Callback called when a task is successful
  62441. */
  62442. onTaskSuccess: (task: AbstractAssetTask) => void;
  62443. /**
  62444. * Callback called when a task had an error
  62445. */
  62446. onTaskError: (task: AbstractAssetTask) => void;
  62447. /**
  62448. * Callback called when a task is done (whatever the result is)
  62449. */
  62450. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62451. /**
  62452. * Observable called when all tasks are processed
  62453. */
  62454. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62455. /**
  62456. * Observable called when a task had an error
  62457. */
  62458. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62459. /**
  62460. * Observable called when all tasks were executed
  62461. */
  62462. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62463. /**
  62464. * Observable called when a task is done (whatever the result is)
  62465. */
  62466. onProgressObservable: Observable<IAssetsProgressEvent>;
  62467. /**
  62468. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62469. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62470. */
  62471. useDefaultLoadingScreen: boolean;
  62472. /**
  62473. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62474. * when all assets have been downloaded.
  62475. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62476. */
  62477. autoHideLoadingUI: boolean;
  62478. /**
  62479. * Creates a new AssetsManager
  62480. * @param scene defines the scene to work on
  62481. */
  62482. constructor(scene: Scene);
  62483. /**
  62484. * Add a MeshAssetTask to the list of active tasks
  62485. * @param taskName defines the name of the new task
  62486. * @param meshesNames defines the name of meshes to load
  62487. * @param rootUrl defines the root url to use to locate files
  62488. * @param sceneFilename defines the filename of the scene file
  62489. * @returns a new MeshAssetTask object
  62490. */
  62491. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62492. /**
  62493. * Add a TextFileAssetTask to the list of active tasks
  62494. * @param taskName defines the name of the new task
  62495. * @param url defines the url of the file to load
  62496. * @returns a new TextFileAssetTask object
  62497. */
  62498. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62499. /**
  62500. * Add a BinaryFileAssetTask to the list of active tasks
  62501. * @param taskName defines the name of the new task
  62502. * @param url defines the url of the file to load
  62503. * @returns a new BinaryFileAssetTask object
  62504. */
  62505. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62506. /**
  62507. * Add a ImageAssetTask to the list of active tasks
  62508. * @param taskName defines the name of the new task
  62509. * @param url defines the url of the file to load
  62510. * @returns a new ImageAssetTask object
  62511. */
  62512. addImageTask(taskName: string, url: string): ImageAssetTask;
  62513. /**
  62514. * Add a TextureAssetTask to the list of active tasks
  62515. * @param taskName defines the name of the new task
  62516. * @param url defines the url of the file to load
  62517. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62518. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62519. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62520. * @returns a new TextureAssetTask object
  62521. */
  62522. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62523. /**
  62524. * Add a CubeTextureAssetTask to the list of active tasks
  62525. * @param taskName defines the name of the new task
  62526. * @param url defines the url of the file to load
  62527. * @param extensions defines the extension to use to load the cube map (can be null)
  62528. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62529. * @param files defines the list of files to load (can be null)
  62530. * @returns a new CubeTextureAssetTask object
  62531. */
  62532. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62533. /**
  62534. *
  62535. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62536. * @param taskName defines the name of the new task
  62537. * @param url defines the url of the file to load
  62538. * @param size defines the size you want for the cubemap (can be null)
  62539. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62540. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62541. * @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)
  62542. * @param reserved Internal use only
  62543. * @returns a new HDRCubeTextureAssetTask object
  62544. */
  62545. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62546. /**
  62547. *
  62548. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62549. * @param taskName defines the name of the new task
  62550. * @param url defines the url of the file to load
  62551. * @param size defines the size you want for the cubemap (can be null)
  62552. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62553. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62554. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62555. * @returns a new EquiRectangularCubeTextureAssetTask object
  62556. */
  62557. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62558. /**
  62559. * Remove a task from the assets manager.
  62560. * @param task the task to remove
  62561. */
  62562. removeTask(task: AbstractAssetTask): void;
  62563. private _decreaseWaitingTasksCount;
  62564. private _runTask;
  62565. /**
  62566. * Reset the AssetsManager and remove all tasks
  62567. * @return the current instance of the AssetsManager
  62568. */
  62569. reset(): AssetsManager;
  62570. /**
  62571. * Start the loading process
  62572. * @return the current instance of the AssetsManager
  62573. */
  62574. load(): AssetsManager;
  62575. /**
  62576. * Start the loading process as an async operation
  62577. * @return a promise returning the list of failed tasks
  62578. */
  62579. loadAsync(): Promise<void>;
  62580. }
  62581. }
  62582. declare module BABYLON {
  62583. /**
  62584. * Wrapper class for promise with external resolve and reject.
  62585. */
  62586. export class Deferred<T> {
  62587. /**
  62588. * The promise associated with this deferred object.
  62589. */
  62590. readonly promise: Promise<T>;
  62591. private _resolve;
  62592. private _reject;
  62593. /**
  62594. * The resolve method of the promise associated with this deferred object.
  62595. */
  62596. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62597. /**
  62598. * The reject method of the promise associated with this deferred object.
  62599. */
  62600. readonly reject: (reason?: any) => void;
  62601. /**
  62602. * Constructor for this deferred object.
  62603. */
  62604. constructor();
  62605. }
  62606. }
  62607. declare module BABYLON {
  62608. /**
  62609. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62610. */
  62611. export class MeshExploder {
  62612. private _centerMesh;
  62613. private _meshes;
  62614. private _meshesOrigins;
  62615. private _toCenterVectors;
  62616. private _scaledDirection;
  62617. private _newPosition;
  62618. private _centerPosition;
  62619. /**
  62620. * Explodes meshes from a center mesh.
  62621. * @param meshes The meshes to explode.
  62622. * @param centerMesh The mesh to be center of explosion.
  62623. */
  62624. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62625. private _setCenterMesh;
  62626. /**
  62627. * Get class name
  62628. * @returns "MeshExploder"
  62629. */
  62630. getClassName(): string;
  62631. /**
  62632. * "Exploded meshes"
  62633. * @returns Array of meshes with the centerMesh at index 0.
  62634. */
  62635. getMeshes(): Array<Mesh>;
  62636. /**
  62637. * Explodes meshes giving a specific direction
  62638. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62639. */
  62640. explode(direction?: number): void;
  62641. }
  62642. }
  62643. declare module BABYLON {
  62644. /**
  62645. * Class used to help managing file picking and drag'n'drop
  62646. */
  62647. export class FilesInput {
  62648. /**
  62649. * List of files ready to be loaded
  62650. */
  62651. static readonly FilesToLoad: {
  62652. [key: string]: File;
  62653. };
  62654. /**
  62655. * Callback called when a file is processed
  62656. */
  62657. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62658. private _engine;
  62659. private _currentScene;
  62660. private _sceneLoadedCallback;
  62661. private _progressCallback;
  62662. private _additionalRenderLoopLogicCallback;
  62663. private _textureLoadingCallback;
  62664. private _startingProcessingFilesCallback;
  62665. private _onReloadCallback;
  62666. private _errorCallback;
  62667. private _elementToMonitor;
  62668. private _sceneFileToLoad;
  62669. private _filesToLoad;
  62670. /**
  62671. * Creates a new FilesInput
  62672. * @param engine defines the rendering engine
  62673. * @param scene defines the hosting scene
  62674. * @param sceneLoadedCallback callback called when scene is loaded
  62675. * @param progressCallback callback called to track progress
  62676. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62677. * @param textureLoadingCallback callback called when a texture is loading
  62678. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62679. * @param onReloadCallback callback called when a reload is requested
  62680. * @param errorCallback callback call if an error occurs
  62681. */
  62682. 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);
  62683. private _dragEnterHandler;
  62684. private _dragOverHandler;
  62685. private _dropHandler;
  62686. /**
  62687. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62688. * @param elementToMonitor defines the DOM element to track
  62689. */
  62690. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62691. /**
  62692. * Release all associated resources
  62693. */
  62694. dispose(): void;
  62695. private renderFunction;
  62696. private drag;
  62697. private drop;
  62698. private _traverseFolder;
  62699. private _processFiles;
  62700. /**
  62701. * Load files from a drop event
  62702. * @param event defines the drop event to use as source
  62703. */
  62704. loadFiles(event: any): void;
  62705. private _processReload;
  62706. /**
  62707. * Reload the current scene from the loaded files
  62708. */
  62709. reload(): void;
  62710. }
  62711. }
  62712. declare module BABYLON {
  62713. /**
  62714. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62715. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62716. */
  62717. export class SceneOptimization {
  62718. /**
  62719. * Defines the priority of this optimization (0 by default which means first in the list)
  62720. */
  62721. priority: number;
  62722. /**
  62723. * Gets a string describing the action executed by the current optimization
  62724. * @returns description string
  62725. */
  62726. getDescription(): string;
  62727. /**
  62728. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62729. * @param scene defines the current scene where to apply this optimization
  62730. * @param optimizer defines the current optimizer
  62731. * @returns true if everything that can be done was applied
  62732. */
  62733. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62734. /**
  62735. * Creates the SceneOptimization object
  62736. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62737. * @param desc defines the description associated with the optimization
  62738. */
  62739. constructor(
  62740. /**
  62741. * Defines the priority of this optimization (0 by default which means first in the list)
  62742. */
  62743. priority?: number);
  62744. }
  62745. /**
  62746. * Defines an optimization used to reduce the size of render target textures
  62747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62748. */
  62749. export class TextureOptimization extends SceneOptimization {
  62750. /**
  62751. * Defines the priority of this optimization (0 by default which means first in the list)
  62752. */
  62753. priority: number;
  62754. /**
  62755. * 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
  62756. */
  62757. maximumSize: number;
  62758. /**
  62759. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62760. */
  62761. step: number;
  62762. /**
  62763. * Gets a string describing the action executed by the current optimization
  62764. * @returns description string
  62765. */
  62766. getDescription(): string;
  62767. /**
  62768. * Creates the TextureOptimization object
  62769. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62770. * @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
  62771. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62772. */
  62773. constructor(
  62774. /**
  62775. * Defines the priority of this optimization (0 by default which means first in the list)
  62776. */
  62777. priority?: number,
  62778. /**
  62779. * 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
  62780. */
  62781. maximumSize?: number,
  62782. /**
  62783. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62784. */
  62785. step?: number);
  62786. /**
  62787. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62788. * @param scene defines the current scene where to apply this optimization
  62789. * @param optimizer defines the current optimizer
  62790. * @returns true if everything that can be done was applied
  62791. */
  62792. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62793. }
  62794. /**
  62795. * Defines an optimization used to increase or decrease the rendering resolution
  62796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62797. */
  62798. export class HardwareScalingOptimization extends SceneOptimization {
  62799. /**
  62800. * Defines the priority of this optimization (0 by default which means first in the list)
  62801. */
  62802. priority: number;
  62803. /**
  62804. * Defines the maximum scale to use (2 by default)
  62805. */
  62806. maximumScale: number;
  62807. /**
  62808. * Defines the step to use between two passes (0.5 by default)
  62809. */
  62810. step: number;
  62811. private _currentScale;
  62812. private _directionOffset;
  62813. /**
  62814. * Gets a string describing the action executed by the current optimization
  62815. * @return description string
  62816. */
  62817. getDescription(): string;
  62818. /**
  62819. * Creates the HardwareScalingOptimization object
  62820. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62821. * @param maximumScale defines the maximum scale to use (2 by default)
  62822. * @param step defines the step to use between two passes (0.5 by default)
  62823. */
  62824. constructor(
  62825. /**
  62826. * Defines the priority of this optimization (0 by default which means first in the list)
  62827. */
  62828. priority?: number,
  62829. /**
  62830. * Defines the maximum scale to use (2 by default)
  62831. */
  62832. maximumScale?: number,
  62833. /**
  62834. * Defines the step to use between two passes (0.5 by default)
  62835. */
  62836. step?: number);
  62837. /**
  62838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62839. * @param scene defines the current scene where to apply this optimization
  62840. * @param optimizer defines the current optimizer
  62841. * @returns true if everything that can be done was applied
  62842. */
  62843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62844. }
  62845. /**
  62846. * Defines an optimization used to remove shadows
  62847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62848. */
  62849. export class ShadowsOptimization extends SceneOptimization {
  62850. /**
  62851. * Gets a string describing the action executed by the current optimization
  62852. * @return description string
  62853. */
  62854. getDescription(): string;
  62855. /**
  62856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62857. * @param scene defines the current scene where to apply this optimization
  62858. * @param optimizer defines the current optimizer
  62859. * @returns true if everything that can be done was applied
  62860. */
  62861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62862. }
  62863. /**
  62864. * Defines an optimization used to turn post-processes off
  62865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62866. */
  62867. export class PostProcessesOptimization extends SceneOptimization {
  62868. /**
  62869. * Gets a string describing the action executed by the current optimization
  62870. * @return description string
  62871. */
  62872. getDescription(): string;
  62873. /**
  62874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62875. * @param scene defines the current scene where to apply this optimization
  62876. * @param optimizer defines the current optimizer
  62877. * @returns true if everything that can be done was applied
  62878. */
  62879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62880. }
  62881. /**
  62882. * Defines an optimization used to turn lens flares off
  62883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62884. */
  62885. export class LensFlaresOptimization extends SceneOptimization {
  62886. /**
  62887. * Gets a string describing the action executed by the current optimization
  62888. * @return description string
  62889. */
  62890. getDescription(): string;
  62891. /**
  62892. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62893. * @param scene defines the current scene where to apply this optimization
  62894. * @param optimizer defines the current optimizer
  62895. * @returns true if everything that can be done was applied
  62896. */
  62897. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62898. }
  62899. /**
  62900. * Defines an optimization based on user defined callback.
  62901. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62902. */
  62903. export class CustomOptimization extends SceneOptimization {
  62904. /**
  62905. * Callback called to apply the custom optimization.
  62906. */
  62907. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62908. /**
  62909. * Callback called to get custom description
  62910. */
  62911. onGetDescription: () => string;
  62912. /**
  62913. * Gets a string describing the action executed by the current optimization
  62914. * @returns description string
  62915. */
  62916. getDescription(): string;
  62917. /**
  62918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62919. * @param scene defines the current scene where to apply this optimization
  62920. * @param optimizer defines the current optimizer
  62921. * @returns true if everything that can be done was applied
  62922. */
  62923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62924. }
  62925. /**
  62926. * Defines an optimization used to turn particles off
  62927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62928. */
  62929. export class ParticlesOptimization extends SceneOptimization {
  62930. /**
  62931. * Gets a string describing the action executed by the current optimization
  62932. * @return description string
  62933. */
  62934. getDescription(): string;
  62935. /**
  62936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62937. * @param scene defines the current scene where to apply this optimization
  62938. * @param optimizer defines the current optimizer
  62939. * @returns true if everything that can be done was applied
  62940. */
  62941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62942. }
  62943. /**
  62944. * Defines an optimization used to turn render targets off
  62945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62946. */
  62947. export class RenderTargetsOptimization extends SceneOptimization {
  62948. /**
  62949. * Gets a string describing the action executed by the current optimization
  62950. * @return description string
  62951. */
  62952. getDescription(): string;
  62953. /**
  62954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62955. * @param scene defines the current scene where to apply this optimization
  62956. * @param optimizer defines the current optimizer
  62957. * @returns true if everything that can be done was applied
  62958. */
  62959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62960. }
  62961. /**
  62962. * Defines an optimization used to merge meshes with compatible materials
  62963. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62964. */
  62965. export class MergeMeshesOptimization extends SceneOptimization {
  62966. private static _UpdateSelectionTree;
  62967. /**
  62968. * Gets or sets a boolean which defines if optimization octree has to be updated
  62969. */
  62970. /**
  62971. * Gets or sets a boolean which defines if optimization octree has to be updated
  62972. */
  62973. static UpdateSelectionTree: boolean;
  62974. /**
  62975. * Gets a string describing the action executed by the current optimization
  62976. * @return description string
  62977. */
  62978. getDescription(): string;
  62979. private _canBeMerged;
  62980. /**
  62981. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62982. * @param scene defines the current scene where to apply this optimization
  62983. * @param optimizer defines the current optimizer
  62984. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62985. * @returns true if everything that can be done was applied
  62986. */
  62987. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62988. }
  62989. /**
  62990. * Defines a list of options used by SceneOptimizer
  62991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62992. */
  62993. export class SceneOptimizerOptions {
  62994. /**
  62995. * Defines the target frame rate to reach (60 by default)
  62996. */
  62997. targetFrameRate: number;
  62998. /**
  62999. * Defines the interval between two checkes (2000ms by default)
  63000. */
  63001. trackerDuration: number;
  63002. /**
  63003. * Gets the list of optimizations to apply
  63004. */
  63005. optimizations: SceneOptimization[];
  63006. /**
  63007. * Creates a new list of options used by SceneOptimizer
  63008. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63009. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63010. */
  63011. constructor(
  63012. /**
  63013. * Defines the target frame rate to reach (60 by default)
  63014. */
  63015. targetFrameRate?: number,
  63016. /**
  63017. * Defines the interval between two checkes (2000ms by default)
  63018. */
  63019. trackerDuration?: number);
  63020. /**
  63021. * Add a new optimization
  63022. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63023. * @returns the current SceneOptimizerOptions
  63024. */
  63025. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63026. /**
  63027. * Add a new custom optimization
  63028. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63029. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63030. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63031. * @returns the current SceneOptimizerOptions
  63032. */
  63033. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63034. /**
  63035. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63036. * @param targetFrameRate defines the target frame rate (60 by default)
  63037. * @returns a SceneOptimizerOptions object
  63038. */
  63039. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63040. /**
  63041. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63042. * @param targetFrameRate defines the target frame rate (60 by default)
  63043. * @returns a SceneOptimizerOptions object
  63044. */
  63045. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63046. /**
  63047. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63048. * @param targetFrameRate defines the target frame rate (60 by default)
  63049. * @returns a SceneOptimizerOptions object
  63050. */
  63051. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63052. }
  63053. /**
  63054. * Class used to run optimizations in order to reach a target frame rate
  63055. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63056. */
  63057. export class SceneOptimizer implements IDisposable {
  63058. private _isRunning;
  63059. private _options;
  63060. private _scene;
  63061. private _currentPriorityLevel;
  63062. private _targetFrameRate;
  63063. private _trackerDuration;
  63064. private _currentFrameRate;
  63065. private _sceneDisposeObserver;
  63066. private _improvementMode;
  63067. /**
  63068. * Defines an observable called when the optimizer reaches the target frame rate
  63069. */
  63070. onSuccessObservable: Observable<SceneOptimizer>;
  63071. /**
  63072. * Defines an observable called when the optimizer enables an optimization
  63073. */
  63074. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63075. /**
  63076. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63077. */
  63078. onFailureObservable: Observable<SceneOptimizer>;
  63079. /**
  63080. * Gets a boolean indicating if the optimizer is in improvement mode
  63081. */
  63082. readonly isInImprovementMode: boolean;
  63083. /**
  63084. * Gets the current priority level (0 at start)
  63085. */
  63086. readonly currentPriorityLevel: number;
  63087. /**
  63088. * Gets the current frame rate checked by the SceneOptimizer
  63089. */
  63090. readonly currentFrameRate: number;
  63091. /**
  63092. * Gets or sets the current target frame rate (60 by default)
  63093. */
  63094. /**
  63095. * Gets or sets the current target frame rate (60 by default)
  63096. */
  63097. targetFrameRate: number;
  63098. /**
  63099. * Gets or sets the current interval between two checks (every 2000ms by default)
  63100. */
  63101. /**
  63102. * Gets or sets the current interval between two checks (every 2000ms by default)
  63103. */
  63104. trackerDuration: number;
  63105. /**
  63106. * Gets the list of active optimizations
  63107. */
  63108. readonly optimizations: SceneOptimization[];
  63109. /**
  63110. * Creates a new SceneOptimizer
  63111. * @param scene defines the scene to work on
  63112. * @param options defines the options to use with the SceneOptimizer
  63113. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63114. * @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)
  63115. */
  63116. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63117. /**
  63118. * Stops the current optimizer
  63119. */
  63120. stop(): void;
  63121. /**
  63122. * Reset the optimizer to initial step (current priority level = 0)
  63123. */
  63124. reset(): void;
  63125. /**
  63126. * Start the optimizer. By default it will try to reach a specific framerate
  63127. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63128. */
  63129. start(): void;
  63130. private _checkCurrentState;
  63131. /**
  63132. * Release all resources
  63133. */
  63134. dispose(): void;
  63135. /**
  63136. * Helper function to create a SceneOptimizer with one single line of code
  63137. * @param scene defines the scene to work on
  63138. * @param options defines the options to use with the SceneOptimizer
  63139. * @param onSuccess defines a callback to call on success
  63140. * @param onFailure defines a callback to call on failure
  63141. * @returns the new SceneOptimizer object
  63142. */
  63143. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63144. }
  63145. }
  63146. declare module BABYLON {
  63147. /**
  63148. * Class used to serialize a scene into a string
  63149. */
  63150. export class SceneSerializer {
  63151. /**
  63152. * Clear cache used by a previous serialization
  63153. */
  63154. static ClearCache(): void;
  63155. /**
  63156. * Serialize a scene into a JSON compatible object
  63157. * @param scene defines the scene to serialize
  63158. * @returns a JSON compatible object
  63159. */
  63160. static Serialize(scene: Scene): any;
  63161. /**
  63162. * Serialize a mesh into a JSON compatible object
  63163. * @param toSerialize defines the mesh to serialize
  63164. * @param withParents defines if parents must be serialized as well
  63165. * @param withChildren defines if children must be serialized as well
  63166. * @returns a JSON compatible object
  63167. */
  63168. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63169. }
  63170. }
  63171. declare module BABYLON {
  63172. /**
  63173. * Class used to host texture specific utilities
  63174. */
  63175. export class TextureTools {
  63176. /**
  63177. * Uses the GPU to create a copy texture rescaled at a given size
  63178. * @param texture Texture to copy from
  63179. * @param width defines the desired width
  63180. * @param height defines the desired height
  63181. * @param useBilinearMode defines if bilinear mode has to be used
  63182. * @return the generated texture
  63183. */
  63184. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63185. }
  63186. }
  63187. declare module BABYLON {
  63188. /**
  63189. * This represents the different options available for the video capture.
  63190. */
  63191. export interface VideoRecorderOptions {
  63192. /** Defines the mime type of the video. */
  63193. mimeType: string;
  63194. /** Defines the FPS the video should be recorded at. */
  63195. fps: number;
  63196. /** Defines the chunk size for the recording data. */
  63197. recordChunckSize: number;
  63198. /** The audio tracks to attach to the recording. */
  63199. audioTracks?: MediaStreamTrack[];
  63200. }
  63201. /**
  63202. * This can help with recording videos from BabylonJS.
  63203. * This is based on the available WebRTC functionalities of the browser.
  63204. *
  63205. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63206. */
  63207. export class VideoRecorder {
  63208. private static readonly _defaultOptions;
  63209. /**
  63210. * Returns whether or not the VideoRecorder is available in your browser.
  63211. * @param engine Defines the Babylon Engine.
  63212. * @returns true if supported otherwise false.
  63213. */
  63214. static IsSupported(engine: Engine): boolean;
  63215. private readonly _options;
  63216. private _canvas;
  63217. private _mediaRecorder;
  63218. private _recordedChunks;
  63219. private _fileName;
  63220. private _resolve;
  63221. private _reject;
  63222. /**
  63223. * True when a recording is already in progress.
  63224. */
  63225. readonly isRecording: boolean;
  63226. /**
  63227. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63228. * @param engine Defines the BabylonJS Engine you wish to record.
  63229. * @param options Defines options that can be used to customize the capture.
  63230. */
  63231. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63232. /**
  63233. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63234. */
  63235. stopRecording(): void;
  63236. /**
  63237. * Starts recording the canvas for a max duration specified in parameters.
  63238. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63239. * If null no automatic download will start and you can rely on the promise to get the data back.
  63240. * @param maxDuration Defines the maximum recording time in seconds.
  63241. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63242. * @return A promise callback at the end of the recording with the video data in Blob.
  63243. */
  63244. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63245. /**
  63246. * Releases internal resources used during the recording.
  63247. */
  63248. dispose(): void;
  63249. private _handleDataAvailable;
  63250. private _handleError;
  63251. private _handleStop;
  63252. }
  63253. }
  63254. declare module BABYLON {
  63255. /**
  63256. * Class containing a set of static utilities functions for screenshots
  63257. */
  63258. export class ScreenshotTools {
  63259. /**
  63260. * Captures a screenshot of the current rendering
  63261. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63262. * @param engine defines the rendering engine
  63263. * @param camera defines the source camera
  63264. * @param size This parameter can be set to a single number or to an object with the
  63265. * following (optional) properties: precision, width, height. If a single number is passed,
  63266. * it will be used for both width and height. If an object is passed, the screenshot size
  63267. * will be derived from the parameters. The precision property is a multiplier allowing
  63268. * rendering at a higher or lower resolution
  63269. * @param successCallback defines the callback receives a single parameter which contains the
  63270. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63271. * src parameter of an <img> to display it
  63272. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63273. * Check your browser for supported MIME types
  63274. */
  63275. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63276. /**
  63277. * Captures a screenshot of the current rendering
  63278. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63279. * @param engine defines the rendering engine
  63280. * @param camera defines the source camera
  63281. * @param size This parameter can be set to a single number or to an object with the
  63282. * following (optional) properties: precision, width, height. If a single number is passed,
  63283. * it will be used for both width and height. If an object is passed, the screenshot size
  63284. * will be derived from the parameters. The precision property is a multiplier allowing
  63285. * rendering at a higher or lower resolution
  63286. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63287. * Check your browser for supported MIME types
  63288. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63289. * to the src parameter of an <img> to display it
  63290. */
  63291. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63292. /**
  63293. * Generates an image screenshot from the specified camera.
  63294. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63295. * @param engine The engine to use for rendering
  63296. * @param camera The camera to use for rendering
  63297. * @param size This parameter can be set to a single number or to an object with the
  63298. * following (optional) properties: precision, width, height. If a single number is passed,
  63299. * it will be used for both width and height. If an object is passed, the screenshot size
  63300. * will be derived from the parameters. The precision property is a multiplier allowing
  63301. * rendering at a higher or lower resolution
  63302. * @param successCallback The callback receives a single parameter which contains the
  63303. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63304. * src parameter of an <img> to display it
  63305. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63306. * Check your browser for supported MIME types
  63307. * @param samples Texture samples (default: 1)
  63308. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63309. * @param fileName A name for for the downloaded file.
  63310. */
  63311. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63312. /**
  63313. * Generates an image screenshot from the specified camera.
  63314. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63315. * @param engine The engine to use for rendering
  63316. * @param camera The camera to use for rendering
  63317. * @param size This parameter can be set to a single number or to an object with the
  63318. * following (optional) properties: precision, width, height. If a single number is passed,
  63319. * it will be used for both width and height. If an object is passed, the screenshot size
  63320. * will be derived from the parameters. The precision property is a multiplier allowing
  63321. * rendering at a higher or lower resolution
  63322. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63323. * Check your browser for supported MIME types
  63324. * @param samples Texture samples (default: 1)
  63325. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63326. * @param fileName A name for for the downloaded file.
  63327. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63328. * to the src parameter of an <img> to display it
  63329. */
  63330. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63331. /**
  63332. * Gets height and width for screenshot size
  63333. * @private
  63334. */
  63335. private static _getScreenshotSize;
  63336. }
  63337. }
  63338. declare module BABYLON {
  63339. /**
  63340. * Interface for a data buffer
  63341. */
  63342. export interface IDataBuffer {
  63343. /**
  63344. * Reads bytes from the data buffer.
  63345. * @param byteOffset The byte offset to read
  63346. * @param byteLength The byte length to read
  63347. * @returns A promise that resolves when the bytes are read
  63348. */
  63349. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  63350. /**
  63351. * The byte length of the buffer.
  63352. */
  63353. readonly byteLength: number;
  63354. }
  63355. /**
  63356. * Utility class for reading from a data buffer
  63357. */
  63358. export class DataReader {
  63359. /**
  63360. * The data buffer associated with this data reader.
  63361. */
  63362. readonly buffer: IDataBuffer;
  63363. /**
  63364. * The current byte offset from the beginning of the data buffer.
  63365. */
  63366. byteOffset: number;
  63367. private _dataView;
  63368. private _dataByteOffset;
  63369. /**
  63370. * Constructor
  63371. * @param buffer The buffer to read
  63372. */
  63373. constructor(buffer: IDataBuffer);
  63374. /**
  63375. * Loads the given byte length.
  63376. * @param byteLength The byte length to load
  63377. * @returns A promise that resolves when the load is complete
  63378. */
  63379. loadAsync(byteLength: number): Promise<void>;
  63380. /**
  63381. * Read a unsigned 32-bit integer from the currently loaded data range.
  63382. * @returns The 32-bit integer read
  63383. */
  63384. readUint32(): number;
  63385. /**
  63386. * Read a byte array from the currently loaded data range.
  63387. * @param byteLength The byte length to read
  63388. * @returns The byte array read
  63389. */
  63390. readUint8Array(byteLength: number): Uint8Array;
  63391. /**
  63392. * Read a string from the currently loaded data range.
  63393. * @param byteLength The byte length to read
  63394. * @returns The string read
  63395. */
  63396. readString(byteLength: number): string;
  63397. /**
  63398. * Skips the given byte length the currently loaded data range.
  63399. * @param byteLength The byte length to skip
  63400. */
  63401. skipBytes(byteLength: number): void;
  63402. }
  63403. }
  63404. declare module BABYLON {
  63405. /**
  63406. * A cursor which tracks a point on a path
  63407. */
  63408. export class PathCursor {
  63409. private path;
  63410. /**
  63411. * Stores path cursor callbacks for when an onchange event is triggered
  63412. */
  63413. private _onchange;
  63414. /**
  63415. * The value of the path cursor
  63416. */
  63417. value: number;
  63418. /**
  63419. * The animation array of the path cursor
  63420. */
  63421. animations: Animation[];
  63422. /**
  63423. * Initializes the path cursor
  63424. * @param path The path to track
  63425. */
  63426. constructor(path: Path2);
  63427. /**
  63428. * Gets the cursor point on the path
  63429. * @returns A point on the path cursor at the cursor location
  63430. */
  63431. getPoint(): Vector3;
  63432. /**
  63433. * Moves the cursor ahead by the step amount
  63434. * @param step The amount to move the cursor forward
  63435. * @returns This path cursor
  63436. */
  63437. moveAhead(step?: number): PathCursor;
  63438. /**
  63439. * Moves the cursor behind by the step amount
  63440. * @param step The amount to move the cursor back
  63441. * @returns This path cursor
  63442. */
  63443. moveBack(step?: number): PathCursor;
  63444. /**
  63445. * Moves the cursor by the step amount
  63446. * If the step amount is greater than one, an exception is thrown
  63447. * @param step The amount to move the cursor
  63448. * @returns This path cursor
  63449. */
  63450. move(step: number): PathCursor;
  63451. /**
  63452. * Ensures that the value is limited between zero and one
  63453. * @returns This path cursor
  63454. */
  63455. private ensureLimits;
  63456. /**
  63457. * Runs onchange callbacks on change (used by the animation engine)
  63458. * @returns This path cursor
  63459. */
  63460. private raiseOnChange;
  63461. /**
  63462. * Executes a function on change
  63463. * @param f A path cursor onchange callback
  63464. * @returns This path cursor
  63465. */
  63466. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63467. }
  63468. }
  63469. declare module BABYLON {
  63470. /** @hidden */
  63471. export var blurPixelShader: {
  63472. name: string;
  63473. shader: string;
  63474. };
  63475. }
  63476. declare module BABYLON {
  63477. /** @hidden */
  63478. export var pointCloudVertexDeclaration: {
  63479. name: string;
  63480. shader: string;
  63481. };
  63482. }
  63483. // Mixins
  63484. interface Window {
  63485. mozIndexedDB: IDBFactory;
  63486. webkitIndexedDB: IDBFactory;
  63487. msIndexedDB: IDBFactory;
  63488. webkitURL: typeof URL;
  63489. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  63490. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  63491. WebGLRenderingContext: WebGLRenderingContext;
  63492. MSGesture: MSGesture;
  63493. CANNON: any;
  63494. AudioContext: AudioContext;
  63495. webkitAudioContext: AudioContext;
  63496. PointerEvent: any;
  63497. Math: Math;
  63498. Uint8Array: Uint8ArrayConstructor;
  63499. Float32Array: Float32ArrayConstructor;
  63500. mozURL: typeof URL;
  63501. msURL: typeof URL;
  63502. VRFrameData: any; // WebVR, from specs 1.1
  63503. DracoDecoderModule: any;
  63504. setImmediate(handler: (...args: any[]) => void): number;
  63505. }
  63506. interface HTMLCanvasElement {
  63507. requestPointerLock(): void;
  63508. msRequestPointerLock?(): void;
  63509. mozRequestPointerLock?(): void;
  63510. webkitRequestPointerLock?(): void;
  63511. /** Track wether a record is in progress */
  63512. isRecording: boolean;
  63513. /** Capture Stream method defined by some browsers */
  63514. captureStream(fps?: number): MediaStream;
  63515. }
  63516. interface CanvasRenderingContext2D {
  63517. msImageSmoothingEnabled: boolean;
  63518. }
  63519. interface MouseEvent {
  63520. mozMovementX: number;
  63521. mozMovementY: number;
  63522. webkitMovementX: number;
  63523. webkitMovementY: number;
  63524. msMovementX: number;
  63525. msMovementY: number;
  63526. }
  63527. interface Navigator {
  63528. mozGetVRDevices: (any: any) => any;
  63529. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63530. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63531. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63532. webkitGetGamepads(): Gamepad[];
  63533. msGetGamepads(): Gamepad[];
  63534. webkitGamepads(): Gamepad[];
  63535. }
  63536. interface HTMLVideoElement {
  63537. mozSrcObject: any;
  63538. }
  63539. interface Math {
  63540. fround(x: number): number;
  63541. imul(a: number, b: number): number;
  63542. }
  63543. interface WebGLRenderingContext {
  63544. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  63545. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  63546. vertexAttribDivisor(index: number, divisor: number): void;
  63547. createVertexArray(): any;
  63548. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  63549. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  63550. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  63551. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  63552. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  63553. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  63554. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  63555. // Queries
  63556. createQuery(): WebGLQuery;
  63557. deleteQuery(query: WebGLQuery): void;
  63558. beginQuery(target: number, query: WebGLQuery): void;
  63559. endQuery(target: number): void;
  63560. getQueryParameter(query: WebGLQuery, pname: number): any;
  63561. getQuery(target: number, pname: number): any;
  63562. MAX_SAMPLES: number;
  63563. RGBA8: number;
  63564. READ_FRAMEBUFFER: number;
  63565. DRAW_FRAMEBUFFER: number;
  63566. UNIFORM_BUFFER: number;
  63567. HALF_FLOAT_OES: number;
  63568. RGBA16F: number;
  63569. RGBA32F: number;
  63570. R32F: number;
  63571. RG32F: number;
  63572. RGB32F: number;
  63573. R16F: number;
  63574. RG16F: number;
  63575. RGB16F: number;
  63576. RED: number;
  63577. RG: number;
  63578. R8: number;
  63579. RG8: number;
  63580. UNSIGNED_INT_24_8: number;
  63581. DEPTH24_STENCIL8: number;
  63582. MIN: number;
  63583. MAX: number;
  63584. /* Multiple Render Targets */
  63585. drawBuffers(buffers: number[]): void;
  63586. readBuffer(src: number): void;
  63587. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  63588. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  63589. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  63590. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63591. // Occlusion Query
  63592. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63593. ANY_SAMPLES_PASSED: number;
  63594. QUERY_RESULT_AVAILABLE: number;
  63595. QUERY_RESULT: number;
  63596. }
  63597. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63598. }
  63599. interface EXT_disjoint_timer_query {
  63600. QUERY_COUNTER_BITS_EXT: number;
  63601. TIME_ELAPSED_EXT: number;
  63602. TIMESTAMP_EXT: number;
  63603. GPU_DISJOINT_EXT: number;
  63604. QUERY_RESULT_EXT: number;
  63605. QUERY_RESULT_AVAILABLE_EXT: number;
  63606. queryCounterEXT(query: WebGLQuery, target: number): void;
  63607. createQueryEXT(): WebGLQuery;
  63608. beginQueryEXT(target: number, query: WebGLQuery): void;
  63609. endQueryEXT(target: number): void;
  63610. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63611. deleteQueryEXT(query: WebGLQuery): void;
  63612. }
  63613. interface WebGLUniformLocation { private _currentState: any;
  63614. }
  63615. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63616. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63617. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63618. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63619. interface WebGLRenderingContext {
  63620. readonly RASTERIZER_DISCARD: number;
  63621. readonly DEPTH_COMPONENT24: number;
  63622. readonly TEXTURE_3D: number;
  63623. readonly TEXTURE_2D_ARRAY: number;
  63624. readonly TEXTURE_COMPARE_FUNC: number;
  63625. readonly TEXTURE_COMPARE_MODE: number;
  63626. readonly COMPARE_REF_TO_TEXTURE: number;
  63627. readonly TEXTURE_WRAP_R: number;
  63628. readonly HALF_FLOAT: number;
  63629. readonly RGB8: number;
  63630. readonly RED_INTEGER: number;
  63631. readonly RG_INTEGER: number;
  63632. readonly RGB_INTEGER: number;
  63633. readonly RGBA_INTEGER: number;
  63634. readonly R8_SNORM: number;
  63635. readonly RG8_SNORM: number;
  63636. readonly RGB8_SNORM: number;
  63637. readonly RGBA8_SNORM: number;
  63638. readonly R8I: number;
  63639. readonly RG8I: number;
  63640. readonly RGB8I: number;
  63641. readonly RGBA8I: number;
  63642. readonly R8UI: number;
  63643. readonly RG8UI: number;
  63644. readonly RGB8UI: number;
  63645. readonly RGBA8UI: number;
  63646. readonly R16I: number;
  63647. readonly RG16I: number;
  63648. readonly RGB16I: number;
  63649. readonly RGBA16I: number;
  63650. readonly R16UI: number;
  63651. readonly RG16UI: number;
  63652. readonly RGB16UI: number;
  63653. readonly RGBA16UI: number;
  63654. readonly R32I: number;
  63655. readonly RG32I: number;
  63656. readonly RGB32I: number;
  63657. readonly RGBA32I: number;
  63658. readonly R32UI: number;
  63659. readonly RG32UI: number;
  63660. readonly RGB32UI: number;
  63661. readonly RGBA32UI: number;
  63662. readonly RGB10_A2UI: number;
  63663. readonly R11F_G11F_B10F: number;
  63664. readonly RGB9_E5: number;
  63665. readonly RGB10_A2: number;
  63666. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63667. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63668. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63669. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63670. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63671. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63672. 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;
  63673. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63674. readonly TRANSFORM_FEEDBACK: number;
  63675. readonly INTERLEAVED_ATTRIBS: number;
  63676. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63677. createTransformFeedback(): WebGLTransformFeedback;
  63678. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63679. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63680. beginTransformFeedback(primitiveMode: number): void;
  63681. endTransformFeedback(): void;
  63682. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63683. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63684. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63685. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63686. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63687. }
  63688. interface ImageBitmap {
  63689. readonly width: number;
  63690. readonly height: number;
  63691. close(): void;
  63692. }
  63693. interface WebGLQuery extends WebGLObject {
  63694. }
  63695. declare var WebGLQuery: {
  63696. prototype: WebGLQuery;
  63697. new(): WebGLQuery;
  63698. };
  63699. interface WebGLSampler extends WebGLObject {
  63700. }
  63701. declare var WebGLSampler: {
  63702. prototype: WebGLSampler;
  63703. new(): WebGLSampler;
  63704. };
  63705. interface WebGLSync extends WebGLObject {
  63706. }
  63707. declare var WebGLSync: {
  63708. prototype: WebGLSync;
  63709. new(): WebGLSync;
  63710. };
  63711. interface WebGLTransformFeedback extends WebGLObject {
  63712. }
  63713. declare var WebGLTransformFeedback: {
  63714. prototype: WebGLTransformFeedback;
  63715. new(): WebGLTransformFeedback;
  63716. };
  63717. interface WebGLVertexArrayObject extends WebGLObject {
  63718. }
  63719. declare var WebGLVertexArrayObject: {
  63720. prototype: WebGLVertexArrayObject;
  63721. new(): WebGLVertexArrayObject;
  63722. };
  63723. // Type definitions for WebVR API
  63724. // Project: https://w3c.github.io/webvr/
  63725. // Definitions by: six a <https://github.com/lostfictions>
  63726. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63727. interface VRDisplay extends EventTarget {
  63728. /**
  63729. * Dictionary of capabilities describing the VRDisplay.
  63730. */
  63731. readonly capabilities: VRDisplayCapabilities;
  63732. /**
  63733. * z-depth defining the far plane of the eye view frustum
  63734. * enables mapping of values in the render target depth
  63735. * attachment to scene coordinates. Initially set to 10000.0.
  63736. */
  63737. depthFar: number;
  63738. /**
  63739. * z-depth defining the near plane of the eye view frustum
  63740. * enables mapping of values in the render target depth
  63741. * attachment to scene coordinates. Initially set to 0.01.
  63742. */
  63743. depthNear: number;
  63744. /**
  63745. * An identifier for this distinct VRDisplay. Used as an
  63746. * association point in the Gamepad API.
  63747. */
  63748. readonly displayId: number;
  63749. /**
  63750. * A display name, a user-readable name identifying it.
  63751. */
  63752. readonly displayName: string;
  63753. readonly isConnected: boolean;
  63754. readonly isPresenting: boolean;
  63755. /**
  63756. * If this VRDisplay supports room-scale experiences, the optional
  63757. * stage attribute contains details on the room-scale parameters.
  63758. */
  63759. readonly stageParameters: VRStageParameters | null;
  63760. /**
  63761. * Passing the value returned by `requestAnimationFrame` to
  63762. * `cancelAnimationFrame` will unregister the callback.
  63763. * @param handle Define the hanle of the request to cancel
  63764. */
  63765. cancelAnimationFrame(handle: number): void;
  63766. /**
  63767. * Stops presenting to the VRDisplay.
  63768. * @returns a promise to know when it stopped
  63769. */
  63770. exitPresent(): Promise<void>;
  63771. /**
  63772. * Return the current VREyeParameters for the given eye.
  63773. * @param whichEye Define the eye we want the parameter for
  63774. * @returns the eye parameters
  63775. */
  63776. getEyeParameters(whichEye: string): VREyeParameters;
  63777. /**
  63778. * Populates the passed VRFrameData with the information required to render
  63779. * the current frame.
  63780. * @param frameData Define the data structure to populate
  63781. * @returns true if ok otherwise false
  63782. */
  63783. getFrameData(frameData: VRFrameData): boolean;
  63784. /**
  63785. * Get the layers currently being presented.
  63786. * @returns the list of VR layers
  63787. */
  63788. getLayers(): VRLayer[];
  63789. /**
  63790. * Return a VRPose containing the future predicted pose of the VRDisplay
  63791. * when the current frame will be presented. The value returned will not
  63792. * change until JavaScript has returned control to the browser.
  63793. *
  63794. * The VRPose will contain the position, orientation, velocity,
  63795. * and acceleration of each of these properties.
  63796. * @returns the pose object
  63797. */
  63798. getPose(): VRPose;
  63799. /**
  63800. * Return the current instantaneous pose of the VRDisplay, with no
  63801. * prediction applied.
  63802. * @returns the current instantaneous pose
  63803. */
  63804. getImmediatePose(): VRPose;
  63805. /**
  63806. * The callback passed to `requestAnimationFrame` will be called
  63807. * any time a new frame should be rendered. When the VRDisplay is
  63808. * presenting the callback will be called at the native refresh
  63809. * rate of the HMD. When not presenting this function acts
  63810. * identically to how window.requestAnimationFrame acts. Content should
  63811. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63812. * asynchronously from other displays and at differing refresh rates.
  63813. * @param callback Define the eaction to run next frame
  63814. * @returns the request handle it
  63815. */
  63816. requestAnimationFrame(callback: FrameRequestCallback): number;
  63817. /**
  63818. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  63819. * Repeat calls while already presenting will update the VRLayers being displayed.
  63820. * @param layers Define the list of layer to present
  63821. * @returns a promise to know when the request has been fulfilled
  63822. */
  63823. requestPresent(layers: VRLayer[]): Promise<void>;
  63824. /**
  63825. * Reset the pose for this display, treating its current position and
  63826. * orientation as the "origin/zero" values. VRPose.position,
  63827. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  63828. * updated when calling resetPose(). This should be called in only
  63829. * sitting-space experiences.
  63830. */
  63831. resetPose(): void;
  63832. /**
  63833. * The VRLayer provided to the VRDisplay will be captured and presented
  63834. * in the HMD. Calling this function has the same effect on the source
  63835. * canvas as any other operation that uses its source image, and canvases
  63836. * created without preserveDrawingBuffer set to true will be cleared.
  63837. * @param pose Define the pose to submit
  63838. */
  63839. submitFrame(pose?: VRPose): void;
  63840. }
  63841. declare var VRDisplay: {
  63842. prototype: VRDisplay;
  63843. new(): VRDisplay;
  63844. };
  63845. interface VRLayer {
  63846. leftBounds?: number[] | Float32Array | null;
  63847. rightBounds?: number[] | Float32Array | null;
  63848. source?: HTMLCanvasElement | null;
  63849. }
  63850. interface VRDisplayCapabilities {
  63851. readonly canPresent: boolean;
  63852. readonly hasExternalDisplay: boolean;
  63853. readonly hasOrientation: boolean;
  63854. readonly hasPosition: boolean;
  63855. readonly maxLayers: number;
  63856. }
  63857. interface VREyeParameters {
  63858. /** @deprecated */
  63859. readonly fieldOfView: VRFieldOfView;
  63860. readonly offset: Float32Array;
  63861. readonly renderHeight: number;
  63862. readonly renderWidth: number;
  63863. }
  63864. interface VRFieldOfView {
  63865. readonly downDegrees: number;
  63866. readonly leftDegrees: number;
  63867. readonly rightDegrees: number;
  63868. readonly upDegrees: number;
  63869. }
  63870. interface VRFrameData {
  63871. readonly leftProjectionMatrix: Float32Array;
  63872. readonly leftViewMatrix: Float32Array;
  63873. readonly pose: VRPose;
  63874. readonly rightProjectionMatrix: Float32Array;
  63875. readonly rightViewMatrix: Float32Array;
  63876. readonly timestamp: number;
  63877. }
  63878. interface VRPose {
  63879. readonly angularAcceleration: Float32Array | null;
  63880. readonly angularVelocity: Float32Array | null;
  63881. readonly linearAcceleration: Float32Array | null;
  63882. readonly linearVelocity: Float32Array | null;
  63883. readonly orientation: Float32Array | null;
  63884. readonly position: Float32Array | null;
  63885. readonly timestamp: number;
  63886. }
  63887. interface VRStageParameters {
  63888. sittingToStandingTransform?: Float32Array;
  63889. sizeX?: number;
  63890. sizeY?: number;
  63891. }
  63892. interface Navigator {
  63893. getVRDisplays(): Promise<VRDisplay[]>;
  63894. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63895. }
  63896. interface Window {
  63897. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63898. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63899. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63900. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63901. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63902. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63903. }
  63904. interface Gamepad {
  63905. readonly displayId: number;
  63906. }
  63907. type XRSessionMode =
  63908. | "inline"
  63909. | "immersive-vr"
  63910. | "immersive-ar";
  63911. type XRReferenceSpaceType =
  63912. | "viewer"
  63913. | "local"
  63914. | "local-floor"
  63915. | "bounded-floor"
  63916. | "unbounded";
  63917. type XREnvironmentBlendMode =
  63918. | "opaque"
  63919. | "additive"
  63920. | "alpha-blend";
  63921. type XRVisibilityState =
  63922. | "visible"
  63923. | "visible-blurred"
  63924. | "hidden";
  63925. type XRHandedness =
  63926. | "none"
  63927. | "left"
  63928. | "right";
  63929. type XRTargetRayMode =
  63930. | "gaze"
  63931. | "tracked-pointer"
  63932. | "screen";
  63933. type XREye =
  63934. | "none"
  63935. | "left"
  63936. | "right";
  63937. interface XRSpace extends EventTarget {
  63938. }
  63939. interface XRRenderState {
  63940. depthNear?: number;
  63941. depthFar?: number;
  63942. inlineVerticalFieldOfView?: number;
  63943. baseLayer?: XRWebGLLayer;
  63944. }
  63945. interface XRInputSource {
  63946. handedness: XRHandedness;
  63947. targetRayMode: XRTargetRayMode;
  63948. targetRaySpace: XRSpace;
  63949. gripSpace: XRSpace | undefined;
  63950. gamepad: Gamepad | undefined;
  63951. profiles: Array<string>;
  63952. }
  63953. interface XRSession {
  63954. addEventListener: Function;
  63955. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63956. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63957. requestAnimationFrame: Function;
  63958. end(): Promise<void>;
  63959. renderState: XRRenderState;
  63960. inputSources: Array<XRInputSource>;
  63961. }
  63962. interface XRReferenceSpace extends XRSpace {
  63963. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63964. onreset: any;
  63965. }
  63966. interface XRFrame {
  63967. session: XRSession;
  63968. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63969. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63970. }
  63971. interface XRViewerPose extends XRPose {
  63972. views: Array<XRView>;
  63973. }
  63974. interface XRPose {
  63975. transform: XRRigidTransform;
  63976. emulatedPosition: boolean;
  63977. }
  63978. declare var XRWebGLLayer: {
  63979. prototype: XRWebGLLayer;
  63980. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63981. };
  63982. interface XRWebGLLayer {
  63983. framebuffer: WebGLFramebuffer;
  63984. framebufferWidth: number;
  63985. framebufferHeight: number;
  63986. getViewport: Function;
  63987. }
  63988. interface XRRigidTransform {
  63989. position: DOMPointReadOnly;
  63990. orientation: DOMPointReadOnly;
  63991. matrix: Float32Array;
  63992. inverse: XRRigidTransform;
  63993. }
  63994. interface XRView {
  63995. eye: XREye;
  63996. projectionMatrix: Float32Array;
  63997. transform: XRRigidTransform;
  63998. }
  63999. interface XRInputSourceChangeEvent {
  64000. session: XRSession;
  64001. removed: Array<XRInputSource>;
  64002. added: Array<XRInputSource>;
  64003. }
  64004. /**
  64005. * @ignore
  64006. */
  64007. declare module BABYLON.GLTF2.Exporter {
  64008. }
  64009. /**
  64010. * @ignore
  64011. */
  64012. declare module BABYLON.GLTF1 {
  64013. }
  64014. declare module BABYLON.GUI {
  64015. /**
  64016. * Class used to specific a value and its associated unit
  64017. */
  64018. export class ValueAndUnit {
  64019. /** defines the unit to store */
  64020. unit: number;
  64021. /** defines a boolean indicating if the value can be negative */
  64022. negativeValueAllowed: boolean;
  64023. private _value;
  64024. private _originalUnit;
  64025. /**
  64026. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  64027. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64028. */
  64029. ignoreAdaptiveScaling: boolean;
  64030. /**
  64031. * Creates a new ValueAndUnit
  64032. * @param value defines the value to store
  64033. * @param unit defines the unit to store
  64034. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64035. */
  64036. constructor(value: number,
  64037. /** defines the unit to store */
  64038. unit?: number,
  64039. /** defines a boolean indicating if the value can be negative */
  64040. negativeValueAllowed?: boolean);
  64041. /** Gets a boolean indicating if the value is a percentage */
  64042. readonly isPercentage: boolean;
  64043. /** Gets a boolean indicating if the value is store as pixel */
  64044. readonly isPixel: boolean;
  64045. /** Gets direct internal value */
  64046. readonly internalValue: number;
  64047. /**
  64048. * Gets value as pixel
  64049. * @param host defines the root host
  64050. * @param refValue defines the reference value for percentages
  64051. * @returns the value as pixel
  64052. */
  64053. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  64054. /**
  64055. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  64056. * @param value defines the value to store
  64057. * @param unit defines the unit to store
  64058. * @returns the current ValueAndUnit
  64059. */
  64060. updateInPlace(value: number, unit?: number): ValueAndUnit;
  64061. /**
  64062. * Gets the value accordingly to its unit
  64063. * @param host defines the root host
  64064. * @returns the value
  64065. */
  64066. getValue(host: AdvancedDynamicTexture): number;
  64067. /**
  64068. * Gets a string representation of the value
  64069. * @param host defines the root host
  64070. * @param decimals defines an optional number of decimals to display
  64071. * @returns a string
  64072. */
  64073. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  64074. /**
  64075. * Store a value parsed from a string
  64076. * @param source defines the source string
  64077. * @returns true if the value was successfully parsed
  64078. */
  64079. fromString(source: string | number): boolean;
  64080. private static _Regex;
  64081. private static _UNITMODE_PERCENTAGE;
  64082. private static _UNITMODE_PIXEL;
  64083. /** UNITMODE_PERCENTAGE */
  64084. static readonly UNITMODE_PERCENTAGE: number;
  64085. /** UNITMODE_PIXEL */
  64086. static readonly UNITMODE_PIXEL: number;
  64087. }
  64088. }
  64089. declare module BABYLON.GUI {
  64090. /**
  64091. * Define a style used by control to automatically setup properties based on a template.
  64092. * Only support font related properties so far
  64093. */
  64094. export class Style implements BABYLON.IDisposable {
  64095. private _fontFamily;
  64096. private _fontStyle;
  64097. private _fontWeight;
  64098. /** @hidden */ private _host: AdvancedDynamicTexture;
  64099. /** @hidden */ private _fontSize: ValueAndUnit;
  64100. /**
  64101. * BABYLON.Observable raised when the style values are changed
  64102. */
  64103. onChangedObservable: BABYLON.Observable<Style>;
  64104. /**
  64105. * Creates a new style object
  64106. * @param host defines the AdvancedDynamicTexture which hosts this style
  64107. */
  64108. constructor(host: AdvancedDynamicTexture);
  64109. /**
  64110. * Gets or sets the font size
  64111. */
  64112. fontSize: string | number;
  64113. /**
  64114. * Gets or sets the font family
  64115. */
  64116. fontFamily: string;
  64117. /**
  64118. * Gets or sets the font style
  64119. */
  64120. fontStyle: string;
  64121. /** Gets or sets font weight */
  64122. fontWeight: string;
  64123. /** Dispose all associated resources */
  64124. dispose(): void;
  64125. }
  64126. }
  64127. declare module BABYLON.GUI {
  64128. /**
  64129. * Class used to transport BABYLON.Vector2 information for pointer events
  64130. */
  64131. export class Vector2WithInfo extends BABYLON.Vector2 {
  64132. /** defines the current mouse button index */
  64133. buttonIndex: number;
  64134. /**
  64135. * Creates a new Vector2WithInfo
  64136. * @param source defines the vector2 data to transport
  64137. * @param buttonIndex defines the current mouse button index
  64138. */
  64139. constructor(source: BABYLON.Vector2,
  64140. /** defines the current mouse button index */
  64141. buttonIndex?: number);
  64142. }
  64143. /** Class used to provide 2D matrix features */
  64144. export class Matrix2D {
  64145. /** Gets the internal array of 6 floats used to store matrix data */
  64146. m: Float32Array;
  64147. /**
  64148. * Creates a new matrix
  64149. * @param m00 defines value for (0, 0)
  64150. * @param m01 defines value for (0, 1)
  64151. * @param m10 defines value for (1, 0)
  64152. * @param m11 defines value for (1, 1)
  64153. * @param m20 defines value for (2, 0)
  64154. * @param m21 defines value for (2, 1)
  64155. */
  64156. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  64157. /**
  64158. * Fills the matrix from direct values
  64159. * @param m00 defines value for (0, 0)
  64160. * @param m01 defines value for (0, 1)
  64161. * @param m10 defines value for (1, 0)
  64162. * @param m11 defines value for (1, 1)
  64163. * @param m20 defines value for (2, 0)
  64164. * @param m21 defines value for (2, 1)
  64165. * @returns the current modified matrix
  64166. */
  64167. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  64168. /**
  64169. * Gets matrix determinant
  64170. * @returns the determinant
  64171. */
  64172. determinant(): number;
  64173. /**
  64174. * Inverses the matrix and stores it in a target matrix
  64175. * @param result defines the target matrix
  64176. * @returns the current matrix
  64177. */
  64178. invertToRef(result: Matrix2D): Matrix2D;
  64179. /**
  64180. * Multiplies the current matrix with another one
  64181. * @param other defines the second operand
  64182. * @param result defines the target matrix
  64183. * @returns the current matrix
  64184. */
  64185. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  64186. /**
  64187. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  64188. * @param x defines the x coordinate to transform
  64189. * @param y defines the x coordinate to transform
  64190. * @param result defines the target vector2
  64191. * @returns the current matrix
  64192. */
  64193. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  64194. /**
  64195. * Creates an identity matrix
  64196. * @returns a new matrix
  64197. */
  64198. static Identity(): Matrix2D;
  64199. /**
  64200. * Creates a translation matrix and stores it in a target matrix
  64201. * @param x defines the x coordinate of the translation
  64202. * @param y defines the y coordinate of the translation
  64203. * @param result defines the target matrix
  64204. */
  64205. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  64206. /**
  64207. * Creates a scaling matrix and stores it in a target matrix
  64208. * @param x defines the x coordinate of the scaling
  64209. * @param y defines the y coordinate of the scaling
  64210. * @param result defines the target matrix
  64211. */
  64212. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  64213. /**
  64214. * Creates a rotation matrix and stores it in a target matrix
  64215. * @param angle defines the rotation angle
  64216. * @param result defines the target matrix
  64217. */
  64218. static RotationToRef(angle: number, result: Matrix2D): void;
  64219. private static _TempPreTranslationMatrix;
  64220. private static _TempPostTranslationMatrix;
  64221. private static _TempRotationMatrix;
  64222. private static _TempScalingMatrix;
  64223. private static _TempCompose0;
  64224. private static _TempCompose1;
  64225. private static _TempCompose2;
  64226. /**
  64227. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  64228. * @param tx defines the x coordinate of the translation
  64229. * @param ty defines the y coordinate of the translation
  64230. * @param angle defines the rotation angle
  64231. * @param scaleX defines the x coordinate of the scaling
  64232. * @param scaleY defines the y coordinate of the scaling
  64233. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  64234. * @param result defines the target matrix
  64235. */
  64236. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  64237. }
  64238. }
  64239. declare module BABYLON.GUI {
  64240. /**
  64241. * Class used to store 2D control sizes
  64242. */
  64243. export class Measure {
  64244. /** defines left coordinate */
  64245. left: number;
  64246. /** defines top coordinate */
  64247. top: number;
  64248. /** defines width dimension */
  64249. width: number;
  64250. /** defines height dimension */
  64251. height: number;
  64252. /**
  64253. * Creates a new measure
  64254. * @param left defines left coordinate
  64255. * @param top defines top coordinate
  64256. * @param width defines width dimension
  64257. * @param height defines height dimension
  64258. */
  64259. constructor(
  64260. /** defines left coordinate */
  64261. left: number,
  64262. /** defines top coordinate */
  64263. top: number,
  64264. /** defines width dimension */
  64265. width: number,
  64266. /** defines height dimension */
  64267. height: number);
  64268. /**
  64269. * Copy from another measure
  64270. * @param other defines the other measure to copy from
  64271. */
  64272. copyFrom(other: Measure): void;
  64273. /**
  64274. * Copy from a group of 4 floats
  64275. * @param left defines left coordinate
  64276. * @param top defines top coordinate
  64277. * @param width defines width dimension
  64278. * @param height defines height dimension
  64279. */
  64280. copyFromFloats(left: number, top: number, width: number, height: number): void;
  64281. /**
  64282. * Computes the axis aligned bounding box measure for two given measures
  64283. * @param a Input measure
  64284. * @param b Input measure
  64285. * @param result the resulting bounding measure
  64286. */
  64287. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  64288. /**
  64289. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  64290. * @param transform the matrix to transform the measure before computing the AABB
  64291. * @param result the resulting AABB
  64292. */
  64293. transformToRef(transform: Matrix2D, result: Measure): void;
  64294. /**
  64295. * Check equality between this measure and another one
  64296. * @param other defines the other measures
  64297. * @returns true if both measures are equals
  64298. */
  64299. isEqualsTo(other: Measure): boolean;
  64300. /**
  64301. * Creates an empty measure
  64302. * @returns a new measure
  64303. */
  64304. static Empty(): Measure;
  64305. }
  64306. }
  64307. declare module BABYLON.GUI {
  64308. /**
  64309. * Interface used to define a control that can receive focus
  64310. */
  64311. export interface IFocusableControl {
  64312. /**
  64313. * Function called when the control receives the focus
  64314. */
  64315. onFocus(): void;
  64316. /**
  64317. * Function called when the control loses the focus
  64318. */
  64319. onBlur(): void;
  64320. /**
  64321. * Function called to let the control handle keyboard events
  64322. * @param evt defines the current keyboard event
  64323. */
  64324. processKeyboard(evt: KeyboardEvent): void;
  64325. /**
  64326. * Function called to get the list of controls that should not steal the focus from this control
  64327. * @returns an array of controls
  64328. */
  64329. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64330. }
  64331. /**
  64332. * Class used to create texture to support 2D GUI elements
  64333. * @see http://doc.babylonjs.com/how_to/gui
  64334. */
  64335. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  64336. private _isDirty;
  64337. private _renderObserver;
  64338. private _resizeObserver;
  64339. private _preKeyboardObserver;
  64340. private _pointerMoveObserver;
  64341. private _pointerObserver;
  64342. private _canvasPointerOutObserver;
  64343. private _background;
  64344. /** @hidden */ private _rootContainer: Container;
  64345. /** @hidden */ private _lastPickedControl: Control;
  64346. /** @hidden */ private _lastControlOver: {
  64347. [pointerId: number]: Control;
  64348. };
  64349. /** @hidden */ private _lastControlDown: {
  64350. [pointerId: number]: Control;
  64351. };
  64352. /** @hidden */ private _capturingControl: {
  64353. [pointerId: number]: Control;
  64354. };
  64355. /** @hidden */ private _shouldBlockPointer: boolean;
  64356. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  64357. /** @hidden */ private _linkedControls: Control[];
  64358. private _isFullscreen;
  64359. private _fullscreenViewport;
  64360. private _idealWidth;
  64361. private _idealHeight;
  64362. private _useSmallestIdeal;
  64363. private _renderAtIdealSize;
  64364. private _focusedControl;
  64365. private _blockNextFocusCheck;
  64366. private _renderScale;
  64367. private _rootElement;
  64368. private _cursorChanged;
  64369. /**
  64370. * Define type to string to ensure compatibility across browsers
  64371. * Safari doesn't support DataTransfer constructor
  64372. */
  64373. private _clipboardData;
  64374. /**
  64375. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64376. */
  64377. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64378. /**
  64379. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64380. */
  64381. onControlPickedObservable: BABYLON.Observable<Control>;
  64382. /**
  64383. * BABYLON.Observable event triggered before layout is evaluated
  64384. */
  64385. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64386. /**
  64387. * BABYLON.Observable event triggered after the layout was evaluated
  64388. */
  64389. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64390. /**
  64391. * BABYLON.Observable event triggered before the texture is rendered
  64392. */
  64393. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64394. /**
  64395. * BABYLON.Observable event triggered after the texture was rendered
  64396. */
  64397. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64398. /**
  64399. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64400. */
  64401. premulAlpha: boolean;
  64402. /**
  64403. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64404. * Useful when you want more antialiasing
  64405. */
  64406. renderScale: number;
  64407. /** Gets or sets the background color */
  64408. background: string;
  64409. /**
  64410. * Gets or sets the ideal width used to design controls.
  64411. * The GUI will then rescale everything accordingly
  64412. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64413. */
  64414. idealWidth: number;
  64415. /**
  64416. * Gets or sets the ideal height used to design controls.
  64417. * The GUI will then rescale everything accordingly
  64418. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64419. */
  64420. idealHeight: number;
  64421. /**
  64422. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64423. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64424. */
  64425. useSmallestIdeal: boolean;
  64426. /**
  64427. * Gets or sets a boolean indicating if adaptive scaling must be used
  64428. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64429. */
  64430. renderAtIdealSize: boolean;
  64431. /**
  64432. * Gets the underlying layer used to render the texture when in fullscreen mode
  64433. */
  64434. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64435. /**
  64436. * Gets the root container control
  64437. */
  64438. readonly rootContainer: Container;
  64439. /**
  64440. * Returns an array containing the root container.
  64441. * This is mostly used to let the Inspector introspects the ADT
  64442. * @returns an array containing the rootContainer
  64443. */
  64444. getChildren(): Array<Container>;
  64445. /**
  64446. * Will return all controls that are inside this texture
  64447. * @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
  64448. * @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
  64449. * @return all child controls
  64450. */
  64451. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64452. /**
  64453. * Gets or sets the current focused control
  64454. */
  64455. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64456. /**
  64457. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64458. */
  64459. isForeground: boolean;
  64460. /**
  64461. * Gets or set information about clipboardData
  64462. */
  64463. clipboardData: string;
  64464. /**
  64465. * Creates a new AdvancedDynamicTexture
  64466. * @param name defines the name of the texture
  64467. * @param width defines the width of the texture
  64468. * @param height defines the height of the texture
  64469. * @param scene defines the hosting scene
  64470. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64471. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64472. */
  64473. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64474. /**
  64475. * Get the current class name of the texture useful for serialization or dynamic coding.
  64476. * @returns "AdvancedDynamicTexture"
  64477. */
  64478. getClassName(): string;
  64479. /**
  64480. * Function used to execute a function on all controls
  64481. * @param func defines the function to execute
  64482. * @param container defines the container where controls belong. If null the root container will be used
  64483. */
  64484. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64485. private _useInvalidateRectOptimization;
  64486. /**
  64487. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64488. */
  64489. useInvalidateRectOptimization: boolean;
  64490. private _invalidatedRectangle;
  64491. /**
  64492. * Invalidates a rectangle area on the gui texture
  64493. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64494. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64495. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64496. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64497. */
  64498. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64499. /**
  64500. * Marks the texture as dirty forcing a complete update
  64501. */
  64502. markAsDirty(): void;
  64503. /**
  64504. * Helper function used to create a new style
  64505. * @returns a new style
  64506. * @see http://doc.babylonjs.com/how_to/gui#styles
  64507. */
  64508. createStyle(): Style;
  64509. /**
  64510. * Adds a new control to the root container
  64511. * @param control defines the control to add
  64512. * @returns the current texture
  64513. */
  64514. addControl(control: Control): AdvancedDynamicTexture;
  64515. /**
  64516. * Removes a control from the root container
  64517. * @param control defines the control to remove
  64518. * @returns the current texture
  64519. */
  64520. removeControl(control: Control): AdvancedDynamicTexture;
  64521. /**
  64522. * Release all resources
  64523. */
  64524. dispose(): void;
  64525. private _onResize;
  64526. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64527. /**
  64528. * Get screen coordinates for a vector3
  64529. * @param position defines the position to project
  64530. * @param worldMatrix defines the world matrix to use
  64531. * @returns the projected position
  64532. */
  64533. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64534. private _checkUpdate;
  64535. private _clearMeasure;
  64536. private _render;
  64537. /** @hidden */ private _changeCursor(cursor: string): void;
  64538. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  64539. private _doPicking;
  64540. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  64541. [pointerId: number]: Control;
  64542. }, control: Control): void;
  64543. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  64544. /** Attach to all scene events required to support pointer events */
  64545. attach(): void;
  64546. /** @hidden */
  64547. private onClipboardCopy;
  64548. /** @hidden */
  64549. private onClipboardCut;
  64550. /** @hidden */
  64551. private onClipboardPaste;
  64552. /**
  64553. * Register the clipboard Events onto the canvas
  64554. */
  64555. registerClipboardEvents(): void;
  64556. /**
  64557. * Unregister the clipboard Events from the canvas
  64558. */
  64559. unRegisterClipboardEvents(): void;
  64560. /**
  64561. * Connect the texture to a hosting mesh to enable interactions
  64562. * @param mesh defines the mesh to attach to
  64563. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64564. */
  64565. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64566. /**
  64567. * Move the focus to a specific control
  64568. * @param control defines the control which will receive the focus
  64569. */
  64570. moveFocusToControl(control: IFocusableControl): void;
  64571. private _manageFocus;
  64572. private _attachToOnPointerOut;
  64573. /**
  64574. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64575. * @param mesh defines the mesh which will receive the texture
  64576. * @param width defines the texture width (1024 by default)
  64577. * @param height defines the texture height (1024 by default)
  64578. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64579. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64580. * @returns a new AdvancedDynamicTexture
  64581. */
  64582. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64583. /**
  64584. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64585. * In this mode the texture will rely on a layer for its rendering.
  64586. * This allows it to be treated like any other layer.
  64587. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64588. * LayerMask is set through advancedTexture.layer.layerMask
  64589. * @param name defines name for the texture
  64590. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64591. * @param scene defines the hsoting scene
  64592. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64593. * @returns a new AdvancedDynamicTexture
  64594. */
  64595. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64596. }
  64597. }
  64598. declare module BABYLON.GUI {
  64599. /**
  64600. * Root class used for all 2D controls
  64601. * @see http://doc.babylonjs.com/how_to/gui#controls
  64602. */
  64603. export class Control {
  64604. /** defines the name of the control */
  64605. name?: string | undefined;
  64606. /**
  64607. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64608. */
  64609. static AllowAlphaInheritance: boolean;
  64610. private _alpha;
  64611. private _alphaSet;
  64612. private _zIndex;
  64613. /** @hidden */ private _host: AdvancedDynamicTexture;
  64614. /** Gets or sets the control parent */
  64615. parent: BABYLON.Nullable<Container>;
  64616. /** @hidden */ private _currentMeasure: Measure;
  64617. private _fontFamily;
  64618. private _fontStyle;
  64619. private _fontWeight;
  64620. private _fontSize;
  64621. private _font;
  64622. /** @hidden */ private _width: ValueAndUnit;
  64623. /** @hidden */ private _height: ValueAndUnit;
  64624. /** @hidden */
  64625. protected _fontOffset: {
  64626. ascent: number;
  64627. height: number;
  64628. descent: number;
  64629. };
  64630. private _color;
  64631. private _style;
  64632. private _styleObserver;
  64633. /** @hidden */
  64634. protected _horizontalAlignment: number;
  64635. /** @hidden */
  64636. protected _verticalAlignment: number;
  64637. /** @hidden */
  64638. protected _isDirty: boolean;
  64639. /** @hidden */
  64640. protected _wasDirty: boolean;
  64641. /** @hidden */ private _tempParentMeasure: Measure;
  64642. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64643. /** @hidden */
  64644. protected _cachedParentMeasure: Measure;
  64645. private _paddingLeft;
  64646. private _paddingRight;
  64647. private _paddingTop;
  64648. private _paddingBottom;
  64649. /** @hidden */ private _left: ValueAndUnit;
  64650. /** @hidden */ private _top: ValueAndUnit;
  64651. private _scaleX;
  64652. private _scaleY;
  64653. private _rotation;
  64654. private _transformCenterX;
  64655. private _transformCenterY;
  64656. /** @hidden */ private _transformMatrix: Matrix2D;
  64657. /** @hidden */
  64658. protected _invertTransformMatrix: Matrix2D;
  64659. /** @hidden */
  64660. protected _transformedPosition: BABYLON.Vector2;
  64661. private _isMatrixDirty;
  64662. private _cachedOffsetX;
  64663. private _cachedOffsetY;
  64664. private _isVisible;
  64665. private _isHighlighted;
  64666. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64667. private _fontSet;
  64668. private _dummyVector2;
  64669. private _downCount;
  64670. private _enterCount;
  64671. private _doNotRender;
  64672. private _downPointerIds;
  64673. protected _isEnabled: boolean;
  64674. protected _disabledColor: string;
  64675. /** @hidden */
  64676. protected _rebuildLayout: boolean;
  64677. /** @hidden */ private _isClipped: boolean;
  64678. /** @hidden */ private _tag: any;
  64679. /**
  64680. * 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
  64681. */
  64682. uniqueId: number;
  64683. /**
  64684. * Gets or sets an object used to store user defined information for the node
  64685. */
  64686. metadata: any;
  64687. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64688. isHitTestVisible: boolean;
  64689. /** Gets or sets a boolean indicating if the control can block pointer events */
  64690. isPointerBlocker: boolean;
  64691. /** Gets or sets a boolean indicating if the control can be focusable */
  64692. isFocusInvisible: boolean;
  64693. /**
  64694. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64695. * 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
  64696. */
  64697. clipChildren: boolean;
  64698. /**
  64699. * Gets or sets a boolean indicating that control content must be clipped
  64700. * 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
  64701. */
  64702. clipContent: boolean;
  64703. /**
  64704. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64705. */
  64706. useBitmapCache: boolean;
  64707. private _cacheData;
  64708. private _shadowOffsetX;
  64709. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64710. shadowOffsetX: number;
  64711. private _shadowOffsetY;
  64712. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64713. shadowOffsetY: number;
  64714. private _shadowBlur;
  64715. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64716. shadowBlur: number;
  64717. private _shadowColor;
  64718. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64719. shadowColor: string;
  64720. /** Gets or sets the cursor to use when the control is hovered */
  64721. hoverCursor: string;
  64722. /** @hidden */
  64723. protected _linkOffsetX: ValueAndUnit;
  64724. /** @hidden */
  64725. protected _linkOffsetY: ValueAndUnit;
  64726. /** Gets the control type name */
  64727. readonly typeName: string;
  64728. /**
  64729. * Get the current class name of the control.
  64730. * @returns current class name
  64731. */
  64732. getClassName(): string;
  64733. /**
  64734. * An event triggered when the pointer move over the control.
  64735. */
  64736. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64737. /**
  64738. * An event triggered when the pointer move out of the control.
  64739. */
  64740. onPointerOutObservable: BABYLON.Observable<Control>;
  64741. /**
  64742. * An event triggered when the pointer taps the control
  64743. */
  64744. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64745. /**
  64746. * An event triggered when pointer up
  64747. */
  64748. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64749. /**
  64750. * An event triggered when a control is clicked on
  64751. */
  64752. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64753. /**
  64754. * An event triggered when pointer enters the control
  64755. */
  64756. onPointerEnterObservable: BABYLON.Observable<Control>;
  64757. /**
  64758. * An event triggered when the control is marked as dirty
  64759. */
  64760. onDirtyObservable: BABYLON.Observable<Control>;
  64761. /**
  64762. * An event triggered before drawing the control
  64763. */
  64764. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64765. /**
  64766. * An event triggered after the control was drawn
  64767. */
  64768. onAfterDrawObservable: BABYLON.Observable<Control>;
  64769. /**
  64770. * Get the hosting AdvancedDynamicTexture
  64771. */
  64772. readonly host: AdvancedDynamicTexture;
  64773. /** Gets or set information about font offsets (used to render and align text) */
  64774. fontOffset: {
  64775. ascent: number;
  64776. height: number;
  64777. descent: number;
  64778. };
  64779. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64780. alpha: number;
  64781. /**
  64782. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64783. */
  64784. isHighlighted: boolean;
  64785. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64786. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64787. */
  64788. scaleX: number;
  64789. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  64790. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64791. */
  64792. scaleY: number;
  64793. /** Gets or sets the rotation angle (0 by default)
  64794. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64795. */
  64796. rotation: number;
  64797. /** Gets or sets the transformation center on Y axis (0 by default)
  64798. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64799. */
  64800. transformCenterY: number;
  64801. /** Gets or sets the transformation center on X axis (0 by default)
  64802. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64803. */
  64804. transformCenterX: number;
  64805. /**
  64806. * Gets or sets the horizontal alignment
  64807. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64808. */
  64809. horizontalAlignment: number;
  64810. /**
  64811. * Gets or sets the vertical alignment
  64812. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64813. */
  64814. verticalAlignment: number;
  64815. /**
  64816. * Gets or sets control width
  64817. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64818. */
  64819. width: string | number;
  64820. /**
  64821. * Gets or sets the control width in pixel
  64822. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64823. */
  64824. widthInPixels: number;
  64825. /**
  64826. * Gets or sets control height
  64827. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64828. */
  64829. height: string | number;
  64830. /**
  64831. * Gets or sets control height in pixel
  64832. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64833. */
  64834. heightInPixels: number;
  64835. /** Gets or set font family */
  64836. fontFamily: string;
  64837. /** Gets or sets font style */
  64838. fontStyle: string;
  64839. /** Gets or sets font weight */
  64840. fontWeight: string;
  64841. /**
  64842. * Gets or sets style
  64843. * @see http://doc.babylonjs.com/how_to/gui#styles
  64844. */
  64845. style: BABYLON.Nullable<Style>;
  64846. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  64847. /** Gets or sets font size in pixels */
  64848. fontSizeInPixels: number;
  64849. /** Gets or sets font size */
  64850. fontSize: string | number;
  64851. /** Gets or sets foreground color */
  64852. color: string;
  64853. /** Gets or sets z index which is used to reorder controls on the z axis */
  64854. zIndex: number;
  64855. /** Gets or sets a boolean indicating if the control can be rendered */
  64856. notRenderable: boolean;
  64857. /** Gets or sets a boolean indicating if the control is visible */
  64858. isVisible: boolean;
  64859. /** Gets a boolean indicating that the control needs to update its rendering */
  64860. readonly isDirty: boolean;
  64861. /**
  64862. * Gets the current linked mesh (or null if none)
  64863. */
  64864. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64865. /**
  64866. * Gets or sets a value indicating the padding to use on the left of the control
  64867. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64868. */
  64869. paddingLeft: string | number;
  64870. /**
  64871. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  64872. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64873. */
  64874. paddingLeftInPixels: number;
  64875. /**
  64876. * Gets or sets a value indicating the padding to use on the right of the control
  64877. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64878. */
  64879. paddingRight: string | number;
  64880. /**
  64881. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  64882. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64883. */
  64884. paddingRightInPixels: number;
  64885. /**
  64886. * Gets or sets a value indicating the padding to use on the top of the control
  64887. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64888. */
  64889. paddingTop: string | number;
  64890. /**
  64891. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  64892. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64893. */
  64894. paddingTopInPixels: number;
  64895. /**
  64896. * Gets or sets a value indicating the padding to use on the bottom of the control
  64897. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64898. */
  64899. paddingBottom: string | number;
  64900. /**
  64901. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  64902. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64903. */
  64904. paddingBottomInPixels: number;
  64905. /**
  64906. * Gets or sets a value indicating the left coordinate of the control
  64907. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64908. */
  64909. left: string | number;
  64910. /**
  64911. * Gets or sets a value indicating the left coordinate in pixels of the control
  64912. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64913. */
  64914. leftInPixels: number;
  64915. /**
  64916. * Gets or sets a value indicating the top coordinate of the control
  64917. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64918. */
  64919. top: string | number;
  64920. /**
  64921. * Gets or sets a value indicating the top coordinate in pixels of the control
  64922. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64923. */
  64924. topInPixels: number;
  64925. /**
  64926. * Gets or sets a value indicating the offset on X axis to the linked mesh
  64927. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64928. */
  64929. linkOffsetX: string | number;
  64930. /**
  64931. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  64932. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64933. */
  64934. linkOffsetXInPixels: number;
  64935. /**
  64936. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  64937. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64938. */
  64939. linkOffsetY: string | number;
  64940. /**
  64941. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  64942. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64943. */
  64944. linkOffsetYInPixels: number;
  64945. /** Gets the center coordinate on X axis */
  64946. readonly centerX: number;
  64947. /** Gets the center coordinate on Y axis */
  64948. readonly centerY: number;
  64949. /** Gets or sets if control is Enabled*/
  64950. isEnabled: boolean;
  64951. /** Gets or sets background color of control if it's disabled*/
  64952. disabledColor: string;
  64953. /**
  64954. * Creates a new control
  64955. * @param name defines the name of the control
  64956. */
  64957. constructor(
  64958. /** defines the name of the control */
  64959. name?: string | undefined);
  64960. /** @hidden */
  64961. protected _getTypeName(): string;
  64962. /**
  64963. * Gets the first ascendant in the hierarchy of the given type
  64964. * @param className defines the required type
  64965. * @returns the ascendant or null if not found
  64966. */
  64967. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  64968. /** @hidden */ private _resetFontCache(): void;
  64969. /**
  64970. * Determines if a container is an ascendant of the current control
  64971. * @param container defines the container to look for
  64972. * @returns true if the container is one of the ascendant of the control
  64973. */
  64974. isAscendant(container: Control): boolean;
  64975. /**
  64976. * Gets coordinates in local control space
  64977. * @param globalCoordinates defines the coordinates to transform
  64978. * @returns the new coordinates in local space
  64979. */
  64980. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64981. /**
  64982. * Gets coordinates in local control space
  64983. * @param globalCoordinates defines the coordinates to transform
  64984. * @param result defines the target vector2 where to store the result
  64985. * @returns the current control
  64986. */
  64987. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  64988. /**
  64989. * Gets coordinates in parent local control space
  64990. * @param globalCoordinates defines the coordinates to transform
  64991. * @returns the new coordinates in parent local space
  64992. */
  64993. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64994. /**
  64995. * Move the current control to a vector3 position projected onto the screen.
  64996. * @param position defines the target position
  64997. * @param scene defines the hosting scene
  64998. */
  64999. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  65000. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65001. /**
  65002. * Will return all controls that have this control as ascendant
  65003. * @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
  65004. * @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
  65005. * @return all child controls
  65006. */
  65007. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65008. /**
  65009. * Link current control with a target mesh
  65010. * @param mesh defines the mesh to link with
  65011. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65012. */
  65013. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  65014. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  65015. /** @hidden */ private _offsetLeft(offset: number): void;
  65016. /** @hidden */ private _offsetTop(offset: number): void;
  65017. /** @hidden */ private _markMatrixAsDirty(): void;
  65018. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  65019. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  65020. /** @hidden */
  65021. protected invalidateRect(): void;
  65022. /** @hidden */ private _markAsDirty(force?: boolean): void;
  65023. /** @hidden */ private _markAllAsDirty(): void;
  65024. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  65025. /** @hidden */
  65026. protected _transform(context?: CanvasRenderingContext2D): void;
  65027. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  65028. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65029. /** @hidden */
  65030. protected _applyStates(context: CanvasRenderingContext2D): void;
  65031. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65032. /** @hidden */
  65033. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65034. protected _evaluateClippingState(parentMeasure: Measure): void;
  65035. /** @hidden */ private _measure(): void;
  65036. /** @hidden */
  65037. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65038. /** @hidden */
  65039. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65040. /** @hidden */
  65041. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65042. /** @hidden */
  65043. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65044. private static _ClipMeasure;
  65045. private _tmpMeasureA;
  65046. private _clip;
  65047. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  65048. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  65049. /**
  65050. * Tests if a given coordinates belong to the current control
  65051. * @param x defines x coordinate to test
  65052. * @param y defines y coordinate to test
  65053. * @returns true if the coordinates are inside the control
  65054. */
  65055. contains(x: number, y: number): boolean;
  65056. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65057. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65058. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  65059. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  65060. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65061. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65062. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65063. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  65064. private _prepareFont;
  65065. /** Releases associated resources */
  65066. dispose(): void;
  65067. private static _HORIZONTAL_ALIGNMENT_LEFT;
  65068. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  65069. private static _HORIZONTAL_ALIGNMENT_CENTER;
  65070. private static _VERTICAL_ALIGNMENT_TOP;
  65071. private static _VERTICAL_ALIGNMENT_BOTTOM;
  65072. private static _VERTICAL_ALIGNMENT_CENTER;
  65073. /** HORIZONTAL_ALIGNMENT_LEFT */
  65074. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  65075. /** HORIZONTAL_ALIGNMENT_RIGHT */
  65076. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  65077. /** HORIZONTAL_ALIGNMENT_CENTER */
  65078. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  65079. /** VERTICAL_ALIGNMENT_TOP */
  65080. static readonly VERTICAL_ALIGNMENT_TOP: number;
  65081. /** VERTICAL_ALIGNMENT_BOTTOM */
  65082. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  65083. /** VERTICAL_ALIGNMENT_CENTER */
  65084. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  65085. private static _FontHeightSizes;
  65086. /** @hidden */ private static _GetFontOffset(font: string): {
  65087. ascent: number;
  65088. height: number;
  65089. descent: number;
  65090. };
  65091. /**
  65092. * Creates a stack panel that can be used to render headers
  65093. * @param control defines the control to associate with the header
  65094. * @param text defines the text of the header
  65095. * @param size defines the size of the header
  65096. * @param options defines options used to configure the header
  65097. * @returns a new StackPanel
  65098. * @ignore
  65099. * @hidden
  65100. */
  65101. static AddHeader: (control: Control, text: string, size: string | number, options: {
  65102. isHorizontal: boolean;
  65103. controlFirst: boolean;
  65104. }) => any;
  65105. /** @hidden */
  65106. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  65107. }
  65108. }
  65109. declare module BABYLON.GUI {
  65110. /**
  65111. * Root class for 2D containers
  65112. * @see http://doc.babylonjs.com/how_to/gui#containers
  65113. */
  65114. export class Container extends Control {
  65115. name?: string | undefined;
  65116. /** @hidden */
  65117. protected _children: Control[];
  65118. /** @hidden */
  65119. protected _measureForChildren: Measure;
  65120. /** @hidden */
  65121. protected _background: string;
  65122. /** @hidden */
  65123. protected _adaptWidthToChildren: boolean;
  65124. /** @hidden */
  65125. protected _adaptHeightToChildren: boolean;
  65126. /**
  65127. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  65128. */
  65129. logLayoutCycleErrors: boolean;
  65130. /**
  65131. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  65132. */
  65133. maxLayoutCycle: number;
  65134. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  65135. adaptHeightToChildren: boolean;
  65136. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  65137. adaptWidthToChildren: boolean;
  65138. /** Gets or sets background color */
  65139. background: string;
  65140. /** Gets the list of children */
  65141. readonly children: Control[];
  65142. /**
  65143. * Creates a new Container
  65144. * @param name defines the name of the container
  65145. */
  65146. constructor(name?: string | undefined);
  65147. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  65148. /**
  65149. * Gets a child using its name
  65150. * @param name defines the child name to look for
  65151. * @returns the child control if found
  65152. */
  65153. getChildByName(name: string): BABYLON.Nullable<Control>;
  65154. /**
  65155. * Gets a child using its type and its name
  65156. * @param name defines the child name to look for
  65157. * @param type defines the child type to look for
  65158. * @returns the child control if found
  65159. */
  65160. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  65161. /**
  65162. * Search for a specific control in children
  65163. * @param control defines the control to look for
  65164. * @returns true if the control is in child list
  65165. */
  65166. containsControl(control: Control): boolean;
  65167. /**
  65168. * Adds a new control to the current container
  65169. * @param control defines the control to add
  65170. * @returns the current container
  65171. */
  65172. addControl(control: BABYLON.Nullable<Control>): Container;
  65173. /**
  65174. * Removes all controls from the current container
  65175. * @returns the current container
  65176. */
  65177. clearControls(): Container;
  65178. /**
  65179. * Removes a control from the current container
  65180. * @param control defines the control to remove
  65181. * @returns the current container
  65182. */
  65183. removeControl(control: Control): Container;
  65184. /** @hidden */ private _reOrderControl(control: Control): void;
  65185. /** @hidden */ private _offsetLeft(offset: number): void;
  65186. /** @hidden */ private _offsetTop(offset: number): void;
  65187. /** @hidden */ private _markAllAsDirty(): void;
  65188. /** @hidden */
  65189. protected _localDraw(context: CanvasRenderingContext2D): void;
  65190. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  65191. /** @hidden */
  65192. protected _beforeLayout(): void;
  65193. /** @hidden */
  65194. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65195. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65196. protected _postMeasure(): void;
  65197. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  65198. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65199. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65200. /** @hidden */
  65201. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65202. /** Releases associated resources */
  65203. dispose(): void;
  65204. }
  65205. }
  65206. declare module BABYLON.GUI {
  65207. /** Class used to create rectangle container */
  65208. export class Rectangle extends Container {
  65209. name?: string | undefined;
  65210. private _thickness;
  65211. private _cornerRadius;
  65212. /** Gets or sets border thickness */
  65213. thickness: number;
  65214. /** Gets or sets the corner radius angle */
  65215. cornerRadius: number;
  65216. /**
  65217. * Creates a new Rectangle
  65218. * @param name defines the control name
  65219. */
  65220. constructor(name?: string | undefined);
  65221. protected _getTypeName(): string;
  65222. protected _localDraw(context: CanvasRenderingContext2D): void;
  65223. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65224. private _drawRoundedRect;
  65225. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65226. }
  65227. }
  65228. declare module BABYLON.GUI {
  65229. /**
  65230. * Enum that determines the text-wrapping mode to use.
  65231. */
  65232. export enum TextWrapping {
  65233. /**
  65234. * Clip the text when it's larger than Control.width; this is the default mode.
  65235. */
  65236. Clip = 0,
  65237. /**
  65238. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  65239. */
  65240. WordWrap = 1,
  65241. /**
  65242. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  65243. */
  65244. Ellipsis = 2
  65245. }
  65246. /**
  65247. * Class used to create text block control
  65248. */
  65249. export class TextBlock extends Control {
  65250. /**
  65251. * Defines the name of the control
  65252. */
  65253. name?: string | undefined;
  65254. private _text;
  65255. private _textWrapping;
  65256. private _textHorizontalAlignment;
  65257. private _textVerticalAlignment;
  65258. private _lines;
  65259. private _resizeToFit;
  65260. private _lineSpacing;
  65261. private _outlineWidth;
  65262. private _outlineColor;
  65263. /**
  65264. * An event triggered after the text is changed
  65265. */
  65266. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  65267. /**
  65268. * An event triggered after the text was broken up into lines
  65269. */
  65270. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  65271. /**
  65272. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  65273. */
  65274. readonly lines: any[];
  65275. /**
  65276. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65277. */
  65278. /**
  65279. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65280. */
  65281. resizeToFit: boolean;
  65282. /**
  65283. * Gets or sets a boolean indicating if text must be wrapped
  65284. */
  65285. /**
  65286. * Gets or sets a boolean indicating if text must be wrapped
  65287. */
  65288. textWrapping: TextWrapping | boolean;
  65289. /**
  65290. * Gets or sets text to display
  65291. */
  65292. /**
  65293. * Gets or sets text to display
  65294. */
  65295. text: string;
  65296. /**
  65297. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65298. */
  65299. /**
  65300. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65301. */
  65302. textHorizontalAlignment: number;
  65303. /**
  65304. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65305. */
  65306. /**
  65307. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65308. */
  65309. textVerticalAlignment: number;
  65310. /**
  65311. * Gets or sets line spacing value
  65312. */
  65313. /**
  65314. * Gets or sets line spacing value
  65315. */
  65316. lineSpacing: string | number;
  65317. /**
  65318. * Gets or sets outlineWidth of the text to display
  65319. */
  65320. /**
  65321. * Gets or sets outlineWidth of the text to display
  65322. */
  65323. outlineWidth: number;
  65324. /**
  65325. * Gets or sets outlineColor of the text to display
  65326. */
  65327. /**
  65328. * Gets or sets outlineColor of the text to display
  65329. */
  65330. outlineColor: string;
  65331. /**
  65332. * Creates a new TextBlock object
  65333. * @param name defines the name of the control
  65334. * @param text defines the text to display (emptry string by default)
  65335. */
  65336. constructor(
  65337. /**
  65338. * Defines the name of the control
  65339. */
  65340. name?: string | undefined, text?: string);
  65341. protected _getTypeName(): string;
  65342. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65343. private _drawText;
  65344. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  65345. protected _applyStates(context: CanvasRenderingContext2D): void;
  65346. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  65347. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  65348. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  65349. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  65350. protected _renderLines(context: CanvasRenderingContext2D): void;
  65351. /**
  65352. * Given a width constraint applied on the text block, find the expected height
  65353. * @returns expected height
  65354. */
  65355. computeExpectedHeight(): number;
  65356. dispose(): void;
  65357. }
  65358. }
  65359. declare module BABYLON.GUI {
  65360. /**
  65361. * Class used to create 2D images
  65362. */
  65363. export class Image extends Control {
  65364. name?: string | undefined;
  65365. private _workingCanvas;
  65366. private _domImage;
  65367. private _imageWidth;
  65368. private _imageHeight;
  65369. private _loaded;
  65370. private _stretch;
  65371. private _source;
  65372. private _autoScale;
  65373. private _sourceLeft;
  65374. private _sourceTop;
  65375. private _sourceWidth;
  65376. private _sourceHeight;
  65377. private _cellWidth;
  65378. private _cellHeight;
  65379. private _cellId;
  65380. private _populateNinePatchSlicesFromImage;
  65381. private _sliceLeft;
  65382. private _sliceRight;
  65383. private _sliceTop;
  65384. private _sliceBottom;
  65385. private _detectPointerOnOpaqueOnly;
  65386. /**
  65387. * BABYLON.Observable notified when the content is loaded
  65388. */
  65389. onImageLoadedObservable: BABYLON.Observable<Image>;
  65390. /**
  65391. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  65392. */
  65393. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  65394. /**
  65395. * Gets a boolean indicating that the content is loaded
  65396. */
  65397. readonly isLoaded: boolean;
  65398. /**
  65399. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65400. */
  65401. populateNinePatchSlicesFromImage: boolean;
  65402. /**
  65403. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65404. * Beware using this as this will comsume more memory as the image has to be stored twice
  65405. */
  65406. detectPointerOnOpaqueOnly: boolean;
  65407. /**
  65408. * Gets or sets the left value for slicing (9-patch)
  65409. */
  65410. sliceLeft: number;
  65411. /**
  65412. * Gets or sets the right value for slicing (9-patch)
  65413. */
  65414. sliceRight: number;
  65415. /**
  65416. * Gets or sets the top value for slicing (9-patch)
  65417. */
  65418. sliceTop: number;
  65419. /**
  65420. * Gets or sets the bottom value for slicing (9-patch)
  65421. */
  65422. sliceBottom: number;
  65423. /**
  65424. * Gets or sets the left coordinate in the source image
  65425. */
  65426. sourceLeft: number;
  65427. /**
  65428. * Gets or sets the top coordinate in the source image
  65429. */
  65430. sourceTop: number;
  65431. /**
  65432. * Gets or sets the width to capture in the source image
  65433. */
  65434. sourceWidth: number;
  65435. /**
  65436. * Gets or sets the height to capture in the source image
  65437. */
  65438. sourceHeight: number;
  65439. /**
  65440. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65441. * @see http://doc.babylonjs.com/how_to/gui#image
  65442. */
  65443. autoScale: boolean;
  65444. /** Gets or sets the streching mode used by the image */
  65445. stretch: number;
  65446. /**
  65447. * Gets or sets the internal DOM image used to render the control
  65448. */
  65449. domImage: HTMLImageElement;
  65450. private _onImageLoaded;
  65451. private _extractNinePatchSliceDataFromImage;
  65452. /**
  65453. * Gets or sets image source url
  65454. */
  65455. source: BABYLON.Nullable<string>;
  65456. /**
  65457. * Checks for svg document with icon id present
  65458. */
  65459. private _svgCheck;
  65460. /**
  65461. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  65462. * given external svg file and icon id
  65463. */
  65464. private _getSVGAttribs;
  65465. /**
  65466. * Gets or sets the cell width to use when animation sheet is enabled
  65467. * @see http://doc.babylonjs.com/how_to/gui#image
  65468. */
  65469. cellWidth: number;
  65470. /**
  65471. * Gets or sets the cell height to use when animation sheet is enabled
  65472. * @see http://doc.babylonjs.com/how_to/gui#image
  65473. */
  65474. cellHeight: number;
  65475. /**
  65476. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65477. * @see http://doc.babylonjs.com/how_to/gui#image
  65478. */
  65479. cellId: number;
  65480. /**
  65481. * Creates a new Image
  65482. * @param name defines the control name
  65483. * @param url defines the image url
  65484. */
  65485. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65486. /**
  65487. * Tests if a given coordinates belong to the current control
  65488. * @param x defines x coordinate to test
  65489. * @param y defines y coordinate to test
  65490. * @returns true if the coordinates are inside the control
  65491. */
  65492. contains(x: number, y: number): boolean;
  65493. protected _getTypeName(): string;
  65494. /** Force the control to synchronize with its content */
  65495. synchronizeSizeWithContent(): void;
  65496. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65497. private _prepareWorkingCanvasForOpaqueDetection;
  65498. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  65499. private _renderCornerPatch;
  65500. private _renderNinePatch;
  65501. dispose(): void;
  65502. /** STRETCH_NONE */
  65503. static readonly STRETCH_NONE: number;
  65504. /** STRETCH_FILL */
  65505. static readonly STRETCH_FILL: number;
  65506. /** STRETCH_UNIFORM */
  65507. static readonly STRETCH_UNIFORM: number;
  65508. /** STRETCH_EXTEND */
  65509. static readonly STRETCH_EXTEND: number;
  65510. /** NINE_PATCH */
  65511. static readonly STRETCH_NINE_PATCH: number;
  65512. }
  65513. }
  65514. declare module BABYLON.GUI {
  65515. /**
  65516. * Class used to create 2D buttons
  65517. */
  65518. export class Button extends Rectangle {
  65519. name?: string | undefined;
  65520. /**
  65521. * Function called to generate a pointer enter animation
  65522. */
  65523. pointerEnterAnimation: () => void;
  65524. /**
  65525. * Function called to generate a pointer out animation
  65526. */
  65527. pointerOutAnimation: () => void;
  65528. /**
  65529. * Function called to generate a pointer down animation
  65530. */
  65531. pointerDownAnimation: () => void;
  65532. /**
  65533. * Function called to generate a pointer up animation
  65534. */
  65535. pointerUpAnimation: () => void;
  65536. /**
  65537. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65538. */
  65539. delegatePickingToChildren: boolean;
  65540. private _image;
  65541. /**
  65542. * Returns the image part of the button (if any)
  65543. */
  65544. readonly image: BABYLON.Nullable<Image>;
  65545. private _textBlock;
  65546. /**
  65547. * Returns the image part of the button (if any)
  65548. */
  65549. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65550. /**
  65551. * Creates a new Button
  65552. * @param name defines the name of the button
  65553. */
  65554. constructor(name?: string | undefined);
  65555. protected _getTypeName(): string;
  65556. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65557. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  65558. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  65559. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65560. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65561. /**
  65562. * Creates a new button made with an image and a text
  65563. * @param name defines the name of the button
  65564. * @param text defines the text of the button
  65565. * @param imageUrl defines the url of the image
  65566. * @returns a new Button
  65567. */
  65568. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65569. /**
  65570. * Creates a new button made with an image
  65571. * @param name defines the name of the button
  65572. * @param imageUrl defines the url of the image
  65573. * @returns a new Button
  65574. */
  65575. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65576. /**
  65577. * Creates a new button made with a text
  65578. * @param name defines the name of the button
  65579. * @param text defines the text of the button
  65580. * @returns a new Button
  65581. */
  65582. static CreateSimpleButton(name: string, text: string): Button;
  65583. /**
  65584. * Creates a new button made with an image and a centered text
  65585. * @param name defines the name of the button
  65586. * @param text defines the text of the button
  65587. * @param imageUrl defines the url of the image
  65588. * @returns a new Button
  65589. */
  65590. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65591. }
  65592. }
  65593. declare module BABYLON.GUI {
  65594. /**
  65595. * Class used to create a 2D stack panel container
  65596. */
  65597. export class StackPanel extends Container {
  65598. name?: string | undefined;
  65599. private _isVertical;
  65600. private _manualWidth;
  65601. private _manualHeight;
  65602. private _doNotTrackManualChanges;
  65603. /**
  65604. * Gets or sets a boolean indicating that layou warnings should be ignored
  65605. */
  65606. ignoreLayoutWarnings: boolean;
  65607. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65608. isVertical: boolean;
  65609. /**
  65610. * Gets or sets panel width.
  65611. * This value should not be set when in horizontal mode as it will be computed automatically
  65612. */
  65613. width: string | number;
  65614. /**
  65615. * Gets or sets panel height.
  65616. * This value should not be set when in vertical mode as it will be computed automatically
  65617. */
  65618. height: string | number;
  65619. /**
  65620. * Creates a new StackPanel
  65621. * @param name defines control name
  65622. */
  65623. constructor(name?: string | undefined);
  65624. protected _getTypeName(): string;
  65625. /** @hidden */
  65626. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65627. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65628. protected _postMeasure(): void;
  65629. }
  65630. }
  65631. declare module BABYLON.GUI {
  65632. /**
  65633. * Class used to represent a 2D checkbox
  65634. */
  65635. export class Checkbox extends Control {
  65636. name?: string | undefined;
  65637. private _isChecked;
  65638. private _background;
  65639. private _checkSizeRatio;
  65640. private _thickness;
  65641. /** Gets or sets border thickness */
  65642. thickness: number;
  65643. /**
  65644. * BABYLON.Observable raised when isChecked property changes
  65645. */
  65646. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65647. /** Gets or sets a value indicating the ratio between overall size and check size */
  65648. checkSizeRatio: number;
  65649. /** Gets or sets background color */
  65650. background: string;
  65651. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65652. isChecked: boolean;
  65653. /**
  65654. * Creates a new CheckBox
  65655. * @param name defines the control name
  65656. */
  65657. constructor(name?: string | undefined);
  65658. protected _getTypeName(): string;
  65659. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  65660. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65661. /**
  65662. * Utility function to easily create a checkbox with a header
  65663. * @param title defines the label to use for the header
  65664. * @param onValueChanged defines the callback to call when value changes
  65665. * @returns a StackPanel containing the checkbox and a textBlock
  65666. */
  65667. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65668. }
  65669. }
  65670. declare module BABYLON.GUI {
  65671. /**
  65672. * Class used to store key control properties
  65673. */
  65674. export class KeyPropertySet {
  65675. /** Width */
  65676. width?: string;
  65677. /** Height */
  65678. height?: string;
  65679. /** Left padding */
  65680. paddingLeft?: string;
  65681. /** Right padding */
  65682. paddingRight?: string;
  65683. /** Top padding */
  65684. paddingTop?: string;
  65685. /** Bottom padding */
  65686. paddingBottom?: string;
  65687. /** Foreground color */
  65688. color?: string;
  65689. /** Background color */
  65690. background?: string;
  65691. }
  65692. /**
  65693. * Class used to create virtual keyboard
  65694. */
  65695. export class VirtualKeyboard extends StackPanel {
  65696. /** BABYLON.Observable raised when a key is pressed */
  65697. onKeyPressObservable: BABYLON.Observable<string>;
  65698. /** Gets or sets default key button width */
  65699. defaultButtonWidth: string;
  65700. /** Gets or sets default key button height */
  65701. defaultButtonHeight: string;
  65702. /** Gets or sets default key button left padding */
  65703. defaultButtonPaddingLeft: string;
  65704. /** Gets or sets default key button right padding */
  65705. defaultButtonPaddingRight: string;
  65706. /** Gets or sets default key button top padding */
  65707. defaultButtonPaddingTop: string;
  65708. /** Gets or sets default key button bottom padding */
  65709. defaultButtonPaddingBottom: string;
  65710. /** Gets or sets default key button foreground color */
  65711. defaultButtonColor: string;
  65712. /** Gets or sets default key button background color */
  65713. defaultButtonBackground: string;
  65714. /** Gets or sets shift button foreground color */
  65715. shiftButtonColor: string;
  65716. /** Gets or sets shift button thickness*/
  65717. selectedShiftThickness: number;
  65718. /** Gets shift key state */
  65719. shiftState: number;
  65720. protected _getTypeName(): string;
  65721. private _createKey;
  65722. /**
  65723. * Adds a new row of keys
  65724. * @param keys defines the list of keys to add
  65725. * @param propertySets defines the associated property sets
  65726. */
  65727. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65728. /**
  65729. * Set the shift key to a specific state
  65730. * @param shiftState defines the new shift state
  65731. */
  65732. applyShiftState(shiftState: number): void;
  65733. private _currentlyConnectedInputText;
  65734. private _connectedInputTexts;
  65735. private _onKeyPressObserver;
  65736. /** Gets the input text control currently attached to the keyboard */
  65737. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65738. /**
  65739. * Connects the keyboard with an input text control
  65740. *
  65741. * @param input defines the target control
  65742. */
  65743. connect(input: InputText): void;
  65744. /**
  65745. * Disconnects the keyboard from connected InputText controls
  65746. *
  65747. * @param input optionally defines a target control, otherwise all are disconnected
  65748. */
  65749. disconnect(input?: InputText): void;
  65750. private _removeConnectedInputObservables;
  65751. /**
  65752. * Release all resources
  65753. */
  65754. dispose(): void;
  65755. /**
  65756. * Creates a new keyboard using a default layout
  65757. *
  65758. * @param name defines control name
  65759. * @returns a new VirtualKeyboard
  65760. */
  65761. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  65762. }
  65763. }
  65764. declare module BABYLON.GUI {
  65765. /**
  65766. * Class used to create input text control
  65767. */
  65768. export class InputText extends Control implements IFocusableControl {
  65769. name?: string | undefined;
  65770. private _text;
  65771. private _placeholderText;
  65772. private _background;
  65773. private _focusedBackground;
  65774. private _focusedColor;
  65775. private _placeholderColor;
  65776. private _thickness;
  65777. private _margin;
  65778. private _autoStretchWidth;
  65779. private _maxWidth;
  65780. private _isFocused;
  65781. private _blinkTimeout;
  65782. private _blinkIsEven;
  65783. private _cursorOffset;
  65784. private _scrollLeft;
  65785. private _textWidth;
  65786. private _clickedCoordinate;
  65787. private _deadKey;
  65788. private _addKey;
  65789. private _currentKey;
  65790. private _isTextHighlightOn;
  65791. private _textHighlightColor;
  65792. private _highligherOpacity;
  65793. private _highlightedText;
  65794. private _startHighlightIndex;
  65795. private _endHighlightIndex;
  65796. private _cursorIndex;
  65797. private _onFocusSelectAll;
  65798. private _isPointerDown;
  65799. private _onClipboardObserver;
  65800. private _onPointerDblTapObserver;
  65801. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  65802. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  65803. promptMessage: string;
  65804. /** Force disable prompt on mobile device */
  65805. disableMobilePrompt: boolean;
  65806. /** BABYLON.Observable raised when the text changes */
  65807. onTextChangedObservable: BABYLON.Observable<InputText>;
  65808. /** BABYLON.Observable raised just before an entered character is to be added */
  65809. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  65810. /** BABYLON.Observable raised when the control gets the focus */
  65811. onFocusObservable: BABYLON.Observable<InputText>;
  65812. /** BABYLON.Observable raised when the control loses the focus */
  65813. onBlurObservable: BABYLON.Observable<InputText>;
  65814. /**Observable raised when the text is highlighted */
  65815. onTextHighlightObservable: BABYLON.Observable<InputText>;
  65816. /**Observable raised when copy event is triggered */
  65817. onTextCopyObservable: BABYLON.Observable<InputText>;
  65818. /** BABYLON.Observable raised when cut event is triggered */
  65819. onTextCutObservable: BABYLON.Observable<InputText>;
  65820. /** BABYLON.Observable raised when paste event is triggered */
  65821. onTextPasteObservable: BABYLON.Observable<InputText>;
  65822. /** BABYLON.Observable raised when a key event was processed */
  65823. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  65824. /** Gets or sets the maximum width allowed by the control */
  65825. maxWidth: string | number;
  65826. /** Gets the maximum width allowed by the control in pixels */
  65827. readonly maxWidthInPixels: number;
  65828. /** Gets or sets the text highlighter transparency; default: 0.4 */
  65829. highligherOpacity: number;
  65830. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  65831. onFocusSelectAll: boolean;
  65832. /** Gets or sets the text hightlight color */
  65833. textHighlightColor: string;
  65834. /** Gets or sets control margin */
  65835. margin: string;
  65836. /** Gets control margin in pixels */
  65837. readonly marginInPixels: number;
  65838. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  65839. autoStretchWidth: boolean;
  65840. /** Gets or sets border thickness */
  65841. thickness: number;
  65842. /** Gets or sets the background color when focused */
  65843. focusedBackground: string;
  65844. /** Gets or sets the background color when focused */
  65845. focusedColor: string;
  65846. /** Gets or sets the background color */
  65847. background: string;
  65848. /** Gets or sets the placeholder color */
  65849. placeholderColor: string;
  65850. /** Gets or sets the text displayed when the control is empty */
  65851. placeholderText: string;
  65852. /** Gets or sets the dead key flag */
  65853. deadKey: boolean;
  65854. /** Gets or sets the highlight text */
  65855. highlightedText: string;
  65856. /** Gets or sets if the current key should be added */
  65857. addKey: boolean;
  65858. /** Gets or sets the value of the current key being entered */
  65859. currentKey: string;
  65860. /** Gets or sets the text displayed in the control */
  65861. text: string;
  65862. /** Gets or sets control width */
  65863. width: string | number;
  65864. /**
  65865. * Creates a new InputText
  65866. * @param name defines the control name
  65867. * @param text defines the text of the control
  65868. */
  65869. constructor(name?: string | undefined, text?: string);
  65870. /** @hidden */
  65871. onBlur(): void;
  65872. /** @hidden */
  65873. onFocus(): void;
  65874. protected _getTypeName(): string;
  65875. /**
  65876. * Function called to get the list of controls that should not steal the focus from this control
  65877. * @returns an array of controls
  65878. */
  65879. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65880. /** @hidden */
  65881. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  65882. /** @hidden */
  65883. private _updateValueFromCursorIndex;
  65884. /** @hidden */
  65885. private _processDblClick;
  65886. /** @hidden */
  65887. private _selectAllText;
  65888. /**
  65889. * Handles the keyboard event
  65890. * @param evt Defines the KeyboardEvent
  65891. */
  65892. processKeyboard(evt: KeyboardEvent): void;
  65893. /** @hidden */
  65894. private _onCopyText;
  65895. /** @hidden */
  65896. private _onCutText;
  65897. /** @hidden */
  65898. 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;
  65899. protected _beforeRenderText(text: string): string;
  65900. dispose(): void;
  65901. }
  65902. }
  65903. declare module BABYLON.GUI {
  65904. /**
  65905. * Class used to create a 2D grid container
  65906. */
  65907. export class Grid extends Container {
  65908. name?: string | undefined;
  65909. private _rowDefinitions;
  65910. private _columnDefinitions;
  65911. private _cells;
  65912. private _childControls;
  65913. /**
  65914. * Gets the number of columns
  65915. */
  65916. readonly columnCount: number;
  65917. /**
  65918. * Gets the number of rows
  65919. */
  65920. readonly rowCount: number;
  65921. /** Gets the list of children */
  65922. readonly children: Control[];
  65923. /** Gets the list of cells (e.g. the containers) */
  65924. readonly cells: {
  65925. [key: string]: Container;
  65926. };
  65927. /**
  65928. * Gets the definition of a specific row
  65929. * @param index defines the index of the row
  65930. * @returns the row definition
  65931. */
  65932. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65933. /**
  65934. * Gets the definition of a specific column
  65935. * @param index defines the index of the column
  65936. * @returns the column definition
  65937. */
  65938. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65939. /**
  65940. * Adds a new row to the grid
  65941. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65942. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  65943. * @returns the current grid
  65944. */
  65945. addRowDefinition(height: number, isPixel?: boolean): Grid;
  65946. /**
  65947. * Adds a new column to the grid
  65948. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65949. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65950. * @returns the current grid
  65951. */
  65952. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  65953. /**
  65954. * Update a row definition
  65955. * @param index defines the index of the row to update
  65956. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65957. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  65958. * @returns the current grid
  65959. */
  65960. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  65961. /**
  65962. * Update a column definition
  65963. * @param index defines the index of the column to update
  65964. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65965. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65966. * @returns the current grid
  65967. */
  65968. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  65969. /**
  65970. * Gets the list of children stored in a specific cell
  65971. * @param row defines the row to check
  65972. * @param column defines the column to check
  65973. * @returns the list of controls
  65974. */
  65975. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  65976. /**
  65977. * Gets a string representing the child cell info (row x column)
  65978. * @param child defines the control to get info from
  65979. * @returns a string containing the child cell info (row x column)
  65980. */
  65981. getChildCellInfo(child: Control): string;
  65982. private _removeCell;
  65983. private _offsetCell;
  65984. /**
  65985. * Remove a column definition at specified index
  65986. * @param index defines the index of the column to remove
  65987. * @returns the current grid
  65988. */
  65989. removeColumnDefinition(index: number): Grid;
  65990. /**
  65991. * Remove a row definition at specified index
  65992. * @param index defines the index of the row to remove
  65993. * @returns the current grid
  65994. */
  65995. removeRowDefinition(index: number): Grid;
  65996. /**
  65997. * Adds a new control to the current grid
  65998. * @param control defines the control to add
  65999. * @param row defines the row where to add the control (0 by default)
  66000. * @param column defines the column where to add the control (0 by default)
  66001. * @returns the current grid
  66002. */
  66003. addControl(control: Control, row?: number, column?: number): Grid;
  66004. /**
  66005. * Removes a control from the current container
  66006. * @param control defines the control to remove
  66007. * @returns the current container
  66008. */
  66009. removeControl(control: Control): Container;
  66010. /**
  66011. * Creates a new Grid
  66012. * @param name defines control name
  66013. */
  66014. constructor(name?: string | undefined);
  66015. protected _getTypeName(): string;
  66016. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  66017. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66018. /** Releases associated resources */
  66019. dispose(): void;
  66020. }
  66021. }
  66022. declare module BABYLON.GUI {
  66023. /** Class used to create color pickers */
  66024. export class ColorPicker extends Control {
  66025. name?: string | undefined;
  66026. private static _Epsilon;
  66027. private _colorWheelCanvas;
  66028. private _value;
  66029. private _tmpColor;
  66030. private _pointerStartedOnSquare;
  66031. private _pointerStartedOnWheel;
  66032. private _squareLeft;
  66033. private _squareTop;
  66034. private _squareSize;
  66035. private _h;
  66036. private _s;
  66037. private _v;
  66038. private _lastPointerDownID;
  66039. /**
  66040. * BABYLON.Observable raised when the value changes
  66041. */
  66042. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  66043. /** Gets or sets the color of the color picker */
  66044. value: BABYLON.Color3;
  66045. /**
  66046. * Gets or sets control width
  66047. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66048. */
  66049. width: string | number;
  66050. /**
  66051. * Gets or sets control height
  66052. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66053. */
  66054. /** Gets or sets control height */
  66055. height: string | number;
  66056. /** Gets or sets control size */
  66057. size: string | number;
  66058. /**
  66059. * Creates a new ColorPicker
  66060. * @param name defines the control name
  66061. */
  66062. constructor(name?: string | undefined);
  66063. protected _getTypeName(): string;
  66064. /** @hidden */
  66065. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66066. private _updateSquareProps;
  66067. private _drawGradientSquare;
  66068. private _drawCircle;
  66069. private _createColorWheelCanvas;
  66070. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  66071. private _pointerIsDown;
  66072. private _updateValueFromPointer;
  66073. private _isPointOnSquare;
  66074. 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;
  66075. /**
  66076. * This function expands the color picker by creating a color picker dialog with manual
  66077. * color value input and the ability to save colors into an array to be used later in
  66078. * subsequent launches of the dialogue.
  66079. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  66080. * @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.
  66081. * @returns picked color as a hex string and the saved colors array as hex strings.
  66082. */
  66083. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  66084. pickerWidth?: string;
  66085. pickerHeight?: string;
  66086. headerHeight?: string;
  66087. lastColor?: string;
  66088. swatchLimit?: number;
  66089. numSwatchesPerLine?: number;
  66090. savedColors?: Array<string>;
  66091. }): Promise<{
  66092. savedColors?: string[];
  66093. pickedColor: string;
  66094. }>;
  66095. }
  66096. }
  66097. declare module BABYLON.GUI {
  66098. /** Class used to create 2D ellipse containers */
  66099. export class Ellipse extends Container {
  66100. name?: string | undefined;
  66101. private _thickness;
  66102. /** Gets or sets border thickness */
  66103. thickness: number;
  66104. /**
  66105. * Creates a new Ellipse
  66106. * @param name defines the control name
  66107. */
  66108. constructor(name?: string | undefined);
  66109. protected _getTypeName(): string;
  66110. protected _localDraw(context: CanvasRenderingContext2D): void;
  66111. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66112. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66113. }
  66114. }
  66115. declare module BABYLON.GUI {
  66116. /**
  66117. * Class used to create a password control
  66118. */
  66119. export class InputPassword extends InputText {
  66120. protected _beforeRenderText(text: string): string;
  66121. }
  66122. }
  66123. declare module BABYLON.GUI {
  66124. /** Class used to render 2D lines */
  66125. export class Line extends Control {
  66126. name?: string | undefined;
  66127. private _lineWidth;
  66128. private _x1;
  66129. private _y1;
  66130. private _x2;
  66131. private _y2;
  66132. private _dash;
  66133. private _connectedControl;
  66134. private _connectedControlDirtyObserver;
  66135. /** Gets or sets the dash pattern */
  66136. dash: Array<number>;
  66137. /** Gets or sets the control connected with the line end */
  66138. connectedControl: Control;
  66139. /** Gets or sets start coordinates on X axis */
  66140. x1: string | number;
  66141. /** Gets or sets start coordinates on Y axis */
  66142. y1: string | number;
  66143. /** Gets or sets end coordinates on X axis */
  66144. x2: string | number;
  66145. /** Gets or sets end coordinates on Y axis */
  66146. y2: string | number;
  66147. /** Gets or sets line width */
  66148. lineWidth: number;
  66149. /** Gets or sets horizontal alignment */
  66150. horizontalAlignment: number;
  66151. /** Gets or sets vertical alignment */
  66152. verticalAlignment: number;
  66153. private readonly _effectiveX2;
  66154. private readonly _effectiveY2;
  66155. /**
  66156. * Creates a new Line
  66157. * @param name defines the control name
  66158. */
  66159. constructor(name?: string | undefined);
  66160. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  66161. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66162. /**
  66163. * Move one end of the line given 3D cartesian coordinates.
  66164. * @param position Targeted world position
  66165. * @param scene BABYLON.Scene
  66166. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66167. */
  66168. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  66169. /**
  66170. * Move one end of the line to a position in screen absolute space.
  66171. * @param projectedPosition Position in screen absolute space (X, Y)
  66172. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66173. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  66174. }
  66175. }
  66176. declare module BABYLON.GUI {
  66177. /**
  66178. * Class used to store a point for a MultiLine object.
  66179. * The point can be pure 2D coordinates, a mesh or a control
  66180. */
  66181. export class MultiLinePoint {
  66182. private _multiLine;
  66183. private _x;
  66184. private _y;
  66185. private _control;
  66186. private _mesh;
  66187. private _controlObserver;
  66188. private _meshObserver;
  66189. /** @hidden */ private _point: BABYLON.Vector2;
  66190. /**
  66191. * Creates a new MultiLinePoint
  66192. * @param multiLine defines the source MultiLine object
  66193. */
  66194. constructor(multiLine: MultiLine);
  66195. /** Gets or sets x coordinate */
  66196. x: string | number;
  66197. /** Gets or sets y coordinate */
  66198. y: string | number;
  66199. /** Gets or sets the control associated with this point */
  66200. control: BABYLON.Nullable<Control>;
  66201. /** Gets or sets the mesh associated with this point */
  66202. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66203. /** Resets links */
  66204. resetLinks(): void;
  66205. /**
  66206. * Gets a translation vector
  66207. * @returns the translation vector
  66208. */
  66209. translate(): BABYLON.Vector2;
  66210. private _translatePoint;
  66211. /** Release associated resources */
  66212. dispose(): void;
  66213. }
  66214. }
  66215. declare module BABYLON.GUI {
  66216. /**
  66217. * Class used to create multi line control
  66218. */
  66219. export class MultiLine extends Control {
  66220. name?: string | undefined;
  66221. private _lineWidth;
  66222. private _dash;
  66223. private _points;
  66224. private _minX;
  66225. private _minY;
  66226. private _maxX;
  66227. private _maxY;
  66228. /**
  66229. * Creates a new MultiLine
  66230. * @param name defines the control name
  66231. */
  66232. constructor(name?: string | undefined);
  66233. /** Gets or sets dash pattern */
  66234. dash: Array<number>;
  66235. /**
  66236. * Gets point stored at specified index
  66237. * @param index defines the index to look for
  66238. * @returns the requested point if found
  66239. */
  66240. getAt(index: number): MultiLinePoint;
  66241. /** Function called when a point is updated */
  66242. onPointUpdate: () => void;
  66243. /**
  66244. * Adds new points to the point collection
  66245. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  66246. * @returns the list of created MultiLinePoint
  66247. */
  66248. add(...items: (AbstractMesh | Control | {
  66249. x: string | number;
  66250. y: string | number;
  66251. })[]): MultiLinePoint[];
  66252. /**
  66253. * Adds a new point to the point collection
  66254. * @param item defines the item (mesh, control or 2d coordiantes) to add
  66255. * @returns the created MultiLinePoint
  66256. */
  66257. push(item?: (AbstractMesh | Control | {
  66258. x: string | number;
  66259. y: string | number;
  66260. })): MultiLinePoint;
  66261. /**
  66262. * Remove a specific value or point from the active point collection
  66263. * @param value defines the value or point to remove
  66264. */
  66265. remove(value: number | MultiLinePoint): void;
  66266. /**
  66267. * Resets this object to initial state (no point)
  66268. */
  66269. reset(): void;
  66270. /**
  66271. * Resets all links
  66272. */
  66273. resetLinks(): void;
  66274. /** Gets or sets line width */
  66275. lineWidth: number;
  66276. horizontalAlignment: number;
  66277. verticalAlignment: number;
  66278. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  66279. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  66280. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66281. dispose(): void;
  66282. }
  66283. }
  66284. declare module BABYLON.GUI {
  66285. /**
  66286. * Class used to create radio button controls
  66287. */
  66288. export class RadioButton extends Control {
  66289. name?: string | undefined;
  66290. private _isChecked;
  66291. private _background;
  66292. private _checkSizeRatio;
  66293. private _thickness;
  66294. /** Gets or sets border thickness */
  66295. thickness: number;
  66296. /** Gets or sets group name */
  66297. group: string;
  66298. /** BABYLON.Observable raised when isChecked is changed */
  66299. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66300. /** Gets or sets a value indicating the ratio between overall size and check size */
  66301. checkSizeRatio: number;
  66302. /** Gets or sets background color */
  66303. background: string;
  66304. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66305. isChecked: boolean;
  66306. /**
  66307. * Creates a new RadioButton
  66308. * @param name defines the control name
  66309. */
  66310. constructor(name?: string | undefined);
  66311. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66312. /**
  66313. * Utility function to easily create a radio button with a header
  66314. * @param title defines the label to use for the header
  66315. * @param group defines the group to use for the radio button
  66316. * @param isChecked defines the initial state of the radio button
  66317. * @param onValueChanged defines the callback to call when value changes
  66318. * @returns a StackPanel containing the radio button and a textBlock
  66319. */
  66320. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  66321. }
  66322. }
  66323. declare module BABYLON.GUI {
  66324. /**
  66325. * Class used to create slider controls
  66326. */
  66327. export class BaseSlider extends Control {
  66328. name?: string | undefined;
  66329. protected _thumbWidth: ValueAndUnit;
  66330. private _minimum;
  66331. private _maximum;
  66332. private _value;
  66333. private _isVertical;
  66334. protected _barOffset: ValueAndUnit;
  66335. private _isThumbClamped;
  66336. protected _displayThumb: boolean;
  66337. private _step;
  66338. private _lastPointerDownID;
  66339. protected _effectiveBarOffset: number;
  66340. protected _renderLeft: number;
  66341. protected _renderTop: number;
  66342. protected _renderWidth: number;
  66343. protected _renderHeight: number;
  66344. protected _backgroundBoxLength: number;
  66345. protected _backgroundBoxThickness: number;
  66346. protected _effectiveThumbThickness: number;
  66347. /** BABYLON.Observable raised when the sldier value changes */
  66348. onValueChangedObservable: BABYLON.Observable<number>;
  66349. /** Gets or sets a boolean indicating if the thumb must be rendered */
  66350. displayThumb: boolean;
  66351. /** Gets or sets a step to apply to values (0 by default) */
  66352. step: number;
  66353. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  66354. barOffset: string | number;
  66355. /** Gets main bar offset in pixels*/
  66356. readonly barOffsetInPixels: number;
  66357. /** Gets or sets thumb width */
  66358. thumbWidth: string | number;
  66359. /** Gets thumb width in pixels */
  66360. readonly thumbWidthInPixels: number;
  66361. /** Gets or sets minimum value */
  66362. minimum: number;
  66363. /** Gets or sets maximum value */
  66364. maximum: number;
  66365. /** Gets or sets current value */
  66366. value: number;
  66367. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66368. isVertical: boolean;
  66369. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66370. isThumbClamped: boolean;
  66371. /**
  66372. * Creates a new BaseSlider
  66373. * @param name defines the control name
  66374. */
  66375. constructor(name?: string | undefined);
  66376. protected _getTypeName(): string;
  66377. protected _getThumbPosition(): number;
  66378. protected _getThumbThickness(type: string): number;
  66379. protected _prepareRenderingData(type: string): void;
  66380. private _pointerIsDown;
  66381. /** @hidden */
  66382. 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;
  66383. }
  66384. }
  66385. declare module BABYLON.GUI {
  66386. /**
  66387. * Class used to create slider controls
  66388. */
  66389. export class Slider extends BaseSlider {
  66390. name?: string | undefined;
  66391. private _background;
  66392. private _borderColor;
  66393. private _isThumbCircle;
  66394. protected _displayValueBar: boolean;
  66395. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66396. displayValueBar: boolean;
  66397. /** Gets or sets border color */
  66398. borderColor: string;
  66399. /** Gets or sets background color */
  66400. background: string;
  66401. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66402. isThumbCircle: boolean;
  66403. /**
  66404. * Creates a new Slider
  66405. * @param name defines the control name
  66406. */
  66407. constructor(name?: string | undefined);
  66408. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  66409. }
  66410. }
  66411. declare module BABYLON.GUI {
  66412. /** Class used to create a RadioGroup
  66413. * which contains groups of radio buttons
  66414. */
  66415. export class SelectorGroup {
  66416. /** name of SelectorGroup */
  66417. name: string;
  66418. private _groupPanel;
  66419. private _selectors;
  66420. private _groupHeader;
  66421. /**
  66422. * Creates a new SelectorGroup
  66423. * @param name of group, used as a group heading
  66424. */
  66425. constructor(
  66426. /** name of SelectorGroup */
  66427. name: string);
  66428. /** Gets the groupPanel of the SelectorGroup */
  66429. readonly groupPanel: StackPanel;
  66430. /** Gets the selectors array */
  66431. readonly selectors: StackPanel[];
  66432. /** Gets and sets the group header */
  66433. header: string;
  66434. /** @hidden */
  66435. private _addGroupHeader;
  66436. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  66437. /** Removes the selector at the given position
  66438. * @param selectorNb the position of the selector within the group
  66439. */
  66440. removeSelector(selectorNb: number): void;
  66441. }
  66442. /** Class used to create a CheckboxGroup
  66443. * which contains groups of checkbox buttons
  66444. */
  66445. export class CheckboxGroup extends SelectorGroup {
  66446. /** Adds a checkbox as a control
  66447. * @param text is the label for the selector
  66448. * @param func is the function called when the Selector is checked
  66449. * @param checked is true when Selector is checked
  66450. */
  66451. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66452. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  66453. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  66454. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  66455. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66456. }
  66457. /** Class used to create a RadioGroup
  66458. * which contains groups of radio buttons
  66459. */
  66460. export class RadioGroup extends SelectorGroup {
  66461. private _selectNb;
  66462. /** Adds a radio button as a control
  66463. * @param label is the label for the selector
  66464. * @param func is the function called when the Selector is checked
  66465. * @param checked is true when Selector is checked
  66466. */
  66467. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66468. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  66469. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  66470. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  66471. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66472. }
  66473. /** Class used to create a SliderGroup
  66474. * which contains groups of slider buttons
  66475. */
  66476. export class SliderGroup extends SelectorGroup {
  66477. /**
  66478. * Adds a slider to the SelectorGroup
  66479. * @param label is the label for the SliderBar
  66480. * @param func is the function called when the Slider moves
  66481. * @param unit is a string describing the units used, eg degrees or metres
  66482. * @param min is the minimum value for the Slider
  66483. * @param max is the maximum value for the Slider
  66484. * @param value is the start value for the Slider between min and max
  66485. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66486. */
  66487. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66488. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  66489. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  66490. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  66491. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66492. }
  66493. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66494. * @see http://doc.babylonjs.com/how_to/selector
  66495. */
  66496. export class SelectionPanel extends Rectangle {
  66497. /** name of SelectionPanel */
  66498. name: string;
  66499. /** an array of SelectionGroups */
  66500. groups: SelectorGroup[];
  66501. private _panel;
  66502. private _buttonColor;
  66503. private _buttonBackground;
  66504. private _headerColor;
  66505. private _barColor;
  66506. private _barHeight;
  66507. private _spacerHeight;
  66508. private _labelColor;
  66509. private _groups;
  66510. private _bars;
  66511. /**
  66512. * Creates a new SelectionPanel
  66513. * @param name of SelectionPanel
  66514. * @param groups is an array of SelectionGroups
  66515. */
  66516. constructor(
  66517. /** name of SelectionPanel */
  66518. name: string,
  66519. /** an array of SelectionGroups */
  66520. groups?: SelectorGroup[]);
  66521. protected _getTypeName(): string;
  66522. /** Gets or sets the headerColor */
  66523. headerColor: string;
  66524. private _setHeaderColor;
  66525. /** Gets or sets the button color */
  66526. buttonColor: string;
  66527. private _setbuttonColor;
  66528. /** Gets or sets the label color */
  66529. labelColor: string;
  66530. private _setLabelColor;
  66531. /** Gets or sets the button background */
  66532. buttonBackground: string;
  66533. private _setButtonBackground;
  66534. /** Gets or sets the color of separator bar */
  66535. barColor: string;
  66536. private _setBarColor;
  66537. /** Gets or sets the height of separator bar */
  66538. barHeight: string;
  66539. private _setBarHeight;
  66540. /** Gets or sets the height of spacers*/
  66541. spacerHeight: string;
  66542. private _setSpacerHeight;
  66543. /** Adds a bar between groups */
  66544. private _addSpacer;
  66545. /** Add a group to the selection panel
  66546. * @param group is the selector group to add
  66547. */
  66548. addGroup(group: SelectorGroup): void;
  66549. /** Remove the group from the given position
  66550. * @param groupNb is the position of the group in the list
  66551. */
  66552. removeGroup(groupNb: number): void;
  66553. /** Change a group header label
  66554. * @param label is the new group header label
  66555. * @param groupNb is the number of the group to relabel
  66556. * */
  66557. setHeaderName(label: string, groupNb: number): void;
  66558. /** Change selector label to the one given
  66559. * @param label is the new selector label
  66560. * @param groupNb is the number of the groupcontaining the selector
  66561. * @param selectorNb is the number of the selector within a group to relabel
  66562. * */
  66563. relabel(label: string, groupNb: number, selectorNb: number): void;
  66564. /** For a given group position remove the selector at the given position
  66565. * @param groupNb is the number of the group to remove the selector from
  66566. * @param selectorNb is the number of the selector within the group
  66567. */
  66568. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66569. /** For a given group position of correct type add a checkbox button
  66570. * @param groupNb is the number of the group to remove the selector from
  66571. * @param label is the label for the selector
  66572. * @param func is the function called when the Selector is checked
  66573. * @param checked is true when Selector is checked
  66574. */
  66575. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66576. /** For a given group position of correct type add a radio button
  66577. * @param groupNb is the number of the group to remove the selector from
  66578. * @param label is the label for the selector
  66579. * @param func is the function called when the Selector is checked
  66580. * @param checked is true when Selector is checked
  66581. */
  66582. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66583. /**
  66584. * For a given slider group add a slider
  66585. * @param groupNb is the number of the group to add the slider to
  66586. * @param label is the label for the Slider
  66587. * @param func is the function called when the Slider moves
  66588. * @param unit is a string describing the units used, eg degrees or metres
  66589. * @param min is the minimum value for the Slider
  66590. * @param max is the maximum value for the Slider
  66591. * @param value is the start value for the Slider between min and max
  66592. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66593. */
  66594. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66595. }
  66596. }
  66597. declare module BABYLON.GUI {
  66598. /**
  66599. * Class used to hold a the container for ScrollViewer
  66600. * @hidden
  66601. */
  66602. export class _ScrollViewerWindow extends Container {
  66603. parentClientWidth: number;
  66604. parentClientHeight: number;
  66605. /**
  66606. * Creates a new ScrollViewerWindow
  66607. * @param name of ScrollViewerWindow
  66608. */
  66609. constructor(name?: string);
  66610. protected _getTypeName(): string;
  66611. /** @hidden */
  66612. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66613. protected _postMeasure(): void;
  66614. }
  66615. }
  66616. declare module BABYLON.GUI {
  66617. /**
  66618. * Class used to create slider controls
  66619. */
  66620. export class ScrollBar extends BaseSlider {
  66621. name?: string | undefined;
  66622. private _background;
  66623. private _borderColor;
  66624. private _thumbMeasure;
  66625. /** Gets or sets border color */
  66626. borderColor: string;
  66627. /** Gets or sets background color */
  66628. background: string;
  66629. /**
  66630. * Creates a new Slider
  66631. * @param name defines the control name
  66632. */
  66633. constructor(name?: string | undefined);
  66634. protected _getTypeName(): string;
  66635. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  66636. private _first;
  66637. private _originX;
  66638. private _originY;
  66639. /** @hidden */
  66640. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66641. }
  66642. }
  66643. declare module BABYLON.GUI {
  66644. /**
  66645. * Class used to hold a viewer window and sliders in a grid
  66646. */
  66647. export class ScrollViewer extends Rectangle {
  66648. private _grid;
  66649. private _horizontalBarSpace;
  66650. private _verticalBarSpace;
  66651. private _dragSpace;
  66652. private _horizontalBar;
  66653. private _verticalBar;
  66654. private _barColor;
  66655. private _barBackground;
  66656. private _barSize;
  66657. private _endLeft;
  66658. private _endTop;
  66659. private _window;
  66660. private _pointerIsOver;
  66661. private _wheelPrecision;
  66662. private _onPointerObserver;
  66663. private _clientWidth;
  66664. private _clientHeight;
  66665. /**
  66666. * Gets the horizontal scrollbar
  66667. */
  66668. readonly horizontalBar: ScrollBar;
  66669. /**
  66670. * Gets the vertical scrollbar
  66671. */
  66672. readonly verticalBar: ScrollBar;
  66673. /**
  66674. * Adds a new control to the current container
  66675. * @param control defines the control to add
  66676. * @returns the current container
  66677. */
  66678. addControl(control: BABYLON.Nullable<Control>): Container;
  66679. /**
  66680. * Removes a control from the current container
  66681. * @param control defines the control to remove
  66682. * @returns the current container
  66683. */
  66684. removeControl(control: Control): Container;
  66685. /** Gets the list of children */
  66686. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  66687. /**
  66688. * Creates a new ScrollViewer
  66689. * @param name of ScrollViewer
  66690. */
  66691. constructor(name?: string);
  66692. /** Reset the scroll viewer window to initial size */
  66693. resetWindow(): void;
  66694. protected _getTypeName(): string;
  66695. private _buildClientSizes;
  66696. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66697. protected _postMeasure(): void;
  66698. /**
  66699. * Gets or sets the mouse wheel precision
  66700. * from 0 to 1 with a default value of 0.05
  66701. * */
  66702. wheelPrecision: number;
  66703. /** Gets or sets the bar color */
  66704. barColor: string;
  66705. /** Gets or sets the size of the bar */
  66706. barSize: number;
  66707. /** Gets or sets the bar background */
  66708. barBackground: string;
  66709. /** @hidden */
  66710. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  66711. /** @hidden */
  66712. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66713. /** Releases associated resources */
  66714. dispose(): void;
  66715. }
  66716. }
  66717. declare module BABYLON.GUI {
  66718. /** Class used to render a grid */
  66719. export class DisplayGrid extends Control {
  66720. name?: string | undefined;
  66721. private _cellWidth;
  66722. private _cellHeight;
  66723. private _minorLineTickness;
  66724. private _minorLineColor;
  66725. private _majorLineTickness;
  66726. private _majorLineColor;
  66727. private _majorLineFrequency;
  66728. private _background;
  66729. private _displayMajorLines;
  66730. private _displayMinorLines;
  66731. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  66732. displayMinorLines: boolean;
  66733. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  66734. displayMajorLines: boolean;
  66735. /** Gets or sets background color (Black by default) */
  66736. background: string;
  66737. /** Gets or sets the width of each cell (20 by default) */
  66738. cellWidth: number;
  66739. /** Gets or sets the height of each cell (20 by default) */
  66740. cellHeight: number;
  66741. /** Gets or sets the tickness of minor lines (1 by default) */
  66742. minorLineTickness: number;
  66743. /** Gets or sets the color of minor lines (DarkGray by default) */
  66744. minorLineColor: string;
  66745. /** Gets or sets the tickness of major lines (2 by default) */
  66746. majorLineTickness: number;
  66747. /** Gets or sets the color of major lines (White by default) */
  66748. majorLineColor: string;
  66749. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  66750. majorLineFrequency: number;
  66751. /**
  66752. * Creates a new GridDisplayRectangle
  66753. * @param name defines the control name
  66754. */
  66755. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  66756. protected _getTypeName(): string;
  66757. }
  66758. }
  66759. declare module BABYLON.GUI {
  66760. /**
  66761. * Class used to create slider controls based on images
  66762. */
  66763. export class ImageBasedSlider extends BaseSlider {
  66764. name?: string | undefined;
  66765. private _backgroundImage;
  66766. private _thumbImage;
  66767. private _valueBarImage;
  66768. private _tempMeasure;
  66769. displayThumb: boolean;
  66770. /**
  66771. * Gets or sets the image used to render the background
  66772. */
  66773. backgroundImage: Image;
  66774. /**
  66775. * Gets or sets the image used to render the value bar
  66776. */
  66777. valueBarImage: Image;
  66778. /**
  66779. * Gets or sets the image used to render the thumb
  66780. */
  66781. thumbImage: Image;
  66782. /**
  66783. * Creates a new ImageBasedSlider
  66784. * @param name defines the control name
  66785. */
  66786. constructor(name?: string | undefined);
  66787. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  66788. }
  66789. }
  66790. declare module BABYLON.GUI {
  66791. /**
  66792. * Forcing an export so that this code will execute
  66793. * @hidden
  66794. */
  66795. const name = "Statics";
  66796. }
  66797. declare module BABYLON.GUI {
  66798. /**
  66799. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  66800. */
  66801. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  66802. /**
  66803. * Define the instrumented AdvancedDynamicTexture.
  66804. */
  66805. texture: AdvancedDynamicTexture;
  66806. private _captureRenderTime;
  66807. private _renderTime;
  66808. private _captureLayoutTime;
  66809. private _layoutTime;
  66810. private _onBeginRenderObserver;
  66811. private _onEndRenderObserver;
  66812. private _onBeginLayoutObserver;
  66813. private _onEndLayoutObserver;
  66814. /**
  66815. * Gets the perf counter used to capture render time
  66816. */
  66817. readonly renderTimeCounter: BABYLON.PerfCounter;
  66818. /**
  66819. * Gets the perf counter used to capture layout time
  66820. */
  66821. readonly layoutTimeCounter: BABYLON.PerfCounter;
  66822. /**
  66823. * Enable or disable the render time capture
  66824. */
  66825. captureRenderTime: boolean;
  66826. /**
  66827. * Enable or disable the layout time capture
  66828. */
  66829. captureLayoutTime: boolean;
  66830. /**
  66831. * Instantiates a new advanced dynamic texture instrumentation.
  66832. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  66833. * @param texture Defines the AdvancedDynamicTexture to instrument
  66834. */
  66835. constructor(
  66836. /**
  66837. * Define the instrumented AdvancedDynamicTexture.
  66838. */
  66839. texture: AdvancedDynamicTexture);
  66840. /**
  66841. * Dispose and release associated resources.
  66842. */
  66843. dispose(): void;
  66844. }
  66845. }
  66846. declare module BABYLON.GUI {
  66847. /**
  66848. * Class used to load GUI via XML.
  66849. */
  66850. export class XmlLoader {
  66851. private _nodes;
  66852. private _nodeTypes;
  66853. private _isLoaded;
  66854. private _objectAttributes;
  66855. private _parentClass;
  66856. /**
  66857. * Create a new xml loader
  66858. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  66859. */
  66860. constructor(parentClass?: null);
  66861. private _getChainElement;
  66862. private _getClassAttribute;
  66863. private _createGuiElement;
  66864. private _parseGrid;
  66865. private _parseElement;
  66866. private _prepareSourceElement;
  66867. private _parseElementsFromSource;
  66868. private _parseXml;
  66869. /**
  66870. * Gets if the loading has finished.
  66871. * @returns whether the loading has finished or not
  66872. */
  66873. isLoaded(): boolean;
  66874. /**
  66875. * Gets a loaded node / control by id.
  66876. * @param id the Controls id set in the xml
  66877. * @returns element of type Control
  66878. */
  66879. getNodeById(id: string): any;
  66880. /**
  66881. * Gets all loaded nodes / controls
  66882. * @returns Array of controls
  66883. */
  66884. getNodes(): any;
  66885. /**
  66886. * Initiates the xml layout loading
  66887. * @param xmlFile defines the xml layout to load
  66888. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  66889. * @param callback defines the callback called on layout load.
  66890. */
  66891. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  66892. }
  66893. }
  66894. declare module BABYLON.GUI {
  66895. /**
  66896. * Class used to create containers for controls
  66897. */
  66898. export class Container3D extends Control3D {
  66899. private _blockLayout;
  66900. /**
  66901. * Gets the list of child controls
  66902. */
  66903. protected _children: Control3D[];
  66904. /**
  66905. * Gets the list of child controls
  66906. */
  66907. readonly children: Array<Control3D>;
  66908. /**
  66909. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  66910. * This is helpful to optimize layout operation when adding multiple children in a row
  66911. */
  66912. blockLayout: boolean;
  66913. /**
  66914. * Creates a new container
  66915. * @param name defines the container name
  66916. */
  66917. constructor(name?: string);
  66918. /**
  66919. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  66920. * @returns the current container
  66921. */
  66922. updateLayout(): Container3D;
  66923. /**
  66924. * Gets a boolean indicating if the given control is in the children of this control
  66925. * @param control defines the control to check
  66926. * @returns true if the control is in the child list
  66927. */
  66928. containsControl(control: Control3D): boolean;
  66929. /**
  66930. * Adds a control to the children of this control
  66931. * @param control defines the control to add
  66932. * @returns the current container
  66933. */
  66934. addControl(control: Control3D): Container3D;
  66935. /**
  66936. * This function will be called everytime a new control is added
  66937. */
  66938. protected _arrangeChildren(): void;
  66939. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66940. /**
  66941. * Removes a control from the children of this control
  66942. * @param control defines the control to remove
  66943. * @returns the current container
  66944. */
  66945. removeControl(control: Control3D): Container3D;
  66946. protected _getTypeName(): string;
  66947. /**
  66948. * Releases all associated resources
  66949. */
  66950. dispose(): void;
  66951. /** Control rotation will remain unchanged */
  66952. static readonly UNSET_ORIENTATION: number;
  66953. /** Control will rotate to make it look at sphere central axis */
  66954. static readonly FACEORIGIN_ORIENTATION: number;
  66955. /** Control will rotate to make it look back at sphere central axis */
  66956. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  66957. /** Control will rotate to look at z axis (0, 0, 1) */
  66958. static readonly FACEFORWARD_ORIENTATION: number;
  66959. /** Control will rotate to look at negative z axis (0, 0, -1) */
  66960. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  66961. }
  66962. }
  66963. declare module BABYLON.GUI {
  66964. /**
  66965. * Class used to manage 3D user interface
  66966. * @see http://doc.babylonjs.com/how_to/gui3d
  66967. */
  66968. export class GUI3DManager implements BABYLON.IDisposable {
  66969. private _scene;
  66970. private _sceneDisposeObserver;
  66971. private _utilityLayer;
  66972. private _rootContainer;
  66973. private _pointerObserver;
  66974. private _pointerOutObserver;
  66975. /** @hidden */ private _lastPickedControl: Control3D;
  66976. /** @hidden */ private _lastControlOver: {
  66977. [pointerId: number]: Control3D;
  66978. };
  66979. /** @hidden */ private _lastControlDown: {
  66980. [pointerId: number]: Control3D;
  66981. };
  66982. /**
  66983. * BABYLON.Observable raised when the point picked by the pointer events changed
  66984. */
  66985. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66986. /** @hidden */ private _sharedMaterials: {
  66987. [key: string]: BABYLON.Material;
  66988. };
  66989. /** Gets the hosting scene */
  66990. readonly scene: BABYLON.Scene;
  66991. /** Gets associated utility layer */
  66992. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66993. /**
  66994. * Creates a new GUI3DManager
  66995. * @param scene
  66996. */
  66997. constructor(scene?: BABYLON.Scene);
  66998. private _handlePointerOut;
  66999. private _doPicking;
  67000. /**
  67001. * Gets the root container
  67002. */
  67003. readonly rootContainer: Container3D;
  67004. /**
  67005. * Gets a boolean indicating if the given control is in the root child list
  67006. * @param control defines the control to check
  67007. * @returns true if the control is in the root child list
  67008. */
  67009. containsControl(control: Control3D): boolean;
  67010. /**
  67011. * Adds a control to the root child list
  67012. * @param control defines the control to add
  67013. * @returns the current manager
  67014. */
  67015. addControl(control: Control3D): GUI3DManager;
  67016. /**
  67017. * Removes a control from the root child list
  67018. * @param control defines the control to remove
  67019. * @returns the current container
  67020. */
  67021. removeControl(control: Control3D): GUI3DManager;
  67022. /**
  67023. * Releases all associated resources
  67024. */
  67025. dispose(): void;
  67026. }
  67027. }
  67028. declare module BABYLON.GUI {
  67029. /**
  67030. * Class used to transport BABYLON.Vector3 information for pointer events
  67031. */
  67032. export class Vector3WithInfo extends BABYLON.Vector3 {
  67033. /** defines the current mouse button index */
  67034. buttonIndex: number;
  67035. /**
  67036. * Creates a new Vector3WithInfo
  67037. * @param source defines the vector3 data to transport
  67038. * @param buttonIndex defines the current mouse button index
  67039. */
  67040. constructor(source: BABYLON.Vector3,
  67041. /** defines the current mouse button index */
  67042. buttonIndex?: number);
  67043. }
  67044. }
  67045. declare module BABYLON.GUI {
  67046. /**
  67047. * Class used as base class for controls
  67048. */
  67049. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  67050. /** Defines the control name */
  67051. name?: string | undefined;
  67052. /** @hidden */ private _host: GUI3DManager;
  67053. private _node;
  67054. private _downCount;
  67055. private _enterCount;
  67056. private _downPointerIds;
  67057. private _isVisible;
  67058. /** Gets or sets the control position in world space */
  67059. position: BABYLON.Vector3;
  67060. /** Gets or sets the control scaling in world space */
  67061. scaling: BABYLON.Vector3;
  67062. /** Callback used to start pointer enter animation */
  67063. pointerEnterAnimation: () => void;
  67064. /** Callback used to start pointer out animation */
  67065. pointerOutAnimation: () => void;
  67066. /** Callback used to start pointer down animation */
  67067. pointerDownAnimation: () => void;
  67068. /** Callback used to start pointer up animation */
  67069. pointerUpAnimation: () => void;
  67070. /**
  67071. * An event triggered when the pointer move over the control
  67072. */
  67073. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  67074. /**
  67075. * An event triggered when the pointer move out of the control
  67076. */
  67077. onPointerOutObservable: BABYLON.Observable<Control3D>;
  67078. /**
  67079. * An event triggered when the pointer taps the control
  67080. */
  67081. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  67082. /**
  67083. * An event triggered when pointer is up
  67084. */
  67085. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  67086. /**
  67087. * An event triggered when a control is clicked on (with a mouse)
  67088. */
  67089. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  67090. /**
  67091. * An event triggered when pointer enters the control
  67092. */
  67093. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  67094. /**
  67095. * Gets or sets the parent container
  67096. */
  67097. parent: BABYLON.Nullable<Container3D>;
  67098. private _behaviors;
  67099. /**
  67100. * Gets the list of attached behaviors
  67101. * @see http://doc.babylonjs.com/features/behaviour
  67102. */
  67103. readonly behaviors: BABYLON.Behavior<Control3D>[];
  67104. /**
  67105. * Attach a behavior to the control
  67106. * @see http://doc.babylonjs.com/features/behaviour
  67107. * @param behavior defines the behavior to attach
  67108. * @returns the current control
  67109. */
  67110. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67111. /**
  67112. * Remove an attached behavior
  67113. * @see http://doc.babylonjs.com/features/behaviour
  67114. * @param behavior defines the behavior to attach
  67115. * @returns the current control
  67116. */
  67117. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67118. /**
  67119. * Gets an attached behavior by name
  67120. * @param name defines the name of the behavior to look for
  67121. * @see http://doc.babylonjs.com/features/behaviour
  67122. * @returns null if behavior was not found else the requested behavior
  67123. */
  67124. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  67125. /** Gets or sets a boolean indicating if the control is visible */
  67126. isVisible: boolean;
  67127. /**
  67128. * Creates a new control
  67129. * @param name defines the control name
  67130. */
  67131. constructor(
  67132. /** Defines the control name */
  67133. name?: string | undefined);
  67134. /**
  67135. * Gets a string representing the class name
  67136. */
  67137. readonly typeName: string;
  67138. /**
  67139. * Get the current class name of the control.
  67140. * @returns current class name
  67141. */
  67142. getClassName(): string;
  67143. protected _getTypeName(): string;
  67144. /**
  67145. * Gets the transform node used by this control
  67146. */
  67147. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  67148. /**
  67149. * Gets the mesh used to render this control
  67150. */
  67151. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67152. /**
  67153. * Link the control as child of the given node
  67154. * @param node defines the node to link to. Use null to unlink the control
  67155. * @returns the current control
  67156. */
  67157. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  67158. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  67159. /**
  67160. * Node creation.
  67161. * Can be overriden by children
  67162. * @param scene defines the scene where the node must be attached
  67163. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  67164. */
  67165. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67166. /**
  67167. * Affect a material to the given mesh
  67168. * @param mesh defines the mesh which will represent the control
  67169. */
  67170. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67171. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  67172. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  67173. /** @hidden */ private _onPointerOut(target: Control3D): void;
  67174. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67175. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67176. /** @hidden */
  67177. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67178. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67179. /** @hidden */ private _disposeNode(): void;
  67180. /**
  67181. * Releases all associated resources
  67182. */
  67183. dispose(): void;
  67184. }
  67185. }
  67186. declare module BABYLON.GUI {
  67187. /**
  67188. * Class used as a root to all buttons
  67189. */
  67190. export class AbstractButton3D extends Control3D {
  67191. /**
  67192. * Creates a new button
  67193. * @param name defines the control name
  67194. */
  67195. constructor(name?: string);
  67196. protected _getTypeName(): string;
  67197. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67198. }
  67199. }
  67200. declare module BABYLON.GUI {
  67201. /**
  67202. * Class used to create a button in 3D
  67203. */
  67204. export class Button3D extends AbstractButton3D {
  67205. /** @hidden */
  67206. protected _currentMaterial: BABYLON.Material;
  67207. private _facadeTexture;
  67208. private _content;
  67209. private _contentResolution;
  67210. private _contentScaleRatio;
  67211. /**
  67212. * Gets or sets the texture resolution used to render content (512 by default)
  67213. */
  67214. contentResolution: BABYLON.int;
  67215. /**
  67216. * Gets or sets the texture scale ratio used to render content (2 by default)
  67217. */
  67218. contentScaleRatio: number;
  67219. protected _disposeFacadeTexture(): void;
  67220. protected _resetContent(): void;
  67221. /**
  67222. * Creates a new button
  67223. * @param name defines the control name
  67224. */
  67225. constructor(name?: string);
  67226. /**
  67227. * Gets or sets the GUI 2D content used to display the button's facade
  67228. */
  67229. content: Control;
  67230. /**
  67231. * Apply the facade texture (created from the content property).
  67232. * This function can be overloaded by child classes
  67233. * @param facadeTexture defines the AdvancedDynamicTexture to use
  67234. */
  67235. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67236. protected _getTypeName(): string;
  67237. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67238. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67239. /**
  67240. * Releases all associated resources
  67241. */
  67242. dispose(): void;
  67243. }
  67244. }
  67245. declare module BABYLON.GUI {
  67246. /**
  67247. * Abstract class used to create a container panel deployed on the surface of a volume
  67248. */
  67249. export abstract class VolumeBasedPanel extends Container3D {
  67250. private _columns;
  67251. private _rows;
  67252. private _rowThenColum;
  67253. private _orientation;
  67254. protected _cellWidth: number;
  67255. protected _cellHeight: number;
  67256. /**
  67257. * Gets or sets the distance between elements
  67258. */
  67259. margin: number;
  67260. /**
  67261. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  67262. * | Value | Type | Description |
  67263. * | ----- | ----------------------------------- | ----------- |
  67264. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  67265. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  67266. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  67267. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  67268. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  67269. */
  67270. orientation: number;
  67271. /**
  67272. * Gets or sets the number of columns requested (10 by default).
  67273. * The panel will automatically compute the number of rows based on number of child controls.
  67274. */
  67275. columns: BABYLON.int;
  67276. /**
  67277. * Gets or sets a the number of rows requested.
  67278. * The panel will automatically compute the number of columns based on number of child controls.
  67279. */
  67280. rows: BABYLON.int;
  67281. /**
  67282. * Creates new VolumeBasedPanel
  67283. */
  67284. constructor();
  67285. protected _arrangeChildren(): void;
  67286. /** Child classes must implement this function to provide correct control positioning */
  67287. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67288. /** Child classes can implement this function to provide additional processing */
  67289. protected _finalProcessing(): void;
  67290. }
  67291. }
  67292. declare module BABYLON.GUI {
  67293. /**
  67294. * Class used to create a container panel deployed on the surface of a cylinder
  67295. */
  67296. export class CylinderPanel extends VolumeBasedPanel {
  67297. private _radius;
  67298. /**
  67299. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  67300. */
  67301. radius: BABYLON.float;
  67302. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67303. private _cylindricalMapping;
  67304. }
  67305. }
  67306. declare module BABYLON.GUI {
  67307. /** @hidden */
  67308. export var fluentVertexShader: {
  67309. name: string;
  67310. shader: string;
  67311. };
  67312. }
  67313. declare module BABYLON.GUI {
  67314. /** @hidden */
  67315. export var fluentPixelShader: {
  67316. name: string;
  67317. shader: string;
  67318. };
  67319. }
  67320. declare module BABYLON.GUI {
  67321. /** @hidden */
  67322. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  67323. INNERGLOW: boolean;
  67324. BORDER: boolean;
  67325. HOVERLIGHT: boolean;
  67326. TEXTURE: boolean;
  67327. constructor();
  67328. }
  67329. /**
  67330. * Class used to render controls with fluent desgin
  67331. */
  67332. export class FluentMaterial extends BABYLON.PushMaterial {
  67333. /**
  67334. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  67335. */
  67336. innerGlowColorIntensity: number;
  67337. /**
  67338. * Gets or sets the inner glow color (white by default)
  67339. */
  67340. innerGlowColor: BABYLON.Color3;
  67341. /**
  67342. * Gets or sets alpha value (default is 1.0)
  67343. */
  67344. alpha: number;
  67345. /**
  67346. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  67347. */
  67348. albedoColor: BABYLON.Color3;
  67349. /**
  67350. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  67351. */
  67352. renderBorders: boolean;
  67353. /**
  67354. * Gets or sets border width (default is 0.5)
  67355. */
  67356. borderWidth: number;
  67357. /**
  67358. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  67359. */
  67360. edgeSmoothingValue: number;
  67361. /**
  67362. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  67363. */
  67364. borderMinValue: number;
  67365. /**
  67366. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  67367. */
  67368. renderHoverLight: boolean;
  67369. /**
  67370. * Gets or sets the radius used to render the hover light (default is 1.0)
  67371. */
  67372. hoverRadius: number;
  67373. /**
  67374. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  67375. */
  67376. hoverColor: BABYLON.Color4;
  67377. /**
  67378. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  67379. */
  67380. hoverPosition: BABYLON.Vector3;
  67381. private _albedoTexture;
  67382. /** Gets or sets the texture to use for albedo color */
  67383. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67384. /**
  67385. * Creates a new Fluent material
  67386. * @param name defines the name of the material
  67387. * @param scene defines the hosting scene
  67388. */
  67389. constructor(name: string, scene: BABYLON.Scene);
  67390. needAlphaBlending(): boolean;
  67391. needAlphaTesting(): boolean;
  67392. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67393. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67394. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67395. getActiveTextures(): BABYLON.BaseTexture[];
  67396. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67397. dispose(forceDisposeEffect?: boolean): void;
  67398. clone(name: string): FluentMaterial;
  67399. serialize(): any;
  67400. getClassName(): string;
  67401. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  67402. }
  67403. }
  67404. declare module BABYLON.GUI {
  67405. /**
  67406. * Class used to create a holographic button in 3D
  67407. */
  67408. export class HolographicButton extends Button3D {
  67409. private _backPlate;
  67410. private _textPlate;
  67411. private _frontPlate;
  67412. private _text;
  67413. private _imageUrl;
  67414. private _shareMaterials;
  67415. private _frontMaterial;
  67416. private _backMaterial;
  67417. private _plateMaterial;
  67418. private _pickedPointObserver;
  67419. private _tooltipFade;
  67420. private _tooltipTextBlock;
  67421. private _tooltipTexture;
  67422. private _tooltipMesh;
  67423. private _tooltipHoverObserver;
  67424. private _tooltipOutObserver;
  67425. private _disposeTooltip;
  67426. /**
  67427. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67428. */
  67429. tooltipText: BABYLON.Nullable<string>;
  67430. /**
  67431. * Gets or sets text for the button
  67432. */
  67433. text: string;
  67434. /**
  67435. * Gets or sets the image url for the button
  67436. */
  67437. imageUrl: string;
  67438. /**
  67439. * Gets the back material used by this button
  67440. */
  67441. readonly backMaterial: FluentMaterial;
  67442. /**
  67443. * Gets the front material used by this button
  67444. */
  67445. readonly frontMaterial: FluentMaterial;
  67446. /**
  67447. * Gets the plate material used by this button
  67448. */
  67449. readonly plateMaterial: BABYLON.StandardMaterial;
  67450. /**
  67451. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67452. */
  67453. readonly shareMaterials: boolean;
  67454. /**
  67455. * Creates a new button
  67456. * @param name defines the control name
  67457. */
  67458. constructor(name?: string, shareMaterials?: boolean);
  67459. protected _getTypeName(): string;
  67460. private _rebuildContent;
  67461. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67462. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67463. private _createBackMaterial;
  67464. private _createFrontMaterial;
  67465. private _createPlateMaterial;
  67466. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67467. /**
  67468. * Releases all associated resources
  67469. */
  67470. dispose(): void;
  67471. }
  67472. }
  67473. declare module BABYLON.GUI {
  67474. /**
  67475. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67476. */
  67477. export class MeshButton3D extends Button3D {
  67478. /** @hidden */
  67479. protected _currentMesh: BABYLON.Mesh;
  67480. /**
  67481. * Creates a new 3D button based on a mesh
  67482. * @param mesh mesh to become a 3D button
  67483. * @param name defines the control name
  67484. */
  67485. constructor(mesh: BABYLON.Mesh, name?: string);
  67486. protected _getTypeName(): string;
  67487. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67488. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67489. }
  67490. }
  67491. declare module BABYLON.GUI {
  67492. /**
  67493. * Class used to create a container panel deployed on the surface of a plane
  67494. */
  67495. export class PlanePanel extends VolumeBasedPanel {
  67496. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67497. }
  67498. }
  67499. declare module BABYLON.GUI {
  67500. /**
  67501. * Class used to create a container panel where items get randomized planar mapping
  67502. */
  67503. export class ScatterPanel extends VolumeBasedPanel {
  67504. private _iteration;
  67505. /**
  67506. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67507. */
  67508. iteration: BABYLON.float;
  67509. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67510. private _scatterMapping;
  67511. protected _finalProcessing(): void;
  67512. }
  67513. }
  67514. declare module BABYLON.GUI {
  67515. /**
  67516. * Class used to create a container panel deployed on the surface of a sphere
  67517. */
  67518. export class SpherePanel extends VolumeBasedPanel {
  67519. private _radius;
  67520. /**
  67521. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67522. */
  67523. radius: BABYLON.float;
  67524. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67525. private _sphericalMapping;
  67526. }
  67527. }
  67528. declare module BABYLON.GUI {
  67529. /**
  67530. * Class used to create a stack panel in 3D on XY plane
  67531. */
  67532. export class StackPanel3D extends Container3D {
  67533. private _isVertical;
  67534. /**
  67535. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67536. */
  67537. isVertical: boolean;
  67538. /**
  67539. * Gets or sets the distance between elements
  67540. */
  67541. margin: number;
  67542. /**
  67543. * Creates new StackPanel
  67544. * @param isVertical
  67545. */
  67546. constructor(isVertical?: boolean);
  67547. protected _arrangeChildren(): void;
  67548. }
  67549. }
  67550. declare module BABYLON {
  67551. /**
  67552. * Mode that determines the coordinate system to use.
  67553. */
  67554. export enum GLTFLoaderCoordinateSystemMode {
  67555. /**
  67556. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67557. */
  67558. AUTO = 0,
  67559. /**
  67560. * Sets the useRightHandedSystem flag on the scene.
  67561. */
  67562. FORCE_RIGHT_HANDED = 1
  67563. }
  67564. /**
  67565. * Mode that determines what animations will start.
  67566. */
  67567. export enum GLTFLoaderAnimationStartMode {
  67568. /**
  67569. * No animation will start.
  67570. */
  67571. NONE = 0,
  67572. /**
  67573. * The first animation will start.
  67574. */
  67575. FIRST = 1,
  67576. /**
  67577. * All animations will start.
  67578. */
  67579. ALL = 2
  67580. }
  67581. /**
  67582. * Interface that contains the data for the glTF asset.
  67583. */
  67584. export interface IGLTFLoaderData {
  67585. /**
  67586. * The object that represents the glTF JSON.
  67587. */
  67588. json: Object;
  67589. /**
  67590. * The BIN chunk of a binary glTF.
  67591. */
  67592. bin: Nullable<IDataBuffer>;
  67593. }
  67594. /**
  67595. * Interface for extending the loader.
  67596. */
  67597. export interface IGLTFLoaderExtension {
  67598. /**
  67599. * The name of this extension.
  67600. */
  67601. readonly name: string;
  67602. /**
  67603. * Defines whether this extension is enabled.
  67604. */
  67605. enabled: boolean;
  67606. /**
  67607. * Defines the order of this extension.
  67608. * The loader sorts the extensions using these values when loading.
  67609. */
  67610. order?: number;
  67611. }
  67612. /**
  67613. * Loader state.
  67614. */
  67615. export enum GLTFLoaderState {
  67616. /**
  67617. * The asset is loading.
  67618. */
  67619. LOADING = 0,
  67620. /**
  67621. * The asset is ready for rendering.
  67622. */
  67623. READY = 1,
  67624. /**
  67625. * The asset is completely loaded.
  67626. */
  67627. COMPLETE = 2
  67628. }
  67629. /** @hidden */
  67630. export interface IGLTFLoader extends IDisposable {
  67631. readonly state: Nullable<GLTFLoaderState>;
  67632. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67633. meshes: AbstractMesh[];
  67634. particleSystems: IParticleSystem[];
  67635. skeletons: Skeleton[];
  67636. animationGroups: AnimationGroup[];
  67637. }>;
  67638. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67639. }
  67640. /**
  67641. * File loader for loading glTF files into a scene.
  67642. */
  67643. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67644. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67645. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67646. /**
  67647. * Raised when the asset has been parsed
  67648. */
  67649. onParsedObservable: Observable<IGLTFLoaderData>;
  67650. private _onParsedObserver;
  67651. /**
  67652. * Raised when the asset has been parsed
  67653. */
  67654. onParsed: (loaderData: IGLTFLoaderData) => void;
  67655. /**
  67656. * 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.
  67657. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67658. * Defaults to true.
  67659. * @hidden
  67660. */
  67661. static IncrementalLoading: boolean;
  67662. /**
  67663. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67664. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67665. * @hidden
  67666. */
  67667. static HomogeneousCoordinates: boolean;
  67668. /**
  67669. * The coordinate system mode. Defaults to AUTO.
  67670. */
  67671. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67672. /**
  67673. * The animation start mode. Defaults to FIRST.
  67674. */
  67675. animationStartMode: GLTFLoaderAnimationStartMode;
  67676. /**
  67677. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67678. */
  67679. compileMaterials: boolean;
  67680. /**
  67681. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67682. */
  67683. useClipPlane: boolean;
  67684. /**
  67685. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67686. */
  67687. compileShadowGenerators: boolean;
  67688. /**
  67689. * Defines if the Alpha blended materials are only applied as coverage.
  67690. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  67691. * If true, no extra effects are applied to transparent pixels.
  67692. */
  67693. transparencyAsCoverage: boolean;
  67694. /**
  67695. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  67696. * Enabling will disable offline support and glTF validator.
  67697. * Defaults to false.
  67698. */
  67699. useRangeRequests: boolean;
  67700. /**
  67701. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  67702. */
  67703. createInstances: boolean;
  67704. /**
  67705. * Function called before loading a url referenced by the asset.
  67706. */
  67707. preprocessUrlAsync: (url: string) => Promise<string>;
  67708. /**
  67709. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67710. */
  67711. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  67712. private _onMeshLoadedObserver;
  67713. /**
  67714. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67715. */
  67716. onMeshLoaded: (mesh: AbstractMesh) => void;
  67717. /**
  67718. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  67719. */
  67720. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  67721. private _onTextureLoadedObserver;
  67722. /**
  67723. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  67724. */
  67725. onTextureLoaded: (texture: BaseTexture) => void;
  67726. /**
  67727. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  67728. */
  67729. readonly onMaterialLoadedObservable: Observable<Material>;
  67730. private _onMaterialLoadedObserver;
  67731. /**
  67732. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  67733. */
  67734. onMaterialLoaded: (material: Material) => void;
  67735. /**
  67736. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  67737. */
  67738. readonly onCameraLoadedObservable: Observable<Camera>;
  67739. private _onCameraLoadedObserver;
  67740. /**
  67741. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  67742. */
  67743. onCameraLoaded: (camera: Camera) => void;
  67744. /**
  67745. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  67746. * For assets with LODs, raised when all of the LODs are complete.
  67747. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67748. */
  67749. readonly onCompleteObservable: Observable<void>;
  67750. private _onCompleteObserver;
  67751. /**
  67752. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  67753. * For assets with LODs, raised when all of the LODs are complete.
  67754. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67755. */
  67756. onComplete: () => void;
  67757. /**
  67758. * Observable raised when an error occurs.
  67759. */
  67760. readonly onErrorObservable: Observable<any>;
  67761. private _onErrorObserver;
  67762. /**
  67763. * Callback raised when an error occurs.
  67764. */
  67765. onError: (reason: any) => void;
  67766. /**
  67767. * Observable raised after the loader is disposed.
  67768. */
  67769. readonly onDisposeObservable: Observable<void>;
  67770. private _onDisposeObserver;
  67771. /**
  67772. * Callback raised after the loader is disposed.
  67773. */
  67774. onDispose: () => void;
  67775. /**
  67776. * Observable raised after a loader extension is created.
  67777. * Set additional options for a loader extension in this event.
  67778. */
  67779. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  67780. private _onExtensionLoadedObserver;
  67781. /**
  67782. * Callback raised after a loader extension is created.
  67783. */
  67784. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  67785. /**
  67786. * Defines if the loader logging is enabled.
  67787. */
  67788. loggingEnabled: boolean;
  67789. /**
  67790. * Defines if the loader should capture performance counters.
  67791. */
  67792. capturePerformanceCounters: boolean;
  67793. /**
  67794. * Defines if the loader should validate the asset.
  67795. */
  67796. validate: boolean;
  67797. /**
  67798. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  67799. */
  67800. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  67801. private _onValidatedObserver;
  67802. /**
  67803. * Callback raised after a loader extension is created.
  67804. */
  67805. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  67806. private _loader;
  67807. /**
  67808. * Name of the loader ("gltf")
  67809. */
  67810. name: string;
  67811. /** @hidden */
  67812. extensions: ISceneLoaderPluginExtensions;
  67813. /**
  67814. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  67815. */
  67816. dispose(): void;
  67817. /** @hidden */ private _clear(): void;
  67818. /** @hidden */
  67819. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  67820. /** @hidden */
  67821. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  67822. /** @hidden */
  67823. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67824. meshes: AbstractMesh[];
  67825. particleSystems: IParticleSystem[];
  67826. skeletons: Skeleton[];
  67827. animationGroups: AnimationGroup[];
  67828. }>;
  67829. /** @hidden */
  67830. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67831. /** @hidden */
  67832. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67833. /** @hidden */
  67834. canDirectLoad(data: string): boolean;
  67835. /** @hidden */
  67836. directLoad(scene: Scene, data: string): any;
  67837. /**
  67838. * The callback that allows custom handling of the root url based on the response url.
  67839. * @param rootUrl the original root url
  67840. * @param responseURL the response url if available
  67841. * @returns the new root url
  67842. */
  67843. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  67844. /** @hidden */
  67845. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  67846. /**
  67847. * The loader state or null if the loader is not active.
  67848. */
  67849. readonly loaderState: Nullable<GLTFLoaderState>;
  67850. /**
  67851. * Returns a promise that resolves when the asset is completely loaded.
  67852. * @returns a promise that resolves when the asset is completely loaded.
  67853. */
  67854. whenCompleteAsync(): Promise<void>;
  67855. private _validateAsync;
  67856. private _getLoader;
  67857. private _parseJson;
  67858. private _unpackBinaryAsync;
  67859. private _unpackBinaryV1Async;
  67860. private _unpackBinaryV2Async;
  67861. private static _parseVersion;
  67862. private static _compareVersion;
  67863. private static readonly _logSpaces;
  67864. private _logIndentLevel;
  67865. private _loggingEnabled;
  67866. /** @hidden */ private _log: (message: string) => void;
  67867. /** @hidden */ private _logOpen(message: string): void;
  67868. /** @hidden */ private _logClose(): void;
  67869. private _logEnabled;
  67870. private _logDisabled;
  67871. private _capturePerformanceCounters;
  67872. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  67873. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  67874. private _startPerformanceCounterEnabled;
  67875. private _startPerformanceCounterDisabled;
  67876. private _endPerformanceCounterEnabled;
  67877. private _endPerformanceCounterDisabled;
  67878. }
  67879. }
  67880. declare module BABYLON.GLTF1 {
  67881. /**
  67882. * Enums
  67883. * @hidden
  67884. */
  67885. export enum EComponentType {
  67886. BYTE = 5120,
  67887. UNSIGNED_BYTE = 5121,
  67888. SHORT = 5122,
  67889. UNSIGNED_SHORT = 5123,
  67890. FLOAT = 5126
  67891. }
  67892. /** @hidden */
  67893. export enum EShaderType {
  67894. FRAGMENT = 35632,
  67895. VERTEX = 35633
  67896. }
  67897. /** @hidden */
  67898. export enum EParameterType {
  67899. BYTE = 5120,
  67900. UNSIGNED_BYTE = 5121,
  67901. SHORT = 5122,
  67902. UNSIGNED_SHORT = 5123,
  67903. INT = 5124,
  67904. UNSIGNED_INT = 5125,
  67905. FLOAT = 5126,
  67906. FLOAT_VEC2 = 35664,
  67907. FLOAT_VEC3 = 35665,
  67908. FLOAT_VEC4 = 35666,
  67909. INT_VEC2 = 35667,
  67910. INT_VEC3 = 35668,
  67911. INT_VEC4 = 35669,
  67912. BOOL = 35670,
  67913. BOOL_VEC2 = 35671,
  67914. BOOL_VEC3 = 35672,
  67915. BOOL_VEC4 = 35673,
  67916. FLOAT_MAT2 = 35674,
  67917. FLOAT_MAT3 = 35675,
  67918. FLOAT_MAT4 = 35676,
  67919. SAMPLER_2D = 35678
  67920. }
  67921. /** @hidden */
  67922. export enum ETextureWrapMode {
  67923. CLAMP_TO_EDGE = 33071,
  67924. MIRRORED_REPEAT = 33648,
  67925. REPEAT = 10497
  67926. }
  67927. /** @hidden */
  67928. export enum ETextureFilterType {
  67929. NEAREST = 9728,
  67930. LINEAR = 9728,
  67931. NEAREST_MIPMAP_NEAREST = 9984,
  67932. LINEAR_MIPMAP_NEAREST = 9985,
  67933. NEAREST_MIPMAP_LINEAR = 9986,
  67934. LINEAR_MIPMAP_LINEAR = 9987
  67935. }
  67936. /** @hidden */
  67937. export enum ETextureFormat {
  67938. ALPHA = 6406,
  67939. RGB = 6407,
  67940. RGBA = 6408,
  67941. LUMINANCE = 6409,
  67942. LUMINANCE_ALPHA = 6410
  67943. }
  67944. /** @hidden */
  67945. export enum ECullingType {
  67946. FRONT = 1028,
  67947. BACK = 1029,
  67948. FRONT_AND_BACK = 1032
  67949. }
  67950. /** @hidden */
  67951. export enum EBlendingFunction {
  67952. ZERO = 0,
  67953. ONE = 1,
  67954. SRC_COLOR = 768,
  67955. ONE_MINUS_SRC_COLOR = 769,
  67956. DST_COLOR = 774,
  67957. ONE_MINUS_DST_COLOR = 775,
  67958. SRC_ALPHA = 770,
  67959. ONE_MINUS_SRC_ALPHA = 771,
  67960. DST_ALPHA = 772,
  67961. ONE_MINUS_DST_ALPHA = 773,
  67962. CONSTANT_COLOR = 32769,
  67963. ONE_MINUS_CONSTANT_COLOR = 32770,
  67964. CONSTANT_ALPHA = 32771,
  67965. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67966. SRC_ALPHA_SATURATE = 776
  67967. }
  67968. /** @hidden */
  67969. export interface IGLTFProperty {
  67970. extensions?: {
  67971. [key: string]: any;
  67972. };
  67973. extras?: Object;
  67974. }
  67975. /** @hidden */
  67976. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67977. name?: string;
  67978. }
  67979. /** @hidden */
  67980. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67981. bufferView: string;
  67982. byteOffset: number;
  67983. byteStride: number;
  67984. count: number;
  67985. type: string;
  67986. componentType: EComponentType;
  67987. max?: number[];
  67988. min?: number[];
  67989. name?: string;
  67990. }
  67991. /** @hidden */
  67992. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67993. buffer: string;
  67994. byteOffset: number;
  67995. byteLength: number;
  67996. byteStride: number;
  67997. target?: number;
  67998. }
  67999. /** @hidden */
  68000. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  68001. uri: string;
  68002. byteLength?: number;
  68003. type?: string;
  68004. }
  68005. /** @hidden */
  68006. export interface IGLTFShader extends IGLTFChildRootProperty {
  68007. uri: string;
  68008. type: EShaderType;
  68009. }
  68010. /** @hidden */
  68011. export interface IGLTFProgram extends IGLTFChildRootProperty {
  68012. attributes: string[];
  68013. fragmentShader: string;
  68014. vertexShader: string;
  68015. }
  68016. /** @hidden */
  68017. export interface IGLTFTechniqueParameter {
  68018. type: number;
  68019. count?: number;
  68020. semantic?: string;
  68021. node?: string;
  68022. value?: number | boolean | string | Array<any>;
  68023. source?: string;
  68024. babylonValue?: any;
  68025. }
  68026. /** @hidden */
  68027. export interface IGLTFTechniqueCommonProfile {
  68028. lightingModel: string;
  68029. texcoordBindings: Object;
  68030. parameters?: Array<any>;
  68031. }
  68032. /** @hidden */
  68033. export interface IGLTFTechniqueStatesFunctions {
  68034. blendColor?: number[];
  68035. blendEquationSeparate?: number[];
  68036. blendFuncSeparate?: number[];
  68037. colorMask: boolean[];
  68038. cullFace: number[];
  68039. }
  68040. /** @hidden */
  68041. export interface IGLTFTechniqueStates {
  68042. enable: number[];
  68043. functions: IGLTFTechniqueStatesFunctions;
  68044. }
  68045. /** @hidden */
  68046. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  68047. parameters: {
  68048. [key: string]: IGLTFTechniqueParameter;
  68049. };
  68050. program: string;
  68051. attributes: {
  68052. [key: string]: string;
  68053. };
  68054. uniforms: {
  68055. [key: string]: string;
  68056. };
  68057. states: IGLTFTechniqueStates;
  68058. }
  68059. /** @hidden */
  68060. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  68061. technique?: string;
  68062. values: string[];
  68063. }
  68064. /** @hidden */
  68065. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  68066. attributes: {
  68067. [key: string]: string;
  68068. };
  68069. indices: string;
  68070. material: string;
  68071. mode?: number;
  68072. }
  68073. /** @hidden */
  68074. export interface IGLTFMesh extends IGLTFChildRootProperty {
  68075. primitives: IGLTFMeshPrimitive[];
  68076. }
  68077. /** @hidden */
  68078. export interface IGLTFImage extends IGLTFChildRootProperty {
  68079. uri: string;
  68080. }
  68081. /** @hidden */
  68082. export interface IGLTFSampler extends IGLTFChildRootProperty {
  68083. magFilter?: number;
  68084. minFilter?: number;
  68085. wrapS?: number;
  68086. wrapT?: number;
  68087. }
  68088. /** @hidden */
  68089. export interface IGLTFTexture extends IGLTFChildRootProperty {
  68090. sampler: string;
  68091. source: string;
  68092. format?: ETextureFormat;
  68093. internalFormat?: ETextureFormat;
  68094. target?: number;
  68095. type?: number;
  68096. babylonTexture?: Texture;
  68097. }
  68098. /** @hidden */
  68099. export interface IGLTFAmbienLight {
  68100. color?: number[];
  68101. }
  68102. /** @hidden */
  68103. export interface IGLTFDirectionalLight {
  68104. color?: number[];
  68105. }
  68106. /** @hidden */
  68107. export interface IGLTFPointLight {
  68108. color?: number[];
  68109. constantAttenuation?: number;
  68110. linearAttenuation?: number;
  68111. quadraticAttenuation?: number;
  68112. }
  68113. /** @hidden */
  68114. export interface IGLTFSpotLight {
  68115. color?: number[];
  68116. constantAttenuation?: number;
  68117. fallOfAngle?: number;
  68118. fallOffExponent?: number;
  68119. linearAttenuation?: number;
  68120. quadraticAttenuation?: number;
  68121. }
  68122. /** @hidden */
  68123. export interface IGLTFLight extends IGLTFChildRootProperty {
  68124. type: string;
  68125. }
  68126. /** @hidden */
  68127. export interface IGLTFCameraOrthographic {
  68128. xmag: number;
  68129. ymag: number;
  68130. zfar: number;
  68131. znear: number;
  68132. }
  68133. /** @hidden */
  68134. export interface IGLTFCameraPerspective {
  68135. aspectRatio: number;
  68136. yfov: number;
  68137. zfar: number;
  68138. znear: number;
  68139. }
  68140. /** @hidden */
  68141. export interface IGLTFCamera extends IGLTFChildRootProperty {
  68142. type: string;
  68143. }
  68144. /** @hidden */
  68145. export interface IGLTFAnimationChannelTarget {
  68146. id: string;
  68147. path: string;
  68148. }
  68149. /** @hidden */
  68150. export interface IGLTFAnimationChannel {
  68151. sampler: string;
  68152. target: IGLTFAnimationChannelTarget;
  68153. }
  68154. /** @hidden */
  68155. export interface IGLTFAnimationSampler {
  68156. input: string;
  68157. output: string;
  68158. interpolation?: string;
  68159. }
  68160. /** @hidden */
  68161. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  68162. channels?: IGLTFAnimationChannel[];
  68163. parameters?: {
  68164. [key: string]: string;
  68165. };
  68166. samplers?: {
  68167. [key: string]: IGLTFAnimationSampler;
  68168. };
  68169. }
  68170. /** @hidden */
  68171. export interface IGLTFNodeInstanceSkin {
  68172. skeletons: string[];
  68173. skin: string;
  68174. meshes: string[];
  68175. }
  68176. /** @hidden */
  68177. export interface IGLTFSkins extends IGLTFChildRootProperty {
  68178. bindShapeMatrix: number[];
  68179. inverseBindMatrices: string;
  68180. jointNames: string[];
  68181. babylonSkeleton?: Skeleton;
  68182. }
  68183. /** @hidden */
  68184. export interface IGLTFNode extends IGLTFChildRootProperty {
  68185. camera?: string;
  68186. children: string[];
  68187. skin?: string;
  68188. jointName?: string;
  68189. light?: string;
  68190. matrix: number[];
  68191. mesh?: string;
  68192. meshes?: string[];
  68193. rotation?: number[];
  68194. scale?: number[];
  68195. translation?: number[];
  68196. babylonNode?: Node;
  68197. }
  68198. /** @hidden */
  68199. export interface IGLTFScene extends IGLTFChildRootProperty {
  68200. nodes: string[];
  68201. }
  68202. /** @hidden */
  68203. export interface IGLTFRuntime {
  68204. extensions: {
  68205. [key: string]: any;
  68206. };
  68207. accessors: {
  68208. [key: string]: IGLTFAccessor;
  68209. };
  68210. buffers: {
  68211. [key: string]: IGLTFBuffer;
  68212. };
  68213. bufferViews: {
  68214. [key: string]: IGLTFBufferView;
  68215. };
  68216. meshes: {
  68217. [key: string]: IGLTFMesh;
  68218. };
  68219. lights: {
  68220. [key: string]: IGLTFLight;
  68221. };
  68222. cameras: {
  68223. [key: string]: IGLTFCamera;
  68224. };
  68225. nodes: {
  68226. [key: string]: IGLTFNode;
  68227. };
  68228. images: {
  68229. [key: string]: IGLTFImage;
  68230. };
  68231. textures: {
  68232. [key: string]: IGLTFTexture;
  68233. };
  68234. shaders: {
  68235. [key: string]: IGLTFShader;
  68236. };
  68237. programs: {
  68238. [key: string]: IGLTFProgram;
  68239. };
  68240. samplers: {
  68241. [key: string]: IGLTFSampler;
  68242. };
  68243. techniques: {
  68244. [key: string]: IGLTFTechnique;
  68245. };
  68246. materials: {
  68247. [key: string]: IGLTFMaterial;
  68248. };
  68249. animations: {
  68250. [key: string]: IGLTFAnimation;
  68251. };
  68252. skins: {
  68253. [key: string]: IGLTFSkins;
  68254. };
  68255. currentScene?: Object;
  68256. scenes: {
  68257. [key: string]: IGLTFScene;
  68258. };
  68259. extensionsUsed: string[];
  68260. extensionsRequired?: string[];
  68261. buffersCount: number;
  68262. shaderscount: number;
  68263. scene: Scene;
  68264. rootUrl: string;
  68265. loadedBufferCount: number;
  68266. loadedBufferViews: {
  68267. [name: string]: ArrayBufferView;
  68268. };
  68269. loadedShaderCount: number;
  68270. importOnlyMeshes: boolean;
  68271. importMeshesNames?: string[];
  68272. dummyNodes: Node[];
  68273. }
  68274. /** @hidden */
  68275. export interface INodeToRoot {
  68276. bone: Bone;
  68277. node: IGLTFNode;
  68278. id: string;
  68279. }
  68280. /** @hidden */
  68281. export interface IJointNode {
  68282. node: IGLTFNode;
  68283. id: string;
  68284. }
  68285. }
  68286. declare module BABYLON.GLTF1 {
  68287. /**
  68288. * Utils functions for GLTF
  68289. * @hidden
  68290. */
  68291. export class GLTFUtils {
  68292. /**
  68293. * Sets the given "parameter" matrix
  68294. * @param scene: the Scene object
  68295. * @param source: the source node where to pick the matrix
  68296. * @param parameter: the GLTF technique parameter
  68297. * @param uniformName: the name of the shader's uniform
  68298. * @param shaderMaterial: the shader material
  68299. */
  68300. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  68301. /**
  68302. * Sets the given "parameter" matrix
  68303. * @param shaderMaterial: the shader material
  68304. * @param uniform: the name of the shader's uniform
  68305. * @param value: the value of the uniform
  68306. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  68307. */
  68308. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  68309. /**
  68310. * Returns the wrap mode of the texture
  68311. * @param mode: the mode value
  68312. */
  68313. static GetWrapMode(mode: number): number;
  68314. /**
  68315. * Returns the byte stride giving an accessor
  68316. * @param accessor: the GLTF accessor objet
  68317. */
  68318. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  68319. /**
  68320. * Returns the texture filter mode giving a mode value
  68321. * @param mode: the filter mode value
  68322. */
  68323. static GetTextureFilterMode(mode: number): ETextureFilterType;
  68324. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  68325. /**
  68326. * Returns a buffer from its accessor
  68327. * @param gltfRuntime: the GLTF runtime
  68328. * @param accessor: the GLTF accessor
  68329. */
  68330. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  68331. /**
  68332. * Decodes a buffer view into a string
  68333. * @param view: the buffer view
  68334. */
  68335. static DecodeBufferToText(view: ArrayBufferView): string;
  68336. /**
  68337. * Returns the default material of gltf. Related to
  68338. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  68339. * @param scene: the Babylon.js scene
  68340. */
  68341. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  68342. private static _DefaultMaterial;
  68343. }
  68344. }
  68345. declare module BABYLON.GLTF1 {
  68346. /**
  68347. * Implementation of the base glTF spec
  68348. * @hidden
  68349. */
  68350. export class GLTFLoaderBase {
  68351. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  68352. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68353. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  68354. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68355. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  68356. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68357. }
  68358. /**
  68359. * glTF V1 Loader
  68360. * @hidden
  68361. */
  68362. export class GLTFLoader implements IGLTFLoader {
  68363. static Extensions: {
  68364. [name: string]: GLTFLoaderExtension;
  68365. };
  68366. static RegisterExtension(extension: GLTFLoaderExtension): void;
  68367. state: Nullable<GLTFLoaderState>;
  68368. dispose(): void;
  68369. private _importMeshAsync;
  68370. /**
  68371. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  68372. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68373. * @param scene the scene the meshes should be added to
  68374. * @param data gltf data containing information of the meshes in a loaded file
  68375. * @param rootUrl root url to load from
  68376. * @param onProgress event that fires when loading progress has occured
  68377. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68378. */
  68379. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  68380. meshes: AbstractMesh[];
  68381. particleSystems: IParticleSystem[];
  68382. skeletons: Skeleton[];
  68383. animationGroups: AnimationGroup[];
  68384. }>;
  68385. private _loadAsync;
  68386. /**
  68387. * Imports all objects from a loaded gltf file and adds them to the scene
  68388. * @param scene the scene the objects should be added to
  68389. * @param data gltf data containing information of the meshes in a loaded file
  68390. * @param rootUrl root url to load from
  68391. * @param onProgress event that fires when loading progress has occured
  68392. * @returns a promise which completes when objects have been loaded to the scene
  68393. */
  68394. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  68395. private _loadShadersAsync;
  68396. private _loadBuffersAsync;
  68397. private _createNodes;
  68398. }
  68399. /** @hidden */
  68400. export abstract class GLTFLoaderExtension {
  68401. private _name;
  68402. constructor(name: string);
  68403. readonly name: string;
  68404. /**
  68405. * Defines an override for loading the runtime
  68406. * Return true to stop further extensions from loading the runtime
  68407. */
  68408. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  68409. /**
  68410. * Defines an onverride for creating gltf runtime
  68411. * Return true to stop further extensions from creating the runtime
  68412. */
  68413. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  68414. /**
  68415. * Defines an override for loading buffers
  68416. * Return true to stop further extensions from loading this buffer
  68417. */
  68418. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  68419. /**
  68420. * Defines an override for loading texture buffers
  68421. * Return true to stop further extensions from loading this texture data
  68422. */
  68423. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68424. /**
  68425. * Defines an override for creating textures
  68426. * Return true to stop further extensions from loading this texture
  68427. */
  68428. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  68429. /**
  68430. * Defines an override for loading shader strings
  68431. * Return true to stop further extensions from loading this shader data
  68432. */
  68433. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68434. /**
  68435. * Defines an override for loading materials
  68436. * Return true to stop further extensions from loading this material
  68437. */
  68438. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68439. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  68440. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  68441. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68442. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68443. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  68444. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68445. private static LoadTextureBufferAsync;
  68446. private static CreateTextureAsync;
  68447. private static ApplyExtensions;
  68448. }
  68449. }
  68450. declare module BABYLON.GLTF1 {
  68451. /** @hidden */
  68452. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  68453. private _bin;
  68454. constructor();
  68455. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  68456. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68457. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68458. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68459. }
  68460. }
  68461. declare module BABYLON.GLTF1 {
  68462. /** @hidden */
  68463. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  68464. constructor();
  68465. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  68466. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68467. private _loadTexture;
  68468. }
  68469. }
  68470. declare module BABYLON.GLTF2.Loader {
  68471. /**
  68472. * Loader interface with an index field.
  68473. */
  68474. export interface IArrayItem {
  68475. /**
  68476. * The index of this item in the array.
  68477. */
  68478. index: number;
  68479. }
  68480. /**
  68481. * Loader interface with additional members.
  68482. */
  68483. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  68484. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68485. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  68486. }
  68487. /**
  68488. * Loader interface with additional members.
  68489. */
  68490. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68491. }
  68492. /** @hidden */
  68493. export interface _IAnimationSamplerData {
  68494. input: Float32Array;
  68495. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68496. output: Float32Array;
  68497. }
  68498. /**
  68499. * Loader interface with additional members.
  68500. */
  68501. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68502. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  68503. }
  68504. /**
  68505. * Loader interface with additional members.
  68506. */
  68507. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68508. channels: IAnimationChannel[];
  68509. samplers: IAnimationSampler[];
  68510. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  68511. }
  68512. /**
  68513. * Loader interface with additional members.
  68514. */
  68515. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68516. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68517. }
  68518. /**
  68519. * Loader interface with additional members.
  68520. */
  68521. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68522. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68523. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  68524. }
  68525. /**
  68526. * Loader interface with additional members.
  68527. */
  68528. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68529. }
  68530. /**
  68531. * Loader interface with additional members.
  68532. */
  68533. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68534. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68535. }
  68536. /**
  68537. * Loader interface with additional members.
  68538. */
  68539. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68540. }
  68541. /**
  68542. * Loader interface with additional members.
  68543. */
  68544. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68545. }
  68546. /**
  68547. * Loader interface with additional members.
  68548. */
  68549. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68550. baseColorTexture?: ITextureInfo;
  68551. metallicRoughnessTexture?: ITextureInfo;
  68552. }
  68553. /**
  68554. * Loader interface with additional members.
  68555. */
  68556. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68557. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68558. normalTexture?: IMaterialNormalTextureInfo;
  68559. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68560. emissiveTexture?: ITextureInfo;
  68561. /** @hidden */ private _data?: {
  68562. [babylonDrawMode: number]: {
  68563. babylonMaterial: Material;
  68564. babylonMeshes: AbstractMesh[];
  68565. promise: Promise<void>;
  68566. };
  68567. };
  68568. }
  68569. /**
  68570. * Loader interface with additional members.
  68571. */
  68572. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68573. primitives: IMeshPrimitive[];
  68574. }
  68575. /**
  68576. * Loader interface with additional members.
  68577. */
  68578. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68579. /** @hidden */ private _instanceData?: {
  68580. babylonSourceMesh: Mesh;
  68581. promise: Promise<any>;
  68582. };
  68583. }
  68584. /**
  68585. * Loader interface with additional members.
  68586. */
  68587. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68588. /**
  68589. * The parent glTF node.
  68590. */
  68591. parent?: INode;
  68592. /** @hidden */ private _babylonTransformNode?: TransformNode;
  68593. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  68594. /** @hidden */ private _babylonBones?: Bone[];
  68595. /** @hidden */ private _numMorphTargets?: number;
  68596. }
  68597. /** @hidden */
  68598. export interface _ISamplerData {
  68599. noMipMaps: boolean;
  68600. samplingMode: number;
  68601. wrapU: number;
  68602. wrapV: number;
  68603. }
  68604. /**
  68605. * Loader interface with additional members.
  68606. */
  68607. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68608. /** @hidden */ private _data?: _ISamplerData;
  68609. }
  68610. /**
  68611. * Loader interface with additional members.
  68612. */
  68613. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68614. }
  68615. /**
  68616. * Loader interface with additional members.
  68617. */
  68618. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68619. /** @hidden */ private _data?: {
  68620. babylonSkeleton: Skeleton;
  68621. promise: Promise<void>;
  68622. };
  68623. }
  68624. /**
  68625. * Loader interface with additional members.
  68626. */
  68627. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68628. }
  68629. /**
  68630. * Loader interface with additional members.
  68631. */
  68632. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68633. }
  68634. /**
  68635. * Loader interface with additional members.
  68636. */
  68637. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68638. accessors?: IAccessor[];
  68639. animations?: IAnimation[];
  68640. buffers?: IBuffer[];
  68641. bufferViews?: IBufferView[];
  68642. cameras?: ICamera[];
  68643. images?: IImage[];
  68644. materials?: IMaterial[];
  68645. meshes?: IMesh[];
  68646. nodes?: INode[];
  68647. samplers?: ISampler[];
  68648. scenes?: IScene[];
  68649. skins?: ISkin[];
  68650. textures?: ITexture[];
  68651. }
  68652. }
  68653. declare module BABYLON.GLTF2 {
  68654. /**
  68655. * Interface for a glTF loader extension.
  68656. */
  68657. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  68658. /**
  68659. * Called after the loader state changes to LOADING.
  68660. */
  68661. onLoading?(): void;
  68662. /**
  68663. * Called after the loader state changes to READY.
  68664. */
  68665. onReady?(): void;
  68666. /**
  68667. * Define this method to modify the default behavior when loading scenes.
  68668. * @param context The context when loading the asset
  68669. * @param scene The glTF scene property
  68670. * @returns A promise that resolves when the load is complete or null if not handled
  68671. */
  68672. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  68673. /**
  68674. * Define this method to modify the default behavior when loading nodes.
  68675. * @param context The context when loading the asset
  68676. * @param node The glTF node property
  68677. * @param assign A function called synchronously after parsing the glTF properties
  68678. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  68679. */
  68680. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68681. /**
  68682. * Define this method to modify the default behavior when loading cameras.
  68683. * @param context The context when loading the asset
  68684. * @param camera The glTF camera property
  68685. * @param assign A function called synchronously after parsing the glTF properties
  68686. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  68687. */
  68688. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68689. /**
  68690. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  68691. * @param context The context when loading the asset
  68692. * @param primitive The glTF mesh primitive property
  68693. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  68694. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68695. /**
  68696. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68697. * @param context The context when loading the asset
  68698. * @param name The mesh name when loading the asset
  68699. * @param node The glTF node when loading the asset
  68700. * @param mesh The glTF mesh when loading the asset
  68701. * @param primitive The glTF mesh primitive property
  68702. * @param assign A function called synchronously after parsing the glTF properties
  68703. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68704. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68705. /**
  68706. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  68707. * @param context The context when loading the asset
  68708. * @param material The glTF material property
  68709. * @param assign A function called synchronously after parsing the glTF properties
  68710. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  68711. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68712. /**
  68713. * Define this method to modify the default behavior when creating materials.
  68714. * @param context The context when loading the asset
  68715. * @param material The glTF material property
  68716. * @param babylonDrawMode The draw mode for the Babylon material
  68717. * @returns The Babylon material or null if not handled
  68718. */
  68719. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68720. /**
  68721. * Define this method to modify the default behavior when loading material properties.
  68722. * @param context The context when loading the asset
  68723. * @param material The glTF material property
  68724. * @param babylonMaterial The Babylon material
  68725. * @returns A promise that resolves when the load is complete or null if not handled
  68726. */
  68727. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68728. /**
  68729. * Define this method to modify the default behavior when loading texture infos.
  68730. * @param context The context when loading the asset
  68731. * @param textureInfo The glTF texture info property
  68732. * @param assign A function called synchronously after parsing the glTF properties
  68733. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  68734. */
  68735. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68736. /**
  68737. * Define this method to modify the default behavior when loading animations.
  68738. * @param context The context when loading the asset
  68739. * @param animation The glTF animation property
  68740. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  68741. */
  68742. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68743. /**
  68744. * @hidden Define this method to modify the default behavior when loading skins.
  68745. * @param context The context when loading the asset
  68746. * @param node The glTF node property
  68747. * @param skin The glTF skin property
  68748. * @returns A promise that resolves when the load is complete or null if not handled
  68749. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  68750. /**
  68751. * @hidden Define this method to modify the default behavior when loading uris.
  68752. * @param context The context when loading the asset
  68753. * @param property The glTF property associated with the uri
  68754. * @param uri The uri to load
  68755. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68756. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68757. /**
  68758. * Define this method to modify the default behavior when loading buffer views.
  68759. * @param context The context when loading the asset
  68760. * @param bufferView The glTF buffer view property
  68761. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68762. */
  68763. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  68764. /**
  68765. * Define this method to modify the default behavior when loading buffers.
  68766. * @param context The context when loading the asset
  68767. * @param buffer The glTF buffer property
  68768. * @param byteOffset The byte offset to load
  68769. * @param byteLength The byte length to load
  68770. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68771. */
  68772. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  68773. }
  68774. }
  68775. declare module BABYLON.GLTF2 {
  68776. /**
  68777. * Helper class for working with arrays when loading the glTF asset
  68778. */
  68779. export class ArrayItem {
  68780. /**
  68781. * Gets an item from the given array.
  68782. * @param context The context when loading the asset
  68783. * @param array The array to get the item from
  68784. * @param index The index to the array
  68785. * @returns The array item
  68786. */
  68787. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  68788. /**
  68789. * Assign an `index` field to each item of the given array.
  68790. * @param array The array of items
  68791. */
  68792. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  68793. }
  68794. /**
  68795. * The glTF 2.0 loader
  68796. */
  68797. export class GLTFLoader implements IGLTFLoader {
  68798. /** @hidden */ private _completePromises: Promise<any>[];
  68799. private _disposed;
  68800. private _parent;
  68801. private _state;
  68802. private _extensions;
  68803. private _rootUrl;
  68804. private _fileName;
  68805. private _uniqueRootUrl;
  68806. private _gltf;
  68807. private _bin;
  68808. private _babylonScene;
  68809. private _rootBabylonMesh;
  68810. private _defaultBabylonMaterialData;
  68811. private _progressCallback?;
  68812. private _requests;
  68813. private static readonly _DefaultSampler;
  68814. private static _RegisteredExtensions;
  68815. /**
  68816. * Registers a loader extension.
  68817. * @param name The name of the loader extension.
  68818. * @param factory The factory function that creates the loader extension.
  68819. */
  68820. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  68821. /**
  68822. * Unregisters a loader extension.
  68823. * @param name The name of the loader extension.
  68824. * @returns A boolean indicating whether the extension has been unregistered
  68825. */
  68826. static UnregisterExtension(name: string): boolean;
  68827. /**
  68828. * Gets the loader state.
  68829. */
  68830. readonly state: Nullable<GLTFLoaderState>;
  68831. /**
  68832. * The object that represents the glTF JSON.
  68833. */
  68834. readonly gltf: IGLTF;
  68835. /**
  68836. * The BIN chunk of a binary glTF.
  68837. */
  68838. readonly bin: Nullable<IDataBuffer>;
  68839. /**
  68840. * The parent file loader.
  68841. */
  68842. readonly parent: GLTFFileLoader;
  68843. /**
  68844. * The Babylon scene when loading the asset.
  68845. */
  68846. readonly babylonScene: Scene;
  68847. /**
  68848. * The root Babylon mesh when loading the asset.
  68849. */
  68850. readonly rootBabylonMesh: Mesh;
  68851. /** @hidden */
  68852. constructor(parent: GLTFFileLoader);
  68853. /** @hidden */
  68854. dispose(): void;
  68855. /** @hidden */
  68856. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68857. meshes: AbstractMesh[];
  68858. particleSystems: IParticleSystem[];
  68859. skeletons: Skeleton[];
  68860. animationGroups: AnimationGroup[];
  68861. }>;
  68862. /** @hidden */
  68863. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68864. private _loadAsync;
  68865. private _loadData;
  68866. private _setupData;
  68867. private _loadExtensions;
  68868. private _checkExtensions;
  68869. private _setState;
  68870. private _createRootNode;
  68871. /**
  68872. * Loads a glTF scene.
  68873. * @param context The context when loading the asset
  68874. * @param scene The glTF scene property
  68875. * @returns A promise that resolves when the load is complete
  68876. */
  68877. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  68878. private _forEachPrimitive;
  68879. private _getMeshes;
  68880. private _getSkeletons;
  68881. private _getAnimationGroups;
  68882. private _startAnimations;
  68883. /**
  68884. * Loads a glTF node.
  68885. * @param context The context when loading the asset
  68886. * @param node The glTF node property
  68887. * @param assign A function called synchronously after parsing the glTF properties
  68888. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  68889. */
  68890. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  68891. private _loadMeshAsync;
  68892. /**
  68893. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68894. * @param context The context when loading the asset
  68895. * @param name The mesh name when loading the asset
  68896. * @param node The glTF node when loading the asset
  68897. * @param mesh The glTF mesh when loading the asset
  68898. * @param primitive The glTF mesh primitive property
  68899. * @param assign A function called synchronously after parsing the glTF properties
  68900. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68901. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68902. private _loadVertexDataAsync;
  68903. private _createMorphTargets;
  68904. private _loadMorphTargetsAsync;
  68905. private _loadMorphTargetVertexDataAsync;
  68906. private static _LoadTransform;
  68907. private _loadSkinAsync;
  68908. private _loadBones;
  68909. private _loadBone;
  68910. private _loadSkinInverseBindMatricesDataAsync;
  68911. private _updateBoneMatrices;
  68912. private _getNodeMatrix;
  68913. /**
  68914. * Loads a glTF camera.
  68915. * @param context The context when loading the asset
  68916. * @param camera The glTF camera property
  68917. * @param assign A function called synchronously after parsing the glTF properties
  68918. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  68919. */
  68920. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  68921. private _loadAnimationsAsync;
  68922. /**
  68923. * Loads a glTF animation.
  68924. * @param context The context when loading the asset
  68925. * @param animation The glTF animation property
  68926. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  68927. */
  68928. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  68929. /**
  68930. * @hidden Loads a glTF animation channel.
  68931. * @param context The context when loading the asset
  68932. * @param animationContext The context of the animation when loading the asset
  68933. * @param animation The glTF animation property
  68934. * @param channel The glTF animation channel property
  68935. * @param babylonAnimationGroup The babylon animation group property
  68936. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  68937. * @returns A void promise when the channel load is complete
  68938. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  68939. private _loadAnimationSamplerAsync;
  68940. private _loadBufferAsync;
  68941. /**
  68942. * Loads a glTF buffer view.
  68943. * @param context The context when loading the asset
  68944. * @param bufferView The glTF buffer view property
  68945. * @returns A promise that resolves with the loaded data when the load is complete
  68946. */
  68947. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68948. private _loadAccessorAsync;
  68949. private _loadFloatAccessorAsync;
  68950. private _loadIndicesAccessorAsync;
  68951. private _loadVertexBufferViewAsync;
  68952. private _loadVertexAccessorAsync;
  68953. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68954. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68955. private _createDefaultMaterial;
  68956. /**
  68957. * Creates a Babylon material from a glTF material.
  68958. * @param context The context when loading the asset
  68959. * @param material The glTF material property
  68960. * @param babylonDrawMode The draw mode for the Babylon material
  68961. * @returns The Babylon material
  68962. */
  68963. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68964. /**
  68965. * Loads properties from a glTF material into a Babylon material.
  68966. * @param context The context when loading the asset
  68967. * @param material The glTF material property
  68968. * @param babylonMaterial The Babylon material
  68969. * @returns A promise that resolves when the load is complete
  68970. */
  68971. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68972. /**
  68973. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68974. * @param context The context when loading the asset
  68975. * @param material The glTF material property
  68976. * @param babylonMaterial The Babylon material
  68977. * @returns A promise that resolves when the load is complete
  68978. */
  68979. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68980. /**
  68981. * Loads the alpha properties from a glTF material into a Babylon material.
  68982. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68983. * @param context The context when loading the asset
  68984. * @param material The glTF material property
  68985. * @param babylonMaterial The Babylon material
  68986. */
  68987. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68988. /**
  68989. * Loads a glTF texture info.
  68990. * @param context The context when loading the asset
  68991. * @param textureInfo The glTF texture info property
  68992. * @param assign A function called synchronously after parsing the glTF properties
  68993. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68994. */
  68995. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68996. private _loadTextureAsync;
  68997. private _loadSampler;
  68998. /**
  68999. * Loads a glTF image.
  69000. * @param context The context when loading the asset
  69001. * @param image The glTF image property
  69002. * @returns A promise that resolves with the loaded data when the load is complete
  69003. */
  69004. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  69005. /**
  69006. * Loads a glTF uri.
  69007. * @param context The context when loading the asset
  69008. * @param property The glTF property associated with the uri
  69009. * @param uri The base64 or relative uri
  69010. * @returns A promise that resolves with the loaded data when the load is complete
  69011. */
  69012. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  69013. private _onProgress;
  69014. /**
  69015. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  69016. * @param babylonObject the Babylon object with metadata
  69017. * @param pointer the JSON pointer
  69018. */
  69019. static AddPointerMetadata(babylonObject: {
  69020. metadata: any;
  69021. }, pointer: string): void;
  69022. private static _GetTextureWrapMode;
  69023. private static _GetTextureSamplingMode;
  69024. private static _GetTypedArrayConstructor;
  69025. private static _GetTypedArray;
  69026. private static _GetNumComponents;
  69027. private static _ValidateUri;
  69028. private static _GetDrawMode;
  69029. private _compileMaterialsAsync;
  69030. private _compileShadowGeneratorsAsync;
  69031. private _forEachExtensions;
  69032. private _applyExtensions;
  69033. private _extensionsOnLoading;
  69034. private _extensionsOnReady;
  69035. private _extensionsLoadSceneAsync;
  69036. private _extensionsLoadNodeAsync;
  69037. private _extensionsLoadCameraAsync;
  69038. private _extensionsLoadVertexDataAsync;
  69039. private _extensionsLoadMeshPrimitiveAsync;
  69040. private _extensionsLoadMaterialAsync;
  69041. private _extensionsCreateMaterial;
  69042. private _extensionsLoadMaterialPropertiesAsync;
  69043. private _extensionsLoadTextureInfoAsync;
  69044. private _extensionsLoadAnimationAsync;
  69045. private _extensionsLoadSkinAsync;
  69046. private _extensionsLoadUriAsync;
  69047. private _extensionsLoadBufferViewAsync;
  69048. private _extensionsLoadBufferAsync;
  69049. /**
  69050. * Helper method called by a loader extension to load an glTF extension.
  69051. * @param context The context when loading the asset
  69052. * @param property The glTF property to load the extension from
  69053. * @param extensionName The name of the extension to load
  69054. * @param actionAsync The action to run
  69055. * @returns The promise returned by actionAsync or null if the extension does not exist
  69056. */
  69057. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69058. /**
  69059. * Helper method called by a loader extension to load a glTF extra.
  69060. * @param context The context when loading the asset
  69061. * @param property The glTF property to load the extra from
  69062. * @param extensionName The name of the extension to load
  69063. * @param actionAsync The action to run
  69064. * @returns The promise returned by actionAsync or null if the extra does not exist
  69065. */
  69066. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69067. /**
  69068. * Checks for presence of an extension.
  69069. * @param name The name of the extension to check
  69070. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  69071. */
  69072. isExtensionUsed(name: string): boolean;
  69073. /**
  69074. * Increments the indentation level and logs a message.
  69075. * @param message The message to log
  69076. */
  69077. logOpen(message: string): void;
  69078. /**
  69079. * Decrements the indentation level.
  69080. */
  69081. logClose(): void;
  69082. /**
  69083. * Logs a message
  69084. * @param message The message to log
  69085. */
  69086. log(message: string): void;
  69087. /**
  69088. * Starts a performance counter.
  69089. * @param counterName The name of the performance counter
  69090. */
  69091. startPerformanceCounter(counterName: string): void;
  69092. /**
  69093. * Ends a performance counter.
  69094. * @param counterName The name of the performance counter
  69095. */
  69096. endPerformanceCounter(counterName: string): void;
  69097. }
  69098. }
  69099. declare module BABYLON.GLTF2.Loader.Extensions {
  69100. /**
  69101. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  69102. */
  69103. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  69104. /**
  69105. * The name of this extension.
  69106. */
  69107. readonly name: string;
  69108. /**
  69109. * Defines whether this extension is enabled.
  69110. */
  69111. enabled: boolean;
  69112. private _loader;
  69113. private _lights?;
  69114. /** @hidden */
  69115. constructor(loader: GLTFLoader);
  69116. /** @hidden */
  69117. dispose(): void;
  69118. /** @hidden */
  69119. onLoading(): void;
  69120. /** @hidden */
  69121. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69122. private _loadLightAsync;
  69123. }
  69124. }
  69125. declare module BABYLON.GLTF2.Loader.Extensions {
  69126. /**
  69127. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  69128. */
  69129. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  69130. /**
  69131. * The name of this extension.
  69132. */
  69133. readonly name: string;
  69134. /**
  69135. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  69136. */
  69137. dracoCompression?: DracoCompression;
  69138. /**
  69139. * Defines whether this extension is enabled.
  69140. */
  69141. enabled: boolean;
  69142. private _loader;
  69143. /** @hidden */
  69144. constructor(loader: GLTFLoader);
  69145. /** @hidden */
  69146. dispose(): void;
  69147. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69148. }
  69149. }
  69150. declare module BABYLON.GLTF2.Loader.Extensions {
  69151. /**
  69152. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69153. */
  69154. export class KHR_lights implements IGLTFLoaderExtension {
  69155. /**
  69156. * The name of this extension.
  69157. */
  69158. readonly name: string;
  69159. /**
  69160. * Defines whether this extension is enabled.
  69161. */
  69162. enabled: boolean;
  69163. private _loader;
  69164. private _lights?;
  69165. /** @hidden */
  69166. constructor(loader: GLTFLoader);
  69167. /** @hidden */
  69168. dispose(): void;
  69169. /** @hidden */
  69170. onLoading(): void;
  69171. /** @hidden */
  69172. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69173. }
  69174. }
  69175. declare module BABYLON.GLTF2.Loader.Extensions {
  69176. /**
  69177. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  69178. */
  69179. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  69180. /**
  69181. * The name of this extension.
  69182. */
  69183. readonly name: string;
  69184. /**
  69185. * Defines whether this extension is enabled.
  69186. */
  69187. enabled: boolean;
  69188. /**
  69189. * Defines a number that determines the order the extensions are applied.
  69190. */
  69191. order: number;
  69192. private _loader;
  69193. /** @hidden */
  69194. constructor(loader: GLTFLoader);
  69195. /** @hidden */
  69196. dispose(): void;
  69197. /** @hidden */
  69198. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69199. private _loadSpecularGlossinessPropertiesAsync;
  69200. }
  69201. }
  69202. declare module BABYLON.GLTF2.Loader.Extensions {
  69203. /**
  69204. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  69205. */
  69206. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  69207. /**
  69208. * The name of this extension.
  69209. */
  69210. readonly name: string;
  69211. /**
  69212. * Defines whether this extension is enabled.
  69213. */
  69214. enabled: boolean;
  69215. /**
  69216. * Defines a number that determines the order the extensions are applied.
  69217. */
  69218. order: number;
  69219. private _loader;
  69220. /** @hidden */
  69221. constructor(loader: GLTFLoader);
  69222. /** @hidden */
  69223. dispose(): void;
  69224. /** @hidden */
  69225. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69226. private _loadUnlitPropertiesAsync;
  69227. }
  69228. }
  69229. declare module BABYLON.GLTF2.Loader.Extensions {
  69230. /**
  69231. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  69232. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  69233. * !!! Experimental Extension Subject to Changes !!!
  69234. */
  69235. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  69236. /**
  69237. * The name of this extension.
  69238. */
  69239. readonly name: string;
  69240. /**
  69241. * Defines whether this extension is enabled.
  69242. */
  69243. enabled: boolean;
  69244. /**
  69245. * Defines a number that determines the order the extensions are applied.
  69246. */
  69247. order: number;
  69248. private _loader;
  69249. /** @hidden */
  69250. constructor(loader: GLTFLoader);
  69251. /** @hidden */
  69252. dispose(): void;
  69253. /** @hidden */
  69254. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69255. private _loadClearCoatPropertiesAsync;
  69256. }
  69257. }
  69258. declare module BABYLON.GLTF2.Loader.Extensions {
  69259. /**
  69260. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  69261. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  69262. * !!! Experimental Extension Subject to Changes !!!
  69263. */
  69264. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  69265. /**
  69266. * The name of this extension.
  69267. */
  69268. readonly name: string;
  69269. /**
  69270. * Defines whether this extension is enabled.
  69271. */
  69272. enabled: boolean;
  69273. /**
  69274. * Defines a number that determines the order the extensions are applied.
  69275. */
  69276. order: number;
  69277. private _loader;
  69278. /** @hidden */
  69279. constructor(loader: GLTFLoader);
  69280. /** @hidden */
  69281. dispose(): void;
  69282. /** @hidden */
  69283. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69284. private _loadSheenPropertiesAsync;
  69285. }
  69286. }
  69287. declare module BABYLON.GLTF2.Loader.Extensions {
  69288. /**
  69289. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  69290. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  69291. * !!! Experimental Extension Subject to Changes !!!
  69292. */
  69293. export class KHR_materials_specular implements IGLTFLoaderExtension {
  69294. /**
  69295. * The name of this extension.
  69296. */
  69297. readonly name: string;
  69298. /**
  69299. * Defines whether this extension is enabled.
  69300. */
  69301. enabled: boolean;
  69302. /**
  69303. * Defines a number that determines the order the extensions are applied.
  69304. */
  69305. order: number;
  69306. private _loader;
  69307. /** @hidden */
  69308. constructor(loader: GLTFLoader);
  69309. /** @hidden */
  69310. dispose(): void;
  69311. /** @hidden */
  69312. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69313. private _loadSpecularPropertiesAsync;
  69314. }
  69315. }
  69316. declare module BABYLON.GLTF2.Loader.Extensions {
  69317. /**
  69318. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  69319. */
  69320. export class KHR_texture_transform implements IGLTFLoaderExtension {
  69321. /**
  69322. * The name of this extension.
  69323. */
  69324. readonly name: string;
  69325. /**
  69326. * Defines whether this extension is enabled.
  69327. */
  69328. enabled: boolean;
  69329. private _loader;
  69330. /** @hidden */
  69331. constructor(loader: GLTFLoader);
  69332. /** @hidden */
  69333. dispose(): void;
  69334. /** @hidden */
  69335. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69336. }
  69337. }
  69338. declare module BABYLON.GLTF2.Loader.Extensions {
  69339. /**
  69340. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  69341. */
  69342. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  69343. /**
  69344. * The name of this extension.
  69345. */
  69346. readonly name: string;
  69347. /**
  69348. * Defines whether this extension is enabled.
  69349. */
  69350. enabled: boolean;
  69351. private _loader;
  69352. private _clips;
  69353. private _emitters;
  69354. /** @hidden */
  69355. constructor(loader: GLTFLoader);
  69356. /** @hidden */
  69357. dispose(): void;
  69358. /** @hidden */
  69359. onLoading(): void;
  69360. /** @hidden */
  69361. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69362. /** @hidden */
  69363. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69364. /** @hidden */
  69365. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69366. private _loadClipAsync;
  69367. private _loadEmitterAsync;
  69368. private _getEventAction;
  69369. private _loadAnimationEventAsync;
  69370. }
  69371. }
  69372. declare module BABYLON.GLTF2.Loader.Extensions {
  69373. /**
  69374. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  69375. */
  69376. export class MSFT_lod implements IGLTFLoaderExtension {
  69377. /**
  69378. * The name of this extension.
  69379. */
  69380. readonly name: string;
  69381. /**
  69382. * Defines whether this extension is enabled.
  69383. */
  69384. enabled: boolean;
  69385. /**
  69386. * Defines a number that determines the order the extensions are applied.
  69387. */
  69388. order: number;
  69389. /**
  69390. * Maximum number of LODs to load, starting from the lowest LOD.
  69391. */
  69392. maxLODsToLoad: number;
  69393. /**
  69394. * Observable raised when all node LODs of one level are loaded.
  69395. * The event data is the index of the loaded LOD starting from zero.
  69396. * Dispose the loader to cancel the loading of the next level of LODs.
  69397. */
  69398. onNodeLODsLoadedObservable: Observable<number>;
  69399. /**
  69400. * Observable raised when all material LODs of one level are loaded.
  69401. * The event data is the index of the loaded LOD starting from zero.
  69402. * Dispose the loader to cancel the loading of the next level of LODs.
  69403. */
  69404. onMaterialLODsLoadedObservable: Observable<number>;
  69405. private _loader;
  69406. private _nodeIndexLOD;
  69407. private _nodeSignalLODs;
  69408. private _nodePromiseLODs;
  69409. private _materialIndexLOD;
  69410. private _materialSignalLODs;
  69411. private _materialPromiseLODs;
  69412. private _indexLOD;
  69413. private _bufferLODs;
  69414. /** @hidden */
  69415. constructor(loader: GLTFLoader);
  69416. /** @hidden */
  69417. dispose(): void;
  69418. /** @hidden */
  69419. onReady(): void;
  69420. /** @hidden */
  69421. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69422. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69423. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69424. /** @hidden */
  69425. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  69426. private _loadBufferLOD;
  69427. /**
  69428. * Gets an array of LOD properties from lowest to highest.
  69429. */
  69430. private _getLODs;
  69431. private _disposeUnusedMaterials;
  69432. }
  69433. }
  69434. declare module BABYLON.GLTF2.Loader.Extensions {
  69435. /** @hidden */
  69436. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  69437. readonly name: string;
  69438. enabled: boolean;
  69439. private _loader;
  69440. constructor(loader: GLTFLoader);
  69441. dispose(): void;
  69442. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69443. }
  69444. }
  69445. declare module BABYLON.GLTF2.Loader.Extensions {
  69446. /** @hidden */
  69447. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  69448. readonly name: string;
  69449. enabled: boolean;
  69450. private _loader;
  69451. constructor(loader: GLTFLoader);
  69452. dispose(): void;
  69453. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69454. }
  69455. }
  69456. declare module BABYLON.GLTF2.Loader.Extensions {
  69457. /**
  69458. * Store glTF extras (if present) in BJS objects' metadata
  69459. */
  69460. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  69461. /**
  69462. * The name of this extension.
  69463. */
  69464. readonly name: string;
  69465. /**
  69466. * Defines whether this extension is enabled.
  69467. */
  69468. enabled: boolean;
  69469. private _loader;
  69470. private _assignExtras;
  69471. /** @hidden */
  69472. constructor(loader: GLTFLoader);
  69473. /** @hidden */
  69474. dispose(): void;
  69475. /** @hidden */
  69476. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69477. /** @hidden */
  69478. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69479. /** @hidden */
  69480. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69481. }
  69482. }
  69483. declare module BABYLON {
  69484. /**
  69485. * Class reading and parsing the MTL file bundled with the obj file.
  69486. */
  69487. export class MTLFileLoader {
  69488. /**
  69489. * All material loaded from the mtl will be set here
  69490. */
  69491. materials: StandardMaterial[];
  69492. /**
  69493. * This function will read the mtl file and create each material described inside
  69494. * This function could be improve by adding :
  69495. * -some component missing (Ni, Tf...)
  69496. * -including the specific options available
  69497. *
  69498. * @param scene defines the scene the material will be created in
  69499. * @param data defines the mtl data to parse
  69500. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  69501. */
  69502. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  69503. /**
  69504. * Gets the texture for the material.
  69505. *
  69506. * If the material is imported from input file,
  69507. * We sanitize the url to ensure it takes the textre from aside the material.
  69508. *
  69509. * @param rootUrl The root url to load from
  69510. * @param value The value stored in the mtl
  69511. * @return The Texture
  69512. */
  69513. private static _getTexture;
  69514. }
  69515. /**
  69516. * Options for loading OBJ/MTL files
  69517. */
  69518. type MeshLoadOptions = {
  69519. /**
  69520. * Defines if UVs are optimized by default during load.
  69521. */
  69522. OptimizeWithUV: boolean;
  69523. /**
  69524. * Defines custom scaling of UV coordinates of loaded meshes.
  69525. */
  69526. UVScaling: Vector2;
  69527. /**
  69528. * Invert model on y-axis (does a model scaling inversion)
  69529. */
  69530. InvertY: boolean;
  69531. /**
  69532. * Invert Y-Axis of referenced textures on load
  69533. */
  69534. InvertTextureY: boolean;
  69535. /**
  69536. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69537. */
  69538. ImportVertexColors: boolean;
  69539. /**
  69540. * Compute the normals for the model, even if normals are present in the file.
  69541. */
  69542. ComputeNormals: boolean;
  69543. /**
  69544. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69545. */
  69546. SkipMaterials: boolean;
  69547. /**
  69548. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69549. */
  69550. MaterialLoadingFailsSilently: boolean;
  69551. };
  69552. /**
  69553. * OBJ file type loader.
  69554. * This is a babylon scene loader plugin.
  69555. */
  69556. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  69557. /**
  69558. * Defines if UVs are optimized by default during load.
  69559. */
  69560. static OPTIMIZE_WITH_UV: boolean;
  69561. /**
  69562. * Invert model on y-axis (does a model scaling inversion)
  69563. */
  69564. static INVERT_Y: boolean;
  69565. /**
  69566. * Invert Y-Axis of referenced textures on load
  69567. */
  69568. static INVERT_TEXTURE_Y: boolean;
  69569. /**
  69570. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69571. */
  69572. static IMPORT_VERTEX_COLORS: boolean;
  69573. /**
  69574. * Compute the normals for the model, even if normals are present in the file.
  69575. */
  69576. static COMPUTE_NORMALS: boolean;
  69577. /**
  69578. * Defines custom scaling of UV coordinates of loaded meshes.
  69579. */
  69580. static UV_SCALING: Vector2;
  69581. /**
  69582. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69583. */
  69584. static SKIP_MATERIALS: boolean;
  69585. /**
  69586. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69587. *
  69588. * Defaults to true for backwards compatibility.
  69589. */
  69590. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  69591. /**
  69592. * Defines the name of the plugin.
  69593. */
  69594. name: string;
  69595. /**
  69596. * Defines the extension the plugin is able to load.
  69597. */
  69598. extensions: string;
  69599. /** @hidden */
  69600. obj: RegExp;
  69601. /** @hidden */
  69602. group: RegExp;
  69603. /** @hidden */
  69604. mtllib: RegExp;
  69605. /** @hidden */
  69606. usemtl: RegExp;
  69607. /** @hidden */
  69608. smooth: RegExp;
  69609. /** @hidden */
  69610. vertexPattern: RegExp;
  69611. /** @hidden */
  69612. normalPattern: RegExp;
  69613. /** @hidden */
  69614. uvPattern: RegExp;
  69615. /** @hidden */
  69616. facePattern1: RegExp;
  69617. /** @hidden */
  69618. facePattern2: RegExp;
  69619. /** @hidden */
  69620. facePattern3: RegExp;
  69621. /** @hidden */
  69622. facePattern4: RegExp;
  69623. /** @hidden */
  69624. facePattern5: RegExp;
  69625. private _meshLoadOptions;
  69626. /**
  69627. * Creates loader for .OBJ files
  69628. *
  69629. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  69630. */
  69631. constructor(meshLoadOptions?: MeshLoadOptions);
  69632. private static readonly currentMeshLoadOptions;
  69633. /**
  69634. * Calls synchronously the MTL file attached to this obj.
  69635. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69636. * Without this function materials are not displayed in the first frame (but displayed after).
  69637. * In consequence it is impossible to get material information in your HTML file
  69638. *
  69639. * @param url The URL of the MTL file
  69640. * @param rootUrl
  69641. * @param onSuccess Callback function to be called when the MTL file is loaded
  69642. * @private
  69643. */
  69644. private _loadMTL;
  69645. /**
  69646. * Instantiates a OBJ file loader plugin.
  69647. * @returns the created plugin
  69648. */
  69649. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69650. /**
  69651. * If the data string can be loaded directly.
  69652. *
  69653. * @param data string containing the file data
  69654. * @returns if the data can be loaded directly
  69655. */
  69656. canDirectLoad(data: string): boolean;
  69657. /**
  69658. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69659. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69660. * @param scene the scene the meshes should be added to
  69661. * @param data the OBJ data to load
  69662. * @param rootUrl root url to load from
  69663. * @param onProgress event that fires when loading progress has occured
  69664. * @param fileName Defines the name of the file to load
  69665. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69666. */
  69667. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69668. meshes: AbstractMesh[];
  69669. particleSystems: IParticleSystem[];
  69670. skeletons: Skeleton[];
  69671. animationGroups: AnimationGroup[];
  69672. }>;
  69673. /**
  69674. * Imports all objects from the loaded OBJ data and adds them to the scene
  69675. * @param scene the scene the objects should be added to
  69676. * @param data the OBJ data to load
  69677. * @param rootUrl root url to load from
  69678. * @param onProgress event that fires when loading progress has occured
  69679. * @param fileName Defines the name of the file to load
  69680. * @returns a promise which completes when objects have been loaded to the scene
  69681. */
  69682. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69683. /**
  69684. * Load into an asset container.
  69685. * @param scene The scene to load into
  69686. * @param data The data to import
  69687. * @param rootUrl The root url for scene and resources
  69688. * @param onProgress The callback when the load progresses
  69689. * @param fileName Defines the name of the file to load
  69690. * @returns The loaded asset container
  69691. */
  69692. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69693. /**
  69694. * Read the OBJ file and create an Array of meshes.
  69695. * Each mesh contains all information given by the OBJ and the MTL file.
  69696. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69697. *
  69698. * @param meshesNames
  69699. * @param scene Scene The scene where are displayed the data
  69700. * @param data String The content of the obj file
  69701. * @param rootUrl String The path to the folder
  69702. * @returns Array<AbstractMesh>
  69703. * @private
  69704. */
  69705. private _parseSolid;
  69706. }
  69707. }
  69708. declare module BABYLON {
  69709. /**
  69710. * STL file type loader.
  69711. * This is a babylon scene loader plugin.
  69712. */
  69713. export class STLFileLoader implements ISceneLoaderPlugin {
  69714. /** @hidden */
  69715. solidPattern: RegExp;
  69716. /** @hidden */
  69717. facetsPattern: RegExp;
  69718. /** @hidden */
  69719. normalPattern: RegExp;
  69720. /** @hidden */
  69721. vertexPattern: RegExp;
  69722. /**
  69723. * Defines the name of the plugin.
  69724. */
  69725. name: string;
  69726. /**
  69727. * Defines the extensions the stl loader is able to load.
  69728. * force data to come in as an ArrayBuffer
  69729. * we'll convert to string if it looks like it's an ASCII .stl
  69730. */
  69731. extensions: ISceneLoaderPluginExtensions;
  69732. /**
  69733. * Import meshes into a scene.
  69734. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69735. * @param scene The scene to import into
  69736. * @param data The data to import
  69737. * @param rootUrl The root url for scene and resources
  69738. * @param meshes The meshes array to import into
  69739. * @param particleSystems The particle systems array to import into
  69740. * @param skeletons The skeletons array to import into
  69741. * @param onError The callback when import fails
  69742. * @returns True if successful or false otherwise
  69743. */
  69744. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69745. /**
  69746. * Load into a scene.
  69747. * @param scene The scene to load into
  69748. * @param data The data to import
  69749. * @param rootUrl The root url for scene and resources
  69750. * @param onError The callback when import fails
  69751. * @returns true if successful or false otherwise
  69752. */
  69753. load(scene: Scene, data: any, rootUrl: string): boolean;
  69754. /**
  69755. * Load into an asset container.
  69756. * @param scene The scene to load into
  69757. * @param data The data to import
  69758. * @param rootUrl The root url for scene and resources
  69759. * @param onError The callback when import fails
  69760. * @returns The loaded asset container
  69761. */
  69762. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69763. private _isBinary;
  69764. private _parseBinary;
  69765. private _parseASCII;
  69766. }
  69767. }
  69768. declare module BABYLON {
  69769. /**
  69770. * Class for generating OBJ data from a Babylon scene.
  69771. */
  69772. export class OBJExport {
  69773. /**
  69774. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69775. * @param mesh defines the list of meshes to serialize
  69776. * @param materials defines if materials should be exported
  69777. * @param matlibname defines the name of the associated mtl file
  69778. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69779. * @returns the OBJ content
  69780. */
  69781. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69782. /**
  69783. * Exports the material(s) of a mesh in .MTL file format (text)
  69784. * @param mesh defines the mesh to extract the material from
  69785. * @returns the mtl content
  69786. */
  69787. static MTL(mesh: Mesh): string;
  69788. }
  69789. }
  69790. declare module BABYLON {
  69791. /** @hidden */
  69792. export var __IGLTFExporterExtension: number;
  69793. /**
  69794. * Interface for extending the exporter
  69795. * @hidden
  69796. */
  69797. export interface IGLTFExporterExtension {
  69798. /**
  69799. * The name of this extension
  69800. */
  69801. readonly name: string;
  69802. /**
  69803. * Defines whether this extension is enabled
  69804. */
  69805. enabled: boolean;
  69806. /**
  69807. * Defines whether this extension is required
  69808. */
  69809. required: boolean;
  69810. }
  69811. }
  69812. declare module BABYLON.GLTF2.Exporter {
  69813. /** @hidden */
  69814. export var __IGLTFExporterExtensionV2: number;
  69815. /**
  69816. * Interface for a glTF exporter extension
  69817. * @hidden
  69818. */
  69819. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  69820. /**
  69821. * Define this method to modify the default behavior before exporting a texture
  69822. * @param context The context when loading the asset
  69823. * @param babylonTexture The glTF texture info property
  69824. * @param mimeType The mime-type of the generated image
  69825. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  69826. */
  69827. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69828. /**
  69829. * Define this method to modify the default behavior when exporting texture info
  69830. * @param context The context when loading the asset
  69831. * @param meshPrimitive glTF mesh primitive
  69832. * @param babylonSubMesh Babylon submesh
  69833. * @param binaryWriter glTF serializer binary writer instance
  69834. * @returns nullable IMeshPrimitive promise
  69835. */
  69836. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69837. /**
  69838. * Define this method to modify the default behavior when exporting a node
  69839. * @param context The context when exporting the node
  69840. * @param node glTF node
  69841. * @param babylonNode BabylonJS node
  69842. * @returns nullable INode promise
  69843. */
  69844. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69845. /**
  69846. * Called after the exporter state changes to EXPORTING
  69847. */
  69848. onExporting?(): void;
  69849. }
  69850. }
  69851. declare module BABYLON.GLTF2.Exporter {
  69852. /**
  69853. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  69854. * @hidden
  69855. */
  69856. export class _GLTFMaterialExporter {
  69857. /**
  69858. * Represents the dielectric specular values for R, G and B
  69859. */
  69860. private static readonly _DielectricSpecular;
  69861. /**
  69862. * Allows the maximum specular power to be defined for material calculations
  69863. */
  69864. private static readonly _MaxSpecularPower;
  69865. /**
  69866. * Mapping to store textures
  69867. */
  69868. private _textureMap;
  69869. /**
  69870. * Numeric tolerance value
  69871. */
  69872. private static readonly _Epsilon;
  69873. /**
  69874. * Reference to the glTF Exporter
  69875. */
  69876. private _exporter;
  69877. constructor(exporter: _Exporter);
  69878. /**
  69879. * Specifies if two colors are approximately equal in value
  69880. * @param color1 first color to compare to
  69881. * @param color2 second color to compare to
  69882. * @param epsilon threshold value
  69883. */
  69884. private static FuzzyEquals;
  69885. /**
  69886. * Gets the materials from a Babylon scene and converts them to glTF materials
  69887. * @param scene babylonjs scene
  69888. * @param mimeType texture mime type
  69889. * @param images array of images
  69890. * @param textures array of textures
  69891. * @param materials array of materials
  69892. * @param imageData mapping of texture names to base64 textures
  69893. * @param hasTextureCoords specifies if texture coordinates are present on the material
  69894. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69895. /**
  69896. * Makes a copy of the glTF material without the texture parameters
  69897. * @param originalMaterial original glTF material
  69898. * @returns glTF material without texture parameters
  69899. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  69900. /**
  69901. * Specifies if the material has any texture parameters present
  69902. * @param material glTF Material
  69903. * @returns boolean specifying if texture parameters are present
  69904. */ private _hasTexturesPresent(material: IMaterial): boolean;
  69905. /**
  69906. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  69907. * @param babylonStandardMaterial
  69908. * @returns glTF Metallic Roughness Material representation
  69909. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  69910. /**
  69911. * Computes the metallic factor
  69912. * @param diffuse diffused value
  69913. * @param specular specular value
  69914. * @param oneMinusSpecularStrength one minus the specular strength
  69915. * @returns metallic value
  69916. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  69917. /**
  69918. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  69919. * @param glTFMaterial glTF material
  69920. * @param babylonMaterial Babylon material
  69921. */
  69922. private static _SetAlphaMode;
  69923. /**
  69924. * Converts a Babylon Standard Material to a glTF Material
  69925. * @param babylonStandardMaterial BJS Standard Material
  69926. * @param mimeType mime type to use for the textures
  69927. * @param images array of glTF image interfaces
  69928. * @param textures array of glTF texture interfaces
  69929. * @param materials array of glTF material interfaces
  69930. * @param imageData map of image file name to data
  69931. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69932. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69933. /**
  69934. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69935. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  69936. * @param mimeType mime type to use for the textures
  69937. * @param images array of glTF image interfaces
  69938. * @param textures array of glTF texture interfaces
  69939. * @param materials array of glTF material interfaces
  69940. * @param imageData map of image file name to data
  69941. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69942. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69943. /**
  69944. * Converts an image typed array buffer to a base64 image
  69945. * @param buffer typed array buffer
  69946. * @param width width of the image
  69947. * @param height height of the image
  69948. * @param mimeType mimetype of the image
  69949. * @returns base64 image string
  69950. */
  69951. private _createBase64FromCanvasAsync;
  69952. /**
  69953. * Generates a white texture based on the specified width and height
  69954. * @param width width of the texture in pixels
  69955. * @param height height of the texture in pixels
  69956. * @param scene babylonjs scene
  69957. * @returns white texture
  69958. */
  69959. private _createWhiteTexture;
  69960. /**
  69961. * 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
  69962. * @param texture1 first texture to resize
  69963. * @param texture2 second texture to resize
  69964. * @param scene babylonjs scene
  69965. * @returns resized textures or null
  69966. */
  69967. private _resizeTexturesToSameDimensions;
  69968. /**
  69969. * Converts an array of pixels to a Float32Array
  69970. * Throws an error if the pixel format is not supported
  69971. * @param pixels - array buffer containing pixel values
  69972. * @returns Float32 of pixels
  69973. */
  69974. private _convertPixelArrayToFloat32;
  69975. /**
  69976. * Convert Specular Glossiness Textures to Metallic Roughness
  69977. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  69978. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  69979. * @param diffuseTexture texture used to store diffuse information
  69980. * @param specularGlossinessTexture texture used to store specular and glossiness information
  69981. * @param factors specular glossiness material factors
  69982. * @param mimeType the mime type to use for the texture
  69983. * @returns pbr metallic roughness interface or null
  69984. */
  69985. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  69986. /**
  69987. * Converts specular glossiness material properties to metallic roughness
  69988. * @param specularGlossiness interface with specular glossiness material properties
  69989. * @returns interface with metallic roughness material properties
  69990. */
  69991. private _convertSpecularGlossinessToMetallicRoughness;
  69992. /**
  69993. * Calculates the surface reflectance, independent of lighting conditions
  69994. * @param color Color source to calculate brightness from
  69995. * @returns number representing the perceived brightness, or zero if color is undefined
  69996. */
  69997. private _getPerceivedBrightness;
  69998. /**
  69999. * Returns the maximum color component value
  70000. * @param color
  70001. * @returns maximum color component value, or zero if color is null or undefined
  70002. */
  70003. private _getMaxComponent;
  70004. /**
  70005. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  70006. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70007. * @param mimeType mime type to use for the textures
  70008. * @param images array of glTF image interfaces
  70009. * @param textures array of glTF texture interfaces
  70010. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70011. * @param imageData map of image file name to data
  70012. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70013. * @returns glTF PBR Metallic Roughness factors
  70014. */
  70015. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  70016. private _getGLTFTextureSampler;
  70017. private _getGLTFTextureWrapMode;
  70018. private _getGLTFTextureWrapModesSampler;
  70019. /**
  70020. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  70021. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70022. * @param mimeType mime type to use for the textures
  70023. * @param images array of glTF image interfaces
  70024. * @param textures array of glTF texture interfaces
  70025. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70026. * @param imageData map of image file name to data
  70027. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70028. * @returns glTF PBR Metallic Roughness factors
  70029. */
  70030. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  70031. /**
  70032. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70033. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70034. * @param mimeType mime type to use for the textures
  70035. * @param images array of glTF image interfaces
  70036. * @param textures array of glTF texture interfaces
  70037. * @param materials array of glTF material interfaces
  70038. * @param imageData map of image file name to data
  70039. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70040. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70041. private setMetallicRoughnessPbrMaterial;
  70042. private getPixelsFromTexture;
  70043. /**
  70044. * Extracts a texture from a Babylon texture into file data and glTF data
  70045. * @param babylonTexture Babylon texture to extract
  70046. * @param mimeType Mime Type of the babylonTexture
  70047. * @return glTF texture info, or null if the texture format is not supported
  70048. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70049. /**
  70050. * Builds a texture from base64 string
  70051. * @param base64Texture base64 texture string
  70052. * @param baseTextureName Name to use for the texture
  70053. * @param mimeType image mime type for the texture
  70054. * @param images array of images
  70055. * @param textures array of textures
  70056. * @param imageData map of image data
  70057. * @returns glTF texture info, or null if the texture format is not supported
  70058. */
  70059. private _getTextureInfoFromBase64;
  70060. }
  70061. }
  70062. declare module BABYLON {
  70063. /**
  70064. * Class for holding and downloading glTF file data
  70065. */
  70066. export class GLTFData {
  70067. /**
  70068. * Object which contains the file name as the key and its data as the value
  70069. */
  70070. glTFFiles: {
  70071. [fileName: string]: string | Blob;
  70072. };
  70073. /**
  70074. * Initializes the glTF file object
  70075. */
  70076. constructor();
  70077. /**
  70078. * Downloads the glTF data as files based on their names and data
  70079. */
  70080. downloadFiles(): void;
  70081. }
  70082. }
  70083. declare module BABYLON {
  70084. /**
  70085. * Holds a collection of exporter options and parameters
  70086. */
  70087. export interface IExportOptions {
  70088. /**
  70089. * Function which indicates whether a babylon node should be exported or not
  70090. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  70091. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  70092. */
  70093. shouldExportNode?(node: Node): boolean;
  70094. /**
  70095. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  70096. * @param metadata source metadata to read from
  70097. * @returns the data to store to glTF node extras
  70098. */
  70099. metadataSelector?(metadata: any): any;
  70100. /**
  70101. * The sample rate to bake animation curves
  70102. */
  70103. animationSampleRate?: number;
  70104. /**
  70105. * Begin serialization without waiting for the scene to be ready
  70106. */
  70107. exportWithoutWaitingForScene?: boolean;
  70108. }
  70109. /**
  70110. * Class for generating glTF data from a Babylon scene.
  70111. */
  70112. export class GLTF2Export {
  70113. /**
  70114. * Exports the geometry of the scene to .gltf file format asynchronously
  70115. * @param scene Babylon scene with scene hierarchy information
  70116. * @param filePrefix File prefix to use when generating the glTF file
  70117. * @param options Exporter options
  70118. * @returns Returns an object with a .gltf file and associates texture names
  70119. * as keys and their data and paths as values
  70120. */
  70121. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70122. private static _PreExportAsync;
  70123. private static _PostExportAsync;
  70124. /**
  70125. * Exports the geometry of the scene to .glb file format asychronously
  70126. * @param scene Babylon scene with scene hierarchy information
  70127. * @param filePrefix File prefix to use when generating glb file
  70128. * @param options Exporter options
  70129. * @returns Returns an object with a .glb filename as key and data as value
  70130. */
  70131. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70132. }
  70133. }
  70134. declare module BABYLON.GLTF2.Exporter {
  70135. /**
  70136. * @hidden
  70137. */
  70138. export class _GLTFUtilities {
  70139. /**
  70140. * Creates a buffer view based on the supplied arguments
  70141. * @param bufferIndex index value of the specified buffer
  70142. * @param byteOffset byte offset value
  70143. * @param byteLength byte length of the bufferView
  70144. * @param byteStride byte distance between conequential elements
  70145. * @param name name of the buffer view
  70146. * @returns bufferView for glTF
  70147. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  70148. /**
  70149. * Creates an accessor based on the supplied arguments
  70150. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  70151. * @param name The name of the accessor
  70152. * @param type The type of the accessor
  70153. * @param componentType The datatype of components in the attribute
  70154. * @param count The number of attributes referenced by this accessor
  70155. * @param byteOffset The offset relative to the start of the bufferView in bytes
  70156. * @param min Minimum value of each component in this attribute
  70157. * @param max Maximum value of each component in this attribute
  70158. * @returns accessor for glTF
  70159. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  70160. /**
  70161. * Calculates the minimum and maximum values of an array of position floats
  70162. * @param positions Positions array of a mesh
  70163. * @param vertexStart Starting vertex offset to calculate min and max values
  70164. * @param vertexCount Number of vertices to check for min and max values
  70165. * @returns min number array and max number array
  70166. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  70167. min: number[];
  70168. max: number[];
  70169. };
  70170. /**
  70171. * Converts a new right-handed Vector3
  70172. * @param vector vector3 array
  70173. * @returns right-handed Vector3
  70174. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  70175. /**
  70176. * Converts a Vector3 to right-handed
  70177. * @param vector Vector3 to convert to right-handed
  70178. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  70179. /**
  70180. * Converts a three element number array to right-handed
  70181. * @param vector number array to convert to right-handed
  70182. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  70183. /**
  70184. * Converts a new right-handed Vector3
  70185. * @param vector vector3 array
  70186. * @returns right-handed Vector3
  70187. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  70188. /**
  70189. * Converts a Vector3 to right-handed
  70190. * @param vector Vector3 to convert to right-handed
  70191. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  70192. /**
  70193. * Converts a three element number array to right-handed
  70194. * @param vector number array to convert to right-handed
  70195. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  70196. /**
  70197. * Converts a Vector4 to right-handed
  70198. * @param vector Vector4 to convert to right-handed
  70199. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  70200. /**
  70201. * Converts a Vector4 to right-handed
  70202. * @param vector Vector4 to convert to right-handed
  70203. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  70204. /**
  70205. * Converts a Quaternion to right-handed
  70206. * @param quaternion Source quaternion to convert to right-handed
  70207. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  70208. /**
  70209. * Converts a Quaternion to right-handed
  70210. * @param quaternion Source quaternion to convert to right-handed
  70211. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  70212. }
  70213. }
  70214. declare module BABYLON.GLTF2.Exporter {
  70215. /**
  70216. * Converts Babylon Scene into glTF 2.0.
  70217. * @hidden
  70218. */
  70219. export class _Exporter {
  70220. /**
  70221. * Stores the glTF to export
  70222. */ private _glTF: IGLTF;
  70223. /**
  70224. * Stores all generated buffer views, which represents views into the main glTF buffer data
  70225. */ private _bufferViews: IBufferView[];
  70226. /**
  70227. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  70228. */ private _accessors: IAccessor[];
  70229. /**
  70230. * Stores all the generated nodes, which contains transform and/or mesh information per node
  70231. */
  70232. private _nodes;
  70233. /**
  70234. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  70235. */
  70236. private _scenes;
  70237. /**
  70238. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  70239. */
  70240. private _meshes;
  70241. /**
  70242. * Stores all the generated material information, which represents the appearance of each primitive
  70243. */ private _materials: IMaterial[]; private _materialMap: {
  70244. [materialID: number]: number;
  70245. };
  70246. /**
  70247. * Stores all the generated texture information, which is referenced by glTF materials
  70248. */ private _textures: ITexture[];
  70249. /**
  70250. * Stores all the generated image information, which is referenced by glTF textures
  70251. */ private _images: IImage[];
  70252. /**
  70253. * Stores all the texture samplers
  70254. */ private _samplers: ISampler[];
  70255. /**
  70256. * Stores all the generated animation samplers, which is referenced by glTF animations
  70257. */
  70258. /**
  70259. * Stores the animations for glTF models
  70260. */
  70261. private _animations;
  70262. /**
  70263. * Stores the total amount of bytes stored in the glTF buffer
  70264. */
  70265. private _totalByteLength;
  70266. /**
  70267. * Stores a reference to the Babylon scene containing the source geometry and material information
  70268. */ private _babylonScene: Scene;
  70269. /**
  70270. * Stores a map of the image data, where the key is the file name and the value
  70271. * is the image data
  70272. */ private _imageData: {
  70273. [fileName: string]: {
  70274. data: Uint8Array;
  70275. mimeType: ImageMimeType;
  70276. };
  70277. };
  70278. /**
  70279. * Stores a map of the unique id of a node to its index in the node array
  70280. */
  70281. private _nodeMap;
  70282. /**
  70283. * Specifies if the Babylon scene should be converted to right-handed on export
  70284. */ private _convertToRightHandedSystem: boolean;
  70285. /**
  70286. * Baked animation sample rate
  70287. */
  70288. private _animationSampleRate;
  70289. private _options;
  70290. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  70291. private _extensions;
  70292. private static _ExtensionNames;
  70293. private static _ExtensionFactories;
  70294. 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>>;
  70295. private _forEachExtensions;
  70296. private _extensionsOnExporting;
  70297. /**
  70298. * Load glTF serializer extensions
  70299. */
  70300. private _loadExtensions;
  70301. /**
  70302. * Creates a glTF Exporter instance, which can accept optional exporter options
  70303. * @param babylonScene Babylon scene object
  70304. * @param options Options to modify the behavior of the exporter
  70305. */
  70306. constructor(babylonScene: Scene, options?: IExportOptions);
  70307. /**
  70308. * Registers a glTF exporter extension
  70309. * @param name Name of the extension to export
  70310. * @param factory The factory function that creates the exporter extension
  70311. */
  70312. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  70313. /**
  70314. * Un-registers an exporter extension
  70315. * @param name The name fo the exporter extension
  70316. * @returns A boolean indicating whether the extension has been un-registered
  70317. */
  70318. static UnregisterExtension(name: string): boolean;
  70319. /**
  70320. * Lazy load a local engine with premultiplied alpha set to false
  70321. */ private _getLocalEngine(): Engine;
  70322. private reorderIndicesBasedOnPrimitiveMode;
  70323. /**
  70324. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  70325. * clock-wise during export to glTF
  70326. * @param submesh BabylonJS submesh
  70327. * @param primitiveMode Primitive mode of the mesh
  70328. * @param sideOrientation the winding order of the submesh
  70329. * @param vertexBufferKind The type of vertex attribute
  70330. * @param meshAttributeArray The vertex attribute data
  70331. * @param byteOffset The offset to the binary data
  70332. * @param binaryWriter The binary data for the glTF file
  70333. */
  70334. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  70335. /**
  70336. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  70337. * clock-wise during export to glTF
  70338. * @param submesh BabylonJS submesh
  70339. * @param primitiveMode Primitive mode of the mesh
  70340. * @param sideOrientation the winding order of the submesh
  70341. * @param vertexBufferKind The type of vertex attribute
  70342. * @param meshAttributeArray The vertex attribute data
  70343. * @param byteOffset The offset to the binary data
  70344. * @param binaryWriter The binary data for the glTF file
  70345. */
  70346. private reorderTriangleFillMode;
  70347. /**
  70348. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  70349. * clock-wise during export to glTF
  70350. * @param submesh BabylonJS submesh
  70351. * @param primitiveMode Primitive mode of the mesh
  70352. * @param sideOrientation the winding order of the submesh
  70353. * @param vertexBufferKind The type of vertex attribute
  70354. * @param meshAttributeArray The vertex attribute data
  70355. * @param byteOffset The offset to the binary data
  70356. * @param binaryWriter The binary data for the glTF file
  70357. */
  70358. private reorderTriangleStripDrawMode;
  70359. /**
  70360. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  70361. * clock-wise during export to glTF
  70362. * @param submesh BabylonJS submesh
  70363. * @param primitiveMode Primitive mode of the mesh
  70364. * @param sideOrientation the winding order of the submesh
  70365. * @param vertexBufferKind The type of vertex attribute
  70366. * @param meshAttributeArray The vertex attribute data
  70367. * @param byteOffset The offset to the binary data
  70368. * @param binaryWriter The binary data for the glTF file
  70369. */
  70370. private reorderTriangleFanMode;
  70371. /**
  70372. * Writes the vertex attribute data to binary
  70373. * @param vertices The vertices to write to the binary writer
  70374. * @param byteOffset The offset into the binary writer to overwrite binary data
  70375. * @param vertexAttributeKind The vertex attribute type
  70376. * @param meshAttributeArray The vertex attribute data
  70377. * @param binaryWriter The writer containing the binary data
  70378. */
  70379. private writeVertexAttributeData;
  70380. /**
  70381. * Writes mesh attribute data to a data buffer
  70382. * Returns the bytelength of the data
  70383. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  70384. * @param meshAttributeArray Array containing the attribute data
  70385. * @param binaryWriter The buffer to write the binary data to
  70386. * @param indices Used to specify the order of the vertex data
  70387. */
  70388. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  70389. /**
  70390. * Generates glTF json data
  70391. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  70392. * @param glTFPrefix Text to use when prefixing a glTF file
  70393. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  70394. * @returns json data as string
  70395. */
  70396. private generateJSON;
  70397. /**
  70398. * Generates data for .gltf and .bin files based on the glTF prefix string
  70399. * @param glTFPrefix Text to use when prefixing a glTF file
  70400. * @returns GLTFData with glTF file data
  70401. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  70402. /**
  70403. * Creates a binary buffer for glTF
  70404. * @returns array buffer for binary data
  70405. */
  70406. private _generateBinaryAsync;
  70407. /**
  70408. * Pads the number to a multiple of 4
  70409. * @param num number to pad
  70410. * @returns padded number
  70411. */
  70412. private _getPadding;
  70413. /**
  70414. * Generates a glb file from the json and binary data
  70415. * Returns an object with the glb file name as the key and data as the value
  70416. * @param glTFPrefix
  70417. * @returns object with glb filename as key and data as value
  70418. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  70419. /**
  70420. * Sets the TRS for each node
  70421. * @param node glTF Node for storing the transformation data
  70422. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  70423. */
  70424. private setNodeTransformation;
  70425. private getVertexBufferFromMesh;
  70426. /**
  70427. * Creates a bufferview based on the vertices type for the Babylon mesh
  70428. * @param kind Indicates the type of vertices data
  70429. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  70430. * @param binaryWriter The buffer to write the bufferview data to
  70431. */
  70432. private createBufferViewKind;
  70433. /**
  70434. * The primitive mode of the Babylon mesh
  70435. * @param babylonMesh The BabylonJS mesh
  70436. */
  70437. private getMeshPrimitiveMode;
  70438. /**
  70439. * Sets the primitive mode of the glTF mesh primitive
  70440. * @param meshPrimitive glTF mesh primitive
  70441. * @param primitiveMode The primitive mode
  70442. */
  70443. private setPrimitiveMode;
  70444. /**
  70445. * Sets the vertex attribute accessor based of the glTF mesh primitive
  70446. * @param meshPrimitive glTF mesh primitive
  70447. * @param attributeKind vertex attribute
  70448. * @returns boolean specifying if uv coordinates are present
  70449. */
  70450. private setAttributeKind;
  70451. /**
  70452. * Sets data for the primitive attributes of each submesh
  70453. * @param mesh glTF Mesh object to store the primitive attribute information
  70454. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  70455. * @param binaryWriter Buffer to write the attribute data to
  70456. */
  70457. private setPrimitiveAttributesAsync;
  70458. /**
  70459. * Creates a glTF scene based on the array of meshes
  70460. * Returns the the total byte offset
  70461. * @param babylonScene Babylon scene to get the mesh data from
  70462. * @param binaryWriter Buffer to write binary data to
  70463. */
  70464. private createSceneAsync;
  70465. /**
  70466. * Creates a mapping of Node unique id to node index and handles animations
  70467. * @param babylonScene Babylon Scene
  70468. * @param nodes Babylon transform nodes
  70469. * @param binaryWriter Buffer to write binary data to
  70470. * @returns Node mapping of unique id to index
  70471. */
  70472. private createNodeMapAndAnimationsAsync;
  70473. /**
  70474. * Creates a glTF node from a Babylon mesh
  70475. * @param babylonMesh Source Babylon mesh
  70476. * @param binaryWriter Buffer for storing geometry data
  70477. * @returns glTF node
  70478. */
  70479. private createNodeAsync;
  70480. }
  70481. /**
  70482. * @hidden
  70483. *
  70484. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  70485. */
  70486. export class _BinaryWriter {
  70487. /**
  70488. * Array buffer which stores all binary data
  70489. */
  70490. private _arrayBuffer;
  70491. /**
  70492. * View of the array buffer
  70493. */
  70494. private _dataView;
  70495. /**
  70496. * byte offset of data in array buffer
  70497. */
  70498. private _byteOffset;
  70499. /**
  70500. * Initialize binary writer with an initial byte length
  70501. * @param byteLength Initial byte length of the array buffer
  70502. */
  70503. constructor(byteLength: number);
  70504. /**
  70505. * Resize the array buffer to the specified byte length
  70506. * @param byteLength
  70507. */
  70508. private resizeBuffer;
  70509. /**
  70510. * Get an array buffer with the length of the byte offset
  70511. * @returns ArrayBuffer resized to the byte offset
  70512. */
  70513. getArrayBuffer(): ArrayBuffer;
  70514. /**
  70515. * Get the byte offset of the array buffer
  70516. * @returns byte offset
  70517. */
  70518. getByteOffset(): number;
  70519. /**
  70520. * Stores an UInt8 in the array buffer
  70521. * @param entry
  70522. * @param byteOffset If defined, specifies where to set the value as an offset.
  70523. */
  70524. setUInt8(entry: number, byteOffset?: number): void;
  70525. /**
  70526. * Gets an UInt32 in the array buffer
  70527. * @param entry
  70528. * @param byteOffset If defined, specifies where to set the value as an offset.
  70529. */
  70530. getUInt32(byteOffset: number): number;
  70531. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70532. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70533. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70534. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70535. /**
  70536. * Stores a Float32 in the array buffer
  70537. * @param entry
  70538. */
  70539. setFloat32(entry: number, byteOffset?: number): void;
  70540. /**
  70541. * Stores an UInt32 in the array buffer
  70542. * @param entry
  70543. * @param byteOffset If defined, specifies where to set the value as an offset.
  70544. */
  70545. setUInt32(entry: number, byteOffset?: number): void;
  70546. }
  70547. }
  70548. declare module BABYLON.GLTF2.Exporter {
  70549. /**
  70550. * @hidden
  70551. * Interface to store animation data.
  70552. */
  70553. export interface _IAnimationData {
  70554. /**
  70555. * Keyframe data.
  70556. */
  70557. inputs: number[];
  70558. /**
  70559. * Value data.
  70560. */
  70561. outputs: number[][];
  70562. /**
  70563. * Animation interpolation data.
  70564. */
  70565. samplerInterpolation: AnimationSamplerInterpolation;
  70566. /**
  70567. * Minimum keyframe value.
  70568. */
  70569. inputsMin: number;
  70570. /**
  70571. * Maximum keyframe value.
  70572. */
  70573. inputsMax: number;
  70574. }
  70575. /**
  70576. * @hidden
  70577. */
  70578. export interface _IAnimationInfo {
  70579. /**
  70580. * The target channel for the animation
  70581. */
  70582. animationChannelTargetPath: AnimationChannelTargetPath;
  70583. /**
  70584. * The glTF accessor type for the data.
  70585. */
  70586. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  70587. /**
  70588. * Specifies if quaternions should be used.
  70589. */
  70590. useQuaternion: boolean;
  70591. }
  70592. /**
  70593. * @hidden
  70594. * Utility class for generating glTF animation data from BabylonJS.
  70595. */
  70596. export class _GLTFAnimation {
  70597. /**
  70598. * @ignore
  70599. *
  70600. * Creates glTF channel animation from BabylonJS animation.
  70601. * @param babylonTransformNode - BabylonJS mesh.
  70602. * @param animation - animation.
  70603. * @param animationChannelTargetPath - The target animation channel.
  70604. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  70605. * @param useQuaternion - Specifies if quaternions are used.
  70606. * @returns nullable IAnimationData
  70607. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  70608. private static _DeduceAnimationInfo;
  70609. /**
  70610. * @ignore
  70611. * Create node animations from the transform node animations
  70612. * @param babylonNode
  70613. * @param runtimeGLTFAnimation
  70614. * @param idleGLTFAnimations
  70615. * @param nodeMap
  70616. * @param nodes
  70617. * @param binaryWriter
  70618. * @param bufferViews
  70619. * @param accessors
  70620. * @param convertToRightHandedSystem
  70621. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70622. [key: number]: number;
  70623. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70624. /**
  70625. * @ignore
  70626. * Create node animations from the animation groups
  70627. * @param babylonScene
  70628. * @param glTFAnimations
  70629. * @param nodeMap
  70630. * @param nodes
  70631. * @param binaryWriter
  70632. * @param bufferViews
  70633. * @param accessors
  70634. * @param convertToRightHandedSystem
  70635. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70636. [key: number]: number;
  70637. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70638. private static AddAnimation;
  70639. /**
  70640. * Create a baked animation
  70641. * @param babylonTransformNode BabylonJS mesh
  70642. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70643. * @param animationChannelTargetPath animation target channel
  70644. * @param minFrame minimum animation frame
  70645. * @param maxFrame maximum animation frame
  70646. * @param fps frames per second of the animation
  70647. * @param inputs input key frames of the animation
  70648. * @param outputs output key frame data of the animation
  70649. * @param convertToRightHandedSystem converts the values to right-handed
  70650. * @param useQuaternion specifies if quaternions should be used
  70651. */
  70652. private static _CreateBakedAnimation;
  70653. private static _ConvertFactorToVector3OrQuaternion;
  70654. private static _SetInterpolatedValue;
  70655. /**
  70656. * Creates linear animation from the animation key frames
  70657. * @param babylonTransformNode BabylonJS mesh
  70658. * @param animation BabylonJS animation
  70659. * @param animationChannelTargetPath The target animation channel
  70660. * @param frameDelta The difference between the last and first frame of the animation
  70661. * @param inputs Array to store the key frame times
  70662. * @param outputs Array to store the key frame data
  70663. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70664. * @param useQuaternion Specifies if quaternions are used in the animation
  70665. */
  70666. private static _CreateLinearOrStepAnimation;
  70667. /**
  70668. * Creates cubic spline animation from the animation key frames
  70669. * @param babylonTransformNode BabylonJS mesh
  70670. * @param animation BabylonJS animation
  70671. * @param animationChannelTargetPath The target animation channel
  70672. * @param frameDelta The difference between the last and first frame of the animation
  70673. * @param inputs Array to store the key frame times
  70674. * @param outputs Array to store the key frame data
  70675. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70676. * @param useQuaternion Specifies if quaternions are used in the animation
  70677. */
  70678. private static _CreateCubicSplineAnimation;
  70679. private static _GetBasePositionRotationOrScale;
  70680. /**
  70681. * Adds a key frame value
  70682. * @param keyFrame
  70683. * @param animation
  70684. * @param outputs
  70685. * @param animationChannelTargetPath
  70686. * @param basePositionRotationOrScale
  70687. * @param convertToRightHandedSystem
  70688. * @param useQuaternion
  70689. */
  70690. private static _AddKeyframeValue;
  70691. /**
  70692. * Determine the interpolation based on the key frames
  70693. * @param keyFrames
  70694. * @param animationChannelTargetPath
  70695. * @param useQuaternion
  70696. */
  70697. private static _DeduceInterpolation;
  70698. /**
  70699. * Adds an input tangent or output tangent to the output data
  70700. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70701. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70702. * @param outputs The animation data by keyframe
  70703. * @param animationChannelTargetPath The target animation channel
  70704. * @param interpolation The interpolation type
  70705. * @param keyFrame The key frame with the animation data
  70706. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70707. * @param useQuaternion Specifies if quaternions are used
  70708. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70709. */
  70710. private static AddSplineTangent;
  70711. /**
  70712. * Get the minimum and maximum key frames' frame values
  70713. * @param keyFrames animation key frames
  70714. * @returns the minimum and maximum key frame value
  70715. */
  70716. private static calculateMinMaxKeyFrames;
  70717. }
  70718. }
  70719. declare module BABYLON.GLTF2.Exporter {
  70720. /** @hidden */
  70721. export var textureTransformPixelShader: {
  70722. name: string;
  70723. shader: string;
  70724. };
  70725. }
  70726. declare module BABYLON.GLTF2.Exporter.Extensions {
  70727. /**
  70728. * @hidden
  70729. */
  70730. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70731. /** Name of this extension */
  70732. readonly name: string;
  70733. /** Defines whether this extension is enabled */
  70734. enabled: boolean;
  70735. /** Defines whether this extension is required */
  70736. required: boolean;
  70737. /** Reference to the glTF exporter */
  70738. private _exporter;
  70739. constructor(exporter: _Exporter);
  70740. dispose(): void;
  70741. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70742. /**
  70743. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70744. * @param babylonTexture
  70745. * @param offset
  70746. * @param rotation
  70747. * @param scale
  70748. * @param scene
  70749. */
  70750. private _textureTransformTextureAsync;
  70751. }
  70752. }
  70753. declare module BABYLON.GLTF2.Exporter.Extensions {
  70754. /**
  70755. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70756. */
  70757. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70758. /** The name of this extension. */
  70759. readonly name: string;
  70760. /** Defines whether this extension is enabled. */
  70761. enabled: boolean;
  70762. /** Defines whether this extension is required */
  70763. required: boolean;
  70764. /** Reference to the glTF exporter */
  70765. private _exporter;
  70766. private _lights;
  70767. /** @hidden */
  70768. constructor(exporter: _Exporter);
  70769. /** @hidden */
  70770. dispose(): void;
  70771. /** @hidden */
  70772. onExporting(): void;
  70773. /**
  70774. * Define this method to modify the default behavior when exporting a node
  70775. * @param context The context when exporting the node
  70776. * @param node glTF node
  70777. * @param babylonNode BabylonJS node
  70778. * @returns nullable INode promise
  70779. */
  70780. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70781. }
  70782. }
  70783. declare module BABYLON {
  70784. /**
  70785. * Class for generating STL data from a Babylon scene.
  70786. */
  70787. export class STLExport {
  70788. /**
  70789. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  70790. * @param meshes list defines the mesh to serialize
  70791. * @param download triggers the automatic download of the file.
  70792. * @param fileName changes the downloads fileName.
  70793. * @param binary changes the STL to a binary type.
  70794. * @param isLittleEndian toggle for binary type exporter.
  70795. * @returns the STL as UTF8 string
  70796. */
  70797. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  70798. }
  70799. }
  70800. declare module "babylonjs-gltf2interface" {
  70801. export = BABYLON.GLTF2;
  70802. }
  70803. /**
  70804. * Module for glTF 2.0 Interface
  70805. */
  70806. declare module BABYLON.GLTF2 {
  70807. /**
  70808. * The datatype of the components in the attribute
  70809. */
  70810. const enum AccessorComponentType {
  70811. /**
  70812. * Byte
  70813. */
  70814. BYTE = 5120,
  70815. /**
  70816. * Unsigned Byte
  70817. */
  70818. UNSIGNED_BYTE = 5121,
  70819. /**
  70820. * Short
  70821. */
  70822. SHORT = 5122,
  70823. /**
  70824. * Unsigned Short
  70825. */
  70826. UNSIGNED_SHORT = 5123,
  70827. /**
  70828. * Unsigned Int
  70829. */
  70830. UNSIGNED_INT = 5125,
  70831. /**
  70832. * Float
  70833. */
  70834. FLOAT = 5126,
  70835. }
  70836. /**
  70837. * Specifies if the attirbute is a scalar, vector, or matrix
  70838. */
  70839. const enum AccessorType {
  70840. /**
  70841. * Scalar
  70842. */
  70843. SCALAR = "SCALAR",
  70844. /**
  70845. * Vector2
  70846. */
  70847. VEC2 = "VEC2",
  70848. /**
  70849. * Vector3
  70850. */
  70851. VEC3 = "VEC3",
  70852. /**
  70853. * Vector4
  70854. */
  70855. VEC4 = "VEC4",
  70856. /**
  70857. * Matrix2x2
  70858. */
  70859. MAT2 = "MAT2",
  70860. /**
  70861. * Matrix3x3
  70862. */
  70863. MAT3 = "MAT3",
  70864. /**
  70865. * Matrix4x4
  70866. */
  70867. MAT4 = "MAT4",
  70868. }
  70869. /**
  70870. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70871. */
  70872. const enum AnimationChannelTargetPath {
  70873. /**
  70874. * Translation
  70875. */
  70876. TRANSLATION = "translation",
  70877. /**
  70878. * Rotation
  70879. */
  70880. ROTATION = "rotation",
  70881. /**
  70882. * Scale
  70883. */
  70884. SCALE = "scale",
  70885. /**
  70886. * Weights
  70887. */
  70888. WEIGHTS = "weights",
  70889. }
  70890. /**
  70891. * Interpolation algorithm
  70892. */
  70893. const enum AnimationSamplerInterpolation {
  70894. /**
  70895. * The animated values are linearly interpolated between keyframes
  70896. */
  70897. LINEAR = "LINEAR",
  70898. /**
  70899. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  70900. */
  70901. STEP = "STEP",
  70902. /**
  70903. * The animation's interpolation is computed using a cubic spline with specified tangents
  70904. */
  70905. CUBICSPLINE = "CUBICSPLINE",
  70906. }
  70907. /**
  70908. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70909. */
  70910. const enum CameraType {
  70911. /**
  70912. * A perspective camera containing properties to create a perspective projection matrix
  70913. */
  70914. PERSPECTIVE = "perspective",
  70915. /**
  70916. * An orthographic camera containing properties to create an orthographic projection matrix
  70917. */
  70918. ORTHOGRAPHIC = "orthographic",
  70919. }
  70920. /**
  70921. * The mime-type of the image
  70922. */
  70923. const enum ImageMimeType {
  70924. /**
  70925. * JPEG Mime-type
  70926. */
  70927. JPEG = "image/jpeg",
  70928. /**
  70929. * PNG Mime-type
  70930. */
  70931. PNG = "image/png",
  70932. }
  70933. /**
  70934. * The alpha rendering mode of the material
  70935. */
  70936. const enum MaterialAlphaMode {
  70937. /**
  70938. * The alpha value is ignored and the rendered output is fully opaque
  70939. */
  70940. OPAQUE = "OPAQUE",
  70941. /**
  70942. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  70943. */
  70944. MASK = "MASK",
  70945. /**
  70946. * 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)
  70947. */
  70948. BLEND = "BLEND",
  70949. }
  70950. /**
  70951. * The type of the primitives to render
  70952. */
  70953. const enum MeshPrimitiveMode {
  70954. /**
  70955. * Points
  70956. */
  70957. POINTS = 0,
  70958. /**
  70959. * Lines
  70960. */
  70961. LINES = 1,
  70962. /**
  70963. * Line Loop
  70964. */
  70965. LINE_LOOP = 2,
  70966. /**
  70967. * Line Strip
  70968. */
  70969. LINE_STRIP = 3,
  70970. /**
  70971. * Triangles
  70972. */
  70973. TRIANGLES = 4,
  70974. /**
  70975. * Triangle Strip
  70976. */
  70977. TRIANGLE_STRIP = 5,
  70978. /**
  70979. * Triangle Fan
  70980. */
  70981. TRIANGLE_FAN = 6,
  70982. }
  70983. /**
  70984. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70985. */
  70986. const enum TextureMagFilter {
  70987. /**
  70988. * Nearest
  70989. */
  70990. NEAREST = 9728,
  70991. /**
  70992. * Linear
  70993. */
  70994. LINEAR = 9729,
  70995. }
  70996. /**
  70997. * Minification filter. All valid values correspond to WebGL enums
  70998. */
  70999. const enum TextureMinFilter {
  71000. /**
  71001. * Nearest
  71002. */
  71003. NEAREST = 9728,
  71004. /**
  71005. * Linear
  71006. */
  71007. LINEAR = 9729,
  71008. /**
  71009. * Nearest Mip-Map Nearest
  71010. */
  71011. NEAREST_MIPMAP_NEAREST = 9984,
  71012. /**
  71013. * Linear Mipmap Nearest
  71014. */
  71015. LINEAR_MIPMAP_NEAREST = 9985,
  71016. /**
  71017. * Nearest Mipmap Linear
  71018. */
  71019. NEAREST_MIPMAP_LINEAR = 9986,
  71020. /**
  71021. * Linear Mipmap Linear
  71022. */
  71023. LINEAR_MIPMAP_LINEAR = 9987,
  71024. }
  71025. /**
  71026. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71027. */
  71028. const enum TextureWrapMode {
  71029. /**
  71030. * Clamp to Edge
  71031. */
  71032. CLAMP_TO_EDGE = 33071,
  71033. /**
  71034. * Mirrored Repeat
  71035. */
  71036. MIRRORED_REPEAT = 33648,
  71037. /**
  71038. * Repeat
  71039. */
  71040. REPEAT = 10497,
  71041. }
  71042. /**
  71043. * glTF Property
  71044. */
  71045. interface IProperty {
  71046. /**
  71047. * Dictionary object with extension-specific objects
  71048. */
  71049. extensions?: {
  71050. [key: string]: any;
  71051. };
  71052. /**
  71053. * Application-Specific data
  71054. */
  71055. extras?: any;
  71056. }
  71057. /**
  71058. * glTF Child of Root Property
  71059. */
  71060. interface IChildRootProperty extends IProperty {
  71061. /**
  71062. * The user-defined name of this object
  71063. */
  71064. name?: string;
  71065. }
  71066. /**
  71067. * Indices of those attributes that deviate from their initialization value
  71068. */
  71069. interface IAccessorSparseIndices extends IProperty {
  71070. /**
  71071. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71072. */
  71073. bufferView: number;
  71074. /**
  71075. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71076. */
  71077. byteOffset?: number;
  71078. /**
  71079. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  71080. */
  71081. componentType: AccessorComponentType;
  71082. }
  71083. /**
  71084. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  71085. */
  71086. interface IAccessorSparseValues extends IProperty {
  71087. /**
  71088. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71089. */
  71090. bufferView: number;
  71091. /**
  71092. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71093. */
  71094. byteOffset?: number;
  71095. }
  71096. /**
  71097. * Sparse storage of attributes that deviate from their initialization value
  71098. */
  71099. interface IAccessorSparse extends IProperty {
  71100. /**
  71101. * The number of attributes encoded in this sparse accessor
  71102. */
  71103. count: number;
  71104. /**
  71105. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  71106. */
  71107. indices: IAccessorSparseIndices;
  71108. /**
  71109. * 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
  71110. */
  71111. values: IAccessorSparseValues;
  71112. }
  71113. /**
  71114. * 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
  71115. */
  71116. interface IAccessor extends IChildRootProperty {
  71117. /**
  71118. * The index of the bufferview
  71119. */
  71120. bufferView?: number;
  71121. /**
  71122. * The offset relative to the start of the bufferView in bytes
  71123. */
  71124. byteOffset?: number;
  71125. /**
  71126. * The datatype of components in the attribute
  71127. */
  71128. componentType: AccessorComponentType;
  71129. /**
  71130. * Specifies whether integer data values should be normalized
  71131. */
  71132. normalized?: boolean;
  71133. /**
  71134. * The number of attributes referenced by this accessor
  71135. */
  71136. count: number;
  71137. /**
  71138. * Specifies if the attribute is a scalar, vector, or matrix
  71139. */
  71140. type: AccessorType;
  71141. /**
  71142. * Maximum value of each component in this attribute
  71143. */
  71144. max?: number[];
  71145. /**
  71146. * Minimum value of each component in this attribute
  71147. */
  71148. min?: number[];
  71149. /**
  71150. * Sparse storage of attributes that deviate from their initialization value
  71151. */
  71152. sparse?: IAccessorSparse;
  71153. }
  71154. /**
  71155. * Targets an animation's sampler at a node's property
  71156. */
  71157. interface IAnimationChannel extends IProperty {
  71158. /**
  71159. * The index of a sampler in this animation used to compute the value for the target
  71160. */
  71161. sampler: number;
  71162. /**
  71163. * The index of the node and TRS property to target
  71164. */
  71165. target: IAnimationChannelTarget;
  71166. }
  71167. /**
  71168. * The index of the node and TRS property that an animation channel targets
  71169. */
  71170. interface IAnimationChannelTarget extends IProperty {
  71171. /**
  71172. * The index of the node to target
  71173. */
  71174. node: number;
  71175. /**
  71176. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71177. */
  71178. path: AnimationChannelTargetPath;
  71179. }
  71180. /**
  71181. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71182. */
  71183. interface IAnimationSampler extends IProperty {
  71184. /**
  71185. * The index of an accessor containing keyframe input values, e.g., time
  71186. */
  71187. input: number;
  71188. /**
  71189. * Interpolation algorithm
  71190. */
  71191. interpolation?: AnimationSamplerInterpolation;
  71192. /**
  71193. * The index of an accessor, containing keyframe output values
  71194. */
  71195. output: number;
  71196. }
  71197. /**
  71198. * A keyframe animation
  71199. */
  71200. interface IAnimation extends IChildRootProperty {
  71201. /**
  71202. * An array of channels, each of which targets an animation's sampler at a node's property
  71203. */
  71204. channels: IAnimationChannel[];
  71205. /**
  71206. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71207. */
  71208. samplers: IAnimationSampler[];
  71209. }
  71210. /**
  71211. * Metadata about the glTF asset
  71212. */
  71213. interface IAsset extends IChildRootProperty {
  71214. /**
  71215. * A copyright message suitable for display to credit the content creator
  71216. */
  71217. copyright?: string;
  71218. /**
  71219. * Tool that generated this glTF model. Useful for debugging
  71220. */
  71221. generator?: string;
  71222. /**
  71223. * The glTF version that this asset targets
  71224. */
  71225. version: string;
  71226. /**
  71227. * The minimum glTF version that this asset targets
  71228. */
  71229. minVersion?: string;
  71230. }
  71231. /**
  71232. * A buffer points to binary geometry, animation, or skins
  71233. */
  71234. interface IBuffer extends IChildRootProperty {
  71235. /**
  71236. * 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
  71237. */
  71238. uri?: string;
  71239. /**
  71240. * The length of the buffer in bytes
  71241. */
  71242. byteLength: number;
  71243. }
  71244. /**
  71245. * A view into a buffer generally representing a subset of the buffer
  71246. */
  71247. interface IBufferView extends IChildRootProperty {
  71248. /**
  71249. * The index of the buffer
  71250. */
  71251. buffer: number;
  71252. /**
  71253. * The offset into the buffer in bytes
  71254. */
  71255. byteOffset?: number;
  71256. /**
  71257. * The lenth of the bufferView in bytes
  71258. */
  71259. byteLength: number;
  71260. /**
  71261. * The stride, in bytes
  71262. */
  71263. byteStride?: number;
  71264. }
  71265. /**
  71266. * An orthographic camera containing properties to create an orthographic projection matrix
  71267. */
  71268. interface ICameraOrthographic extends IProperty {
  71269. /**
  71270. * The floating-point horizontal magnification of the view. Must not be zero
  71271. */
  71272. xmag: number;
  71273. /**
  71274. * The floating-point vertical magnification of the view. Must not be zero
  71275. */
  71276. ymag: number;
  71277. /**
  71278. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  71279. */
  71280. zfar: number;
  71281. /**
  71282. * The floating-point distance to the near clipping plane
  71283. */
  71284. znear: number;
  71285. }
  71286. /**
  71287. * A perspective camera containing properties to create a perspective projection matrix
  71288. */
  71289. interface ICameraPerspective extends IProperty {
  71290. /**
  71291. * The floating-point aspect ratio of the field of view
  71292. */
  71293. aspectRatio?: number;
  71294. /**
  71295. * The floating-point vertical field of view in radians
  71296. */
  71297. yfov: number;
  71298. /**
  71299. * The floating-point distance to the far clipping plane
  71300. */
  71301. zfar?: number;
  71302. /**
  71303. * The floating-point distance to the near clipping plane
  71304. */
  71305. znear: number;
  71306. }
  71307. /**
  71308. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71309. */
  71310. interface ICamera extends IChildRootProperty {
  71311. /**
  71312. * An orthographic camera containing properties to create an orthographic projection matrix
  71313. */
  71314. orthographic?: ICameraOrthographic;
  71315. /**
  71316. * A perspective camera containing properties to create a perspective projection matrix
  71317. */
  71318. perspective?: ICameraPerspective;
  71319. /**
  71320. * Specifies if the camera uses a perspective or orthographic projection
  71321. */
  71322. type: CameraType;
  71323. }
  71324. /**
  71325. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  71326. */
  71327. interface IImage extends IChildRootProperty {
  71328. /**
  71329. * 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
  71330. */
  71331. uri?: string;
  71332. /**
  71333. * The image's MIME type
  71334. */
  71335. mimeType?: ImageMimeType;
  71336. /**
  71337. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  71338. */
  71339. bufferView?: number;
  71340. }
  71341. /**
  71342. * Material Normal Texture Info
  71343. */
  71344. interface IMaterialNormalTextureInfo extends ITextureInfo {
  71345. /**
  71346. * The scalar multiplier applied to each normal vector of the normal texture
  71347. */
  71348. scale?: number;
  71349. }
  71350. /**
  71351. * Material Occlusion Texture Info
  71352. */
  71353. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  71354. /**
  71355. * A scalar multiplier controlling the amount of occlusion applied
  71356. */
  71357. strength?: number;
  71358. }
  71359. /**
  71360. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  71361. */
  71362. interface IMaterialPbrMetallicRoughness {
  71363. /**
  71364. * The material's base color factor
  71365. */
  71366. baseColorFactor?: number[];
  71367. /**
  71368. * The base color texture
  71369. */
  71370. baseColorTexture?: ITextureInfo;
  71371. /**
  71372. * The metalness of the material
  71373. */
  71374. metallicFactor?: number;
  71375. /**
  71376. * The roughness of the material
  71377. */
  71378. roughnessFactor?: number;
  71379. /**
  71380. * The metallic-roughness texture
  71381. */
  71382. metallicRoughnessTexture?: ITextureInfo;
  71383. }
  71384. /**
  71385. * The material appearance of a primitive
  71386. */
  71387. interface IMaterial extends IChildRootProperty {
  71388. /**
  71389. * 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
  71390. */
  71391. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71392. /**
  71393. * The normal map texture
  71394. */
  71395. normalTexture?: IMaterialNormalTextureInfo;
  71396. /**
  71397. * The occlusion map texture
  71398. */
  71399. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71400. /**
  71401. * The emissive map texture
  71402. */
  71403. emissiveTexture?: ITextureInfo;
  71404. /**
  71405. * 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
  71406. */
  71407. emissiveFactor?: number[];
  71408. /**
  71409. * The alpha rendering mode of the material
  71410. */
  71411. alphaMode?: MaterialAlphaMode;
  71412. /**
  71413. * The alpha cutoff value of the material
  71414. */
  71415. alphaCutoff?: number;
  71416. /**
  71417. * Specifies whether the material is double sided
  71418. */
  71419. doubleSided?: boolean;
  71420. }
  71421. /**
  71422. * Geometry to be rendered with the given material
  71423. */
  71424. interface IMeshPrimitive extends IProperty {
  71425. /**
  71426. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  71427. */
  71428. attributes: {
  71429. [name: string]: number;
  71430. };
  71431. /**
  71432. * The index of the accessor that contains the indices
  71433. */
  71434. indices?: number;
  71435. /**
  71436. * The index of the material to apply to this primitive when rendering
  71437. */
  71438. material?: number;
  71439. /**
  71440. * The type of primitives to render. All valid values correspond to WebGL enums
  71441. */
  71442. mode?: MeshPrimitiveMode;
  71443. /**
  71444. * 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
  71445. */
  71446. targets?: {
  71447. [name: string]: number;
  71448. }[];
  71449. }
  71450. /**
  71451. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  71452. */
  71453. interface IMesh extends IChildRootProperty {
  71454. /**
  71455. * An array of primitives, each defining geometry to be rendered with a material
  71456. */
  71457. primitives: IMeshPrimitive[];
  71458. /**
  71459. * Array of weights to be applied to the Morph Targets
  71460. */
  71461. weights?: number[];
  71462. }
  71463. /**
  71464. * A node in the node hierarchy
  71465. */
  71466. interface INode extends IChildRootProperty {
  71467. /**
  71468. * The index of the camera referenced by this node
  71469. */
  71470. camera?: number;
  71471. /**
  71472. * The indices of this node's children
  71473. */
  71474. children?: number[];
  71475. /**
  71476. * The index of the skin referenced by this node
  71477. */
  71478. skin?: number;
  71479. /**
  71480. * A floating-point 4x4 transformation matrix stored in column-major order
  71481. */
  71482. matrix?: number[];
  71483. /**
  71484. * The index of the mesh in this node
  71485. */
  71486. mesh?: number;
  71487. /**
  71488. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  71489. */
  71490. rotation?: number[];
  71491. /**
  71492. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  71493. */
  71494. scale?: number[];
  71495. /**
  71496. * The node's translation along the x, y, and z axes
  71497. */
  71498. translation?: number[];
  71499. /**
  71500. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  71501. */
  71502. weights?: number[];
  71503. }
  71504. /**
  71505. * Texture sampler properties for filtering and wrapping modes
  71506. */
  71507. interface ISampler extends IChildRootProperty {
  71508. /**
  71509. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71510. */
  71511. magFilter?: TextureMagFilter;
  71512. /**
  71513. * Minification filter. All valid values correspond to WebGL enums
  71514. */
  71515. minFilter?: TextureMinFilter;
  71516. /**
  71517. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71518. */
  71519. wrapS?: TextureWrapMode;
  71520. /**
  71521. * T (V) wrapping mode. All valid values correspond to WebGL enums
  71522. */
  71523. wrapT?: TextureWrapMode;
  71524. }
  71525. /**
  71526. * The root nodes of a scene
  71527. */
  71528. interface IScene extends IChildRootProperty {
  71529. /**
  71530. * The indices of each root node
  71531. */
  71532. nodes: number[];
  71533. }
  71534. /**
  71535. * Joints and matrices defining a skin
  71536. */
  71537. interface ISkin extends IChildRootProperty {
  71538. /**
  71539. * 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
  71540. */
  71541. inverseBindMatrices?: number;
  71542. /**
  71543. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  71544. */
  71545. skeleton?: number;
  71546. /**
  71547. * 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)
  71548. */
  71549. joints: number[];
  71550. }
  71551. /**
  71552. * A texture and its sampler
  71553. */
  71554. interface ITexture extends IChildRootProperty {
  71555. /**
  71556. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  71557. */
  71558. sampler?: number;
  71559. /**
  71560. * The index of the image used by this texture
  71561. */
  71562. source: number;
  71563. }
  71564. /**
  71565. * Reference to a texture
  71566. */
  71567. interface ITextureInfo extends IProperty {
  71568. /**
  71569. * The index of the texture
  71570. */
  71571. index: number;
  71572. /**
  71573. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  71574. */
  71575. texCoord?: number;
  71576. }
  71577. /**
  71578. * The root object for a glTF asset
  71579. */
  71580. interface IGLTF extends IProperty {
  71581. /**
  71582. * An array of accessors. An accessor is a typed view into a bufferView
  71583. */
  71584. accessors?: IAccessor[];
  71585. /**
  71586. * An array of keyframe animations
  71587. */
  71588. animations?: IAnimation[];
  71589. /**
  71590. * Metadata about the glTF asset
  71591. */
  71592. asset: IAsset;
  71593. /**
  71594. * An array of buffers. A buffer points to binary geometry, animation, or skins
  71595. */
  71596. buffers?: IBuffer[];
  71597. /**
  71598. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  71599. */
  71600. bufferViews?: IBufferView[];
  71601. /**
  71602. * An array of cameras
  71603. */
  71604. cameras?: ICamera[];
  71605. /**
  71606. * Names of glTF extensions used somewhere in this asset
  71607. */
  71608. extensionsUsed?: string[];
  71609. /**
  71610. * Names of glTF extensions required to properly load this asset
  71611. */
  71612. extensionsRequired?: string[];
  71613. /**
  71614. * An array of images. An image defines data used to create a texture
  71615. */
  71616. images?: IImage[];
  71617. /**
  71618. * An array of materials. A material defines the appearance of a primitive
  71619. */
  71620. materials?: IMaterial[];
  71621. /**
  71622. * An array of meshes. A mesh is a set of primitives to be rendered
  71623. */
  71624. meshes?: IMesh[];
  71625. /**
  71626. * An array of nodes
  71627. */
  71628. nodes?: INode[];
  71629. /**
  71630. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71631. */
  71632. samplers?: ISampler[];
  71633. /**
  71634. * The index of the default scene
  71635. */
  71636. scene?: number;
  71637. /**
  71638. * An array of scenes
  71639. */
  71640. scenes?: IScene[];
  71641. /**
  71642. * An array of skins. A skin is defined by joints and matrices
  71643. */
  71644. skins?: ISkin[];
  71645. /**
  71646. * An array of textures
  71647. */
  71648. textures?: ITexture[];
  71649. }
  71650. /**
  71651. * The glTF validation results
  71652. * @ignore
  71653. */
  71654. interface IGLTFValidationResults {
  71655. info: {
  71656. generator: string;
  71657. hasAnimations: boolean;
  71658. hasDefaultScene: boolean;
  71659. hasMaterials: boolean;
  71660. hasMorphTargets: boolean;
  71661. hasSkins: boolean;
  71662. hasTextures: boolean;
  71663. maxAttributesUsed: number;
  71664. primitivesCount: number
  71665. };
  71666. issues: {
  71667. messages: Array<string>;
  71668. numErrors: number;
  71669. numHints: number;
  71670. numInfos: number;
  71671. numWarnings: number;
  71672. truncated: boolean
  71673. };
  71674. mimeType: string;
  71675. uri: string;
  71676. validatedAt: string;
  71677. validatorVersion: string;
  71678. }
  71679. /**
  71680. * The glTF validation options
  71681. */
  71682. interface IGLTFValidationOptions {
  71683. /** Uri to use */
  71684. uri?: string;
  71685. /** Function used to load external resources */
  71686. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71687. /** Boolean indicating that we need to validate accessor data */
  71688. validateAccessorData?: boolean;
  71689. /** max number of issues allowed */
  71690. maxIssues?: number;
  71691. /** Ignored issues */
  71692. ignoredIssues?: Array<string>;
  71693. /** Value to override severy settings */
  71694. severityOverrides?: Object;
  71695. }
  71696. /**
  71697. * The glTF validator object
  71698. * @ignore
  71699. */
  71700. interface IGLTFValidator {
  71701. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71702. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71703. }
  71704. }
  71705. declare module BABYLON {
  71706. /** @hidden */
  71707. export var cellPixelShader: {
  71708. name: string;
  71709. shader: string;
  71710. };
  71711. }
  71712. declare module BABYLON {
  71713. /** @hidden */
  71714. export var cellVertexShader: {
  71715. name: string;
  71716. shader: string;
  71717. };
  71718. }
  71719. declare module BABYLON {
  71720. export class CellMaterial extends BABYLON.PushMaterial {
  71721. private _diffuseTexture;
  71722. diffuseTexture: BABYLON.BaseTexture;
  71723. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  71724. computeHighLevel: boolean;
  71725. private _disableLighting;
  71726. disableLighting: boolean;
  71727. private _maxSimultaneousLights;
  71728. maxSimultaneousLights: number;
  71729. private _renderId;
  71730. constructor(name: string, scene: BABYLON.Scene);
  71731. needAlphaBlending(): boolean;
  71732. needAlphaTesting(): boolean;
  71733. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71734. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71735. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71736. getAnimatables(): BABYLON.IAnimatable[];
  71737. getActiveTextures(): BABYLON.BaseTexture[];
  71738. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71739. dispose(forceDisposeEffect?: boolean): void;
  71740. getClassName(): string;
  71741. clone(name: string): CellMaterial;
  71742. serialize(): any;
  71743. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71744. }
  71745. }
  71746. declare module BABYLON {
  71747. export class CustomShaderStructure {
  71748. FragmentStore: string;
  71749. VertexStore: string;
  71750. constructor();
  71751. }
  71752. export class ShaderSpecialParts {
  71753. constructor();
  71754. Fragment_Begin: string;
  71755. Fragment_Definitions: string;
  71756. Fragment_MainBegin: string;
  71757. Fragment_Custom_Diffuse: string;
  71758. Fragment_Before_Lights: string;
  71759. Fragment_Before_Fog: string;
  71760. Fragment_Custom_Alpha: string;
  71761. Fragment_Before_FragColor: string;
  71762. Vertex_Begin: string;
  71763. Vertex_Definitions: string;
  71764. Vertex_MainBegin: string;
  71765. Vertex_Before_PositionUpdated: string;
  71766. Vertex_Before_NormalUpdated: string;
  71767. Vertex_MainEnd: string;
  71768. }
  71769. export class CustomMaterial extends BABYLON.StandardMaterial {
  71770. static ShaderIndexer: number;
  71771. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  71772. FragmentShader: string;
  71773. VertexShader: string;
  71774. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71775. ReviewUniform(name: string, arr: string[]): string[];
  71776. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  71777. constructor(name: string, scene: BABYLON.Scene);
  71778. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  71779. Fragment_Begin(shaderPart: string): CustomMaterial;
  71780. Fragment_Definitions(shaderPart: string): CustomMaterial;
  71781. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  71782. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  71783. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  71784. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  71785. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  71786. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  71787. Vertex_Begin(shaderPart: string): CustomMaterial;
  71788. Vertex_Definitions(shaderPart: string): CustomMaterial;
  71789. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  71790. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  71791. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  71792. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  71793. }
  71794. }
  71795. declare module BABYLON {
  71796. export class ShaderAlebdoParts {
  71797. constructor();
  71798. Fragment_Begin: string;
  71799. Fragment_Definitions: string;
  71800. Fragment_MainBegin: string;
  71801. Fragment_Custom_Albedo: string;
  71802. Fragment_Before_Lights: string;
  71803. Fragment_Custom_MetallicRoughness: string;
  71804. Fragment_Custom_MicroSurface: string;
  71805. Fragment_Before_Fog: string;
  71806. Fragment_Custom_Alpha: string;
  71807. Fragment_Before_FragColor: string;
  71808. Vertex_Begin: string;
  71809. Vertex_Definitions: string;
  71810. Vertex_MainBegin: string;
  71811. Vertex_Before_PositionUpdated: string;
  71812. Vertex_Before_NormalUpdated: string;
  71813. Vertex_MainEnd: string;
  71814. }
  71815. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  71816. static ShaderIndexer: number;
  71817. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  71818. FragmentShader: string;
  71819. VertexShader: string;
  71820. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71821. ReviewUniform(name: string, arr: string[]): string[];
  71822. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  71823. constructor(name: string, scene: BABYLON.Scene);
  71824. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  71825. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  71826. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  71827. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  71828. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  71829. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  71830. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  71831. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  71832. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  71833. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  71834. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  71835. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  71836. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  71837. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  71838. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  71839. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  71840. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  71841. }
  71842. }
  71843. declare module BABYLON {
  71844. /** @hidden */
  71845. export var firePixelShader: {
  71846. name: string;
  71847. shader: string;
  71848. };
  71849. }
  71850. declare module BABYLON {
  71851. /** @hidden */
  71852. export var fireVertexShader: {
  71853. name: string;
  71854. shader: string;
  71855. };
  71856. }
  71857. declare module BABYLON {
  71858. export class FireMaterial extends BABYLON.PushMaterial {
  71859. private _diffuseTexture;
  71860. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71861. private _distortionTexture;
  71862. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71863. private _opacityTexture;
  71864. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71865. diffuseColor: BABYLON.Color3;
  71866. speed: number;
  71867. private _scaledDiffuse;
  71868. private _renderId;
  71869. private _lastTime;
  71870. constructor(name: string, scene: BABYLON.Scene);
  71871. needAlphaBlending(): boolean;
  71872. needAlphaTesting(): boolean;
  71873. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71874. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71875. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71876. getAnimatables(): BABYLON.IAnimatable[];
  71877. getActiveTextures(): BABYLON.BaseTexture[];
  71878. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71879. getClassName(): string;
  71880. dispose(forceDisposeEffect?: boolean): void;
  71881. clone(name: string): FireMaterial;
  71882. serialize(): any;
  71883. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  71884. }
  71885. }
  71886. declare module BABYLON {
  71887. /** @hidden */
  71888. export var furPixelShader: {
  71889. name: string;
  71890. shader: string;
  71891. };
  71892. }
  71893. declare module BABYLON {
  71894. /** @hidden */
  71895. export var furVertexShader: {
  71896. name: string;
  71897. shader: string;
  71898. };
  71899. }
  71900. declare module BABYLON {
  71901. export class FurMaterial extends BABYLON.PushMaterial {
  71902. private _diffuseTexture;
  71903. diffuseTexture: BABYLON.BaseTexture;
  71904. private _heightTexture;
  71905. heightTexture: BABYLON.BaseTexture;
  71906. diffuseColor: BABYLON.Color3;
  71907. furLength: number;
  71908. furAngle: number;
  71909. furColor: BABYLON.Color3;
  71910. furOffset: number;
  71911. furSpacing: number;
  71912. furGravity: BABYLON.Vector3;
  71913. furSpeed: number;
  71914. furDensity: number;
  71915. furOcclusion: number;
  71916. furTexture: BABYLON.DynamicTexture;
  71917. private _disableLighting;
  71918. disableLighting: boolean;
  71919. private _maxSimultaneousLights;
  71920. maxSimultaneousLights: number;
  71921. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  71922. private _renderId;
  71923. private _furTime;
  71924. constructor(name: string, scene: BABYLON.Scene);
  71925. furTime: number;
  71926. needAlphaBlending(): boolean;
  71927. needAlphaTesting(): boolean;
  71928. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71929. updateFur(): void;
  71930. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71931. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71932. getAnimatables(): BABYLON.IAnimatable[];
  71933. getActiveTextures(): BABYLON.BaseTexture[];
  71934. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71935. dispose(forceDisposeEffect?: boolean): void;
  71936. clone(name: string): FurMaterial;
  71937. serialize(): any;
  71938. getClassName(): string;
  71939. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  71940. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  71941. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  71942. }
  71943. }
  71944. declare module BABYLON {
  71945. /** @hidden */
  71946. export var gradientPixelShader: {
  71947. name: string;
  71948. shader: string;
  71949. };
  71950. }
  71951. declare module BABYLON {
  71952. /** @hidden */
  71953. export var gradientVertexShader: {
  71954. name: string;
  71955. shader: string;
  71956. };
  71957. }
  71958. declare module BABYLON {
  71959. export class GradientMaterial extends BABYLON.PushMaterial {
  71960. private _maxSimultaneousLights;
  71961. maxSimultaneousLights: number;
  71962. topColor: BABYLON.Color3;
  71963. topColorAlpha: number;
  71964. bottomColor: BABYLON.Color3;
  71965. bottomColorAlpha: number;
  71966. offset: number;
  71967. scale: number;
  71968. smoothness: number;
  71969. private _disableLighting;
  71970. disableLighting: boolean;
  71971. private _renderId;
  71972. constructor(name: string, scene: BABYLON.Scene);
  71973. needAlphaBlending(): boolean;
  71974. needAlphaTesting(): boolean;
  71975. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71976. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71977. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71978. getAnimatables(): BABYLON.IAnimatable[];
  71979. dispose(forceDisposeEffect?: boolean): void;
  71980. clone(name: string): GradientMaterial;
  71981. serialize(): any;
  71982. getClassName(): string;
  71983. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  71984. }
  71985. }
  71986. declare module BABYLON {
  71987. /** @hidden */
  71988. export var gridPixelShader: {
  71989. name: string;
  71990. shader: string;
  71991. };
  71992. }
  71993. declare module BABYLON {
  71994. /** @hidden */
  71995. export var gridVertexShader: {
  71996. name: string;
  71997. shader: string;
  71998. };
  71999. }
  72000. declare module BABYLON {
  72001. /**
  72002. * The grid materials allows you to wrap any shape with a grid.
  72003. * Colors are customizable.
  72004. */
  72005. export class GridMaterial extends BABYLON.PushMaterial {
  72006. /**
  72007. * Main color of the grid (e.g. between lines)
  72008. */
  72009. mainColor: BABYLON.Color3;
  72010. /**
  72011. * Color of the grid lines.
  72012. */
  72013. lineColor: BABYLON.Color3;
  72014. /**
  72015. * The scale of the grid compared to unit.
  72016. */
  72017. gridRatio: number;
  72018. /**
  72019. * Allows setting an offset for the grid lines.
  72020. */
  72021. gridOffset: BABYLON.Vector3;
  72022. /**
  72023. * The frequency of thicker lines.
  72024. */
  72025. majorUnitFrequency: number;
  72026. /**
  72027. * The visibility of minor units in the grid.
  72028. */
  72029. minorUnitVisibility: number;
  72030. /**
  72031. * The grid opacity outside of the lines.
  72032. */
  72033. opacity: number;
  72034. /**
  72035. * Determine RBG output is premultiplied by alpha value.
  72036. */
  72037. preMultiplyAlpha: boolean;
  72038. private _opacityTexture;
  72039. opacityTexture: BABYLON.BaseTexture;
  72040. private _gridControl;
  72041. private _renderId;
  72042. /**
  72043. * constructor
  72044. * @param name The name given to the material in order to identify it afterwards.
  72045. * @param scene The scene the material is used in.
  72046. */
  72047. constructor(name: string, scene: BABYLON.Scene);
  72048. /**
  72049. * Returns wehter or not the grid requires alpha blending.
  72050. */
  72051. needAlphaBlending(): boolean;
  72052. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72053. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72054. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72055. /**
  72056. * Dispose the material and its associated resources.
  72057. * @param forceDisposeEffect will also dispose the used effect when true
  72058. */
  72059. dispose(forceDisposeEffect?: boolean): void;
  72060. clone(name: string): GridMaterial;
  72061. serialize(): any;
  72062. getClassName(): string;
  72063. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  72064. }
  72065. }
  72066. declare module BABYLON {
  72067. /** @hidden */
  72068. export var lavaPixelShader: {
  72069. name: string;
  72070. shader: string;
  72071. };
  72072. }
  72073. declare module BABYLON {
  72074. /** @hidden */
  72075. export var lavaVertexShader: {
  72076. name: string;
  72077. shader: string;
  72078. };
  72079. }
  72080. declare module BABYLON {
  72081. export class LavaMaterial extends BABYLON.PushMaterial {
  72082. private _diffuseTexture;
  72083. diffuseTexture: BABYLON.BaseTexture;
  72084. noiseTexture: BABYLON.BaseTexture;
  72085. fogColor: BABYLON.Color3;
  72086. speed: number;
  72087. movingSpeed: number;
  72088. lowFrequencySpeed: number;
  72089. fogDensity: number;
  72090. private _lastTime;
  72091. diffuseColor: BABYLON.Color3;
  72092. private _disableLighting;
  72093. disableLighting: boolean;
  72094. private _unlit;
  72095. unlit: boolean;
  72096. private _maxSimultaneousLights;
  72097. maxSimultaneousLights: number;
  72098. private _scaledDiffuse;
  72099. private _renderId;
  72100. constructor(name: string, scene: BABYLON.Scene);
  72101. needAlphaBlending(): boolean;
  72102. needAlphaTesting(): boolean;
  72103. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72104. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72105. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72106. getAnimatables(): BABYLON.IAnimatable[];
  72107. getActiveTextures(): BABYLON.BaseTexture[];
  72108. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72109. dispose(forceDisposeEffect?: boolean): void;
  72110. clone(name: string): LavaMaterial;
  72111. serialize(): any;
  72112. getClassName(): string;
  72113. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  72114. }
  72115. }
  72116. declare module BABYLON {
  72117. /** @hidden */
  72118. export var mixPixelShader: {
  72119. name: string;
  72120. shader: string;
  72121. };
  72122. }
  72123. declare module BABYLON {
  72124. /** @hidden */
  72125. export var mixVertexShader: {
  72126. name: string;
  72127. shader: string;
  72128. };
  72129. }
  72130. declare module BABYLON {
  72131. export class MixMaterial extends BABYLON.PushMaterial {
  72132. /**
  72133. * Mix textures
  72134. */
  72135. private _mixTexture1;
  72136. mixTexture1: BABYLON.BaseTexture;
  72137. private _mixTexture2;
  72138. mixTexture2: BABYLON.BaseTexture;
  72139. /**
  72140. * Diffuse textures
  72141. */
  72142. private _diffuseTexture1;
  72143. diffuseTexture1: BABYLON.Texture;
  72144. private _diffuseTexture2;
  72145. diffuseTexture2: BABYLON.Texture;
  72146. private _diffuseTexture3;
  72147. diffuseTexture3: BABYLON.Texture;
  72148. private _diffuseTexture4;
  72149. diffuseTexture4: BABYLON.Texture;
  72150. private _diffuseTexture5;
  72151. diffuseTexture5: BABYLON.Texture;
  72152. private _diffuseTexture6;
  72153. diffuseTexture6: BABYLON.Texture;
  72154. private _diffuseTexture7;
  72155. diffuseTexture7: BABYLON.Texture;
  72156. private _diffuseTexture8;
  72157. diffuseTexture8: BABYLON.Texture;
  72158. /**
  72159. * Uniforms
  72160. */
  72161. diffuseColor: BABYLON.Color3;
  72162. specularColor: BABYLON.Color3;
  72163. specularPower: number;
  72164. private _disableLighting;
  72165. disableLighting: boolean;
  72166. private _maxSimultaneousLights;
  72167. maxSimultaneousLights: number;
  72168. private _renderId;
  72169. constructor(name: string, scene: BABYLON.Scene);
  72170. needAlphaBlending(): boolean;
  72171. needAlphaTesting(): boolean;
  72172. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72173. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72174. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72175. getAnimatables(): BABYLON.IAnimatable[];
  72176. getActiveTextures(): BABYLON.BaseTexture[];
  72177. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72178. dispose(forceDisposeEffect?: boolean): void;
  72179. clone(name: string): MixMaterial;
  72180. serialize(): any;
  72181. getClassName(): string;
  72182. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  72183. }
  72184. }
  72185. declare module BABYLON {
  72186. /** @hidden */
  72187. export var normalPixelShader: {
  72188. name: string;
  72189. shader: string;
  72190. };
  72191. }
  72192. declare module BABYLON {
  72193. /** @hidden */
  72194. export var normalVertexShader: {
  72195. name: string;
  72196. shader: string;
  72197. };
  72198. }
  72199. declare module BABYLON {
  72200. export class NormalMaterial extends BABYLON.PushMaterial {
  72201. private _diffuseTexture;
  72202. diffuseTexture: BABYLON.BaseTexture;
  72203. diffuseColor: BABYLON.Color3;
  72204. private _disableLighting;
  72205. disableLighting: boolean;
  72206. private _maxSimultaneousLights;
  72207. maxSimultaneousLights: number;
  72208. private _renderId;
  72209. constructor(name: string, scene: BABYLON.Scene);
  72210. needAlphaBlending(): boolean;
  72211. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72212. needAlphaTesting(): boolean;
  72213. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72214. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72215. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72216. getAnimatables(): BABYLON.IAnimatable[];
  72217. getActiveTextures(): BABYLON.BaseTexture[];
  72218. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72219. dispose(forceDisposeEffect?: boolean): void;
  72220. clone(name: string): NormalMaterial;
  72221. serialize(): any;
  72222. getClassName(): string;
  72223. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  72224. }
  72225. }
  72226. declare module BABYLON {
  72227. /** @hidden */
  72228. export var shadowOnlyPixelShader: {
  72229. name: string;
  72230. shader: string;
  72231. };
  72232. }
  72233. declare module BABYLON {
  72234. /** @hidden */
  72235. export var shadowOnlyVertexShader: {
  72236. name: string;
  72237. shader: string;
  72238. };
  72239. }
  72240. declare module BABYLON {
  72241. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  72242. private _renderId;
  72243. private _activeLight;
  72244. constructor(name: string, scene: BABYLON.Scene);
  72245. shadowColor: BABYLON.Color3;
  72246. needAlphaBlending(): boolean;
  72247. needAlphaTesting(): boolean;
  72248. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72249. activeLight: BABYLON.IShadowLight;
  72250. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72251. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72252. clone(name: string): ShadowOnlyMaterial;
  72253. serialize(): any;
  72254. getClassName(): string;
  72255. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  72256. }
  72257. }
  72258. declare module BABYLON {
  72259. /** @hidden */
  72260. export var simplePixelShader: {
  72261. name: string;
  72262. shader: string;
  72263. };
  72264. }
  72265. declare module BABYLON {
  72266. /** @hidden */
  72267. export var simpleVertexShader: {
  72268. name: string;
  72269. shader: string;
  72270. };
  72271. }
  72272. declare module BABYLON {
  72273. export class SimpleMaterial extends BABYLON.PushMaterial {
  72274. private _diffuseTexture;
  72275. diffuseTexture: BABYLON.BaseTexture;
  72276. diffuseColor: BABYLON.Color3;
  72277. private _disableLighting;
  72278. disableLighting: boolean;
  72279. private _maxSimultaneousLights;
  72280. maxSimultaneousLights: number;
  72281. private _renderId;
  72282. constructor(name: string, scene: BABYLON.Scene);
  72283. needAlphaBlending(): boolean;
  72284. needAlphaTesting(): boolean;
  72285. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72286. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72287. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72288. getAnimatables(): BABYLON.IAnimatable[];
  72289. getActiveTextures(): BABYLON.BaseTexture[];
  72290. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72291. dispose(forceDisposeEffect?: boolean): void;
  72292. clone(name: string): SimpleMaterial;
  72293. serialize(): any;
  72294. getClassName(): string;
  72295. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  72296. }
  72297. }
  72298. declare module BABYLON {
  72299. /** @hidden */
  72300. export var skyPixelShader: {
  72301. name: string;
  72302. shader: string;
  72303. };
  72304. }
  72305. declare module BABYLON {
  72306. /** @hidden */
  72307. export var skyVertexShader: {
  72308. name: string;
  72309. shader: string;
  72310. };
  72311. }
  72312. declare module BABYLON {
  72313. /**
  72314. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  72315. * @see https://doc.babylonjs.com/extensions/sky
  72316. */
  72317. export class SkyMaterial extends BABYLON.PushMaterial {
  72318. /**
  72319. * Defines the overall luminance of sky in interval ]0, 1[.
  72320. */
  72321. luminance: number;
  72322. /**
  72323. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  72324. */
  72325. turbidity: number;
  72326. /**
  72327. * Defines the sky appearance (light intensity).
  72328. */
  72329. rayleigh: number;
  72330. /**
  72331. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  72332. */
  72333. mieCoefficient: number;
  72334. /**
  72335. * Defines the amount of haze particles following the Mie scattering theory.
  72336. */
  72337. mieDirectionalG: number;
  72338. /**
  72339. * Defines the distance of the sun according to the active scene camera.
  72340. */
  72341. distance: number;
  72342. /**
  72343. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  72344. * "inclined".
  72345. */
  72346. inclination: number;
  72347. /**
  72348. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  72349. * an object direction and a reference direction.
  72350. */
  72351. azimuth: number;
  72352. /**
  72353. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  72354. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  72355. */
  72356. sunPosition: BABYLON.Vector3;
  72357. /**
  72358. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  72359. * .sunPosition property.
  72360. */
  72361. useSunPosition: boolean;
  72362. /**
  72363. * Defines an offset vector used to get a horizon offset.
  72364. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  72365. */
  72366. cameraOffset: BABYLON.Vector3;
  72367. private _cameraPosition;
  72368. private _renderId;
  72369. /**
  72370. * Instantiates a new sky material.
  72371. * This material allows to create dynamic and texture free
  72372. * effects for skyboxes by taking care of the atmosphere state.
  72373. * @see https://doc.babylonjs.com/extensions/sky
  72374. * @param name Define the name of the material in the scene
  72375. * @param scene Define the scene the material belong to
  72376. */
  72377. constructor(name: string, scene: BABYLON.Scene);
  72378. /**
  72379. * Specifies if the material will require alpha blending
  72380. * @returns a boolean specifying if alpha blending is needed
  72381. */
  72382. needAlphaBlending(): boolean;
  72383. /**
  72384. * Specifies if this material should be rendered in alpha test mode
  72385. * @returns false as the sky material doesn't need alpha testing.
  72386. */
  72387. needAlphaTesting(): boolean;
  72388. /**
  72389. * Get the texture used for alpha test purpose.
  72390. * @returns null as the sky material has no texture.
  72391. */
  72392. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72393. /**
  72394. * Get if the submesh is ready to be used and all its information available.
  72395. * Child classes can use it to update shaders
  72396. * @param mesh defines the mesh to check
  72397. * @param subMesh defines which submesh to check
  72398. * @param useInstances specifies that instances should be used
  72399. * @returns a boolean indicating that the submesh is ready or not
  72400. */
  72401. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72402. /**
  72403. * Binds the submesh to this material by preparing the effect and shader to draw
  72404. * @param world defines the world transformation matrix
  72405. * @param mesh defines the mesh containing the submesh
  72406. * @param subMesh defines the submesh to bind the material to
  72407. */
  72408. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72409. /**
  72410. * Get the list of animatables in the material.
  72411. * @returns the list of animatables object used in the material
  72412. */
  72413. getAnimatables(): BABYLON.IAnimatable[];
  72414. /**
  72415. * Disposes the material
  72416. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72417. */
  72418. dispose(forceDisposeEffect?: boolean): void;
  72419. /**
  72420. * Makes a duplicate of the material, and gives it a new name
  72421. * @param name defines the new name for the duplicated material
  72422. * @returns the cloned material
  72423. */
  72424. clone(name: string): SkyMaterial;
  72425. /**
  72426. * Serializes this material in a JSON representation
  72427. * @returns the serialized material object
  72428. */
  72429. serialize(): any;
  72430. /**
  72431. * Gets the current class name of the material e.g. "SkyMaterial"
  72432. * Mainly use in serialization.
  72433. * @returns the class name
  72434. */
  72435. getClassName(): string;
  72436. /**
  72437. * Creates a sky material from parsed material data
  72438. * @param source defines the JSON representation of the material
  72439. * @param scene defines the hosting scene
  72440. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72441. * @returns a new sky material
  72442. */
  72443. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  72444. }
  72445. }
  72446. declare module BABYLON {
  72447. /** @hidden */
  72448. export var terrainPixelShader: {
  72449. name: string;
  72450. shader: string;
  72451. };
  72452. }
  72453. declare module BABYLON {
  72454. /** @hidden */
  72455. export var terrainVertexShader: {
  72456. name: string;
  72457. shader: string;
  72458. };
  72459. }
  72460. declare module BABYLON {
  72461. export class TerrainMaterial extends BABYLON.PushMaterial {
  72462. private _mixTexture;
  72463. mixTexture: BABYLON.BaseTexture;
  72464. private _diffuseTexture1;
  72465. diffuseTexture1: BABYLON.Texture;
  72466. private _diffuseTexture2;
  72467. diffuseTexture2: BABYLON.Texture;
  72468. private _diffuseTexture3;
  72469. diffuseTexture3: BABYLON.Texture;
  72470. private _bumpTexture1;
  72471. bumpTexture1: BABYLON.Texture;
  72472. private _bumpTexture2;
  72473. bumpTexture2: BABYLON.Texture;
  72474. private _bumpTexture3;
  72475. bumpTexture3: BABYLON.Texture;
  72476. diffuseColor: BABYLON.Color3;
  72477. specularColor: BABYLON.Color3;
  72478. specularPower: number;
  72479. private _disableLighting;
  72480. disableLighting: boolean;
  72481. private _maxSimultaneousLights;
  72482. maxSimultaneousLights: number;
  72483. private _renderId;
  72484. constructor(name: string, scene: BABYLON.Scene);
  72485. needAlphaBlending(): boolean;
  72486. needAlphaTesting(): boolean;
  72487. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72488. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72489. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72490. getAnimatables(): BABYLON.IAnimatable[];
  72491. getActiveTextures(): BABYLON.BaseTexture[];
  72492. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72493. dispose(forceDisposeEffect?: boolean): void;
  72494. clone(name: string): TerrainMaterial;
  72495. serialize(): any;
  72496. getClassName(): string;
  72497. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  72498. }
  72499. }
  72500. declare module BABYLON {
  72501. /** @hidden */
  72502. export var triplanarPixelShader: {
  72503. name: string;
  72504. shader: string;
  72505. };
  72506. }
  72507. declare module BABYLON {
  72508. /** @hidden */
  72509. export var triplanarVertexShader: {
  72510. name: string;
  72511. shader: string;
  72512. };
  72513. }
  72514. declare module BABYLON {
  72515. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  72516. mixTexture: BABYLON.BaseTexture;
  72517. private _diffuseTextureX;
  72518. diffuseTextureX: BABYLON.BaseTexture;
  72519. private _diffuseTextureY;
  72520. diffuseTextureY: BABYLON.BaseTexture;
  72521. private _diffuseTextureZ;
  72522. diffuseTextureZ: BABYLON.BaseTexture;
  72523. private _normalTextureX;
  72524. normalTextureX: BABYLON.BaseTexture;
  72525. private _normalTextureY;
  72526. normalTextureY: BABYLON.BaseTexture;
  72527. private _normalTextureZ;
  72528. normalTextureZ: BABYLON.BaseTexture;
  72529. tileSize: number;
  72530. diffuseColor: BABYLON.Color3;
  72531. specularColor: BABYLON.Color3;
  72532. specularPower: number;
  72533. private _disableLighting;
  72534. disableLighting: boolean;
  72535. private _maxSimultaneousLights;
  72536. maxSimultaneousLights: number;
  72537. private _renderId;
  72538. constructor(name: string, scene: BABYLON.Scene);
  72539. needAlphaBlending(): boolean;
  72540. needAlphaTesting(): boolean;
  72541. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72542. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72543. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72544. getAnimatables(): BABYLON.IAnimatable[];
  72545. getActiveTextures(): BABYLON.BaseTexture[];
  72546. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72547. dispose(forceDisposeEffect?: boolean): void;
  72548. clone(name: string): TriPlanarMaterial;
  72549. serialize(): any;
  72550. getClassName(): string;
  72551. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  72552. }
  72553. }
  72554. declare module BABYLON {
  72555. /** @hidden */
  72556. export var waterPixelShader: {
  72557. name: string;
  72558. shader: string;
  72559. };
  72560. }
  72561. declare module BABYLON {
  72562. /** @hidden */
  72563. export var waterVertexShader: {
  72564. name: string;
  72565. shader: string;
  72566. };
  72567. }
  72568. declare module BABYLON {
  72569. export class WaterMaterial extends BABYLON.PushMaterial {
  72570. renderTargetSize: BABYLON.Vector2;
  72571. private _bumpTexture;
  72572. bumpTexture: BABYLON.BaseTexture;
  72573. diffuseColor: BABYLON.Color3;
  72574. specularColor: BABYLON.Color3;
  72575. specularPower: number;
  72576. private _disableLighting;
  72577. disableLighting: boolean;
  72578. private _maxSimultaneousLights;
  72579. maxSimultaneousLights: number;
  72580. /**
  72581. * @param {number}: Represents the wind force
  72582. */
  72583. windForce: number;
  72584. /**
  72585. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  72586. */
  72587. windDirection: BABYLON.Vector2;
  72588. /**
  72589. * @param {number}: Wave height, represents the height of the waves
  72590. */
  72591. waveHeight: number;
  72592. /**
  72593. * @param {number}: Bump height, represents the bump height related to the bump map
  72594. */
  72595. bumpHeight: number;
  72596. /**
  72597. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72598. */
  72599. private _bumpSuperimpose;
  72600. bumpSuperimpose: boolean;
  72601. /**
  72602. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72603. */
  72604. private _fresnelSeparate;
  72605. fresnelSeparate: boolean;
  72606. /**
  72607. * @param {boolean}: bump Waves modify the reflection.
  72608. */
  72609. private _bumpAffectsReflection;
  72610. bumpAffectsReflection: boolean;
  72611. /**
  72612. * @param {number}: The water color blended with the refraction (near)
  72613. */
  72614. waterColor: BABYLON.Color3;
  72615. /**
  72616. * @param {number}: The blend factor related to the water color
  72617. */
  72618. colorBlendFactor: number;
  72619. /**
  72620. * @param {number}: The water color blended with the reflection (far)
  72621. */
  72622. waterColor2: BABYLON.Color3;
  72623. /**
  72624. * @param {number}: The blend factor related to the water color (reflection, far)
  72625. */
  72626. colorBlendFactor2: number;
  72627. /**
  72628. * @param {number}: Represents the maximum length of a wave
  72629. */
  72630. waveLength: number;
  72631. /**
  72632. * @param {number}: Defines the waves speed
  72633. */
  72634. waveSpeed: number;
  72635. /**
  72636. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72637. * will avoid calculating useless pixels in the pixel shader of the water material.
  72638. */
  72639. disableClipPlane: boolean;
  72640. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72641. private _mesh;
  72642. private _refractionRTT;
  72643. private _reflectionRTT;
  72644. private _reflectionTransform;
  72645. private _lastTime;
  72646. private _lastDeltaTime;
  72647. private _renderId;
  72648. private _useLogarithmicDepth;
  72649. private _waitingRenderList;
  72650. private _imageProcessingConfiguration;
  72651. private _imageProcessingObserver;
  72652. /**
  72653. * Gets a boolean indicating that current material needs to register RTT
  72654. */
  72655. readonly hasRenderTargetTextures: boolean;
  72656. /**
  72657. * Constructor
  72658. */
  72659. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72660. useLogarithmicDepth: boolean;
  72661. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72662. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72663. addToRenderList(node: any): void;
  72664. enableRenderTargets(enable: boolean): void;
  72665. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72666. readonly renderTargetsEnabled: boolean;
  72667. needAlphaBlending(): boolean;
  72668. needAlphaTesting(): boolean;
  72669. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72670. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72671. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72672. private _createRenderTargets;
  72673. getAnimatables(): BABYLON.IAnimatable[];
  72674. getActiveTextures(): BABYLON.BaseTexture[];
  72675. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72676. dispose(forceDisposeEffect?: boolean): void;
  72677. clone(name: string): WaterMaterial;
  72678. serialize(): any;
  72679. getClassName(): string;
  72680. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72681. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72682. }
  72683. }
  72684. declare module BABYLON {
  72685. /** @hidden */
  72686. export var asciiartPixelShader: {
  72687. name: string;
  72688. shader: string;
  72689. };
  72690. }
  72691. declare module BABYLON {
  72692. /**
  72693. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72694. *
  72695. * It basically takes care rendering the font front the given font size to a texture.
  72696. * This is used later on in the postprocess.
  72697. */
  72698. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72699. private _font;
  72700. private _text;
  72701. private _charSize;
  72702. /**
  72703. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72704. */
  72705. readonly charSize: number;
  72706. /**
  72707. * Create a new instance of the Ascii Art FontTexture class
  72708. * @param name the name of the texture
  72709. * @param font the font to use, use the W3C CSS notation
  72710. * @param text the caracter set to use in the rendering.
  72711. * @param scene the scene that owns the texture
  72712. */
  72713. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72714. /**
  72715. * Gets the max char width of a font.
  72716. * @param font the font to use, use the W3C CSS notation
  72717. * @return the max char width
  72718. */
  72719. private getFontWidth;
  72720. /**
  72721. * Gets the max char height of a font.
  72722. * @param font the font to use, use the W3C CSS notation
  72723. * @return the max char height
  72724. */
  72725. private getFontHeight;
  72726. /**
  72727. * Clones the current AsciiArtTexture.
  72728. * @return the clone of the texture.
  72729. */
  72730. clone(): AsciiArtFontTexture;
  72731. /**
  72732. * Parses a json object representing the texture and returns an instance of it.
  72733. * @param source the source JSON representation
  72734. * @param scene the scene to create the texture for
  72735. * @return the parsed texture
  72736. */
  72737. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72738. }
  72739. /**
  72740. * Option available in the Ascii Art Post Process.
  72741. */
  72742. export interface IAsciiArtPostProcessOptions {
  72743. /**
  72744. * The font to use following the w3c font definition.
  72745. */
  72746. font?: string;
  72747. /**
  72748. * The character set to use in the postprocess.
  72749. */
  72750. characterSet?: string;
  72751. /**
  72752. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72753. * This number is defined between 0 and 1;
  72754. */
  72755. mixToTile?: number;
  72756. /**
  72757. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72758. * This number is defined between 0 and 1;
  72759. */
  72760. mixToNormal?: number;
  72761. }
  72762. /**
  72763. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  72764. *
  72765. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72766. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  72767. */
  72768. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  72769. /**
  72770. * The font texture used to render the char in the post process.
  72771. */
  72772. private _asciiArtFontTexture;
  72773. /**
  72774. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72775. * This number is defined between 0 and 1;
  72776. */
  72777. mixToTile: number;
  72778. /**
  72779. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72780. * This number is defined between 0 and 1;
  72781. */
  72782. mixToNormal: number;
  72783. /**
  72784. * Instantiates a new Ascii Art Post Process.
  72785. * @param name the name to give to the postprocess
  72786. * @camera the camera to apply the post process to.
  72787. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  72788. */
  72789. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  72790. }
  72791. }
  72792. declare module BABYLON {
  72793. /** @hidden */
  72794. export var digitalrainPixelShader: {
  72795. name: string;
  72796. shader: string;
  72797. };
  72798. }
  72799. declare module BABYLON {
  72800. /**
  72801. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  72802. *
  72803. * It basically takes care rendering the font front the given font size to a texture.
  72804. * This is used later on in the postprocess.
  72805. */
  72806. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  72807. private _font;
  72808. private _text;
  72809. private _charSize;
  72810. /**
  72811. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72812. */
  72813. readonly charSize: number;
  72814. /**
  72815. * Create a new instance of the Digital Rain FontTexture class
  72816. * @param name the name of the texture
  72817. * @param font the font to use, use the W3C CSS notation
  72818. * @param text the caracter set to use in the rendering.
  72819. * @param scene the scene that owns the texture
  72820. */
  72821. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72822. /**
  72823. * Gets the max char width of a font.
  72824. * @param font the font to use, use the W3C CSS notation
  72825. * @return the max char width
  72826. */
  72827. private getFontWidth;
  72828. /**
  72829. * Gets the max char height of a font.
  72830. * @param font the font to use, use the W3C CSS notation
  72831. * @return the max char height
  72832. */
  72833. private getFontHeight;
  72834. /**
  72835. * Clones the current DigitalRainFontTexture.
  72836. * @return the clone of the texture.
  72837. */
  72838. clone(): DigitalRainFontTexture;
  72839. /**
  72840. * Parses a json object representing the texture and returns an instance of it.
  72841. * @param source the source JSON representation
  72842. * @param scene the scene to create the texture for
  72843. * @return the parsed texture
  72844. */
  72845. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  72846. }
  72847. /**
  72848. * Option available in the Digital Rain Post Process.
  72849. */
  72850. export interface IDigitalRainPostProcessOptions {
  72851. /**
  72852. * The font to use following the w3c font definition.
  72853. */
  72854. font?: string;
  72855. /**
  72856. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72857. * This number is defined between 0 and 1;
  72858. */
  72859. mixToTile?: number;
  72860. /**
  72861. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72862. * This number is defined between 0 and 1;
  72863. */
  72864. mixToNormal?: number;
  72865. }
  72866. /**
  72867. * DigitalRainPostProcess helps rendering everithing in digital rain.
  72868. *
  72869. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72870. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  72871. */
  72872. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  72873. /**
  72874. * The font texture used to render the char in the post process.
  72875. */
  72876. private _digitalRainFontTexture;
  72877. /**
  72878. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72879. * This number is defined between 0 and 1;
  72880. */
  72881. mixToTile: number;
  72882. /**
  72883. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72884. * This number is defined between 0 and 1;
  72885. */
  72886. mixToNormal: number;
  72887. /**
  72888. * Instantiates a new Digital Rain Post Process.
  72889. * @param name the name to give to the postprocess
  72890. * @camera the camera to apply the post process to.
  72891. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  72892. */
  72893. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  72894. }
  72895. }
  72896. declare module BABYLON {
  72897. /** @hidden */
  72898. export var oceanPostProcessPixelShader: {
  72899. name: string;
  72900. shader: string;
  72901. };
  72902. }
  72903. declare module BABYLON {
  72904. /**
  72905. * Option available in the Ocean Post Process.
  72906. */
  72907. export interface IOceanPostProcessOptions {
  72908. /**
  72909. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72910. */
  72911. reflectionSize?: number | {
  72912. width: number;
  72913. height: number;
  72914. } | {
  72915. ratio: number;
  72916. };
  72917. /**
  72918. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72919. */
  72920. refractionSize?: number | {
  72921. width: number;
  72922. height: number;
  72923. } | {
  72924. ratio: number;
  72925. };
  72926. }
  72927. /**
  72928. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  72929. *
  72930. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72931. * Example usage:
  72932. * var pp = new OceanPostProcess("myOcean", camera);
  72933. * pp.reflectionEnabled = true;
  72934. * pp.refractionEnabled = true;
  72935. */
  72936. export class OceanPostProcess extends BABYLON.PostProcess {
  72937. /**
  72938. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  72939. */
  72940. /**
  72941. * Sets weither or not the real-time reflection is enabled on the ocean.
  72942. * Is set to true, the reflection mirror texture will be used as reflection texture.
  72943. */
  72944. reflectionEnabled: boolean;
  72945. /**
  72946. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  72947. */
  72948. /**
  72949. * Sets weither or not the real-time refraction is enabled on the ocean.
  72950. * Is set to true, the refraction render target texture will be used as refraction texture.
  72951. */
  72952. refractionEnabled: boolean;
  72953. /**
  72954. * Gets wether or not the post-processes is supported by the running hardware.
  72955. * This requires draw buffer supports.
  72956. */
  72957. readonly isSupported: boolean;
  72958. /**
  72959. * This is the reflection mirror texture used to display reflections on the ocean.
  72960. * By default, render list is empty.
  72961. */
  72962. reflectionTexture: BABYLON.MirrorTexture;
  72963. /**
  72964. * This is the refraction render target texture used to display refraction on the ocean.
  72965. * By default, render list is empty.
  72966. */
  72967. refractionTexture: BABYLON.RenderTargetTexture;
  72968. private _time;
  72969. private _cameraRotation;
  72970. private _cameraViewMatrix;
  72971. private _reflectionEnabled;
  72972. private _refractionEnabled;
  72973. private _geometryRenderer;
  72974. /**
  72975. * Instantiates a new Ocean Post Process.
  72976. * @param name the name to give to the postprocess.
  72977. * @camera the camera to apply the post process to.
  72978. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  72979. */
  72980. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  72981. /**
  72982. * Returns the appropriate defines according to the current configuration.
  72983. */
  72984. private _getDefines;
  72985. /**
  72986. * Computes the current camera rotation as the shader requires a camera rotation.
  72987. */
  72988. private _computeCameraRotation;
  72989. }
  72990. }
  72991. declare module BABYLON {
  72992. /** @hidden */
  72993. export var brickProceduralTexturePixelShader: {
  72994. name: string;
  72995. shader: string;
  72996. };
  72997. }
  72998. declare module BABYLON {
  72999. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  73000. private _numberOfBricksHeight;
  73001. private _numberOfBricksWidth;
  73002. private _jointColor;
  73003. private _brickColor;
  73004. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73005. updateShaderUniforms(): void;
  73006. numberOfBricksHeight: number;
  73007. numberOfBricksWidth: number;
  73008. jointColor: BABYLON.Color3;
  73009. brickColor: BABYLON.Color3;
  73010. /**
  73011. * Serializes this brick procedural texture
  73012. * @returns a serialized brick procedural texture object
  73013. */
  73014. serialize(): any;
  73015. /**
  73016. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  73017. * @param parsedTexture defines parsed texture data
  73018. * @param scene defines the current scene
  73019. * @param rootUrl defines the root URL containing brick procedural texture information
  73020. * @returns a parsed Brick Procedural BABYLON.Texture
  73021. */
  73022. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  73023. }
  73024. }
  73025. declare module BABYLON {
  73026. /** @hidden */
  73027. export var cloudProceduralTexturePixelShader: {
  73028. name: string;
  73029. shader: string;
  73030. };
  73031. }
  73032. declare module BABYLON {
  73033. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  73034. private _skyColor;
  73035. private _cloudColor;
  73036. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73037. updateShaderUniforms(): void;
  73038. skyColor: BABYLON.Color4;
  73039. cloudColor: BABYLON.Color4;
  73040. /**
  73041. * Serializes this cloud procedural texture
  73042. * @returns a serialized cloud procedural texture object
  73043. */
  73044. serialize(): any;
  73045. /**
  73046. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  73047. * @param parsedTexture defines parsed texture data
  73048. * @param scene defines the current scene
  73049. * @param rootUrl defines the root URL containing cloud procedural texture information
  73050. * @returns a parsed Cloud Procedural BABYLON.Texture
  73051. */
  73052. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  73053. }
  73054. }
  73055. declare module BABYLON {
  73056. /** @hidden */
  73057. export var fireProceduralTexturePixelShader: {
  73058. name: string;
  73059. shader: string;
  73060. };
  73061. }
  73062. declare module BABYLON {
  73063. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  73064. private _time;
  73065. private _speed;
  73066. private _autoGenerateTime;
  73067. private _fireColors;
  73068. private _alphaThreshold;
  73069. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73070. updateShaderUniforms(): void;
  73071. render(useCameraPostProcess?: boolean): void;
  73072. static readonly PurpleFireColors: BABYLON.Color3[];
  73073. static readonly GreenFireColors: BABYLON.Color3[];
  73074. static readonly RedFireColors: BABYLON.Color3[];
  73075. static readonly BlueFireColors: BABYLON.Color3[];
  73076. autoGenerateTime: boolean;
  73077. fireColors: BABYLON.Color3[];
  73078. time: number;
  73079. speed: BABYLON.Vector2;
  73080. alphaThreshold: number;
  73081. /**
  73082. * Serializes this fire procedural texture
  73083. * @returns a serialized fire procedural texture object
  73084. */
  73085. serialize(): any;
  73086. /**
  73087. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  73088. * @param parsedTexture defines parsed texture data
  73089. * @param scene defines the current scene
  73090. * @param rootUrl defines the root URL containing fire procedural texture information
  73091. * @returns a parsed Fire Procedural BABYLON.Texture
  73092. */
  73093. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  73094. }
  73095. }
  73096. declare module BABYLON {
  73097. /** @hidden */
  73098. export var grassProceduralTexturePixelShader: {
  73099. name: string;
  73100. shader: string;
  73101. };
  73102. }
  73103. declare module BABYLON {
  73104. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  73105. private _grassColors;
  73106. private _groundColor;
  73107. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73108. updateShaderUniforms(): void;
  73109. grassColors: BABYLON.Color3[];
  73110. groundColor: BABYLON.Color3;
  73111. /**
  73112. * Serializes this grass procedural texture
  73113. * @returns a serialized grass procedural texture object
  73114. */
  73115. serialize(): any;
  73116. /**
  73117. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  73118. * @param parsedTexture defines parsed texture data
  73119. * @param scene defines the current scene
  73120. * @param rootUrl defines the root URL containing grass procedural texture information
  73121. * @returns a parsed Grass Procedural BABYLON.Texture
  73122. */
  73123. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  73124. }
  73125. }
  73126. declare module BABYLON {
  73127. /** @hidden */
  73128. export var marbleProceduralTexturePixelShader: {
  73129. name: string;
  73130. shader: string;
  73131. };
  73132. }
  73133. declare module BABYLON {
  73134. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  73135. private _numberOfTilesHeight;
  73136. private _numberOfTilesWidth;
  73137. private _amplitude;
  73138. private _jointColor;
  73139. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73140. updateShaderUniforms(): void;
  73141. numberOfTilesHeight: number;
  73142. amplitude: number;
  73143. numberOfTilesWidth: number;
  73144. jointColor: BABYLON.Color3;
  73145. /**
  73146. * Serializes this marble procedural texture
  73147. * @returns a serialized marble procedural texture object
  73148. */
  73149. serialize(): any;
  73150. /**
  73151. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  73152. * @param parsedTexture defines parsed texture data
  73153. * @param scene defines the current scene
  73154. * @param rootUrl defines the root URL containing marble procedural texture information
  73155. * @returns a parsed Marble Procedural BABYLON.Texture
  73156. */
  73157. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  73158. }
  73159. }
  73160. declare module BABYLON {
  73161. /** @hidden */
  73162. export var normalMapProceduralTexturePixelShader: {
  73163. name: string;
  73164. shader: string;
  73165. };
  73166. }
  73167. declare module BABYLON {
  73168. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  73169. private _baseTexture;
  73170. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73171. updateShaderUniforms(): void;
  73172. render(useCameraPostProcess?: boolean): void;
  73173. resize(size: any, generateMipMaps: any): void;
  73174. baseTexture: BABYLON.Texture;
  73175. /**
  73176. * Serializes this normal map procedural texture
  73177. * @returns a serialized normal map procedural texture object
  73178. */
  73179. serialize(): any;
  73180. /**
  73181. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  73182. * @param parsedTexture defines parsed texture data
  73183. * @param scene defines the current scene
  73184. * @param rootUrl defines the root URL containing normal map procedural texture information
  73185. * @returns a parsed Normal Map Procedural BABYLON.Texture
  73186. */
  73187. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  73188. }
  73189. }
  73190. declare module BABYLON {
  73191. /** @hidden */
  73192. export var perlinNoiseProceduralTexturePixelShader: {
  73193. name: string;
  73194. shader: string;
  73195. };
  73196. }
  73197. declare module BABYLON {
  73198. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  73199. time: number;
  73200. timeScale: number;
  73201. translationSpeed: number;
  73202. private _currentTranslation;
  73203. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73204. updateShaderUniforms(): void;
  73205. render(useCameraPostProcess?: boolean): void;
  73206. resize(size: any, generateMipMaps: any): void;
  73207. /**
  73208. * Serializes this perlin noise procedural texture
  73209. * @returns a serialized perlin noise procedural texture object
  73210. */
  73211. serialize(): any;
  73212. /**
  73213. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  73214. * @param parsedTexture defines parsed texture data
  73215. * @param scene defines the current scene
  73216. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  73217. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  73218. */
  73219. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  73220. }
  73221. }
  73222. declare module BABYLON {
  73223. /** @hidden */
  73224. export var roadProceduralTexturePixelShader: {
  73225. name: string;
  73226. shader: string;
  73227. };
  73228. }
  73229. declare module BABYLON {
  73230. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  73231. private _roadColor;
  73232. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73233. updateShaderUniforms(): void;
  73234. roadColor: BABYLON.Color3;
  73235. /**
  73236. * Serializes this road procedural texture
  73237. * @returns a serialized road procedural texture object
  73238. */
  73239. serialize(): any;
  73240. /**
  73241. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  73242. * @param parsedTexture defines parsed texture data
  73243. * @param scene defines the current scene
  73244. * @param rootUrl defines the root URL containing road procedural texture information
  73245. * @returns a parsed Road Procedural BABYLON.Texture
  73246. */
  73247. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  73248. }
  73249. }
  73250. declare module BABYLON {
  73251. /** @hidden */
  73252. export var starfieldProceduralTexturePixelShader: {
  73253. name: string;
  73254. shader: string;
  73255. };
  73256. }
  73257. declare module BABYLON {
  73258. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  73259. private _time;
  73260. private _alpha;
  73261. private _beta;
  73262. private _zoom;
  73263. private _formuparam;
  73264. private _stepsize;
  73265. private _tile;
  73266. private _brightness;
  73267. private _darkmatter;
  73268. private _distfading;
  73269. private _saturation;
  73270. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73271. updateShaderUniforms(): void;
  73272. time: number;
  73273. alpha: number;
  73274. beta: number;
  73275. formuparam: number;
  73276. stepsize: number;
  73277. zoom: number;
  73278. tile: number;
  73279. brightness: number;
  73280. darkmatter: number;
  73281. distfading: number;
  73282. saturation: number;
  73283. /**
  73284. * Serializes this starfield procedural texture
  73285. * @returns a serialized starfield procedural texture object
  73286. */
  73287. serialize(): any;
  73288. /**
  73289. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  73290. * @param parsedTexture defines parsed texture data
  73291. * @param scene defines the current scene
  73292. * @param rootUrl defines the root URL containing startfield procedural texture information
  73293. * @returns a parsed Starfield Procedural BABYLON.Texture
  73294. */
  73295. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  73296. }
  73297. }
  73298. declare module BABYLON {
  73299. /** @hidden */
  73300. export var woodProceduralTexturePixelShader: {
  73301. name: string;
  73302. shader: string;
  73303. };
  73304. }
  73305. declare module BABYLON {
  73306. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  73307. private _ampScale;
  73308. private _woodColor;
  73309. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73310. updateShaderUniforms(): void;
  73311. ampScale: number;
  73312. woodColor: BABYLON.Color3;
  73313. /**
  73314. * Serializes this wood procedural texture
  73315. * @returns a serialized wood procedural texture object
  73316. */
  73317. serialize(): any;
  73318. /**
  73319. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  73320. * @param parsedTexture defines parsed texture data
  73321. * @param scene defines the current scene
  73322. * @param rootUrl defines the root URL containing wood procedural texture information
  73323. * @returns a parsed Wood Procedural BABYLON.Texture
  73324. */
  73325. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  73326. }
  73327. }